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

Unified Diff: gm/gamut.cpp

Issue 2343253002: Support for color-spaces with multi-stop (texture) gradients (Closed)
Patch Set: SkASSERT -> SkDEBUGFAIL Created 4 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 | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gamut.cpp
diff --git a/gm/gamut.cpp b/gm/gamut.cpp
index 595e36b7d260d50a3f0525d6a2b9365ef42943ae..26231c5e8fe954ecb067195b35d7b906d0502237 100644
--- a/gm/gamut.cpp
+++ b/gm/gamut.cpp
@@ -58,9 +58,10 @@ protected:
};
struct GradientCellRenderer : public CellRenderer {
- GradientCellRenderer(SkColor colorOne, SkColor colorTwo) {
+ GradientCellRenderer(SkColor colorOne, SkColor colorTwo, bool manyStops) {
fColors[0] = colorOne;
fColors[1] = colorTwo;
+ fManyStops = manyStops;
}
void draw(SkCanvas* canvas) override {
SkPoint points[2] = {
@@ -68,8 +69,16 @@ struct GradientCellRenderer : public CellRenderer {
SkPoint::Make(0, gScalarSize)
};
SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(points, fColors, nullptr, 2,
- SkShader::kClamp_TileMode));
+ if (fManyStops) {
+ SkColor colors[4] ={
+ fColors[0], fColors[0], fColors[1], fColors[1]
+ };
+ paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 4,
+ SkShader::kClamp_TileMode));
+ } else {
+ paint.setShader(SkGradientShader::MakeLinear(points, fColors, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ }
canvas->drawPaint(paint);
}
const char* label() override {
@@ -77,6 +86,7 @@ struct GradientCellRenderer : public CellRenderer {
}
protected:
SkColor fColors[2];
+ bool fManyStops;
};
struct VerticesCellRenderer : public CellRenderer {
@@ -198,9 +208,16 @@ DEF_SIMPLE_GM_BG(gamut, canvas, gTestWidth, gTestHeight, SK_ColorBLACK) {
renderers.push_back(new BitmapCellRenderer(SK_ColorGREEN, kHigh_SkFilterQuality, 0.5f));
// Various gradients involving sRGB primaries and white/black
- renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN));
- renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK));
- renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE));
+
+ // First with just two stops (implemented with uniforms on GPU)
+ renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, false));
+ renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, false));
+ renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, false));
+
+ // ... and then with four stops (implemented with textures on GPU)
+ renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, true));
+ renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, true));
+ renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, true));
// Vertex colors
renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorRED));
« no previous file with comments | « no previous file | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698