SkImage_Raster's pixels are always immutable.
To make this work, we tag their pixelrefs as temporarily immutable, allowing
ourselves to restore the pixels to mutability only when the image drops away.
This should allow us to wobble back and forth between writing to the Surface
and reading from the Image without a COW, with the Surface seeing mutable
pixels and the Image seeing immutable pixels.
The big idea is, Image doesn't need forever-immutable pixels, it just needs
pixels that are immutable as long as it's alive.
BUG=skia:
patch from issue 804523002 at patchset 40001 (http://crrev.com/804523002#ps40001)
Review URL: https://codereview.chromium.org/1254383006
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index a52a2b4..8f0eef3 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -68,9 +68,17 @@
*/
virtual void onCopyOnWrite(ContentChangeMode) = 0;
+ /**
+ * Signal the surface to remind its backing store that it's mutable again.
+ * Called only when we _didn't_ copy-on-write; we assume the copies start mutable.
+ */
+ virtual void onRestoreBackingMutability() {}
+
inline SkCanvas* getCachedCanvas();
inline SkImage* getCachedImage(Budgeted);
+ bool hasCachedImage() const { return fCachedImage != NULL; }
+
// called by SkSurface to compute a new genID
uint32_t newGenerationID();