Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: src/effects/gradients/SkTwoPointConicalGradient.cpp

Issue 1767163003: Use float rather than SkFixed for gradient TileProcs. (Closed) Base URL: https://skia.googlesource.com/skia@scalar-pin-to-fixed
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.h ('k') | tests/ClampRangeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkTwoPointConicalGradient.cpp
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 43d6f1f7c997e87888e407537dfae942eeb972bc..cb3c0af48b1331fcde6e4da2e747d277e86617e5 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -17,7 +17,7 @@ struct TwoPtRadialContext {
TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkScalar fy,
SkScalar dfx, SkScalar dfy);
- SkFixed nextT();
+ float nextT();
};
static int valid_divide(float numer, float denom, float* ratio) {
@@ -77,6 +77,8 @@ static float lerp(float x, float dx, float t) {
static float sqr(float x) { return x * x; }
+const float TwoPtRadial::kDontDrawT = NAN;
+
void TwoPtRadial::init(const SkPoint& center0, SkScalar rad0,
const SkPoint& center1, SkScalar rad1,
bool flipped) {
@@ -104,7 +106,7 @@ TwoPtRadialContext::TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkSc
, fB(-2 * (rec.fDCenterX * fRelX + rec.fDCenterY * fRelY + rec.fRDR))
, fDB(-2 * (rec.fDCenterX * fIncX + rec.fDCenterY * fIncY)) {}
-SkFixed TwoPtRadialContext::nextT() {
+float TwoPtRadialContext::nextT() {
float roots[2];
float C = sqr(fRelX) + sqr(fRelY) - fRec.fRadius2;
@@ -129,7 +131,7 @@ SkFixed TwoPtRadialContext::nextT() {
return TwoPtRadial::kDontDrawT;
}
}
- return SkFloatToFixed(t);
+ return t;
}
typedef void (*TwoPointConicalProc)(TwoPtRadialContext* rec, SkPMColor* dstC,
@@ -139,11 +141,11 @@ static void twopoint_clamp(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC,
const SkPMColor* SK_RESTRICT cache, int toggle,
int count) {
for (; count > 0; --count) {
- SkFixed t = rec->nextT();
+ float t = rec->nextT();
if (TwoPtRadial::DontDrawT(t)) {
*dstC++ = 0;
} else {
- SkFixed index = SkClampMax(t, 0xFFFF);
+ const unsigned index = clamp_tileproc(t);
SkASSERT(index <= 0xFFFF);
*dstC++ = cache[toggle +
(index >> SkGradientShaderBase::kCache32Shift)];
@@ -156,11 +158,11 @@ static void twopoint_repeat(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC
const SkPMColor* SK_RESTRICT cache, int toggle,
int count) {
for (; count > 0; --count) {
- SkFixed t = rec->nextT();
+ float t = rec->nextT();
if (TwoPtRadial::DontDrawT(t)) {
*dstC++ = 0;
} else {
- SkFixed index = repeat_tileproc(t);
+ const unsigned index = repeat_tileproc(t);
SkASSERT(index <= 0xFFFF);
*dstC++ = cache[toggle +
(index >> SkGradientShaderBase::kCache32Shift)];
@@ -173,11 +175,11 @@ static void twopoint_mirror(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC
const SkPMColor* SK_RESTRICT cache, int toggle,
int count) {
for (; count > 0; --count) {
- SkFixed t = rec->nextT();
+ float t = rec->nextT();
if (TwoPtRadial::DontDrawT(t)) {
*dstC++ = 0;
} else {
- SkFixed index = mirror_tileproc(t);
+ const unsigned index = mirror_tileproc(t);
SkASSERT(index <= 0xFFFF);
*dstC++ = cache[toggle +
(index >> SkGradientShaderBase::kCache32Shift)];
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.h ('k') | tests/ClampRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698