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

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 yet another bug 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
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerCache.cpp
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 2c97387c7f93fdcfa8851e3773f05c21c8d31118..5fb76d7392dbdda6bec1e3461ca4f93b0235dd47 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -13,8 +13,8 @@ DECLARE_SKMESSAGEBUS_MESSAGE(GrPictureDeletedMessage);
#ifdef SK_DEBUG
void GrCachedLayer::validate(const GrTexture* backingTexture) const {
- SkASSERT(SK_InvalidGenID != fKey.getPictureID());
- SkASSERT(-1 != fKey.getLayerID());
+ SkASSERT(SK_InvalidGenID != fKey.pictureID());
+ SkASSERT(fKey.start() > 0 && fKey.stop() > 0);
if (NULL != fTexture) {
@@ -117,24 +117,31 @@ void GrLayerCache::freeAll() {
this->initAtlas();
}
-GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture, int layerID) {
- SkASSERT(picture->uniqueID() != SK_InvalidGenID && layerID >= 0);
+GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture,
+ int start, int stop,
+ const SkMatrix& ctm) {
+ SkASSERT(picture->uniqueID() != SK_InvalidGenID && start > 0 && stop > 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) {
- SkASSERT(picture->uniqueID() != SK_InvalidGenID && layerID >= 0);
- return fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(), layerID));
+GrCachedLayer* GrLayerCache::findLayer(const SkPicture* picture,
+ int start, int stop,
+ const SkMatrix& ctm) {
+ SkASSERT(picture->uniqueID() != SK_InvalidGenID && start > 0 && stop > 0);
+ return fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(), start, stop, ctm));
}
-GrCachedLayer* GrLayerCache::findLayerOrCreate(const SkPicture* picture, int layerID) {
- SkASSERT(picture->uniqueID() != SK_InvalidGenID && layerID >= 0);
- GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(picture->uniqueID(), layerID));
+GrCachedLayer* GrLayerCache::findLayerOrCreate(const SkPicture* picture,
+ int start, int stop,
+ const SkMatrix& ctm) {
+ SkASSERT(picture->uniqueID() != SK_InvalidGenID && start > 0 && stop > 0);
+ 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());
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698