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

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

Issue 2265803002: Simplify the gradient color stop optimizer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: the test goes in separate CL Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkGradientShader.cpp
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 58c0d3bd5dcc2aaa8a266a7ef23141255e895b40..a0cbe974f2bab401a6a94fe8dafe2e6c96fde4da 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -786,14 +786,10 @@ struct ColorStopOptimizer {
SkShader::kMirror_TileMode == mode ||
colors[0] == colors[1]) {
- fColorStorage[0] = colors[1];
- fColorStorage[1] = colors[2];
- fPosStorage[0] = 0.0f;
- fPosStorage[1] = 1.0f;
-
- fColors = fColorStorage;
- fPos = fPosStorage;
- fCount = 2;
+ // Ignore the leftmost color/pos.
+ fColors += 1;
+ fPos += 1;
+ fCount = 2;
}
} else if (SkScalarNearlyEqual(pos[0], 0.0f) &&
SkScalarNearlyEqual(pos[1], 1.0f) &&
@@ -803,6 +799,7 @@ struct ColorStopOptimizer {
SkShader::kMirror_TileMode == mode ||
colors[1] == colors[2]) {
+ // Ignore the rightmost color/pos.
fCount = 2;
}
}
@@ -811,9 +808,6 @@ struct ColorStopOptimizer {
const SkColor* fColors;
const SkScalar* fPos;
int fCount;
-
- SkColor fColorStorage[2];
- SkScalar fPosStorage[2];
};
sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2],
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698