Fixes for factory GM.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 16 Aug 2013 19:18:12 +0000 (19:18 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 16 Aug 2013 19:18:12 +0000 (19:18 +0000)
Skip cross process pipe playback in gm/factory.cpp. Add a new flag to
gm.h to skip only this form of pipe playback.

In gmmain.cpp, use a bitmap encoder function for serialization that
stores the encoded data if present, and use a bitmap decoder on
deserialization. This allows gm/factory to work through serialization.
Also respect the new pipe skipping flag.

BUG=https://code.google.com/p/skia/issues/detail?id=1231
R=borenet@google.com

Author: scroggo@google.com

Review URL: https://chromiumcodereview.appspot.com/23192004

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

gm/factory.cpp
gm/gm.h
gm/gmmain.cpp

index a7356a96e30a61288c5be5aaa883a201fbe21927..6734235abb583aa66b5325feeca1ff1e5edefd1e 100644 (file)
@@ -57,6 +57,11 @@ protected:
         canvas->drawBitmap(fBitmap, 0, 0);
     }
 
+    // Skip cross process pipe due to https://code.google.com/p/skia/issues/detail?id=1520
+    virtual uint32_t onGetFlags() const {
+        return INHERITED::onGetFlags() | kSkipPipeCrossProcess_Flag;
+    }
+
 private:
     SkBitmap fBitmap;
 
diff --git a/gm/gm.h b/gm/gm.h
index bb263c774126c770e7f64f858f6f908a808c0e35..f8069737b2c9d223d0254dcb810c7f83d2183e25 100644 (file)
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -34,13 +34,14 @@ namespace skiagm {
         virtual ~GM();
 
         enum Flags {
-            kSkipPDF_Flag           = 1 << 0,
-            kSkipPicture_Flag       = 1 << 1,
-            kSkipPipe_Flag          = 1 << 2,
-            kSkipTiled_Flag         = 1 << 3,
-            kSkip565_Flag           = 1 << 4,
-            kSkipScaledReplay_Flag  = 1 << 5,
-            kSkipGPU_Flag           = 1 << 6,
+            kSkipPDF_Flag               = 1 << 0,
+            kSkipPicture_Flag           = 1 << 1,
+            kSkipPipe_Flag              = 1 << 2,
+            kSkipPipeCrossProcess_Flag  = 1 << 3,
+            kSkipTiled_Flag             = 1 << 4,
+            kSkip565_Flag               = 1 << 5,
+            kSkipScaledReplay_Flag      = 1 << 6,
+            kSkipGPU_Flag               = 1 << 7,
         };
 
         void draw(SkCanvas*);
index a4ddbcee4789dffc5cc3834899d2e3679d6b372d..773e1e769c72811cf458aac59278b3cd1a3d2c04 100644 (file)
@@ -1014,11 +1014,24 @@ public:
         return pict;
     }
 
+    static SkData* bitmap_encoder(size_t* pixelRefOffset, const SkBitmap& bm) {
+        SkPixelRef* pr = bm.pixelRef();
+        if (pr != NULL) {
+            SkData* data = pr->refEncodedData();
+            if (data != NULL) {
+                *pixelRefOffset = bm.pixelRefOffset();
+                return data;
+            }
+        }
+        return NULL;
+    }
+
     static SkPicture* stream_to_new_picture(const SkPicture& src) {
         SkDynamicMemoryWStream storage;
-        src.serialize(&storage);
+        src.serialize(&storage, &bitmap_encoder);
         SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream());
-        SkPicture* retval = SkPicture::CreateFromStream(pictReadback);
+        SkPicture* retval = SkPicture::CreateFromStream(pictReadback,
+                                                        &SkImageDecoder::DecodeMemory);
         return retval;
     }
 
@@ -1108,7 +1121,9 @@ public:
             SkString renderModeDescriptor("-pipe");
             renderModeDescriptor.append(gPipeWritingFlagCombos[i].name);
 
-            if (gm->getFlags() & GM::kSkipPipe_Flag) {
+            if (gm->getFlags() & GM::kSkipPipe_Flag
+                || (gPipeWritingFlagCombos[i].flags == SkGPipeWriter::kCrossProcess_Flag
+                    && gm->getFlags() & GM::kSkipPipeCrossProcess_Flag)) {
                 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
                                   renderModeDescriptor.c_str());
                 errors.add(kIntentionallySkipped_ErrorType);