diff options
author | Robert Phillips <robertphillips@google.com> | 2017-12-04 13:48:14 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-04 18:54:09 +0000 |
commit | 8d1e67ed6b75909ac20211ae3aec130587920cec (patch) | |
tree | 7132b299b0492ae8088f0160faccf06d2bf9878d /src | |
parent | 7d0cd9c3c6262db1a21d22b6ed82241f2463b5ec (diff) |
Add resource cache limits to SkSurfaceCharacterization
Change-Id: I4c3b2f1c6ecc39b2364cefae07d5dee5e3d20d60
Reviewed-on: https://skia-review.googlesource.com/79600
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 14 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 15 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 68cf42ef2a..2b185c4ebc 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1022,19 +1022,19 @@ bool GrContext::validPMUPMConversionExists() { ////////////////////////////////////////////////////////////////////////////// -void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes) const { +void GrContext::getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const { ASSERT_SINGLE_OWNER - if (maxTextures) { - *maxTextures = fResourceCache->getMaxResourceCount(); + if (maxResources) { + *maxResources = fResourceCache->getMaxResourceCount(); } - if (maxTextureBytes) { - *maxTextureBytes = fResourceCache->getMaxResourceBytes(); + if (maxResourceBytes) { + *maxResourceBytes = fResourceCache->getMaxResourceBytes(); } } -void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { +void GrContext::setResourceCacheLimits(int maxResources, size_t maxResourceBytes) { ASSERT_SINGLE_OWNER - fResourceCache->setLimits(maxTextures, maxTextureBytes); + fResourceCache->setLimits(maxResources, maxResourceBytes); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index dc1f308512..fc66e43e6c 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -164,7 +164,12 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* data) const { GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext(); GrContext* ctx = fDevice->context(); - data->set(ctx->threadSafeProxy(), rtc->origin(), rtc->width(), rtc->height(), + int maxResourceCount; + size_t maxResourceBytes; + ctx->getResourceCacheLimits(&maxResourceCount, &maxResourceBytes); + + data->set(ctx->threadSafeProxy(), maxResourceCount, maxResourceBytes, + rtc->origin(), rtc->width(), rtc->height(), rtc->colorSpaceInfo().config(), rtc->fsaaType(), rtc->numStencilSamples(), rtc->colorSpaceInfo().refColorSpace(), this->props()); @@ -175,7 +180,15 @@ bool SkSurface_Gpu::isCompatible(const SkSurfaceCharacterization& data) const { GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext(); GrContext* ctx = fDevice->context(); + // As long as the current state if the context allows for greater or equal resources, + // we allow the DDL to be replayed. + int maxResourceCount; + size_t maxResourceBytes; + ctx->getResourceCacheLimits(&maxResourceCount, &maxResourceBytes); + return data.contextInfo() && data.contextInfo()->matches(ctx) && + data.cacheMaxResourceCount() <= maxResourceCount && + data.cacheMaxResourceBytes() <= maxResourceBytes && data.origin() == rtc->origin() && data.width() == rtc->width() && data.height() == rtc->height() && data.config() == rtc->colorSpaceInfo().config() && data.fsaaType() == rtc->fsaaType() && data.stencilCount() == rtc->numStencilSamples() && |