commit | e6af96a88901b3c6f0c27575197a93db6cb04042 | [log] [tgz] |
---|---|---|
author | benjaminwagner <benjaminwagner@google.com> | Fri Feb 12 12:19:14 2016 -0800 |
committer | Commit bot <commit-bot@chromium.org> | Fri Feb 12 12:19:14 2016 -0800 |
tree | 19729a6bad1ea90423095283f442d962d6f961d2 | |
parent | 013475a27222c46e528c83704fa2bf43ba207571 [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
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index e205ee4..d07bcb8 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp
@@ -1761,14 +1761,7 @@ #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); }