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

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

Issue 167683006: Offer single-param version of deepCopyTo -- much easier to migrate to colortypes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapHeap.cpp ('k') | src/pdf/SkPDFImage.cpp » ('j') | 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { 118 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
119 // are we sharing pixelrefs with the image? 119 // are we sharing pixelrefs with the image?
120 SkASSERT(NULL != this->getCachedImage()); 120 SkASSERT(NULL != this->getCachedImage());
121 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef()) { 121 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef()) {
122 SkASSERT(fWeOwnThePixels); 122 SkASSERT(fWeOwnThePixels);
123 if (kDiscard_ContentChangeMode == mode) { 123 if (kDiscard_ContentChangeMode == mode) {
124 fBitmap.setPixelRef(NULL); 124 fBitmap.setPixelRef(NULL);
125 fBitmap.allocPixels(); 125 fBitmap.allocPixels();
126 } else { 126 } else {
127 SkBitmap prev(fBitmap); 127 SkBitmap prev(fBitmap);
128 prev.deepCopyTo(&fBitmap, prev.config()); 128 prev.deepCopyTo(&fBitmap);
129 } 129 }
130 // Now fBitmap is a deep copy of itself (and therefore different from 130 // Now fBitmap is a deep copy of itself (and therefore different from
131 // what is being used by the image. Next we update the canvas to use 131 // what is being used by the image. Next we update the canvas to use
132 // this as its backend, so we can't modify the image's pixels anymore. 132 // this as its backend, so we can't modify the image's pixels anymore.
133 SkASSERT(NULL != this->getCachedCanvas()); 133 SkASSERT(NULL != this->getCachedCanvas());
134 this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurfa ce(fBitmap); 134 this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurfa ce(fBitmap);
135 } 135 }
136 } 136 }
137 137
138 /////////////////////////////////////////////////////////////////////////////// 138 ///////////////////////////////////////////////////////////////////////////////
(...skipping 13 matching lines...) Expand all
152 if (!SkSurface_Raster::Valid(info)) { 152 if (!SkSurface_Raster::Valid(info)) {
153 return NULL; 153 return NULL;
154 } 154 }
155 155
156 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); 156 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
157 if (NULL == pr.get()) { 157 if (NULL == pr.get()) {
158 return NULL; 158 return NULL;
159 } 159 }
160 return SkNEW_ARGS(SkSurface_Raster, (pr)); 160 return SkNEW_ARGS(SkSurface_Raster, (pr));
161 } 161 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapHeap.cpp ('k') | src/pdf/SkPDFImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698