diff options
author | 2014-10-28 07:21:44 -0700 | |
---|---|---|
committer | 2014-10-28 07:21:44 -0700 | |
commit | fd61ed0d7929cf85e0b936f48c72035af4c0a4b3 (patch) | |
tree | c91a06c5372a7846a01fe12a21e7597a790f88a3 /src/gpu/GrLayerCache.h | |
parent | ed53742e92c94d5ce20b982833725cf20546aaca (diff) |
Alter layer hoisting to only hoist layers for one canvas at a time
This CL alters layer hoisting to defer creation of the free floating layers until they are actually needed (rather than creating _all_ the hoisted layers at the start).
It also fixes a pre vs. post Concat bug with how matrices were being accumulated.
BUG=skia:2315
Review URL: https://codereview.chromium.org/657383004
Diffstat (limited to 'src/gpu/GrLayerCache.h')
-rw-r--r-- | src/gpu/GrLayerCache.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h index adf904f833..58887d6405 100644 --- a/src/gpu/GrLayerCache.h +++ b/src/gpu/GrLayerCache.h @@ -208,10 +208,20 @@ public: const SkMatrix& ctm, const SkPaint* paint); - // Inform the cache that layer's cached image is now required. - // Return true if the layer must be re-rendered. Return false if the - // layer was found in the cache and can be reused. - bool lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool dontAtlas); + // Attempt to place 'layer' in the atlas. Return true on success; false on failure. + // When true is returned, 'needsRendering' will indicate if the layer must be (re)drawn. + // Additionally, the GPU resources will be locked. + bool tryToAtlas(GrCachedLayer* layer, const GrTextureDesc& desc, bool* needsRendering); + + // Attempt to lock the GPU resources required for a layer. Return true on success; + // false on failure. When true is returned 'needsRendering' will indicate if the + // layer must be (re)drawn. + // Note that atlased layers should already have been locked and rendered so only + // free floating layers will have 'needsRendering' set. + // Currently, this path always uses a new scratch texture for non-Atlased layers + // and (thus) doesn't cache anything. This can yield a lot of re-rendering. + // TODO: allow rediscovery of free-floating layers that are still in the resource cache. + bool lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool* needsRendering); // addUse is just here to keep the API symmetric void addUse(GrCachedLayer* layer) { layer->addUse(); } @@ -235,6 +245,10 @@ public: void writeLayersToDisk(const SkString& dirName); #endif + static bool PlausiblyAtlasable(int width, int height) { + return width <= kPlotWidth && height <= kPlotHeight; + } + private: static const int kAtlasTextureWidth = 1024; static const int kAtlasTextureHeight = 1024; @@ -282,10 +296,6 @@ private: // Remove all the layers (and unlock any resources) associated with 'pictureID' void purge(uint32_t pictureID); - static bool PlausiblyAtlasable(int width, int height) { - return width <= kPlotWidth && height <= kPlotHeight; - } - void purgePlot(GrPlot* plot); // Try to find a purgeable plot and clear it out. Return true if a plot |