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

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: one gm, side by side 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..3cba41cc9d4d2c5e55ebca16fed7393cf46bb2cb 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -367,7 +367,7 @@ public:
protected:
SkString onShortName() { return SkString("radial_gradient2"); }
- virtual SkISize onISize() { return make_isize(400, 400); }
+ virtual SkISize onISize() { return make_isize(800, 400); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFF000000);
}
@@ -388,24 +388,35 @@ protected:
SkPoint center;
center.set(cx, cy);
- SkAutoTUnref<SkShader> sweep(
- SkGradientShader::CreateSweep(cx, cy, sweep_colors,
- NULL, SK_ARRAY_COUNT(sweep_colors)));
- SkAutoTUnref<SkShader> radial1(
- SkGradientShader::CreateRadial(center, radius, colors1,
- NULL, SK_ARRAY_COUNT(colors1),
- SkShader::kClamp_TileMode));
- SkAutoTUnref<SkShader> radial2(
- SkGradientShader::CreateRadial(center, radius, colors2,
- NULL, SK_ARRAY_COUNT(colors2),
- SkShader::kClamp_TileMode));
- paint1.setShader(sweep);
- paint2.setShader(radial1);
- paint3.setShader(radial2);
-
- canvas->drawCircle(cx, cy, radius, paint1);
- canvas->drawCircle(cx, cy, radius, paint3);
- canvas->drawCircle(cx, cy, radius, paint2);
+ // 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[] = { 0, SkGradientShader::kInterpolateColorsInPremul_Flag };
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(flags); i++) {
+ SkAutoTUnref<SkShader> sweep(
+ SkGradientShader::CreateSweep(cx, cy, sweep_colors,
+ NULL, SK_ARRAY_COUNT(sweep_colors),
+ NULL, flags[i]));
+ SkAutoTUnref<SkShader> radial1(
+ SkGradientShader::CreateRadial(center, radius, colors1,
+ NULL, SK_ARRAY_COUNT(colors1),
+ SkShader::kClamp_TileMode,
+ NULL, flags[i]));
+ SkAutoTUnref<SkShader> radial2(
+ SkGradientShader::CreateRadial(center, radius, colors2,
+ NULL, SK_ARRAY_COUNT(colors2),
+ SkShader::kClamp_TileMode,
+ NULL, flags[i]));
+ paint1.setShader(sweep);
+ paint2.setShader(radial1);
+ paint3.setShader(radial2);
+
+ canvas->drawCircle(cx, cy, radius, paint1);
+ canvas->drawCircle(cx, cy, radius, paint3);
+ canvas->drawCircle(cx, cy, radius, paint2);
+
+ canvas->translate(400, 0);
+ }
}
private:
« 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