aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2016-02-12 12:19:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-12 12:19:14 -0800
commite6af96a88901b3c6f0c27575197a93db6cb04042 (patch)
tree19729a6bad1ea90423095283f442d962d6f961d2 /src
parent013475a27222c46e528c83704fa2bf43ba207571 (diff)
Change ScalarTo256 to more efficient implementation.
The previous implementation was likely more efficient when SkScalar was SkFixed. BUG=skia:4632 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1693683002 Review URL: https://codereview.chromium.org/1693683002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkDraw.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index e205ee45c0..d07bcb8fcf 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1761,14 +1761,7 @@ bool SkTriColorShader::TriColorShaderContext::setup(const SkPoint pts[], const S
#include "SkComposeShader.h"
static int ScalarTo256(SkScalar v) {
- int scale = SkScalarToFixed(v) >> 8;
- if (scale < 0) {
- scale = 0;
- }
- if (scale > 255) {
- scale = 255;
- }
- return SkAlpha255To256(scale);
+ return static_cast<int>(SkScalarPin(v, 0, 1) * 256);
}