Offer single-param version of deepCopyTo -- much easier to migrate to colortypes
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Feb 2014 19:08:07 +0000 (19:08 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Feb 2014 19:08:07 +0000 (19:08 +0000)
BUG=skia:
R=reed@google.com

Author: reed@chromium.org

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

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

gm/bitmapcopy.cpp
gm/simpleaaclip.cpp
include/core/SkBitmap.h
src/core/SkBitmap.cpp
src/core/SkBitmapHeap.cpp
src/image/SkSurface_Raster.cpp
src/pdf/SkPDFImage.cpp
tests/GpuBitmapCopyTest.cpp

index f210b4a..5bd2bf8 100644 (file)
@@ -72,9 +72,7 @@ protected:
         draw_checks(&canvasTmp, 40, 40);
 
         for (unsigned i = 0; i < NUM_CONFIGS; ++i) {
-            if (!src.deepCopyTo(&fDst[i], gConfigs[i])) {
-                src.copyTo(&fDst[i], gConfigs[i]);
-            }
+            src.copyTo(&fDst[i], gConfigs[i]);
         }
 
         canvas->clear(0xFFDDDDDD);
index a517b50..41fb9fb 100644 (file)
@@ -26,7 +26,7 @@ static void paint_rgn(SkCanvas* canvas, const SkAAClip& clip,
     // need to copy for deferred drawing test to work
     SkBitmap bm2;
 
-    bm.deepCopyTo(&bm2, SkBitmap::kA8_Config);
+    bm.deepCopyTo(&bm2);
 
     canvas->drawBitmap(bm2,
                        SK_Scalar1 * mask.fBounds.fLeft,
index 92d7473..80ccd0a 100644 (file)
@@ -23,6 +23,8 @@ class SkPixelRefFactory;
 class SkRegion;
 class SkString;
 
+#define SK_SUPPORT_DEEPCOPYTO_CONFIG
+
 class GrTexture;
 
 /** \class SkBitmap
@@ -637,7 +639,19 @@ public:
      *  gpu (typically as a texture), the it will do the same for the dst.
      *  If the request cannot be fulfilled, returns false and dst is unmodified.
      */
+#ifndef SK_SUPPORT_DEEPCOPYTO_CONFIG
+private:
+#endif
     bool deepCopyTo(SkBitmap* dst, Config c) const;
+public:
+
+    /** Makes a deep copy of this bitmap, keeping the copied pixels
+     *  in the same domain as the source: If the src pixels are allocated for
+     *  the cpu, then so will the dst. If the src pixels are allocated on the
+     *  gpu (typically as a texture), the it will do the same for the dst.
+     *  If the request cannot be fulfilled, returns false and dst is unmodified.
+     */
+    bool deepCopyTo(SkBitmap* dst) const;
 
     /** Returns true if this bitmap can be deep copied into the requested config
         by calling copyTo().
index 6c9e81f..520ccd3 100644 (file)
@@ -1173,6 +1173,10 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst, Config dstConfig) const {
     }
 }
 
+bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
+    return this->deepCopyTo(dst, this->config());
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
index da62893..efaa23f 100644 (file)
@@ -265,7 +265,7 @@ bool SkBitmapHeap::copyBitmap(const SkBitmap& originalBitmap, SkBitmap& copiedBi
 //        copiedBitmap.setPixelRef(sharedPixelRef, originalBitmap.pixelRefOffset());
     } else if (originalBitmap.empty()) {
         copiedBitmap.reset();
-    } else if (!originalBitmap.deepCopyTo(&copiedBitmap, originalBitmap.config())) {
+    } else if (!originalBitmap.deepCopyTo(&copiedBitmap)) {
         return false;
     }
     copiedBitmap.setImmutable();
index 1b218eb..e24c0e8 100644 (file)
@@ -125,7 +125,7 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
             fBitmap.allocPixels();
         } else {
             SkBitmap prev(fBitmap);
-            prev.deepCopyTo(&fBitmap, prev.config());
+            prev.deepCopyTo(&fBitmap);
         }
         // Now fBitmap is a deep copy of itself (and therefore different from
         // what is being used by the image. Next we update the canvas to use
index 81adcc2..f39dc59 100644 (file)
@@ -507,7 +507,7 @@ SkPDFImage::SkPDFImage(SkStream* stream,
     if (bitmap.isImmutable()) {
         fBitmap = bitmap;
     } else {
-        bitmap.deepCopyTo(&fBitmap, bitmap.config());
+        bitmap.deepCopyTo(&fBitmap);
         fBitmap.setImmutable();
     }
 
index 08ceff2..d5485bb 100644 (file)
@@ -161,6 +161,7 @@ DEF_GPUTEST(GpuBitmapCopy, reporter, factory) {
 
             // Extract a subset. If this succeeds we will test copying the subset.
             SkBitmap subset;
+#ifdef SK_SUPPORT_DEEPCOPYTO_CONFIG
             const bool extracted = src.extractSubset(&subset, subsetRect);
 
             for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) {
@@ -228,6 +229,7 @@ DEF_GPUTEST(GpuBitmapCopy, reporter, factory) {
                                        true);
                 }
             } // for (size_t j = ...
+#endif
         } // for (size_t i = ...
     } // GrContextFactory::GLContextType
 }