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

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

Issue 1236023004: have canvas send discard instead of retain if the draw would overwrite everything (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(kYes_Budgeted); 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 bool SkSurface_Base::outstandingImageSnapshot() const {
90 return fCachedImage && !fCachedImage->unique();
91 }
92
89 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) { 93 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
90 this->dirtyGenerationID(); 94 this->dirtyGenerationID();
91 95
92 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); 96 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
93 97
94 if (fCachedImage) { 98 if (fCachedImage) {
95 // the surface may need to fork its backend, if its sharing it with 99 // the surface may need to fork its backend, if its sharing it with
96 // the cached image. Note: we only call if there is an outstanding owner 100 // the cached image. Note: we only call if there is an outstanding owner
97 // on the image (besides us). 101 // on the image (besides us).
98 if (!fCachedImage->unique()) { 102 if (!fCachedImage->unique()) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 const SkSurfaceProps*) { 204 const SkSurfaceProps*) {
201 return NULL; 205 return NULL;
202 } 206 }
203 207
204 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend erTargetDesc&, 208 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend erTargetDesc&,
205 const SkSurfaceProps*) { 209 const SkSurfaceProps*) {
206 return NULL; 210 return NULL;
207 } 211 }
208 212
209 #endif 213 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698