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

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

Issue 105893012: change offset to xy for pixelref subsetting (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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/image/SkImage_Raster.cpp ('k') | tests/PictureTest.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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 SkImage* SkSurface_Raster::onNewImageSnapshot() { 116 SkImage* SkSurface_Raster::onNewImageSnapshot() {
117 return SkNewImageFromBitmap(fBitmap, fWeOwnThePixels); 117 return SkNewImageFromBitmap(fBitmap, fWeOwnThePixels);
118 } 118 }
119 119
120 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { 120 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
121 // are we sharing pixelrefs with the image? 121 // are we sharing pixelrefs with the image?
122 SkASSERT(NULL != this->getCachedImage()); 122 SkASSERT(NULL != this->getCachedImage());
123 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef()) { 123 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef()) {
124 SkASSERT(fWeOwnThePixels); 124 SkASSERT(fWeOwnThePixels);
125 if (kDiscard_ContentChangeMode == mode) { 125 if (kDiscard_ContentChangeMode == mode) {
126 fBitmap.setPixelRef(NULL, 0); 126 fBitmap.setPixelRef(NULL);
127 fBitmap.allocPixels(); 127 fBitmap.allocPixels();
128 } else { 128 } else {
129 SkBitmap prev(fBitmap); 129 SkBitmap prev(fBitmap);
130 prev.deepCopyTo(&fBitmap, prev.config()); 130 prev.deepCopyTo(&fBitmap, prev.config());
131 } 131 }
132 // Now fBitmap is a deep copy of itself (and therefore different from 132 // Now fBitmap is a deep copy of itself (and therefore different from
133 // what is being used by the image. Next we update the canvas to use 133 // what is being used by the image. Next we update the canvas to use
134 // this as its backend, so we can't modify the image's pixels anymore. 134 // this as its backend, so we can't modify the image's pixels anymore.
135 SkASSERT(NULL != this->getCachedCanvas()); 135 SkASSERT(NULL != this->getCachedCanvas());
136 this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurfa ce(fBitmap); 136 this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurfa ce(fBitmap);
(...skipping 17 matching lines...) Expand all
154 if (!SkSurface_Raster::Valid(info)) { 154 if (!SkSurface_Raster::Valid(info)) {
155 return NULL; 155 return NULL;
156 } 156 }
157 157
158 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); 158 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
159 if (NULL == pr.get()) { 159 if (NULL == pr.get()) {
160 return NULL; 160 return NULL;
161 } 161 }
162 return SkNEW_ARGS(SkSurface_Raster, (info, pr, info.minRowBytes())); 162 return SkNEW_ARGS(SkSurface_Raster, (info, pr, info.minRowBytes()));
163 } 163 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698