Revert of Remove setLocalMatrix calls from picture shader GM. (https://codereview...
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 2 May 2014 20:51:13 +0000 (20:51 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 2 May 2014 20:51:13 +0000 (20:51 +0000)
Reason for revert:
changed GM unexpectedly.  will sort out and try again

Original issue's description:
> Remove setLocalMatrix calls from picture shader GM.
>
> This makes all --skr tests pass for me.  Enabling it by default in DM.
>
> BUG=skia:2378
>
> Committed: http://code.google.com/p/skia/source/detail?r=14549

R=reed@google.com, fmalita@google.com, mtklein@chromium.org
TBR=fmalita@google.com, mtklein@chromium.org, reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2378

Author: mtklein@google.com

Review URL: https://codereview.chromium.org/265013003

git-svn-id: http://skia.googlecode.com/svn/trunk@14550 2bbb7eff-a529-9590-31e7-b0007b416f81

dm/DMRecordTask.cpp
gm/pictureshader.cpp
include/core/SkShader.h
src/core/SkPictureShader.cpp
src/core/SkPictureShader.h
src/core/SkShader.cpp

index d1c552f569ae55dffccc9681c3cbf1b6438e5175..eb8ceecbbd09dbca414df088ec1df68ae89a959e 100644 (file)
@@ -4,7 +4,7 @@
 #include "SkCommandLineFlags.h"
 #include "SkRecording.h"
 
-DEFINE_bool(skr, true, "If true, run SKR tests.");
+DEFINE_bool(skr, false, "If true, run SKR tests.");
 
 namespace DM {
 
index 8b26e48663b8339f750752a7478eb105645da0ea..44db338fc203bf38fd6ec698e26757bfcd9a3fda 100644 (file)
@@ -13,6 +13,8 @@
 #include "SkPictureRecorder.h"
 #include "SkShader.h"
 
+namespace skiagm {
+
 static struct {
     SkShader::TileMode tmx;
     SkShader::TileMode tmy;
@@ -22,8 +24,9 @@ static struct {
     { SkShader::kMirror_TileMode, SkShader::kRepeat_TileMode },
 };
 
-class PictureShaderGM : public skiagm::GM {
+class PictureShaderGM : public GM {
 public:
+
     PictureShaderGM(SkScalar tileSize, SkScalar sceneSize)
         : fTileSize(tileSize)
         , fSceneSize(sceneSize) {
@@ -34,13 +37,24 @@ public:
                                                           SkScalarRoundToInt(tileSize),
                                                           NULL, 0);
         this->drawTile(pictureCanvas);
-        fPicture.reset(recorder.endRecording());
+        SkAutoTUnref<SkPicture> p(recorder.endRecording());
 
         // Build a reference bitmap.
-        fBitmap.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
-        fBitmap.eraseColor(SK_ColorTRANSPARENT);
-        SkCanvas bitmapCanvas(fBitmap);
+        SkBitmap bm;
+        bm.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
+        bm.eraseColor(SK_ColorTRANSPARENT);
+        SkCanvas bitmapCanvas(bm);
         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:
@@ -131,22 +145,14 @@ private:
         canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
         canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSceneSize), paint);
 
-        SkAutoTUnref<SkShader> pictureShader(SkShader::CreatePictureShader(
-                    fPicture,
-                    kTileConfigs[tileMode].tmx,
-                    kTileConfigs[tileMode].tmy,
-                    &localMatrix));
-        paint.setShader(pictureShader.get());
+        fPictureShaders[tileMode]->setLocalMatrix(localMatrix);
+        paint.setShader(fPictureShaders[tileMode].get());
         canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
 
         canvas->translate(fSceneSize * 1.1f, 0);
 
-        SkAutoTUnref<SkShader> bitmapShader(SkShader::CreateBitmapShader(
-                    fBitmap,
-                    kTileConfigs[tileMode].tmx,
-                    kTileConfigs[tileMode].tmy,
-                    &localMatrix));
-        paint.setShader(bitmapShader.get());
+        fBitmapShaders[tileMode]->setLocalMatrix(localMatrix);
+        paint.setShader(fBitmapShaders[tileMode].get());
         canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
 
         canvas->restore();
@@ -155,10 +161,11 @@ private:
     SkScalar    fTileSize;
     SkScalar    fSceneSize;
 
-    SkAutoTUnref<SkPicture> fPicture;
-    SkBitmap fBitmap;
+    SkAutoTUnref<SkShader> fPictureShaders[SK_ARRAY_COUNT(kTileConfigs)];
+    SkAutoTUnref<SkShader> fBitmapShaders[SK_ARRAY_COUNT(kTileConfigs)];
 
     typedef GM INHERITED;
 };
 
 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
+}
index bcb229d767143caaa0f68370300ddd610966e800..32707d7313c789af8118cd9c4510aa94d715c5a9 100644 (file)
@@ -402,8 +402,7 @@ public:
      *  @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,
-                                         const SkMatrix* localMatrix = NULL);
+    static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy);
 
     SK_TO_STRING_VIRT()
     SK_DEFINE_FLATTENABLE_TYPE(SkShader)
index 9084e92f967d09fbc4048f540c51c9e4612f5e1e..27cbb00f63d0bd0ad0a9feaea43a75e97783c092 100644 (file)
 #include "GrContext.h"
 #endif
 
-SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy,
-                                 const SkMatrix* localMatrix)
-    : INHERITED(localMatrix)
-    , fPicture(SkRef(picture))
+SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy)
+    : fPicture(SkRef(picture))
     , fTmx(tmx)
     , fTmy(tmy) { }
 
@@ -36,8 +34,7 @@ SkPictureShader::~SkPictureShader() {
     fPicture->unref();
 }
 
-SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy,
-                                         const SkMatrix* localMatrix) {
+SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy) {
     if (!picture || 0 == picture->width() || 0 == picture->height()) {
         return NULL;
     }
@@ -82,7 +79,6 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix) const {
 
     SkAutoMutexAcquire ama(fCachedBitmapShaderMutex);
 
-    // TODO(fmalita): remove fCachedLocalMatrix from this key after getLocalMatrix is removed.
     if (!fCachedBitmapShader || tileScale != fCachedTileScale ||
         this->getLocalMatrix() != fCachedLocalMatrix) {
         SkBitmap bm;
index 2ef6c1c92a57e24afedcdcc76cf4408e55886b65..510c9888f58c5eaa391a0856123040ab6be8410a 100644 (file)
@@ -21,7 +21,7 @@ class SkPicture;
  */
 class SkPictureShader : public SkShader {
 public:
-    static SkPictureShader* Create(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
+    static SkPictureShader* Create(SkPicture*, TileMode, TileMode);
     virtual ~SkPictureShader();
 
     virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const SK_OVERRIDE;
@@ -59,7 +59,7 @@ protected:
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
 private:
-    SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
+    SkPictureShader(SkPicture*, TileMode, TileMode);
 
     SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const;
     SkShader* refBitmapShader(const SkMatrix&) const;
index 67dd581543e737970b47b2789df3e16d29509f95..0f6ba4ce9f65855e9937593dddcf6e61e2dff8f7 100644 (file)
@@ -193,9 +193,8 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
     return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
 }
 
-SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
-                                       const SkMatrix* localMatrix) {
-    return SkPictureShader::Create(src, tmx, tmy, localMatrix);
+SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy) {
+    return SkPictureShader::Create(src, tmx, tmy);
 }
 
 #ifndef SK_IGNORE_TO_STRING