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

Unified Diff: gm/gradients.cpp

Issue 1688543002: Initial linear gradient 4f impl (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | gyp/effects.gypi » ('j') | 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 c1847d446243b18558c7b25e0684eddfe492b0d8..5fb3465913bf345326473a8baf89364f7b5cc72b 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -7,6 +7,7 @@
#include "gm.h"
#include "SkGradientShader.h"
+#include "SkLinearGradient.h"
namespace skiagm {
@@ -593,9 +594,16 @@ DEF_GM( return new LinearGradientGM(true); )
DEF_GM( return new LinearGradientGM(false); )
class LinearGradientTinyGM : public GM {
+public:
+ LinearGradientTinyGM(uint32_t flags, const char* suffix = nullptr)
+ : fName("linear_gradient_tiny")
+ , fFlags(flags) {
+ fName.append(suffix);
+ }
+
protected:
SkString onShortName() override {
- return SkString("linear_gradient_tiny");
+ return fName;
}
SkISize onISize() override {
@@ -631,7 +639,7 @@ protected:
SkAutoCanvasRestore acr(canvas, true);
SkAutoTUnref<SkShader> gradient(
SkGradientShader::CreateLinear(configs[i].pts, colors, configs[i].pos, kStopCount,
- SkShader::kClamp_TileMode));
+ SkShader::kClamp_TileMode, fFlags, nullptr));
canvas->translate(kRectSize * ((i % 4) * 1.5f + 0.25f),
kRectSize * ((i / 4) * 1.5f + 0.25f));
@@ -642,9 +650,12 @@ protected:
private:
typedef GM INHERITED;
-};
-DEF_GM( return new LinearGradientTinyGM(); )
+ SkString fName;
+ uint32_t fFlags;
+};
+DEF_GM( return new LinearGradientTinyGM(0); )
+DEF_GM( return new LinearGradientTinyGM(SkLinearGradient::kForce4fContext_PrivateFlag, "_4f"); )
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -736,3 +747,35 @@ DEF_SIMPLE_GM(gradients_dup_color_stops, canvas, 704, 564) {
}
}
}
+
+static void draw_many_stops(SkCanvas* canvas, uint32_t flags) {
+ const unsigned kStopCount = 200;
+ const SkPoint pts[] = { {50, 50}, {450, 465}};
+
+ SkColor colors[kStopCount];
+ for (unsigned i = 0; i < kStopCount; i++) {
+ switch (i % 5) {
+ case 0: colors[i] = SK_ColorRED; break;
+ case 1: colors[i] = SK_ColorGREEN; break;
+ case 2: colors[i] = SK_ColorGREEN; break;
+ case 3: colors[i] = SK_ColorBLUE; break;
+ case 4: colors[i] = SK_ColorRED; break;
+ }
+ }
+
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(
+ pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, flags, nullptr));
+
+ SkPaint p;
+ p.setShader(shader);
+
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p);
+}
+
+DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) {
+ draw_many_stops(canvas, 0);
+}
+
+DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) {
+ draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag);
+}
« no previous file with comments | « no previous file | gyp/effects.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698