Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: include/core/SkPixelRef.h

Issue 1254383006: SkImage_Raster's pixels are always immutable. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkPixelRef.cpp » ('j') | src/core/SkPixelRef.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPixelRef.h
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 4d84665a98c0997374d32231a2503fff72532fae..a67855de5fbf03fa8872f9f02dd6ac75e1b3007c 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -152,7 +152,7 @@ public:
/** Returns true if this pixelref is marked as immutable, meaning that the
contents of its pixels will not change for the lifetime of the pixelref.
*/
- bool isImmutable() const { return fIsImmutable; }
+ bool isImmutable() const { return fMutability != kMutable; }
/** Marks this pixelref is immutable, meaning that the contents of its
pixels will not change for the lifetime of the pixelref. This state can
@@ -366,8 +366,13 @@ private:
// Set true by caches when they cache content that's derived from the current pixels.
SkAtomic<bool> fAddedToCache;
- // can go from false to true, but never from true to false
- bool fIsImmutable;
+
+ enum {
+ kMutable, // PixelRefs begin mutable.
+ kTemporarilyImmutable, // Considered immutable, but can revert to mutable.
+ kImmutable, // Once set to this state, it never leaves.
+ } fMutability : 8; // easily fits inside a byte
+
// only ever set in constructor, const after that
bool fPreLocked;
@@ -376,6 +381,10 @@ private:
void setMutex(SkBaseMutex* mutex);
+ void setTemporarilyImmutable();
+ void restoreMutability();
+ friend class SkSurface_Raster; // For the two methods above.
+
// When copying a bitmap to another with the same shape and config, we can safely
// clone the pixelref generation ID too, which makes them equivalent under caching.
friend class SkBitmap; // only for cloneGenID
« no previous file with comments | « no previous file | src/core/SkPixelRef.cpp » ('j') | src/core/SkPixelRef.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698