aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gradients_no_texture.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-11-13 06:23:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-13 06:23:54 -0800
commit6b90df6b1c6ed843be3ac09605050605f9ec9150 (patch)
tree8a74c7c9fb07ee7996705a3044c77a17eb80de39 /gm/gradients_no_texture.cpp
parent506e19a4c8395178e8da81576b3c37616593e560 (diff)
augment gradients_many to exercise flipped gradients and clampping
BUG=skia: TBR= NOTREECHECKS=True Review URL: https://codereview.chromium.org/1442833004
Diffstat (limited to 'gm/gradients_no_texture.cpp')
-rw-r--r--gm/gradients_no_texture.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/gm/gradients_no_texture.cpp b/gm/gradients_no_texture.cpp
index 726a14fd26..00c865c178 100644
--- a/gm/gradients_no_texture.cpp
+++ b/gm/gradients_no_texture.cpp
@@ -203,6 +203,16 @@ static void make2(ColorPos* rec) {
rec->construct(colors, pos, N);
}
+static void make3(ColorPos* rec) {
+ const SkColor colors[] = {
+ SK_ColorRED, SK_ColorBLUE, SK_ColorBLUE, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLACK,
+ };
+ const SkScalar pos[] = {
+ 0, 0, 0.5f, 0.5, 1, 1,
+ };
+ rec->construct(colors, pos, SK_ARRAY_COUNT(colors));
+}
+
class GradientsManyColorsGM : public GM {
enum {
W = 800,
@@ -219,11 +229,11 @@ protected:
return SkString(fDither ? "gradients_many" : "gradients_many_nodither");
}
- SkISize onISize() override { return SkISize::Make(850, 100); }
+ SkISize onISize() override { return SkISize::Make(880, 400); }
void onDraw(SkCanvas* canvas) override {
const Proc procs[] = {
- make0, make1, make2,
+ make0, make1, make2, make3,
};
const SkPoint pts[] = {
{ 0, 0 },
@@ -234,21 +244,31 @@ protected:
SkPaint paint;
paint.setDither(fDither);
- canvas->translate(20, 20);
+ canvas->translate(40, 20);
for (int i = 0; i <= 8; ++i) {
SkScalar x = r.width() * i / 8;
canvas->drawLine(x, 0, x, 10000, paint);
}
+ // expand the drawing rect so we exercise clampping in the gradients
+ const SkRect drawR = r.makeOutset(20, 0);
for (size_t i = 0; i < SK_ARRAY_COUNT(procs); ++i) {
ColorPos rec;
procs[i](&rec);
SkShader* s = SkGradientShader::CreateLinear(pts, rec.fColors, rec.fPos, rec.fCount,
SkShader::kClamp_TileMode);
paint.setShader(s)->unref();
- canvas->drawRect(r, paint);
- canvas->translate(0, r.height() + 20);
+ canvas->drawRect(drawR, paint);
+
+ canvas->save();
+ canvas->translate(r.centerX(), r.height() + 4);
+ canvas->scale(-1, 1);
+ canvas->translate(-r.centerX(), 0);
+ canvas->drawRect(drawR, paint);
+ canvas->restore();
+
+ canvas->translate(0, r.height() + 2*r.height() + 8);
}
}