| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrLayerCache_DEFINED | 8 #ifndef GrLayerCache_DEFINED |
| 9 #define GrLayerCache_DEFINED | 9 #define GrLayerCache_DEFINED |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 GrTexture* texture() { return fTexture; } | 116 GrTexture* texture() { return fTexture; } |
| 117 const GrIRect16& rect() const { return fRect; } | 117 const GrIRect16& rect() const { return fRect; } |
| 118 | 118 |
| 119 void setPlot(GrPlot* plot) { | 119 void setPlot(GrPlot* plot) { |
| 120 SkASSERT(NULL == plot || NULL == fPlot); | 120 SkASSERT(NULL == plot || NULL == fPlot); |
| 121 fPlot = plot; | 121 fPlot = plot; |
| 122 } | 122 } |
| 123 GrPlot* plot() { return fPlot; } | 123 GrPlot* plot() { return fPlot; } |
| 124 | 124 |
| 125 bool isAtlased() const { return NULL != fPlot; } | 125 bool isAtlased() const { return SkToBool(fPlot); } |
| 126 | 126 |
| 127 void setLocked(bool locked) { fLocked = locked; } | 127 void setLocked(bool locked) { fLocked = locked; } |
| 128 bool locked() const { return fLocked; } | 128 bool locked() const { return fLocked; } |
| 129 | 129 |
| 130 SkDEBUGCODE(const GrPlot* plot() const { return fPlot; }) | 130 SkDEBUGCODE(const GrPlot* plot() const { return fPlot; }) |
| 131 SkDEBUGCODE(void validate(const GrTexture* backingTexture) const;) | 131 SkDEBUGCODE(void validate(const GrTexture* backingTexture) const;) |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 const Key fKey; | 134 const Key fKey; |
| 135 | 135 |
| 136 // fTexture is a ref on the atlasing texture for atlased layers and a | 136 // fTexture is a ref on the atlasing texture for atlased layers and a |
| 137 // ref on a GrTexture for non-atlased textures. | 137 // ref on a GrTexture for non-atlased textures. |
| 138 GrTexture* fTexture; | 138 GrTexture* fTexture; |
| 139 | 139 |
| 140 // For both atlased and non-atlased layers 'fRect' contains the bound of | 140 // For both atlased and non-atlased layers 'fRect' contains the bound of |
| 141 // the layer in whichever texture it resides. It is empty when 'fTexture' | 141 // the layer in whichever texture it resides. It is empty when 'fTexture' |
| 142 // is NULL. | 142 // is NULL. |
| 143 GrIRect16 fRect; | 143 GrIRect16 fRect; |
| 144 | 144 |
| 145 // For atlased layers, fPlot stores the atlas plot in which the layer rests. | 145 // For atlased layers, fPlot stores the atlas plot in which the layer rests. |
| 146 // It is always NULL for non-atlased layers. | 146 // It is always NULL for non-atlased layers. |
| 147 GrPlot* fPlot; | 147 GrPlot* fPlot; |
| 148 | 148 |
| 149 // For non-atlased layers 'fLocked' should always match "NULL != fTexture". | 149 // For non-atlased layers 'fLocked' should always match "fTexture". |
| 150 // (i.e., if there is a texture it is locked). | 150 // (i.e., if there is a texture it is locked). |
| 151 // For atlased layers, 'fLocked' is true if the layer is in a plot and | 151 // For atlased layers, 'fLocked' is true if the layer is in a plot and |
| 152 // actively required for rendering. If the layer is in a plot but not | 152 // actively required for rendering. If the layer is in a plot but not |
| 153 // actively required for rendering, then 'fLocked' is false. If the | 153 // actively required for rendering, then 'fLocked' is false. If the |
| 154 // layer isn't in a plot then is can never be locked. | 154 // layer isn't in a plot then is can never be locked. |
| 155 bool fLocked; | 155 bool fLocked; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 // The GrLayerCache caches pre-computed saveLayers for later rendering. | 158 // The GrLayerCache caches pre-computed saveLayers for later rendering. |
| 159 // Non-atlased layers are stored in their own GrTexture while the atlased | 159 // Non-atlased layers are stored in their own GrTexture while the atlased |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // Try to find a purgeable plot and clear it out. Return true if a plot | 244 // Try to find a purgeable plot and clear it out. Return true if a plot |
| 245 // was purged; false otherwise. | 245 // was purged; false otherwise. |
| 246 bool purgePlot(); | 246 bool purgePlot(); |
| 247 | 247 |
| 248 // for testing | 248 // for testing |
| 249 friend class TestingAccess; | 249 friend class TestingAccess; |
| 250 int numLayers() const { return fLayerHash.count(); } | 250 int numLayers() const { return fLayerHash.count(); } |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 #endif | 253 #endif |
| OLD | NEW |