Patch to prevent chromium breakage until the DEPS.
authorscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 21 May 2013 20:45:03 +0000 (20:45 +0000)
committerscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 21 May 2013 20:45:03 +0000 (20:45 +0000)
Once https://codereview.chromium.org/15489004/ is submitted to
Skia, a DEPS roll into chrome will break due to a change in the
API. A long term fix for chrome to use the new API is at
https://codereview.chromium.org/15496006/, but since it depends
on the earlier Skia change, this patch fills in the gap.

Will be reverted once https://codereview.chromium.org/15496006/
is submitted to chrome.

R=djsollen@google.com

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

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

include/core/SkPicture.h
src/core/SkPicture.cpp

index f4acdc8322e30893f260c1162d308f053b6c58e8..156d098ae6c8384783089a4f018d9fc94f4d0b81 100644 (file)
@@ -189,6 +189,21 @@ public:
      */
     void serialize(SkWStream*, EncodeBitmap encoder = NULL) const;
 
+    /**
+     *  @Deprecated
+     *  Old version of EncodeBitmap, here to prevent chrome tree from going
+     *  red. Will be removed once chrome is switched to the new version.
+     */
+    typedef bool (*OldEncodeBitmap)(SkWStream*, const SkBitmap&);
+
+    /**
+     *  @Deprecated
+     *  Old version of serialize, taking the old version of EncodeBitmap,
+     *  to keep the chrome build green. Will be removed once chrome is
+     *  switched to the new version.
+     */
+    void serialize(SkWStream*, OldEncodeBitmap) const;
+
 #ifdef SK_BUILD_FOR_ANDROID
     /** Signals that the caller is prematurely done replaying the drawing
         commands. This can be called from a canvas virtual while the picture
index ab2faea6b6b4eb38b6e0a9a9ac4ae5338cb46c8b..6d3772823c899408f935419dde90ae8791b1881c 100644 (file)
@@ -301,6 +301,34 @@ void SkPicture::initFromStream(SkStream* stream, bool* success, InstallPixelRefP
     }
 }
 
+#define PREVENT_CHROME_BREAKAGE
+#ifdef PREVENT_CHROME_BREAKAGE
+// This block of code is to allow chromium to build until https://codereview.chromium.org/15496006/
+// is submitted. Then it will be reverted.
+#include "SkThread.h"
+
+static SkPicture::OldEncodeBitmap gOldEncodeBitmapFunction;
+
+SK_DECLARE_STATIC_MUTEX(gEncodeFunctionMutex);
+
+static SkData* encode_from_old_encoder(size_t* pixelRefOffset, const SkBitmap& bm) {
+    SkASSERT(gOldEncodeBitmapFunction != NULL);
+    SkDynamicMemoryWStream stream;
+    if (!gOldEncodeBitmapFunction(&stream, bm)) {
+        return NULL;
+    }
+    return stream.copyToData();
+}
+
+void SkPicture::serialize(SkWStream* stream, OldEncodeBitmap oldEncoder) const {
+    SkAutoMutexAcquire ac(gEncodeFunctionMutex);
+    gOldEncodeBitmapFunction = oldEncoder;
+    this->serialize(stream, &encode_from_old_encoder);
+    gOldEncodeBitmapFunction = NULL;
+}
+
+#endif // PREVENT_CHROME_BREAKAGE
+
 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
     SkPicturePlayback* playback = fPlayback;