Index: gm/bitmapshader.cpp |
diff --git a/gm/bitmapshader.cpp b/gm/bitmapshader.cpp |
index fb563070d1d19abf01677dac68609eccfcdf2b82..99262bbf706d54bc21dcb5ae0205537da4f7bedd 100644 |
--- a/gm/bitmapshader.cpp |
+++ b/gm/bitmapshader.cpp |
@@ -35,7 +35,8 @@ static void draw_mask(SkBitmap* bm) { |
canvas.drawCircle(10, 10, 10, circlePaint); |
} |
-static void adopt_shader(SkPaint* paint, SkShader* shader) { |
+static void adopt_shader(SkPaint* paint, SkShader* shader, SkMatrix s) { |
+ shader->setLocalMatrix(s); |
paint->setShader(shader); |
SkSafeUnref(shader); |
} |
@@ -55,33 +56,53 @@ protected: |
} |
virtual SkISize onISize() { |
- return SkISize::Make(75, 100); |
+ return SkISize::Make(150, 100); |
} |
virtual void onDraw(SkCanvas* canvas) { |
SkPaint paint; |
- adopt_shader(&paint, SkShader::CreateBitmapShader(fBitmap, SkShader::kClamp_TileMode, |
- SkShader::kClamp_TileMode)); |
+ for (int i = 0; i < 2; i++) { |
+ SkMatrix s; |
+ s.reset(); |
+ if (1 == i) { |
+ s.setScale(1.5, 1.5); |
+ s.postTranslate(2, 2); |
+ } |
- // draw the shader with a bitmap mask |
- canvas->drawBitmap(fMask, 0, 0, &paint); |
- canvas->drawBitmap(fMask, 30, 0, &paint); |
+ canvas->save(); |
+ adopt_shader(&paint, SkShader::CreateBitmapShader(fBitmap, SkShader::kClamp_TileMode, |
+ SkShader::kClamp_TileMode), s); |
- canvas->translate(0, 25); |
+ // draw the shader with a bitmap mask |
+ canvas->drawBitmap(fMask, 0, 0, &paint); |
+ canvas->drawBitmap(fMask, 30, 0, &paint); |
- canvas->drawCircle(10, 10, 10, paint); |
- canvas->drawCircle(40, 10, 10, paint); // no blue circle expected |
+ canvas->translate(0, 25); |
- canvas->translate(0, 25); |
+ canvas->drawCircle(10, 10, 10, paint); |
+ canvas->drawCircle(40, 10, 10, paint); // no blue circle expected |
- adopt_shader(&paint, SkShader::CreateBitmapShader(fMask, SkShader::kRepeat_TileMode, |
- SkShader::kRepeat_TileMode)); |
- paint.setColor(SK_ColorRED); |
+ canvas->translate(0, 25); |
- // draw the mask using the shader and a color |
- canvas->drawRect(SkRect::MakeXYWH(0, 0, 20, 20), paint); |
- canvas->drawRect(SkRect::MakeXYWH(30, 0, 20, 20), paint); |
+ // clear the shader, colorized by a solid color with a bitmap mask |
+ paint.setShader(NULL); |
+ paint.setColor(SK_ColorGREEN); |
+ canvas->drawBitmap(fMask, 0, 0, &paint); |
+ canvas->drawBitmap(fMask, 30, 0, &paint); |
+ |
+ canvas->translate(0, 25); |
+ |
+ adopt_shader(&paint, SkShader::CreateBitmapShader(fMask, SkShader::kRepeat_TileMode, |
+ SkShader::kRepeat_TileMode), s); |
+ paint.setColor(SK_ColorRED); |
+ |
+ // draw the mask using the shader and a color |
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, 20, 20), paint); |
+ canvas->drawRect(SkRect::MakeXYWH(30, 0, 20, 20), paint); |
+ canvas->restore(); |
+ canvas->translate(60, 0); |
+ } |
} |
private: |