| OLD | NEW |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // We'll undo this via onRestoreBackingMutability() if we can avoid the
COW. | 124 // We'll undo this via onRestoreBackingMutability() if we can avoid the
COW. |
| 125 if (SkPixelRef* pr = fBitmap.pixelRef()) { | 125 if (SkPixelRef* pr = fBitmap.pixelRef()) { |
| 126 pr->setTemporarilyImmutable(); | 126 pr->setTemporarilyImmutable(); |
| 127 } | 127 } |
| 128 } else { | 128 } else { |
| 129 forceCopyMode = kYes_ForceCopyMode; | 129 forceCopyMode = kYes_ForceCopyMode; |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Our pixels are in memory, so read access on the snapshot SkImage could be
cheap. | 132 // Our pixels are in memory, so read access on the snapshot SkImage could be
cheap. |
| 133 // Lock the shared pixel ref to ensure peekPixels() is usable. | 133 // Lock the shared pixel ref to ensure peekPixels() is usable. |
| 134 return SkNewImageFromRasterBitmap(fBitmap, forceCopyMode); | 134 return SkMakeImageFromRasterBitmap(fBitmap, forceCopyMode).release(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void SkSurface_Raster::onRestoreBackingMutability() { | 137 void SkSurface_Raster::onRestoreBackingMutability() { |
| 138 SkASSERT(!this->hasCachedImage()); // Shouldn't be any snapshots out there. | 138 SkASSERT(!this->hasCachedImage()); // Shouldn't be any snapshots out there. |
| 139 if (SkPixelRef* pr = fBitmap.pixelRef()) { | 139 if (SkPixelRef* pr = fBitmap.pixelRef()) { |
| 140 pr->restoreMutability(); | 140 pr->restoreMutability(); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { | 144 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 if (rowBytes) { | 203 if (rowBytes) { |
| 204 SkASSERT(pr->rowBytes() == rowBytes); | 204 SkASSERT(pr->rowBytes() == rowBytes); |
| 205 } | 205 } |
| 206 return new SkSurface_Raster(pr, props); | 206 return new SkSurface_Raster(pr, props); |
| 207 } | 207 } |
| 208 | 208 |
| 209 SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 209 SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
| 210 return NewRaster(info, 0, props); | 210 return NewRaster(info, 0, props); |
| 211 } | 211 } |
| OLD | NEW |