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

Unified Diff: gm/gradients.cpp

Issue 22484002: Mozilla diabolical clamp case added to gm/gradients.cpp (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: nit from Mike Created 7 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: gm/gradients.cpp
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index 97f8fdaca8b5813b06ae010fddf4dda8f1113fa4..604d1c3f5d6ebf927d954f4440218aeceb582cd5 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -25,12 +25,18 @@ static const SkScalar gPos2[] = {
0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
};
+static const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
+static const SkColor gColorClamp[] = {
+ SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE
+};
+
static const GradData gGradData[] = {
{ 2, gColors, NULL },
{ 2, gColors, gPos0 },
{ 2, gColors, gPos1 },
{ 5, gColors, NULL },
- { 5, gColors, gPos2 }
+ { 5, gColors, gPos2 },
+ { 4, gColorClamp, gPosClamp }
};
static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
@@ -120,6 +126,14 @@ protected:
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL);
+
+ if (i == 5) { // if the clamp case
+ SkMatrix scale;
+ scale.setScale(0.5f, 0.5f);
+ scale.postTranslate(25.f, 25.f);
+ shader->setLocalMatrix(scale);
+ }
+
paint.setShader(shader);
canvas->drawRect(r, paint);
shader->unref();
@@ -173,6 +187,7 @@ protected:
SkIntToScalar(500)));
perspective.setSkewX(SkScalarDiv(SkIntToScalar((unsigned) i+1),
SkIntToScalar(10)));
+
shader->setLocalMatrix(perspective);
paint.setShader(shader);
« 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