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

Unified Diff: gm/pictureshader.cpp

Issue 260863007: Remove setLocalMatrix calls from picture shader GM. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pass the localMatrix... Created 6 years, 8 months 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 | « dm/DMRecordTask.cpp ('k') | include/core/SkShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/pictureshader.cpp
diff --git a/gm/pictureshader.cpp b/gm/pictureshader.cpp
index 44db338fc203bf38fd6ec698e26757bfcd9a3fda..8b26e48663b8339f750752a7478eb105645da0ea 100644
--- a/gm/pictureshader.cpp
+++ b/gm/pictureshader.cpp
@@ -13,8 +13,6 @@
#include "SkPictureRecorder.h"
#include "SkShader.h"
-namespace skiagm {
-
static struct {
SkShader::TileMode tmx;
SkShader::TileMode tmy;
@@ -24,9 +22,8 @@ static struct {
{ SkShader::kMirror_TileMode, SkShader::kRepeat_TileMode },
};
-class PictureShaderGM : public GM {
+class PictureShaderGM : public skiagm::GM {
public:
-
PictureShaderGM(SkScalar tileSize, SkScalar sceneSize)
: fTileSize(tileSize)
, fSceneSize(sceneSize) {
@@ -37,24 +34,13 @@ public:
SkScalarRoundToInt(tileSize),
NULL, 0);
this->drawTile(pictureCanvas);
- SkAutoTUnref<SkPicture> p(recorder.endRecording());
+ fPicture.reset(recorder.endRecording());
// Build a reference bitmap.
- SkBitmap bm;
- bm.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
- bm.eraseColor(SK_ColorTRANSPARENT);
- SkCanvas bitmapCanvas(bm);
+ fBitmap.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
+ fBitmap.eraseColor(SK_ColorTRANSPARENT);
+ SkCanvas bitmapCanvas(fBitmap);
this->drawTile(&bitmapCanvas);
-
- for (unsigned i = 0; i < SK_ARRAY_COUNT(kTileConfigs); ++i) {
- fPictureShaders[i].reset(SkShader::CreatePictureShader(p,
- kTileConfigs[i].tmx,
- kTileConfigs[i].tmy));
-
- fBitmapShaders[i].reset(SkShader::CreateBitmapShader(bm,
- kTileConfigs[i].tmx,
- kTileConfigs[i].tmy));
- }
}
protected:
@@ -145,14 +131,22 @@ private:
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSceneSize), paint);
- fPictureShaders[tileMode]->setLocalMatrix(localMatrix);
- paint.setShader(fPictureShaders[tileMode].get());
+ SkAutoTUnref<SkShader> pictureShader(SkShader::CreatePictureShader(
+ fPicture,
+ kTileConfigs[tileMode].tmx,
+ kTileConfigs[tileMode].tmy,
+ &localMatrix));
+ paint.setShader(pictureShader.get());
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->translate(fSceneSize * 1.1f, 0);
- fBitmapShaders[tileMode]->setLocalMatrix(localMatrix);
- paint.setShader(fBitmapShaders[tileMode].get());
+ SkAutoTUnref<SkShader> bitmapShader(SkShader::CreateBitmapShader(
+ fBitmap,
+ kTileConfigs[tileMode].tmx,
+ kTileConfigs[tileMode].tmy,
+ &localMatrix));
+ paint.setShader(bitmapShader.get());
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->restore();
@@ -161,11 +155,10 @@ private:
SkScalar fTileSize;
SkScalar fSceneSize;
- SkAutoTUnref<SkShader> fPictureShaders[SK_ARRAY_COUNT(kTileConfigs)];
- SkAutoTUnref<SkShader> fBitmapShaders[SK_ARRAY_COUNT(kTileConfigs)];
+ SkAutoTUnref<SkPicture> fPicture;
+ SkBitmap fBitmap;
typedef GM INHERITED;
};
DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
-}
« no previous file with comments | « dm/DMRecordTask.cpp ('k') | include/core/SkShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698