Turn on quilt mode in DM.
  - Rename TileGrid -> Quilt to avoid the name overload.
  - Tag all failing GMs with kSkipTiled_Flag.

You may be wondering, do any GMs pass?  Yes, some do!  And that trends towards all of them as we increase --quiltTile.

Two GMs only fail in --quilt mode in 565.  Otherwise all GMs which fail are skipped, and those which don't fail aren't. (The 8888 variants of those two GMs are skipped even though they pass.)

BUG=skia:2477
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14457 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/dm/DMCpuGMTask.cpp b/dm/DMCpuGMTask.cpp
index 7ab1d44..e1ba81d 100644
--- a/dm/DMCpuGMTask.cpp
+++ b/dm/DMCpuGMTask.cpp
@@ -1,10 +1,10 @@
 #include "DMCpuGMTask.h"
 #include "DMExpectationsTask.h"
 #include "DMPipeTask.h"
+#include "DMQuiltTask.h"
 #include "DMRecordTask.h"
 #include "DMReplayTask.h"
 #include "DMSerializeTask.h"
-#include "DMTileGridTask.h"
 #include "DMUtil.h"
 #include "DMWriteTask.h"
 
@@ -39,11 +39,11 @@
     SPAWN(PipeTask, fGMFactory(NULL), bitmap, false, false);
     SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, false);
     SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, true);
+    SPAWN(QuiltTask, fGMFactory(NULL), bitmap);
     SPAWN(RecordTask, fGMFactory(NULL), bitmap);
     SPAWN(ReplayTask, fGMFactory(NULL), bitmap, false);
     SPAWN(ReplayTask, fGMFactory(NULL), bitmap, true);
     SPAWN(SerializeTask, fGMFactory(NULL), bitmap);
-    SPAWN(TileGridTask, fGMFactory(NULL), bitmap, SkISize::Make(16,16));
 
     SPAWN(WriteTask, bitmap);
 #undef SPAWN
diff --git a/dm/DMQuiltTask.cpp b/dm/DMQuiltTask.cpp
new file mode 100644
index 0000000..e8f8b60
--- /dev/null
+++ b/dm/DMQuiltTask.cpp
@@ -0,0 +1,68 @@
+#include "DMQuiltTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+
+#include "SkCommandLineFlags.h"
+#include "SkPicture.h"
+
+DEFINE_bool(quilt, true, "If true, draw into a quilt of small tiles and compare.");
+DEFINE_int32(quiltTile, 16, "Dimension of (square) quilt tile.");
+
+namespace DM {
+
+QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
+    : CpuTask(parent)
+    , fName(UnderJoin(parent.name().c_str(), "quilt"))
+    , fGM(gm)
+    , fReference(reference)
+    {}
+
+static int tiles_needed(int fullDimension, int tileDimension) {
+    return (fullDimension + tileDimension - 1) / tileDimension;
+}
+
+void QuiltTask::draw() {
+    SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get()));
+
+    SkBitmap full;
+    SetupBitmap(fReference.colorType(), fGM.get(), &full);
+    SkCanvas fullCanvas(full);
+
+    SkBitmap tile;
+    tile.allocPixels(SkImageInfo::Make(FLAGS_quiltTile, FLAGS_quiltTile,
+                                       fReference.colorType(), kPremul_SkAlphaType));
+    SkCanvas tileCanvas(tile);
+
+    for (int y = 0; y < tiles_needed(full.height(), tile.height()); y++) {
+        for (int x = 0; x < tiles_needed(full.width(), tile.width()); x++) {
+            SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/);
+
+            const SkScalar xOffset = SkIntToScalar(x * tile.width()),
+                           yOffset = SkIntToScalar(y * tile.height());
+            SkMatrix matrix = tileCanvas.getTotalMatrix();
+            matrix.postTranslate(-xOffset, -yOffset);
+            tileCanvas.setMatrix(matrix);
+
+            recorded->draw(&tileCanvas);
+            tileCanvas.flush();
+            fullCanvas.drawBitmap(tile, xOffset, yOffset, NULL);
+        }
+    }
+
+    if (!BitmapsEqual(full, fReference)) {
+        this->fail();
+        this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
+    }
+}
+
+bool QuiltTask::shouldSkip() const {
+    if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
+        return true;
+    }
+    if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) {
+        return true;
+    }
+    return !FLAGS_quilt;
+}
+
+}  // namespace DM
diff --git a/dm/DMQuiltTask.h b/dm/DMQuiltTask.h
new file mode 100644
index 0000000..56f322f
--- /dev/null
+++ b/dm/DMQuiltTask.h
@@ -0,0 +1,33 @@
+#ifndef DMQuiltTask_DEFINED
+#define DMQuiltTask_DEFINED
+
+#include "DMTask.h"
+#include "SkBitmap.h"
+#include "SkString.h"
+#include "SkTemplates.h"
+#include "gm.h"
+
+// Records a GM through an SkPicture, draws it in tiles, and compares against the reference bitmap.
+
+namespace DM {
+
+class QuiltTask : public CpuTask {
+
+public:
+    QuiltTask(const Task& parent,   // QuiltTask must be a child task.  Pass its parent here.
+                skiagm::GM*,          // GM to run through a picture.  Takes ownership.
+                SkBitmap reference);  // Bitmap to compare picture replay results to.
+
+    virtual void draw() SK_OVERRIDE;
+    virtual bool shouldSkip() const SK_OVERRIDE;
+    virtual SkString name() const SK_OVERRIDE { return fName; }
+
+private:
+    const SkString fName;
+    SkAutoTDelete<skiagm::GM> fGM;
+    const SkBitmap fReference;
+};
+
+}  // namespace DM
+
+#endif  // DMReplayTask_DEFINED
diff --git a/dm/DMTileGridTask.cpp b/dm/DMTileGridTask.cpp
deleted file mode 100644
index 4299bd7..0000000
--- a/dm/DMTileGridTask.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "DMTileGridTask.h"
-#include "DMWriteTask.h"
-#include "DMUtil.h"
-
-#include "SkBBHFactory.h"
-#include "SkCommandLineFlags.h"
-#include "SkPicture.h"
-
-// TODO(mtklein): Tile grid tests are currently failing.  (Skia issue 1198).  When fixed, -> true.
-DEFINE_bool(tileGrid, false, "If true, run picture replay tests with a tile grid.");
-
-namespace DM {
-
-TileGridTask::TileGridTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, SkISize tileSize)
-    : CpuTask(parent)
-    , fName(UnderJoin(parent.name().c_str(), "tilegrid"))
-    , fGM(gm)
-    , fReference(reference)
-    , fTileSize(tileSize)
-    {}
-
-static int tiles_needed(int fullDimension, int tileDimension) {
-    return (fullDimension + tileDimension - 1) / tileDimension;
-}
-
-void TileGridTask::draw() {
-    const SkTileGridFactory::TileGridInfo info = {
-        fTileSize,
-        SkISize::Make(0,0),    // Overlap between adjacent tiles.
-        SkIPoint::Make(0,0),   // Offset.
-    };
-    SkTileGridFactory factory(info);
-    SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(),
-                                                   SkPicture::kUsePathBoundsForClip_RecordingFlag,
-                                                   &factory));
-
-    SkBitmap full;
-    SetupBitmap(fReference.colorType(), fGM.get(), &full);
-    SkCanvas fullCanvas(full);
-
-    SkBitmap tile;
-    tile.allocPixels(SkImageInfo::Make(fTileSize.width(), fTileSize.height(),
-                                       fReference.colorType(), kPremul_SkAlphaType));
-    SkCanvas tileCanvas(tile);
-
-    SkPaint paint;
-    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-
-    for (int y = 0; y < tiles_needed(full.height(), tile.height()); y++) {
-        for (int x = 0; x < tiles_needed(full.width(), tile.width()); x++) {
-            SkAutoCanvasRestore ar(&tileCanvas, true/*also save now*/);
-
-            const SkScalar xOffset = SkIntToScalar(x * tile.width()),
-                           yOffset = SkIntToScalar(y * tile.height());
-            SkMatrix matrix = tileCanvas.getTotalMatrix();
-            matrix.postTranslate(-xOffset, -yOffset);
-            tileCanvas.setMatrix(matrix);
-
-            recorded->draw(&tileCanvas);
-            tileCanvas.flush();
-            fullCanvas.drawBitmap(tile, xOffset, yOffset, &paint);
-        }
-    }
-
-    if (!BitmapsEqual(full, fReference)) {
-        this->fail();
-        this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
-    }
-}
-
-bool TileGridTask::shouldSkip() const {
-    if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
-        return true;
-    }
-    if (fGM->getFlags() & skiagm::GM::kSkipTiled_Flag) {
-        return true;
-    }
-    return !FLAGS_tileGrid;
-}
-
-}  // namespace DM
diff --git a/dm/DMTileGridTask.h b/dm/DMTileGridTask.h
deleted file mode 100644
index 911a1c5..0000000
--- a/dm/DMTileGridTask.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef DMTileGridTask_DEFINED
-#define DMTileGridTask_DEFINED
-
-#include "DMTask.h"
-#include "SkBitmap.h"
-#include "SkString.h"
-#include "SkTemplates.h"
-#include "gm.h"
-
-// Records a GM through an SkPicture, draws it in tiles, and compares against the reference bitmap.
-
-namespace DM {
-
-class TileGridTask : public CpuTask {
-
-public:
-    TileGridTask(const Task& parent,  // TileGridTask must be a child task.  Pass its parent here.
-                 skiagm::GM*,         // GM to run through a picture.  Takes ownership.
-                 SkBitmap reference,  // Bitmap to compare picture replay results to.
-                 SkISize tileSize);   // Tile size to use.
-
-    virtual void draw() SK_OVERRIDE;
-    virtual bool shouldSkip() const SK_OVERRIDE;
-    virtual SkString name() const SK_OVERRIDE { return fName; }
-
-private:
-    const SkString fName;
-    SkAutoTDelete<skiagm::GM> fGM;
-    const SkBitmap fReference;
-    const SkISize fTileSize;
-};
-
-}  // namespace DM
-
-#endif  // DMReplayTask_DEFINED