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

Side by Side Diff: src/gpu/GrLayerCache.h

Issue 678403002: Discard atlas after every MultiPictureDraw::draw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix rebase error Created 6 years, 1 month 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
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | 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 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
11 #include "GrAtlas.h" 11 #include "GrAtlas.h"
12 #include "GrPictureUtils.h" 12 #include "GrPictureUtils.h"
13 #include "GrRect.h" 13 #include "GrRect.h"
14 14
15 #include "SkChecksum.h" 15 #include "SkChecksum.h"
16 #include "SkMessageBus.h" 16 #include "SkMessageBus.h"
17 #include "SkTDynamicHash.h" 17 #include "SkTDynamicHash.h"
18 18
19 class SkPicture; 19 class SkPicture;
20 20
21 // Set to 0 to disable caching of hoisted layers
22 #define GR_CACHE_HOISTED_LAYERS 0
23
21 // The layer cache listens for these messages to purge picture-related resources . 24 // The layer cache listens for these messages to purge picture-related resources .
22 struct GrPictureDeletedMessage { 25 struct GrPictureDeletedMessage {
23 uint32_t pictureID; 26 uint32_t pictureID;
24 }; 27 };
25 28
26 // GrPictureInfo stores the atlas plots used by a single picture. A single 29 // GrPictureInfo stores the atlas plots used by a single picture. A single
27 // plot may be used to store layers from multiple pictures. 30 // plot may be used to store layers from multiple pictures.
28 struct GrPictureInfo { 31 struct GrPictureInfo {
29 public: 32 public:
30 // for SkTDynamicHash - just use the pictureID as the hash key 33 // for SkTDynamicHash - just use the pictureID as the hash key
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 SkDEBUGCODE(void validate() const;) 245 SkDEBUGCODE(void validate() const;)
243 246
244 #ifdef SK_DEVELOPER 247 #ifdef SK_DEVELOPER
245 void writeLayersToDisk(const SkString& dirName); 248 void writeLayersToDisk(const SkString& dirName);
246 #endif 249 #endif
247 250
248 static bool PlausiblyAtlasable(int width, int height) { 251 static bool PlausiblyAtlasable(int width, int height) {
249 return width <= kPlotWidth && height <= kPlotHeight; 252 return width <= kPlotWidth && height <= kPlotHeight;
250 } 253 }
251 254
255 #if !GR_CACHE_HOISTED_LAYERS
256 void purgeAll();
257 #endif
258
252 private: 259 private:
253 static const int kAtlasTextureWidth = 1024; 260 static const int kAtlasTextureWidth = 1024;
254 static const int kAtlasTextureHeight = 1024; 261 static const int kAtlasTextureHeight = 1024;
255 262
256 static const int kNumPlotsX = 2; 263 static const int kNumPlotsX = 2;
257 static const int kNumPlotsY = 2; 264 static const int kNumPlotsY = 2;
258 265
259 static const int kPlotWidth = kAtlasTextureWidth / kNumPlotsX; 266 static const int kPlotWidth = kAtlasTextureWidth / kNumPlotsX;
260 static const int kPlotHeight = kAtlasTextureHeight / kNumPlotsY; 267 static const int kPlotHeight = kAtlasTextureHeight / kNumPlotsY;
261 268
(...skipping 22 matching lines...) Expand all
284 int fPlotLocks[kNumPlotsX * kNumPlotsY]; 291 int fPlotLocks[kNumPlotsX * kNumPlotsY];
285 292
286 // Inform the cache that layer's cached image is not currently required 293 // Inform the cache that layer's cached image is not currently required
287 void unlock(GrCachedLayer* layer); 294 void unlock(GrCachedLayer* layer);
288 295
289 void initAtlas(); 296 void initAtlas();
290 GrCachedLayer* createLayer(uint32_t pictureID, int start, int stop, 297 GrCachedLayer* createLayer(uint32_t pictureID, int start, int stop,
291 const SkIRect& bounds, const SkMatrix& ctm, 298 const SkIRect& bounds, const SkMatrix& ctm,
292 const SkPaint* paint); 299 const SkPaint* paint);
293 300
294 void purgeAll();
295
296 // Remove all the layers (and unlock any resources) associated with 'picture ID' 301 // Remove all the layers (and unlock any resources) associated with 'picture ID'
297 void purge(uint32_t pictureID); 302 void purge(uint32_t pictureID);
298 303
299 void purgePlot(GrPlot* plot); 304 void purgePlot(GrPlot* plot);
300 305
301 // Try to find a purgeable plot and clear it out. Return true if a plot 306 // Try to find a purgeable plot and clear it out. Return true if a plot
302 // was purged; false otherwise. 307 // was purged; false otherwise.
303 bool purgePlot(); 308 bool purgePlot();
304 309
305 void incPlotLock(int plotIdx) { ++fPlotLocks[plotIdx]; } 310 void incPlotLock(int plotIdx) { ++fPlotLocks[plotIdx]; }
306 void decPlotLock(int plotIdx) { 311 void decPlotLock(int plotIdx) {
307 SkASSERT(fPlotLocks[plotIdx] > 0); 312 SkASSERT(fPlotLocks[plotIdx] > 0);
308 --fPlotLocks[plotIdx]; 313 --fPlotLocks[plotIdx];
309 } 314 }
310 315
311 // for testing 316 // for testing
312 friend class TestingAccess; 317 friend class TestingAccess;
313 int numLayers() const { return fLayerHash.count(); } 318 int numLayers() const { return fLayerHash.count(); }
314 }; 319 };
315 320
316 #endif 321 #endif
OLDNEW
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698