diff options
author | Chris Dalton <csmartdalton@google.com> | 2019-01-04 13:23:51 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2019-01-04 20:51:09 +0000 |
commit | d6fa45472cb82b7d8e58d0437f7723c672488b8b (patch) | |
tree | f774473053a70543dd10c5baf22f1eafc12c9205 /tools | |
parent | 5809a4e2c3adfdacf32862dbed41042e270f9b81 (diff) | |
download | skqp-d6fa45472cb82b7d8e58d0437f7723c672488b8b.tar.gz |
ccpr: Rework the path cache to support sporadic flushing
Removes the notion of a stashed atlas that we store from the previous
flush. Now we just cache every atlas we ever render. Cached atlases
can either be 16-bit or 8-bit.
The "reuse" and "animation" cases should both behave exactly the same
as before: Where before we would copy from the stashed atlas to 8-bit
atlases, we now copy from a cached 16-bit atlas and then invalidate
it. Where before we would recycle the stashed atlas's backing texture
object, we now recycle this same texture object from an invalidated
16-bit cached atlas.
The main difference is that cases like tiled rendering now work. If
you draw your whole scene in one flush, you still get one big 16-bit
cached atlas, just like the "stashed atlas" implementation. But if you
draw your scene in tiles, you now get lots of little cached 16-bit
atlases, which can be reused and eventually copied to 8-bit atlases.
Bug: skia:8462
Change-Id: Ibae65febb948230aaaf1f1361eef9c8f06ebef18
Reviewed-on: https://skia-review.googlesource.com/c/179991
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gpu/GrTest.cpp | 50 | ||||
-rw-r--r-- | tools/sk_tool_utils.cpp | 3 |
2 files changed, 50 insertions, 3 deletions
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index 89dbaa59be..43b9b38477 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -27,6 +27,7 @@ #include "SkString.h" #include "SkTo.h" #include "ccpr/GrCoverageCountingPathRenderer.h" +#include "ccpr/GrCCPathCache.h" #include "ops/GrMeshDrawOp.h" #include "text/GrGlyphCache.h" #include "text/GrTextBlobCache.h" @@ -278,10 +279,55 @@ void GrCoverageCountingPathRenderer::testingOnly_drawPathDirectly(const DrawPath this->onDrawPath(args); } -const GrUniqueKey& GrCoverageCountingPathRenderer::testingOnly_getStashedAtlasKey() const { - return fStashedAtlasKey; +const GrCCPerFlushResources* +GrCoverageCountingPathRenderer::testingOnly_getCurrentFlushResources() { + SkASSERT(fFlushing); + if (fFlushingPaths.empty()) { + return nullptr; + } + // All pending paths should share the same resources. + const GrCCPerFlushResources* resources = fFlushingPaths.front()->fFlushResources.get(); +#ifdef SK_DEBUG + for (const auto& flushingPaths : fFlushingPaths) { + SkASSERT(flushingPaths->fFlushResources.get() == resources); + } +#endif + return resources; +} + +const GrCCPathCache* GrCoverageCountingPathRenderer::testingOnly_getPathCache() const { + return fPathCache.get(); +} + +const GrTexture* GrCCPerFlushResources::testingOnly_frontCopyAtlasTexture() const { + if (fCopyAtlasStack.empty()) { + return nullptr; + } + const GrTextureProxy* proxy = fCopyAtlasStack.front().textureProxy(); + return (proxy) ? proxy->peekTexture() : nullptr; } +const GrTexture* GrCCPerFlushResources::testingOnly_frontRenderedAtlasTexture() const { + if (fRenderedAtlasStack.empty()) { + return nullptr; + } + const GrTextureProxy* proxy = fRenderedAtlasStack.front().textureProxy(); + return (proxy) ? proxy->peekTexture() : nullptr; +} + +const SkTHashTable<GrCCPathCache::HashNode, const GrCCPathCache::Key&>& +GrCCPathCache::testingOnly_getHashTable() const { + return fHashTable; +} + +const SkTInternalLList<GrCCPathCacheEntry>& GrCCPathCache::testingOnly_getLRU() const { + return fLRU; +} + +int GrCCPathCacheEntry::testingOnly_peekOnFlushRefCnt() const { return fOnFlushRefCnt; } + +int GrCCCachedAtlas::testingOnly_peekOnFlushRefCnt() const { return fOnFlushRefCnt; } + ////////////////////////////////////////////////////////////////////////////// #define DRAW_OP_TEST_EXTERN(Op) \ diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index 374d00fd9c..a50dffc788 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -175,11 +175,12 @@ void get_text_path(const SkFont& font, const void* text, size_t length, SkTextEn } SkPath make_star(const SkRect& bounds, int numPts, int step) { + SkASSERT(numPts != step); SkPath path; path.setFillType(SkPath::kEvenOdd_FillType); path.moveTo(0,-1); for (int i = 1; i < numPts; ++i) { - int idx = i*step; + int idx = i*step % numPts; SkScalar theta = idx * 2*SK_ScalarPI/numPts + SK_ScalarPI/2; SkScalar x = SkScalarCos(theta); SkScalar y = -SkScalarSin(theta); |