OLD | NEW |
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 Loading... |
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 |
OLD | NEW |