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

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

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