Remove setLocalMatrix calls from picture shader GM.
This makes all --skr tests pass for me. Enabling it by default in DM.
BUG=skia:2378
R=reed@google.com, mtklein@google.com, fmalita@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/260863007
git-svn-id: http://skia.googlecode.com/svn/trunk@14549 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/dm/DMRecordTask.cpp b/dm/DMRecordTask.cpp
index eb8ceec..d1c552f 100644
--- a/dm/DMRecordTask.cpp
+++ b/dm/DMRecordTask.cpp
@@ -4,7 +4,7 @@
#include "SkCommandLineFlags.h"
#include "SkRecording.h"
-DEFINE_bool(skr, false, "If true, run SKR tests.");
+DEFINE_bool(skr, true, "If true, run SKR tests.");
namespace DM {
diff --git a/gm/pictureshader.cpp b/gm/pictureshader.cpp
index 44db338..8b26e48 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 @@
{ 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 @@
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 @@
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 @@
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)); )
-}
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 32707d7..bcb229d 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -402,7 +402,8 @@
* @param tmy The tiling mode to use when sampling the bitmap in the y-direction.
* @return Returns a new shader object. Note: this function never returns null.
*/
- static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy);
+ static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix = NULL);
SK_TO_STRING_VIRT()
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 27cbb00..9084e92 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -18,8 +18,10 @@
#include "GrContext.h"
#endif
-SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy)
- : fPicture(SkRef(picture))
+SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix)
+ : INHERITED(localMatrix)
+ , fPicture(SkRef(picture))
, fTmx(tmx)
, fTmy(tmy) { }
@@ -34,7 +36,8 @@
fPicture->unref();
}
-SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy) {
+SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix) {
if (!picture || 0 == picture->width() || 0 == picture->height()) {
return NULL;
}
@@ -79,6 +82,7 @@
SkAutoMutexAcquire ama(fCachedBitmapShaderMutex);
+ // TODO(fmalita): remove fCachedLocalMatrix from this key after getLocalMatrix is removed.
if (!fCachedBitmapShader || tileScale != fCachedTileScale ||
this->getLocalMatrix() != fCachedLocalMatrix) {
SkBitmap bm;
diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h
index 510c988..2ef6c1c 100644
--- a/src/core/SkPictureShader.h
+++ b/src/core/SkPictureShader.h
@@ -21,7 +21,7 @@
*/
class SkPictureShader : public SkShader {
public:
- static SkPictureShader* Create(SkPicture*, TileMode, TileMode);
+ static SkPictureShader* Create(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
virtual ~SkPictureShader();
virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const SK_OVERRIDE;
@@ -59,7 +59,7 @@
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private:
- SkPictureShader(SkPicture*, TileMode, TileMode);
+ SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const;
SkShader* refBitmapShader(const SkMatrix&) const;
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 0f6ba4c..67dd581 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -193,8 +193,9 @@
return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
}
-SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy) {
- return SkPictureShader::Create(src, tmx, tmy);
+SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix) {
+ return SkPictureShader::Create(src, tmx, tmy, localMatrix);
}
#ifndef SK_IGNORE_TO_STRING