aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkSurface_Gpu.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-12-04 13:48:14 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-04 18:54:09 +0000
commit8d1e67ed6b75909ac20211ae3aec130587920cec (patch)
tree7132b299b0492ae8088f0160faccf06d2bf9878d /src/image/SkSurface_Gpu.cpp
parent7d0cd9c3c6262db1a21d22b6ed82241f2463b5ec (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/image/SkSurface_Gpu.cpp')
-rw-r--r--src/image/SkSurface_Gpu.cpp15
1 files changed, 14 insertions, 1 deletions
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() &&