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

Unified Diff: gm/gradients.cpp

Issue 1464693002: Tiny linear gradient GM (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: bump isize Created 5 years, 1 month 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 b0a8a5ad89198325b61d3283b589c4df464f1876..92e22eebefd1a64d8e5864f6c4b0c8fd62ef5685 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -592,4 +592,56 @@ private:
DEF_GM( return new LinearGradientGM(true); )
DEF_GM( return new LinearGradientGM(false); )
+class LinearGradientTinyGM : public GM {
+protected:
+ SkString onShortName() override {
+ return SkString("linear_gradient_tiny");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(600, 500);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ const SkScalar kRectSize = 100;
+ const unsigned kStopCount = 3;
+ const SkColor colors[kStopCount] = { SK_ColorGREEN, SK_ColorRED, SK_ColorGREEN };
+ const struct {
+ SkPoint pts[2];
+ SkScalar pos[kStopCount];
+ } configs[] = {
+ { { SkPoint::Make(0, 0), SkPoint::Make(10, 0) }, { 0, 0.999999f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(10, 0) }, { 0, 0.000001f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(10, 0) }, { 0, 0.999999999f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(10, 0) }, { 0, 0.000000001f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(0, 10) }, { 0, 0.999999f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(0, 10) }, { 0, 0.000001f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(0, 10) }, { 0, 0.999999999f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(0, 10) }, { 0, 0.000000001f, 1 }},
+
+ { { SkPoint::Make(0, 0), SkPoint::Make(0.00001f, 0) } , { 0, 0.5f, 1 }},
+ { { SkPoint::Make(9.99999f, 0), SkPoint::Make(10, 0) }, { 0, 0.5f, 1 }},
+ { { SkPoint::Make(0, 0), SkPoint::Make(0, 0.00001f) }, { 0, 0.5f, 1 }},
+ { { SkPoint::Make(0, 9.99999f), SkPoint::Make(0, 10) }, { 0, 0.5f, 1 }},
+ };
+
+ SkPaint paint;
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(configs); ++i) {
+ SkAutoCanvasRestore acr(canvas, true);
+ SkAutoTUnref<SkShader> gradient(
+ SkGradientShader::CreateLinear(configs[i].pts, colors, configs[i].pos, kStopCount,
+ SkShader::kClamp_TileMode));
+ canvas->translate(kRectSize * ((i % 4) * 1.5f + 0.25f),
+ kRectSize * ((i / 4) * 1.5f + 0.25f));
+
+ paint.setShader(gradient);
+ canvas->drawRect(SkRect::MakeWH(kRectSize, kRectSize), paint);
+ }
+ }
+
+private:
+ typedef GM INHERITED;
+};
+DEF_GM( return new LinearGradientTinyGM(); )
+
}
« 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