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

Side by Side Diff: src/image/SkSurface_Base.h

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
« src/core/SkCanvas.cpp ('K') | « src/image/SkSurface.cpp ('k') | no next file » | 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 #ifndef SkSurface_Base_DEFINED 8 #ifndef SkSurface_Base_DEFINED
9 #define SkSurface_Base_DEFINED 9 #define SkSurface_Base_DEFINED
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 inline SkImage* getCachedImage(Budgeted); 72 inline SkImage* getCachedImage(Budgeted);
73 73
74 // called by SkSurface to compute a new genID 74 // called by SkSurface to compute a new genID
75 uint32_t newGenerationID(); 75 uint32_t newGenerationID();
76 76
77 private: 77 private:
78 SkCanvas* fCachedCanvas; 78 SkCanvas* fCachedCanvas;
79 SkImage* fCachedImage; 79 SkImage* fCachedImage;
80 80
81 void aboutToDraw(ContentChangeMode mode); 81 void aboutToDraw(ContentChangeMode mode);
82
83 // Returns true if there is an outstanding image-snapshot, indicating that a call to aboutToDraw
84 // would trigger a copy-on-write.
85 bool outstandingImageSnapshot() const;
86
82 friend class SkCanvas; 87 friend class SkCanvas;
83 friend class SkSurface; 88 friend class SkSurface;
84 89
85 typedef SkSurface INHERITED; 90 typedef SkSurface INHERITED;
86 }; 91 };
87 92
88 SkCanvas* SkSurface_Base::getCachedCanvas() { 93 SkCanvas* SkSurface_Base::getCachedCanvas() {
89 if (NULL == fCachedCanvas) { 94 if (NULL == fCachedCanvas) {
90 fCachedCanvas = this->onNewCanvas(); 95 fCachedCanvas = this->onNewCanvas();
91 if (fCachedCanvas) { 96 if (fCachedCanvas) {
92 fCachedCanvas->setSurfaceBase(this); 97 fCachedCanvas->setSurfaceBase(this);
93 } 98 }
94 } 99 }
95 return fCachedCanvas; 100 return fCachedCanvas;
96 } 101 }
97 102
98 SkImage* SkSurface_Base::getCachedImage(Budgeted budgeted) { 103 SkImage* SkSurface_Base::getCachedImage(Budgeted budgeted) {
99 if (NULL == fCachedImage) { 104 if (NULL == fCachedImage) {
100 fCachedImage = this->onNewImageSnapshot(budgeted); 105 fCachedImage = this->onNewImageSnapshot(budgeted);
101 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); 106 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
102 } 107 }
103 return fCachedImage; 108 return fCachedImage;
104 } 109 }
105 110
106 #endif 111 #endif
OLDNEW
« src/core/SkCanvas.cpp ('K') | « src/image/SkSurface.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698