aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/bitmapcopy.cpp4
-rw-r--r--gm/simpleaaclip.cpp2
-rw-r--r--include/core/SkBitmap.h14
-rw-r--r--src/core/SkBitmap.cpp4
-rw-r--r--src/core/SkBitmapHeap.cpp2
-rw-r--r--src/image/SkSurface_Raster.cpp2
-rw-r--r--src/pdf/SkPDFImage.cpp2
-rw-r--r--tests/GpuBitmapCopyTest.cpp2
8 files changed, 25 insertions, 7 deletions
diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp
index f210b4aa5e..5bd2bf88da 100644
--- a/gm/bitmapcopy.cpp
+++ b/gm/bitmapcopy.cpp
@@ -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);
diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp
index a517b50dc1..41fb9fba69 100644
--- a/gm/simpleaaclip.cpp
+++ b/gm/simpleaaclip.cpp
@@ -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,
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 92d7473a35..80ccd0ae51 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -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().
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 6c9e81f120..520ccd39f8 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1173,6 +1173,10 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst, Config dstConfig) const {
}
}
+bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
+ return this->deepCopyTo(dst, this->config());
+}
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkBitmapHeap.cpp b/src/core/SkBitmapHeap.cpp
index da628937e9..efaa23fc64 100644
--- a/src/core/SkBitmapHeap.cpp
+++ b/src/core/SkBitmapHeap.cpp
@@ -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();
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 1b218eb446..e24c0e8699 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -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
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index 81adcc20d6..f39dc59085 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -507,7 +507,7 @@ SkPDFImage::SkPDFImage(SkStream* stream,
if (bitmap.isImmutable()) {
fBitmap = bitmap;
} else {
- bitmap.deepCopyTo(&fBitmap, bitmap.config());
+ bitmap.deepCopyTo(&fBitmap);
fBitmap.setImmutable();
}
diff --git a/tests/GpuBitmapCopyTest.cpp b/tests/GpuBitmapCopyTest.cpp
index 08ceff23fb..d5485bbe35 100644
--- a/tests/GpuBitmapCopyTest.cpp
+++ b/tests/GpuBitmapCopyTest.cpp
@@ -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
}