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

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

Issue 872543002: Take budgeted param when snapping new image. (Closed) Base URL: https://skia.googlesource.com/skia.git@budgeted
Patch Set: Address comment and rebase Created 5 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
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/image/SkSurface_Base.h » ('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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // in case the canvas outsurvives us, we null the callback 72 // in case the canvas outsurvives us, we null the callback
73 if (fCachedCanvas) { 73 if (fCachedCanvas) {
74 fCachedCanvas->setSurfaceBase(NULL); 74 fCachedCanvas->setSurfaceBase(NULL);
75 } 75 }
76 76
77 SkSafeUnref(fCachedImage); 77 SkSafeUnref(fCachedImage);
78 SkSafeUnref(fCachedCanvas); 78 SkSafeUnref(fCachedCanvas);
79 } 79 }
80 80
81 void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) { 81 void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) {
82 SkImage* image = this->newImageSnapshot(); 82 SkImage* image = this->newImageSnapshot(kYes_Budgeted);
83 if (image) { 83 if (image) {
84 canvas->drawImage(image, x, y, paint); 84 canvas->drawImage(image, x, y, paint);
85 image->unref(); 85 image->unref();
86 } 86 }
87 } 87 }
88 88
89 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) { 89 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
90 this->dirtyGenerationID(); 90 this->dirtyGenerationID();
91 91
92 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); 92 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 void SkSurface::notifyContentWillChange(ContentChangeMode mode) { 146 void SkSurface::notifyContentWillChange(ContentChangeMode mode) {
147 asSB(this)->aboutToDraw(mode); 147 asSB(this)->aboutToDraw(mode);
148 } 148 }
149 149
150 SkCanvas* SkSurface::getCanvas() { 150 SkCanvas* SkSurface::getCanvas() {
151 return asSB(this)->getCachedCanvas(); 151 return asSB(this)->getCachedCanvas();
152 } 152 }
153 153
154 SkImage* SkSurface::newImageSnapshot() { 154 SkImage* SkSurface::newImageSnapshot(Budgeted budgeted) {
155 SkImage* image = asSB(this)->getCachedImage(); 155 SkImage* image = asSB(this)->getCachedImage(budgeted);
156 SkSafeRef(image); // the caller will call unref() to balance this 156 SkSafeRef(image); // the caller will call unref() to balance this
157 return image; 157 return image;
158 } 158 }
159 159
160 SkSurface* SkSurface::newSurface(const SkImageInfo& info) { 160 SkSurface* SkSurface::newSurface(const SkImageInfo& info) {
161 return asSB(this)->onNewSurface(info); 161 return asSB(this)->onNewSurface(info);
162 } 162 }
163 163
164 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, 164 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y,
165 const SkPaint* paint) { 165 const SkPaint* paint) {
(...skipping 17 matching lines...) Expand all
183 return NULL; 183 return NULL;
184 } 184 }
185 185
186 SkSurface* SkSurface::NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&, int, 186 SkSurface* SkSurface::NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&, int,
187 const SkSurfaceProps*) { 187 const SkSurfaceProps*) {
188 return NULL; 188 return NULL;
189 } 189 }
190 190
191 191
192 #endif 192 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/image/SkSurface_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698