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

Unified Diff: src/gpu/GrLayerCache.cpp

Issue 433553002: Add CTM to the cached layers' key and reduce render target pingponging in layer pre-rendering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix overlength lines Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrLayerCache.cpp
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 2c97387c7f93fdcfa8851e3773f05c21c8d31118..fc4d08fd33e141d1e9eb78f82b8cc78438c98ba7 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -117,24 +117,31 @@ void GrLayerCache::freeAll() {
this->initAtlas();
}
-GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture,
+ int start, int stop,
+ const SkMatrix& ctm) {
SkASSERT(picture->uniqueID() != SK_InvalidGenID && layerID >= 0);
- GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (picture->uniqueID(), layerID));
+ GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (picture->uniqueID(), start, stop, ctm));
fLayerHash.add(layer);
return layer;
}
-GrCachedLayer* GrLayerCache::findLayer(const SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::findLayer(const SkPicture* picture,
+ int start, int stop,
+ const SkMatrix& ctm) {
SkASSERT(picture->uniqueID() != SK_InvalidGenID && layerID >= 0);
- return fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(), layerID));
+ return fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(), start, stop, ctm));
}
-GrCachedLayer* GrLayerCache::findLayerOrCreate(const SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::findLayerOrCreate(const SkPicture* picture,
+ int start, int stop,
+ const SkMatrix& ctm) {
SkASSERT(picture->uniqueID() != SK_InvalidGenID && layerID >= 0);
- GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(), layerID));
+ GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(),
+ start, stop, ctm));
if (NULL == layer) {
- layer = this->createLayer(picture, layerID);
+ layer = this->createLayer(picture, start, stop, ctm);
}
return layer;
@@ -221,6 +228,19 @@ void GrLayerCache::unlock(GrCachedLayer* layer) {
fPlotLocks[plotID]--;
// At this point we could aggressively clear out un-locked plots but
// by delaying we may be able to reuse some of the atlased layers later.
+#if 0
+ // This testing code aggressively removes the atlased layers. This
+ // can be used to separate the performance contribution of less
+ // render target pingponging from that due to the re-use of cached layers
+ GrPictureInfo* pictInfo = fPictureHash.find(layer->pictureID());
+ SkASSERT(NULL != pictInfo);
+
+ GrAtlas::RemovePlot(&pictInfo->fPlotUsage, layer->plot());
+
+ layer->setPlot(NULL);
+ layer->setTexture(NULL, GrIRect16::MakeEmpty());
+#endif
+
} else {
fContext->unlockScratchTexture(layer->texture());
layer->setTexture(NULL, GrIRect16::MakeEmpty());
« src/gpu/GrLayerCache.h ('K') | « src/gpu/GrLayerCache.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698