Index: gm/pictureshadertile.cpp |
diff --git a/gm/pictureshadertile.cpp b/gm/pictureshadertile.cpp |
index ecea55334ba0d8fbef90d3cc8fe4c74977f2e7a5..ae87a5534dec7ef327751b51e8be5227779c4f80 100644 |
--- a/gm/pictureshadertile.cpp |
+++ b/gm/pictureshadertile.cpp |
@@ -21,50 +21,69 @@ static const struct { |
SkScalar offsetX, offsetY; |
} tiles[] = { |
{ 0, 0, 1, 1, 0, 0 }, |
- { 0.5f, 0.5f, 1, 1, 0, 0 }, |
{ -0.5f, -0.5f, 1, 1, 0, 0 }, |
+ { 0.5f, 0.5f, 1, 1, 0, 0 }, |
{ 0, 0, 1.5f, 1.5f, 0, 0 }, |
- { 0.5f, 0.5f, 1.5f, 1.5f, 0, 0 }, |
{ -0.5f, -0.5f, 1.5f, 1.5f, 0, 0 }, |
+ { 0.5f, 0.5f, 1.5f, 1.5f, 0, 0 }, |
{ 0, 0, 0.5f, 0.5f, 0, 0 }, |
- { -0.25f, -0.25f, 0.5f, 0.5f, 0, 0 }, |
{ 0.25f, 0.25f, 0.5f, 0.5f, 0, 0 }, |
+ { -0.25f, -0.25f, 0.5f, 0.5f, 0, 0 }, |
{ 0, 0, 1, 1, 0.5f, 0.5f }, |
- { 0.5f, 0.5f, 1, 1, 0.5f, 0.5f }, |
{ -0.5f, -0.5f, 1, 1, 0.5f, 0.5f }, |
+ { 0.5f, 0.5f, 1, 1, 0.5f, 0.5f }, |
{ 0, 0, 1.5f, 1.5f, 0.5f, 0.5f }, |
- { 0.5f, 0.5f, 1.5f, 1.5f, 0.5f, 0.5f }, |
{ -0.5f, -0.5f, 1.5f, 1.5f, 0.5f, 0.5f }, |
+ { 0.5f, 0.5f, 1.5f, 1.5f, 0.5f, 0.5f }, |
{ 0, 0, 1.5f, 1, 0, 0 }, |
- { 0.5f, 0.5f, 1.5f, 1, 0, 0 }, |
{ -0.5f, -0.5f, 1.5f, 1, 0, 0 }, |
+ { 0.5f, 0.5f, 1.5f, 1, 0, 0 }, |
{ 0, 0, 0.5f, 1, 0, 0 }, |
- { -0.25f, -0.25f, 0.5f, 1, 0, 0 }, |
{ 0.25f, 0.25f, 0.5f, 1, 0, 0 }, |
+ { -0.25f, -0.25f, 0.5f, 1, 0, 0 }, |
{ 0, 0, 1, 1.5f, 0, 0 }, |
- { 0.5f, 0.5f, 1, 1.5f, 0, 0 }, |
{ -0.5f, -0.5f, 1, 1.5f, 0, 0 }, |
+ { 0.5f, 0.5f, 1, 1.5f, 0, 0 }, |
{ 0, 0, 1, 0.5f, 0, 0 }, |
- { -0.25f, -0.25f, 1, 0.5f, 0, 0 }, |
{ 0.25f, 0.25f, 1, 0.5f, 0, 0 }, |
+ { -0.25f, -0.25f, 1, 0.5f, 0, 0 }, |
}; |
class PictureShaderTileGM : public skiagm::GM { |
-public: |
- PictureShaderTileGM() { |
+protected: |
robertphillips
2014/12/08 20:01:31
rm these virtual keywords?
|
+ virtual uint32_t onGetFlags() const SK_OVERRIDE { |
+ return kSkipTiled_Flag; |
+ } |
+ |
+ virtual SkString onShortName() SK_OVERRIDE { |
+ return SkString("pictureshadertile"); |
+ } |
+ |
+ virtual SkISize onISize() SK_OVERRIDE { |
+ return SkISize::Make(800, 600); |
+ } |
+ |
+ virtual void onOnceBeforeDraw() SK_OVERRIDE { |
SkPictureRecorder recorder; |
- SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPictureSize, NULL, 0); |
+ SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPictureSize); |
drawScene(pictureCanvas, kPictureSize); |
SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
+ SkPoint offset = SkPoint::Make(100, 100); |
+ pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), offset.y(), |
+ kPictureSize, kPictureSize)); |
+ pictureCanvas->translate(offset.x(), offset.y()); |
+ drawScene(pictureCanvas, kPictureSize); |
+ SkAutoTUnref<SkPicture> offsetPicture(recorder.endRecording()); |
+ |
for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) { |
SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize, |
tiles[i].y * kPictureSize, |
@@ -75,27 +94,24 @@ public: |
tiles[i].offsetY * kPictureSize); |
localMatrix.postScale(kFillSize / (2 * kPictureSize), |
kFillSize / (2 * kPictureSize)); |
- fShaders[i].reset(SkShader::CreatePictureShader(picture, |
+ |
+ SkPicture* picturePtr = picture.get(); |
+ SkRect* tilePtr = &tile; |
+ |
+ if (tile == SkRect::MakeWH(kPictureSize, kPictureSize)) { |
+ // When the tile == picture bounds, exercise the picture + offset path. |
+ picturePtr = offsetPicture.get(); |
+ tilePtr = NULL; |
+ } |
+ |
+ fShaders[i].reset(SkShader::CreatePictureShader(picturePtr, |
robertphillips
2014/12/08 20:01:31
tab these guys over?
|
SkShader::kRepeat_TileMode, |
SkShader::kRepeat_TileMode, |
&localMatrix, |
- &tile)); |
+ tilePtr)); |
} |
} |
-protected: |
- virtual uint32_t onGetFlags() const SK_OVERRIDE { |
- return kSkipTiled_Flag; |
- } |
- |
- virtual SkString onShortName() SK_OVERRIDE { |
- return SkString("pictureshadertile"); |
- } |
- |
- virtual SkISize onISize() SK_OVERRIDE { |
- return SkISize::Make(800, 600); |
- } |
- |
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
canvas->clear(SK_ColorBLACK); |