Rename onGetPixelsEnum back to onGetPixels.
authorscroggo <scroggo@google.com>
Fri, 20 Feb 2015 02:44:58 +0000 (18:44 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 20 Feb 2015 02:44:58 +0000 (18:44 -0800)
Replace the old signature of onGetPixels (return bool) to return an
enum (Result). Remove onGetPixelsEnum.

Add a define for onGetPixelsEnum to onGetPixels. This is for staging
in Chromium, where some implementations override onGetPixelsEnum.

Add the define in skia_for_chromium_defines. Remove
SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN, which is no longer needed by
Chromium.

BUG=skia:3257

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

gyp/skia_for_chromium_defines.gypi
include/core/SkImageGenerator.h
src/core/SkImageGenerator.cpp
src/images/SkDecodingImageGenerator.cpp
src/ports/SkImageGenerator_skia.cpp
tests/CachedDecodingPixelRefTest.cpp

index bcb33a2..6d10ac2 100644 (file)
@@ -14,7 +14,7 @@
     #
     'skia_for_chromium_defines': [
       'SK_LEGACY_DRAWPICTURECALLBACK',
-      'SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN',
+      'SK_SUPPORT_LEGACY_GET_PIXELS_ENUM',
     ],
   },
 }
index de58b68..4e89d76 100644 (file)
@@ -15,7 +15,11 @@ class SkBitmap;
 class SkData;
 class SkImageGenerator;
 
-//#define SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
+//#define SK_SUPPORT_LEGACY_GET_PIXELS_ENUM
+
+#ifdef SK_SUPPORT_LEGACY_GET_PIXELS_ENUM
+    #define onGetPixelsEnum onGetPixels
+#endif
 
 /**
  *  Takes ownership of SkImageGenerator.  If this method fails for
@@ -179,15 +183,9 @@ public:
 protected:
     virtual SkData* onRefEncodedData();
     virtual bool onGetInfo(SkImageInfo* info);
-#ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
-    virtual bool onGetPixels(const SkImageInfo& info,
-                             void* pixels, size_t rowBytes,
-                             SkPMColor ctable[], int* ctableCount);
-#endif
-    // TODO (scroggo): rename to onGetPixels.
-    virtual Result onGetPixelsEnum(const SkImageInfo& info,
-                                   void* pixels, size_t rowBytes,
-                                   SkPMColor ctable[], int* ctableCount);
+    virtual Result onGetPixels(const SkImageInfo& info,
+                               void* pixels, size_t rowBytes,
+                               SkPMColor ctable[], int* ctableCount);
     virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]);
     virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
                                  SkYUVColorSpace* colorSpace);
index 0e43d1d..aabe83e 100644 (file)
@@ -40,7 +40,7 @@ SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
         ctable = NULL;
     }
 
-    const Result result = this->onGetPixelsEnum(info, pixels, rowBytes, ctable, ctableCount);
+    const Result result = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount);
 
     if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
         SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
@@ -119,19 +119,7 @@ bool SkImageGenerator::onGetInfo(SkImageInfo*) {
     return false;
 }
 
-#ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
-bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t,
+SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t,
                                                        SkPMColor*, int*) {
-    return false;
-}
-#endif
-SkImageGenerator::Result SkImageGenerator::onGetPixelsEnum(const SkImageInfo& info, void* pixels,
-                                                           size_t rowBytes, SkPMColor* colors,
-                                                           int* colorCount) {
-#ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
-    if (this->onGetPixels(info, pixels, rowBytes, colors, colorCount)) {
-        return kSuccess;
-    }
-#endif
     return kUnimplemented;
 }
index cce01d2..f9b9393 100644 (file)
@@ -42,9 +42,9 @@ protected:
         *info = fInfo;
         return true;
     }
-    virtual Result onGetPixelsEnum(const SkImageInfo& info,
-                              void* pixels, size_t rowBytes,
-                              SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
+    virtual Result onGetPixels(const SkImageInfo& info,
+                               void* pixels, size_t rowBytes,
+                               SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
     virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
                                  SkYUVColorSpace* colorSpace) SK_OVERRIDE;
 
@@ -147,7 +147,7 @@ SkData* DecodingImageGenerator::onRefEncodedData() {
     return SkSafeRef(fData);
 }
 
-SkImageGenerator::Result DecodingImageGenerator::onGetPixelsEnum(const SkImageInfo& info,
+SkImageGenerator::Result DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
         void* pixels, size_t rowBytes, SkPMColor ctableEntries[], int* ctableCount) {
     if (fInfo != info) {
         // The caller has specified a different info.  This is an
index 079da56..6c27f45 100644 (file)
@@ -52,7 +52,7 @@ protected:
         return true;
     }
 
-    virtual Result onGetPixelsEnum(const SkImageInfo& info, void* pixels, size_t rowBytes,
+    virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
                                SkPMColor ctableEntries[], int* ctableCount) SK_OVERRIDE {
         SkMemoryStream stream(fData->data(), fData->size(), false);
         SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocator,
index 51cb7ba..3882026 100644 (file)
@@ -189,7 +189,7 @@ protected:
         return true;
     }
 
-    virtual Result onGetPixelsEnum(const SkImageInfo& info, void* pixels, size_t rowBytes,
+    virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
                                SkPMColor ctable[], int* ctableCount) SK_OVERRIDE {
         REPORTER_ASSERT(fReporter, pixels != NULL);
         REPORTER_ASSERT(fReporter, rowBytes >= info.minRowBytes());