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

Side by Side Diff: src/image/SkSurface_Raster.cpp

Issue 1372153006: SkImage doesn't use props, so don't need to store it (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 SkImage* SkSurface_Raster::onNewImageSnapshot(Budgeted) { 119 SkImage* SkSurface_Raster::onNewImageSnapshot(Budgeted) {
120 if (fWeOwnThePixels) { 120 if (fWeOwnThePixels) {
121 // SkImage_raster requires these pixels are immutable for its full lifet ime. 121 // SkImage_raster requires these pixels are immutable for its full lifet ime.
122 // We'll undo this via onRestoreBackingMutability() if we can avoid the COW. 122 // We'll undo this via onRestoreBackingMutability() if we can avoid the COW.
123 if (SkPixelRef* pr = fBitmap.pixelRef()) { 123 if (SkPixelRef* pr = fBitmap.pixelRef()) {
124 pr->setTemporarilyImmutable(); 124 pr->setTemporarilyImmutable();
125 } 125 }
126 } 126 }
127 // Our pixels are in memory, so read access on the snapshot SkImage could be cheap. 127 // Our pixels are in memory, so read access on the snapshot SkImage could be cheap.
128 // Lock the shared pixel ref to ensure peekPixels() is usable. 128 // Lock the shared pixel ref to ensure peekPixels() is usable.
129 return SkNewImageFromRasterBitmap(fBitmap, &this->props(), 129 return SkNewImageFromRasterBitmap(fBitmap,
130 fWeOwnThePixels ? kNo_ForceCopyMode : kYes _ForceCopyMode); 130 fWeOwnThePixels ? kNo_ForceCopyMode : kYes _ForceCopyMode);
131 } 131 }
132 132
133 void SkSurface_Raster::onRestoreBackingMutability() { 133 void SkSurface_Raster::onRestoreBackingMutability() {
134 SkASSERT(!this->hasCachedImage()); // Shouldn't be any snapshots out there. 134 SkASSERT(!this->hasCachedImage()); // Shouldn't be any snapshots out there.
135 if (SkPixelRef* pr = fBitmap.pixelRef()) { 135 if (SkPixelRef* pr = fBitmap.pixelRef()) {
136 pr->restoreMutability(); 136 pr->restoreMutability();
137 } 137 }
138 } 138 }
139 139
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (!SkSurface_Raster::Valid(info)) { 184 if (!SkSurface_Raster::Valid(info)) {
185 return nullptr; 185 return nullptr;
186 } 186 }
187 187
188 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, nullptr)) ; 188 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, nullptr)) ;
189 if (nullptr == pr.get()) { 189 if (nullptr == pr.get()) {
190 return nullptr; 190 return nullptr;
191 } 191 }
192 return new SkSurface_Raster(pr, props); 192 return new SkSurface_Raster(pr, props);
193 } 193 }
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698