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

Unified Diff: src/gpu/GrLayerCache.cpp

Issue 657383004: Alter layer hoisting to only hoist layers for one canvas at a time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix noGPU build Created 6 years, 2 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/GrLayerHoister.h » ('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 154c6f3621f16c515f054f949171ab539daaa5ad..ccb5bb0be48661de61f055d9960e711bfef883e5 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -161,29 +161,29 @@ GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID,
return layer;
}
-bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool dontAtlas) {
+bool GrLayerCache::tryToAtlas(GrCachedLayer* layer,
+ const GrTextureDesc& desc,
+ bool* needsRendering) {
SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);)
+ SkASSERT(PlausiblyAtlasable(desc.fWidth, desc.fHeight));
+
if (layer->locked()) {
// This layer is already locked
-#ifdef SK_DEBUG
- if (layer->isAtlased()) {
- // It claims to be atlased
- SkASSERT(!dontAtlas);
- SkASSERT(layer->rect().width() == desc.fWidth);
- SkASSERT(layer->rect().height() == desc.fHeight);
- }
-#endif
- return false;
+ SkASSERT(layer->isAtlased());
+ SkASSERT(layer->rect().width() == desc.fWidth);
+ SkASSERT(layer->rect().height() == desc.fHeight);
+ *needsRendering = false;
+ return true;
}
if (layer->isAtlased()) {
// Hooray it is still in the atlas - make sure it stays there
- SkASSERT(!dontAtlas);
layer->setLocked(true);
this->incPlotLock(layer->plot()->id());
- return false;
- } else if (!dontAtlas && PlausiblyAtlasable(desc.fWidth, desc.fHeight)) {
+ *needsRendering = false;
+ return true;
+ } else {
// Not in the atlas - will it fit?
GrPictureInfo* pictInfo = fPictureHash.find(layer->pictureID());
if (NULL == pictInfo) {
@@ -207,6 +207,7 @@ bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do
layer->setPlot(plot);
layer->setLocked(true);
this->incPlotLock(layer->plot()->id());
+ *needsRendering = true;
return true;
}
@@ -218,14 +219,26 @@ bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do
}
}
- // The texture wouldn't fit in the cache - give it it's own texture.
- // This path always uses a new scratch texture and (thus) doesn't cache anything.
- // This can yield a lot of re-rendering
+ return false;
+}
+
+bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool* needsRendering) {
+ if (layer->locked()) {
+ // This layer is already locked
+ *needsRendering = false;
+ return true;
+ }
+
SkAutoTUnref<GrTexture> tex(
fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
+ if (!tex) {
+ return false;
+ }
+
layer->setTexture(tex, GrIRect16::MakeWH(SkToS16(desc.fWidth), SkToS16(desc.fHeight)));
layer->setLocked(true);
+ *needsRendering = true;
return true;
}
@@ -275,13 +288,7 @@ void GrLayerCache::validate() const {
layer->validate(fAtlas->getTexture());
const GrPictureInfo* pictInfo = fPictureHash.find(layer->pictureID());
- if (pictInfo) {
- // In aggressive cleanup mode a picture info should only exist if
- // it has some atlased layers
-#if !DISABLE_CACHING
- SkASSERT(!pictInfo->fPlotUsage.isEmpty());
-#endif
- } else {
+ if (!pictInfo) {
// If there is no picture info for this picture then all of its
// layers should be non-atlased.
SkASSERT(!layer->isAtlased());
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | src/gpu/GrLayerHoister.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698