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

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

Issue 741763002: add SkImage::newSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: another warning fix Created 6 years, 1 month 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') | tests/DeferredCanvasTest.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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { 108 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
109 return SkSurface::NewRaster(info); 109 return SkSurface::NewRaster(info);
110 } 110 }
111 111
112 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, 112 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
113 const SkPaint* paint) { 113 const SkPaint* paint) {
114 canvas->drawBitmap(fBitmap, x, y, paint); 114 canvas->drawBitmap(fBitmap, x, y, paint);
115 } 115 }
116 116
117 SkImage* SkSurface_Raster::onNewImageSnapshot() { 117 SkImage* SkSurface_Raster::onNewImageSnapshot() {
118 return SkNewImageFromBitmap(fBitmap, fWeOwnThePixels); 118 return SkNewImageFromBitmap(fBitmap, fWeOwnThePixels, &this->props());
119 } 119 }
120 120
121 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { 121 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
122 // are we sharing pixelrefs with the image? 122 // are we sharing pixelrefs with the image?
123 SkASSERT(this->getCachedImage()); 123 SkASSERT(this->getCachedImage());
124 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef()) { 124 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef()) {
125 SkASSERT(fWeOwnThePixels); 125 SkASSERT(fWeOwnThePixels);
126 if (kDiscard_ContentChangeMode == mode) { 126 if (kDiscard_ContentChangeMode == mode) {
127 fBitmap.setPixelRef(NULL); 127 fBitmap.setPixelRef(NULL);
128 fBitmap.allocPixels(); 128 fBitmap.allocPixels();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 if (!SkSurface_Raster::Valid(info)) { 165 if (!SkSurface_Raster::Valid(info)) {
166 return NULL; 166 return NULL;
167 } 167 }
168 168
169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); 169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
170 if (NULL == pr.get()) { 170 if (NULL == pr.get()) {
171 return NULL; 171 return NULL;
172 } 172 }
173 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); 173 return SkNEW_ARGS(SkSurface_Raster, (pr, props));
174 } 174 }
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698