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

Unified Diff: gm/pictureshadertile.cpp

Issue 733203005: Tweak SkPictureShader's tile semantics. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | src/core/SkPictureShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | src/core/SkPictureShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698