blob: b9b59d06bcf209a5d1a5fa788e501837c3da75f1 [file] [log] [blame]
robertphillips@google.come930a072014-04-03 00:34:27 +00001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrLayerCache_DEFINED
9#define GrLayerCache_DEFINED
10
robertphillips4ec84da2014-06-24 13:10:43 -070011#include "GrAtlas.h"
robertphillips@google.come930a072014-04-03 00:34:27 +000012#include "GrRect.h"
robertphillips9e6835d2014-10-22 05:33:52 -070013
robertphillips3d533ac2014-07-20 09:40:00 -070014#include "SkChecksum.h"
robertphillipsd771f6b2014-07-22 10:18:06 -070015#include "SkMessageBus.h"
robertphillips82365912014-11-12 09:32:34 -080016#include "SkPicture.h"
robertphillips9e6835d2014-10-22 05:33:52 -070017#include "SkTDynamicHash.h"
robertphillips@google.come930a072014-04-03 00:34:27 +000018
robertphillips4ab5a902014-10-29 13:56:02 -070019// Set to 0 to disable caching of hoisted layers
20#define GR_CACHE_HOISTED_LAYERS 0
21
mtklein04c96952014-11-24 08:20:57 -080022// GrPictureInfo stores the atlas plots used by a single picture. A single
robertphillips261b8a92014-07-17 08:26:44 -070023// plot may be used to store layers from multiple pictures.
24struct GrPictureInfo {
25public:
robertphillips225a6272014-10-30 11:39:19 -070026 static const int kNumPlots = 4;
27
robertphillips3d533ac2014-07-20 09:40:00 -070028 // for SkTDynamicHash - just use the pictureID as the hash key
29 static const uint32_t& GetKey(const GrPictureInfo& pictInfo) { return pictInfo.fPictureID; }
30 static uint32_t Hash(const uint32_t& key) { return SkChecksum::Mix(key); }
31
32 // GrPictureInfo proper
robertphillips225a6272014-10-30 11:39:19 -070033 GrPictureInfo(uint32_t pictureID) : fPictureID(pictureID) {
34#if !GR_CACHE_HOISTED_LAYERS
35 memset(fPlotUses, 0, sizeof(fPlotUses));
36#endif
37 }
38
39#if !GR_CACHE_HOISTED_LAYERS
40 void incPlotUsage(int plotID) {
41 SkASSERT(plotID < kNumPlots);
42 fPlotUses[plotID]++;
43 }
44
45 void decPlotUsage(int plotID) {
46 SkASSERT(plotID < kNumPlots);
47 SkASSERT(fPlotUses[plotID] > 0);
48 fPlotUses[plotID]--;
49 }
50
51 int plotUsage(int plotID) const {
52 SkASSERT(plotID < kNumPlots);
53 return fPlotUses[plotID];
54 }
55#endif
robertphillips261b8a92014-07-17 08:26:44 -070056
robertphillips3d533ac2014-07-20 09:40:00 -070057 const uint32_t fPictureID;
robertphillips261b8a92014-07-17 08:26:44 -070058 GrAtlas::ClientPlotUsage fPlotUsage;
robertphillips225a6272014-10-30 11:39:19 -070059
60#if !GR_CACHE_HOISTED_LAYERS
61private:
62 int fPlotUses[kNumPlots];
63#endif
robertphillips261b8a92014-07-17 08:26:44 -070064};
65
commit-bot@chromium.org365cd312014-04-11 15:53:47 +000066// GrCachedLayer encapsulates the caching information for a single saveLayer.
67//
robertphillips21048b52014-07-15 19:46:35 -070068// Atlased layers get a ref to the backing GrTexture while non-atlased layers
69// get a ref to the GrTexture in which they reside. In both cases 'fRect'
70// contains the layer's extent in its texture.
robertphillips261b8a92014-07-17 08:26:44 -070071// Atlased layers also get a pointer to the plot in which they reside.
robertphillips0c423322014-07-31 11:02:38 -070072// For non-atlased layers, the lock field just corresponds to locking in
73// the resource cache. For atlased layers, it implements an additional level
robertphillips320c9232014-07-29 06:07:19 -070074// of locking to allow atlased layers to be reused multiple times.
commit-bot@chromium.org365cd312014-04-11 15:53:47 +000075struct GrCachedLayer {
robertphillips@google.come930a072014-04-03 00:34:27 +000076public:
robertphillips3d533ac2014-07-20 09:40:00 -070077 // For SkTDynamicHash
78 struct Key {
robertphillips01d6e5f2014-12-01 09:09:27 -080079 Key(uint32_t pictureID, const SkMatrix& initialMat,
robertphillipse99d4992014-12-03 07:33:57 -080080 const unsigned* key, int keySize, bool copyKey = false)
robertphillips01d6e5f2014-12-01 09:09:27 -080081 : fKeySize(keySize)
82 , fFreeKey(copyKey) {
83 fIDMatrix.fPictureID = pictureID;
84 fIDMatrix.fInitialMat = initialMat;
85 fIDMatrix.fInitialMat.getType(); // force initialization of type so hashes match
robertphillips3aac6e02014-10-20 08:52:40 -070086
robertphillips01d6e5f2014-12-01 09:09:27 -080087 if (copyKey) {
robertphillipse99d4992014-12-03 07:33:57 -080088 unsigned* tempKey = SkNEW_ARRAY(unsigned, keySize);
89 memcpy(tempKey, key, keySize*sizeof(unsigned));
robertphillips01d6e5f2014-12-01 09:09:27 -080090 fKey = tempKey;
91 } else {
92 fKey = key;
93 }
94
95 // The pictureID/matrix portion needs to be tightly packed.
96 GR_STATIC_ASSERT(sizeof(IDMatrix) == sizeof(uint32_t)+ // pictureID
97 9 * sizeof(SkScalar) + sizeof(uint32_t)); // matrix
98 }
99
100 ~Key() {
101 if (fFreeKey) {
102 SkDELETE_ARRAY(fKey);
103 }
robertphillips3d533ac2014-07-20 09:40:00 -0700104 }
105
robertphillips0c423322014-07-31 11:02:38 -0700106 bool operator==(const Key& other) const {
robertphillips01d6e5f2014-12-01 09:09:27 -0800107 if (fKeySize != other.fKeySize) {
108 return false;
109 }
110 return fIDMatrix.fPictureID == other.fIDMatrix.fPictureID &&
111 fIDMatrix.fInitialMat.cheapEqualTo(other.fIDMatrix.fInitialMat) &&
112 !memcmp(fKey, other.fKey, fKeySize * sizeof(int));
robertphillips0c423322014-07-31 11:02:38 -0700113 }
114
robertphillips01d6e5f2014-12-01 09:09:27 -0800115 uint32_t pictureID() const { return fIDMatrix.fPictureID; }
116
117 // TODO: remove these when GrCachedLayer & ReplacementInfo fuse
robertphillipse99d4992014-12-03 07:33:57 -0800118 const unsigned* key() const { SkASSERT(fFreeKey); return fKey; }
robertphillips01d6e5f2014-12-01 09:09:27 -0800119 int keySize() const { SkASSERT(fFreeKey); return fKeySize; }
120
121 uint32_t hash() const {
122 uint32_t hash = SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(fKey),
123 fKeySize * sizeof(int));
124 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&fIDMatrix),
125 sizeof(IDMatrix), hash);
126 }
robertphillips3d533ac2014-07-20 09:40:00 -0700127
128 private:
robertphillips01d6e5f2014-12-01 09:09:27 -0800129 struct IDMatrix {
130 // ID of the picture of which this layer is a part
131 uint32_t fPictureID;
132 // The initial matrix passed into drawPicture
133 SkMatrix fInitialMat;
134 } fIDMatrix;
135
robertphillipse99d4992014-12-03 07:33:57 -0800136 const unsigned* fKey;
137 const int fKeySize;
138 bool fFreeKey;
robertphillips3d533ac2014-07-20 09:40:00 -0700139 };
140
141 static const Key& GetKey(const GrCachedLayer& layer) { return layer.fKey; }
robertphillips01d6e5f2014-12-01 09:09:27 -0800142 static uint32_t Hash(const Key& key) { return key.hash(); }
robertphillips952841b2014-06-30 08:26:50 -0700143
robertphillips3d533ac2014-07-20 09:40:00 -0700144 // GrCachedLayer proper
robertphillipse99d4992014-12-03 07:33:57 -0800145 GrCachedLayer(uint32_t pictureID, unsigned start, unsigned stop,
robertphillips3aac6e02014-10-20 08:52:40 -0700146 const SkIRect& bounds, const SkMatrix& ctm,
robertphillipse99d4992014-12-03 07:33:57 -0800147 const unsigned* key, int keySize,
robertphillips3aac6e02014-10-20 08:52:40 -0700148 const SkPaint* paint)
robertphillips01d6e5f2014-12-01 09:09:27 -0800149 : fKey(pictureID, ctm, key, keySize, true)
150 , fStart(start)
robertphillipsed420592014-09-29 11:39:38 -0700151 , fStop(stop)
robertphillips01d6e5f2014-12-01 09:09:27 -0800152 , fBounds(bounds)
robertphillipsa0537de2014-09-18 08:01:23 -0700153 , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL)
robertphillips3d533ac2014-07-20 09:40:00 -0700154 , fTexture(NULL)
robertphillipse99d4992014-12-03 07:33:57 -0800155 , fRect(SkIRect::MakeEmpty())
robertphillips320c9232014-07-29 06:07:19 -0700156 , fPlot(NULL)
robertphillips7bb9ed72014-10-10 11:38:29 -0700157 , fUses(0)
robertphillips320c9232014-07-29 06:07:19 -0700158 , fLocked(false) {
robertphillipse99d4992014-12-03 07:33:57 -0800159 SkASSERT(SK_InvalidGenID != pictureID);
robertphillips3d533ac2014-07-20 09:40:00 -0700160 }
161
robertphillipsed6f03e2014-07-30 07:31:35 -0700162 ~GrCachedLayer() {
163 SkSafeUnref(fTexture);
robertphillipsa0537de2014-09-18 08:01:23 -0700164 SkDELETE(fPaint);
robertphillipsed6f03e2014-07-30 07:31:35 -0700165 }
166
robertphillips0c423322014-07-31 11:02:38 -0700167 uint32_t pictureID() const { return fKey.pictureID(); }
robertphillips01d6e5f2014-12-01 09:09:27 -0800168 // TODO: remove these when GrCachedLayer & ReplacementInfo fuse
robertphillipse99d4992014-12-03 07:33:57 -0800169 const unsigned* key() const { return fKey.key(); }
robertphillips01d6e5f2014-12-01 09:09:27 -0800170 int keySize() const { return fKey.keySize(); }
robertphillips@google.come930a072014-04-03 00:34:27 +0000171
robertphillipse99d4992014-12-03 07:33:57 -0800172 unsigned start() const { return fStart; }
robertphillips01d6e5f2014-12-01 09:09:27 -0800173 // TODO: make bound debug only
174 const SkIRect& bound() const { return fBounds; }
robertphillipse99d4992014-12-03 07:33:57 -0800175 unsigned stop() const { return fStop; }
176 void setTexture(GrTexture* texture, const SkIRect& rect) {
robertphillipsed6f03e2014-07-30 07:31:35 -0700177 SkRefCnt_SafeAssign(fTexture, texture);
robertphillips952841b2014-06-30 08:26:50 -0700178 fRect = rect;
commit-bot@chromium.org365cd312014-04-11 15:53:47 +0000179 }
robertphillips952841b2014-06-30 08:26:50 -0700180 GrTexture* texture() { return fTexture; }
robertphillips4aa6dfc2014-09-17 07:50:47 -0700181 const SkPaint* paint() const { return fPaint; }
robertphillipse99d4992014-12-03 07:33:57 -0800182 const SkIRect& rect() const { return fRect; }
commit-bot@chromium.org365cd312014-04-11 15:53:47 +0000183
robertphillips261b8a92014-07-17 08:26:44 -0700184 void setPlot(GrPlot* plot) {
robertphillips6f294af2014-08-18 08:50:03 -0700185 SkASSERT(NULL == plot || NULL == fPlot);
robertphillips261b8a92014-07-17 08:26:44 -0700186 fPlot = plot;
187 }
188 GrPlot* plot() { return fPlot; }
robertphillips21048b52014-07-15 19:46:35 -0700189
bsalomon49f085d2014-09-05 13:34:00 -0700190 bool isAtlased() const { return SkToBool(fPlot); }
robertphillips261b8a92014-07-17 08:26:44 -0700191
robertphillips320c9232014-07-29 06:07:19 -0700192 void setLocked(bool locked) { fLocked = locked; }
193 bool locked() const { return fLocked; }
194
195 SkDEBUGCODE(const GrPlot* plot() const { return fPlot; })
robertphillips261b8a92014-07-17 08:26:44 -0700196 SkDEBUGCODE(void validate(const GrTexture* backingTexture) const;)
robertphillips21048b52014-07-15 19:46:35 -0700197
robertphillips@google.come930a072014-04-03 00:34:27 +0000198private:
robertphillips3d533ac2014-07-20 09:40:00 -0700199 const Key fKey;
commit-bot@chromium.org365cd312014-04-11 15:53:47 +0000200
robertphillips01d6e5f2014-12-01 09:09:27 -0800201 // The "saveLayer" operation index of the cached layer
robertphillipse99d4992014-12-03 07:33:57 -0800202 const unsigned fStart;
robertphillipsed420592014-09-29 11:39:38 -0700203 // The final "restore" operation index of the cached layer
robertphillipse99d4992014-12-03 07:33:57 -0800204 const unsigned fStop;
robertphillipsed420592014-09-29 11:39:38 -0700205
robertphillips01d6e5f2014-12-01 09:09:27 -0800206 const SkIRect fBounds;
207
robertphillips4aa6dfc2014-09-17 07:50:47 -0700208 // The paint used when dropping the layer down into the owning canvas.
robertphillipsa0537de2014-09-18 08:01:23 -0700209 // Can be NULL. This class makes a copy for itself.
robertphillips4aa6dfc2014-09-17 07:50:47 -0700210 const SkPaint* fPaint;
211
skia.committer@gmail.comd9427312014-04-12 03:05:59 +0000212 // fTexture is a ref on the atlasing texture for atlased layers and a
robertphillips320c9232014-07-29 06:07:19 -0700213 // ref on a GrTexture for non-atlased textures.
commit-bot@chromium.org365cd312014-04-11 15:53:47 +0000214 GrTexture* fTexture;
215
robertphillips21048b52014-07-15 19:46:35 -0700216 // For both atlased and non-atlased layers 'fRect' contains the bound of
217 // the layer in whichever texture it resides. It is empty when 'fTexture'
218 // is NULL.
robertphillipse99d4992014-12-03 07:33:57 -0800219 SkIRect fRect;
robertphillips261b8a92014-07-17 08:26:44 -0700220
221 // For atlased layers, fPlot stores the atlas plot in which the layer rests.
222 // It is always NULL for non-atlased layers.
223 GrPlot* fPlot;
robertphillips320c9232014-07-29 06:07:19 -0700224
robertphillips7bb9ed72014-10-10 11:38:29 -0700225 // The number of actively hoisted layers using this cached image (e.g.,
226 // extant GrHoistedLayers pointing at this object). This object will
227 // be unlocked when the use count reaches 0.
228 int fUses;
229
bsalomon49f085d2014-09-05 13:34:00 -0700230 // For non-atlased layers 'fLocked' should always match "fTexture".
robertphillips320c9232014-07-29 06:07:19 -0700231 // (i.e., if there is a texture it is locked).
232 // For atlased layers, 'fLocked' is true if the layer is in a plot and
233 // actively required for rendering. If the layer is in a plot but not
234 // actively required for rendering, then 'fLocked' is false. If the
235 // layer isn't in a plot then is can never be locked.
236 bool fLocked;
robertphillips7bb9ed72014-10-10 11:38:29 -0700237
238 void addUse() { ++fUses; }
239 void removeUse() { SkASSERT(fUses > 0); --fUses; }
240 int uses() const { return fUses; }
241
242 friend class GrLayerCache; // for access to usage methods
243 friend class TestingAccess; // for testing
robertphillips@google.come930a072014-04-03 00:34:27 +0000244};
245
246// The GrLayerCache caches pre-computed saveLayers for later rendering.
commit-bot@chromium.org365cd312014-04-11 15:53:47 +0000247// Non-atlased layers are stored in their own GrTexture while the atlased
248// layers share a single GrTexture.
robertphillips1d86ee82014-06-24 15:08:49 -0700249// Unlike the GrFontCache, the GrTexture atlas only has one GrAtlas (for 8888)
robertphillips@google.come930a072014-04-03 00:34:27 +0000250// and one GrPlot (for the entire atlas). As such, the GrLayerCache
251// roughly combines the functionality of the GrFontCache and GrTextStrike
252// classes.
253class GrLayerCache {
254public:
robertphillips4ec84da2014-06-24 13:10:43 -0700255 GrLayerCache(GrContext*);
robertphillips@google.come930a072014-04-03 00:34:27 +0000256 ~GrLayerCache();
257
robertphillips4ec84da2014-06-24 13:10:43 -0700258 // As a cache, the GrLayerCache can be ordered to free up all its cached
259 // elements by the GrContext
robertphillips@google.come930a072014-04-03 00:34:27 +0000260 void freeAll();
261
robertphillipse99d4992014-12-03 07:33:57 -0800262 GrCachedLayer* findLayer(uint32_t pictureID, const SkMatrix& ctm,
263 const unsigned* key, int keySize);
robertphillips6f294af2014-08-18 08:50:03 -0700264 GrCachedLayer* findLayerOrCreate(uint32_t pictureID,
robertphillips0c423322014-07-31 11:02:38 -0700265 int start, int stop,
robertphillips3aac6e02014-10-20 08:52:40 -0700266 const SkIRect& bounds,
robertphillips01d6e5f2014-12-01 09:09:27 -0800267 const SkMatrix& initialMat,
robertphillipse99d4992014-12-03 07:33:57 -0800268 const unsigned* key, int keySize,
robertphillips4aa6dfc2014-09-17 07:50:47 -0700269 const SkPaint* paint);
robertphillips6f294af2014-08-18 08:50:03 -0700270
robertphillipsfd61ed02014-10-28 07:21:44 -0700271 // Attempt to place 'layer' in the atlas. Return true on success; false on failure.
272 // When true is returned, 'needsRendering' will indicate if the layer must be (re)drawn.
273 // Additionally, the GPU resources will be locked.
bsalomonf2703d82014-10-28 14:33:06 -0700274 bool tryToAtlas(GrCachedLayer* layer, const GrSurfaceDesc& desc, bool* needsRendering);
robertphillipsfd61ed02014-10-28 07:21:44 -0700275
276 // Attempt to lock the GPU resources required for a layer. Return true on success;
277 // false on failure. When true is returned 'needsRendering' will indicate if the
278 // layer must be (re)drawn.
279 // Note that atlased layers should already have been locked and rendered so only
280 // free floating layers will have 'needsRendering' set.
281 // Currently, this path always uses a new scratch texture for non-Atlased layers
282 // and (thus) doesn't cache anything. This can yield a lot of re-rendering.
283 // TODO: allow rediscovery of free-floating layers that are still in the resource cache.
bsalomonf2703d82014-10-28 14:33:06 -0700284 bool lock(GrCachedLayer* layer, const GrSurfaceDesc& desc, bool* needsRendering);
robertphillips4ec84da2014-06-24 13:10:43 -0700285
robertphillips7bb9ed72014-10-10 11:38:29 -0700286 // addUse is just here to keep the API symmetric
287 void addUse(GrCachedLayer* layer) { layer->addUse(); }
288 void removeUse(GrCachedLayer* layer) {
289 layer->removeUse();
290 if (layer->uses() == 0) {
291 // If no one cares about the layer allow it to be recycled.
292 this->unlock(layer);
293 }
294 }
robertphillips@google.come930a072014-04-03 00:34:27 +0000295
robertphillipsd771f6b2014-07-22 10:18:06 -0700296 // Cleanup after any SkPicture deletions
297 void processDeletedPictures();
robertphillips952841b2014-06-30 08:26:50 -0700298
robertphillips21048b52014-07-15 19:46:35 -0700299 SkDEBUGCODE(void validate() const;)
300
robertphillips84ac0822014-10-14 07:07:59 -0700301#ifdef SK_DEVELOPER
302 void writeLayersToDisk(const SkString& dirName);
303#endif
304
robertphillipsfd61ed02014-10-28 07:21:44 -0700305 static bool PlausiblyAtlasable(int width, int height) {
306 return width <= kPlotWidth && height <= kPlotHeight;
307 }
308
robertphillips4ab5a902014-10-29 13:56:02 -0700309#if !GR_CACHE_HOISTED_LAYERS
310 void purgeAll();
311#endif
312
robertphillips@google.come930a072014-04-03 00:34:27 +0000313private:
robertphillips320c9232014-07-29 06:07:19 -0700314 static const int kAtlasTextureWidth = 1024;
315 static const int kAtlasTextureHeight = 1024;
316
robertphillips261b8a92014-07-17 08:26:44 -0700317 static const int kNumPlotsX = 2;
318 static const int kNumPlotsY = 2;
319
robertphillips320c9232014-07-29 06:07:19 -0700320 static const int kPlotWidth = kAtlasTextureWidth / kNumPlotsX;
321 static const int kPlotHeight = kAtlasTextureHeight / kNumPlotsY;
322
robertphillips4ec84da2014-06-24 13:10:43 -0700323 GrContext* fContext; // pointer back to owning context
robertphillips1d86ee82014-06-24 15:08:49 -0700324 SkAutoTDelete<GrAtlas> fAtlas; // TODO: could lazily allocate
robertphillips261b8a92014-07-17 08:26:44 -0700325
326 // We cache this information here (rather then, say, on the owning picture)
327 // because we want to be able to clean it up as needed (e.g., if a picture
328 // is leaked and never cleans itself up we still want to be able to
329 // remove the GrPictureInfo once its layers are purged from all the atlas
330 // plots).
robertphillips3d533ac2014-07-20 09:40:00 -0700331 SkTDynamicHash<GrPictureInfo, uint32_t> fPictureHash;
robertphillips@google.come930a072014-04-03 00:34:27 +0000332
robertphillips3d533ac2014-07-20 09:40:00 -0700333 SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key> fLayerHash;
robertphillips@google.come930a072014-04-03 00:34:27 +0000334
mtklein04c96952014-11-24 08:20:57 -0800335 SkMessageBus<SkPicture::DeletionMessage>::Inbox fPictDeletionInbox;
robertphillipsd771f6b2014-07-22 10:18:06 -0700336
robertphillips320c9232014-07-29 06:07:19 -0700337 // This implements a plot-centric locking mechanism (since the atlas
338 // backing texture is always locked). Each layer that is locked (i.e.,
339 // needed for the current rendering) in a plot increments the plot lock
robertphillipsa32c6bc2014-10-09 12:47:01 -0700340 // count for that plot. Similarly, once a rendering is complete all the
341 // layers used in it decrement the lock count for the used plots.
342 // Plots with a 0 lock count are open for recycling/purging.
robertphillips320c9232014-07-29 06:07:19 -0700343 int fPlotLocks[kNumPlotsX * kNumPlotsY];
344
robertphillips7bb9ed72014-10-10 11:38:29 -0700345 // Inform the cache that layer's cached image is not currently required
346 void unlock(GrCachedLayer* layer);
347
robertphillips952841b2014-06-30 08:26:50 -0700348 void initAtlas();
robertphillips01d6e5f2014-12-01 09:09:27 -0800349 GrCachedLayer* createLayer(uint32_t pictureID, int start, int stop,
350 const SkIRect& bounds, const SkMatrix& initialMat,
robertphillipse99d4992014-12-03 07:33:57 -0800351 const unsigned* key, int keySize,
robertphillips3aac6e02014-10-20 08:52:40 -0700352 const SkPaint* paint);
robertphillips6f294af2014-08-18 08:50:03 -0700353
robertphillipsd771f6b2014-07-22 10:18:06 -0700354 // Remove all the layers (and unlock any resources) associated with 'pictureID'
355 void purge(uint32_t pictureID);
356
robertphillips6f294af2014-08-18 08:50:03 -0700357 void purgePlot(GrPlot* plot);
358
robertphillips320c9232014-07-29 06:07:19 -0700359 // Try to find a purgeable plot and clear it out. Return true if a plot
360 // was purged; false otherwise.
361 bool purgePlot();
362
robertphillips7bb9ed72014-10-10 11:38:29 -0700363 void incPlotLock(int plotIdx) { ++fPlotLocks[plotIdx]; }
364 void decPlotLock(int plotIdx) {
365 SkASSERT(fPlotLocks[plotIdx] > 0);
366 --fPlotLocks[plotIdx];
367 }
368
robertphillips952841b2014-06-30 08:26:50 -0700369 // for testing
robertphillipsd771f6b2014-07-22 10:18:06 -0700370 friend class TestingAccess;
robertphillips952841b2014-06-30 08:26:50 -0700371 int numLayers() const { return fLayerHash.count(); }
robertphillips@google.come930a072014-04-03 00:34:27 +0000372};
373
374#endif