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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSurface_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) { 93 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
94 this->dirtyGenerationID(); 94 this->dirtyGenerationID();
95 95
96 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); 96 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
97 97
98 if (fCachedImage) { 98 if (fCachedImage) {
99 // the surface may need to fork its backend, if its sharing it with 99 // the surface may need to fork its backend, if its sharing it with
100 // the cached image. Note: we only call if there is an outstanding owner 100 // the cached image. Note: we only call if there is an outstanding owner
101 // on the image (besides us). 101 // on the image (besides us).
102 if (!fCachedImage->unique()) { 102 bool unique = fCachedImage->unique();
103 if (!unique) {
103 this->onCopyOnWrite(mode); 104 this->onCopyOnWrite(mode);
104 } 105 }
105 106
106 // regardless of copy-on-write, we must drop our cached image now, so 107 // regardless of copy-on-write, we must drop our cached image now, so
107 // that the next request will get our new contents. 108 // that the next request will get our new contents.
108 fCachedImage->unref(); 109 fCachedImage->unref();
109 fCachedImage = NULL; 110 fCachedImage = NULL;
111
112 if (unique) {
113 // Our content isn't held by any image now, so we can consider that content mutable.
114 // Raster surfaces need to be told it's safe to consider its pixels mutable again.
115 // We make this call after the ->unref() so the subclass can assert there are no images.
116 this->onRestoreBackingMutability();
117 }
110 } else if (kDiscard_ContentChangeMode == mode) { 118 } else if (kDiscard_ContentChangeMode == mode) {
111 this->onDiscard(); 119 this->onDiscard();
112 } 120 }
113 } 121 }
114 122
115 uint32_t SkSurface_Base::newGenerationID() { 123 uint32_t SkSurface_Base::newGenerationID() {
116 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); 124 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
117 static int32_t gID; 125 static int32_t gID;
118 return sk_atomic_inc(&gID) + 1; 126 return sk_atomic_inc(&gID) + 1;
119 } 127 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const SkSurfaceProps*) { 212 const SkSurfaceProps*) {
205 return NULL; 213 return NULL;
206 } 214 }
207 215
208 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend erTargetDesc&, 216 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend erTargetDesc&,
209 const SkSurfaceProps*) { 217 const SkSurfaceProps*) {
210 return NULL; 218 return NULL;
211 } 219 }
212 220
213 #endif 221 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698