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

Unified Diff: gm/gradients.cpp

Issue 23637008: Split radial_gradients2 GM into two to reproduce its bug. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 9438c33bdc166d38391bb4c1ddcc7a9aacdedc78..e7964fc9ecceba24fcff483545861263400cc3e4 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -363,10 +363,13 @@ private:
class RadialGradient2GM : public GM {
public:
- RadialGradient2GM() {}
+ explicit RadialGradient2GM(bool premulFirst) : fPremulFirst(premulFirst) {}
protected:
- SkString onShortName() { return SkString("radial_gradient2"); }
+ SkString onShortName() {
+ return SkString(fPremulFirst ? "radial_gradient2_premul_then_interp"
+ : "radial_gradient2_interp_then_premul");
+ }
virtual SkISize onISize() { return make_isize(400, 400); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFF000000);
@@ -388,17 +391,24 @@ protected:
SkPoint center;
center.set(cx, cy);
+ // We can either interpolate endpoints and premultiply each point (default, more precision),
+ // or premultiply the endpoints first, avoiding the need to premultiply each point (cheap).
+ const uint32_t flags = fPremulFirst ? SkGradientShader::kInterpolateColorsInPremul_Flag : 0;
+
SkAutoTUnref<SkShader> sweep(
SkGradientShader::CreateSweep(cx, cy, sweep_colors,
- NULL, SK_ARRAY_COUNT(sweep_colors)));
+ NULL, SK_ARRAY_COUNT(sweep_colors),
+ NULL, flags));
SkAutoTUnref<SkShader> radial1(
SkGradientShader::CreateRadial(center, radius, colors1,
NULL, SK_ARRAY_COUNT(colors1),
- SkShader::kClamp_TileMode));
+ SkShader::kClamp_TileMode,
+ NULL, flags));
SkAutoTUnref<SkShader> radial2(
SkGradientShader::CreateRadial(center, radius, colors2,
NULL, SK_ARRAY_COUNT(colors2),
- SkShader::kClamp_TileMode));
+ SkShader::kClamp_TileMode,
+ NULL, flags));
paint1.setShader(sweep);
paint2.setShader(radial1);
paint3.setShader(radial2);
@@ -409,6 +419,7 @@ protected:
}
private:
+ bool fPremulFirst;
typedef GM INHERITED;
};
@@ -432,6 +443,9 @@ static GMRegistry reg5(MyFactory5);
static GM* MyFactory6(void*) { return new GradientsViewPerspectiveGM; }
static GMRegistry reg6(MyFactory6);
-static GM* MyFactory7(void*) { return new RadialGradient2GM; }
+static GM* MyFactory7(void*) { return new RadialGradient2GM(true); }
reed1 2013/09/11 14:33:27 nitties: 1. If we're going to have 2 gms, might b
static GMRegistry reg7(MyFactory7);
+
+static GM* MyFactory8(void*) { return new RadialGradient2GM(false); }
+static GMRegistry reg8(MyFactory8);
}
« 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