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

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient.cpp

Issue 1756573002: [Reland] Fix SkTwoPointConicalGradient zero-radius handling (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: avoid all-zero radius instantiation 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 unified diff | Download patch
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | tests/GradientTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTwoPointConicalGradient.h" 8 #include "SkTwoPointConicalGradient.h"
9 #include "SkTwoPointConicalGradient_gpu.h" 9 #include "SkTwoPointConicalGradient_gpu.h"
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 fB += fDB; 115 fB += fDB;
116 116
117 if (0 == countRoots) { 117 if (0 == countRoots) {
118 return TwoPtRadial::kDontDrawT; 118 return TwoPtRadial::kDontDrawT;
119 } 119 }
120 120
121 // Prefer the bigger t value if both give a radius(t) > 0 121 // Prefer the bigger t value if both give a radius(t) > 0
122 // find_quad_roots returns the values sorted, so we start with the last 122 // find_quad_roots returns the values sorted, so we start with the last
123 float t = roots[countRoots - 1]; 123 float t = roots[countRoots - 1];
124 float r = lerp(fRec.fRadius, fRec.fDRadius, t); 124 float r = lerp(fRec.fRadius, fRec.fDRadius, t);
125 if (r <= 0) { 125 if (r < 0) {
126 t = roots[0]; // might be the same as roots[countRoots-1] 126 t = roots[0]; // might be the same as roots[countRoots-1]
127 r = lerp(fRec.fRadius, fRec.fDRadius, t); 127 r = lerp(fRec.fRadius, fRec.fDRadius, t);
128 if (r <= 0) { 128 if (r < 0) {
129 return TwoPtRadial::kDontDrawT; 129 return TwoPtRadial::kDontDrawT;
130 } 130 }
131 } 131 }
132 return SkFloatToFixed(t); 132 return SkFloatToFixed(t);
133 } 133 }
134 134
135 typedef void (*TwoPointConicalProc)(TwoPtRadialContext* rec, SkPMColor* dstC, 135 typedef void (*TwoPointConicalProc)(TwoPtRadialContext* rec, SkPMColor* dstC,
136 const SkPMColor* cache, int toggle, int coun t); 136 const SkPMColor* cache, int toggle, int coun t);
137 137
138 static void twopoint_clamp(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC, 138 static void twopoint_clamp(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC,
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 str->appendScalar(fCenter2.fY); 388 str->appendScalar(fCenter2.fY);
389 str->append(") radius2: "); 389 str->append(") radius2: ");
390 str->appendScalar(fRadius2); 390 str->appendScalar(fRadius2);
391 str->append(" "); 391 str->append(" ");
392 392
393 this->INHERITED::toString(str); 393 this->INHERITED::toString(str);
394 394
395 str->append(")"); 395 str->append(")");
396 } 396 }
397 #endif 397 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | tests/GradientTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698