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

Unified Diff: src/image/SkSurface.cpp

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
Index: src/image/SkSurface.cpp
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index bfc019bd4fa7c2a6f7711689ef346e35a663ad22..8c356a8080c818f5cb937da10cb3574ca78f39c7 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -99,7 +99,8 @@ void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
// the surface may need to fork its backend, if its sharing it with
// the cached image. Note: we only call if there is an outstanding owner
// on the image (besides us).
- if (!fCachedImage->unique()) {
+ bool unique = fCachedImage->unique();
+ if (!unique) {
this->onCopyOnWrite(mode);
}
@@ -107,6 +108,13 @@ void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
// that the next request will get our new contents.
fCachedImage->unref();
fCachedImage = NULL;
+
+ if (unique) {
+ // Our content isn't held by any image now, so we can consider that content mutable.
+ // Raster surfaces need to be told it's safe to consider its pixels mutable again.
+ // We make this call after the ->unref() so the subclass can assert there are no images.
+ this->onRestoreBackingMutability();
+ }
} else if (kDiscard_ContentChangeMode == mode) {
this->onDiscard();
}

Powered by Google App Engine
This is Rietveld 408576698