From fc711a2b0143aa4f559ef041068af1c04d7dab85 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 13 Feb 2018 17:03:00 -0500 Subject: Add SkCharacterization creation helper to GrContextThreadSafeProxy (take 2) TBR=bsalomon@google.com Change-Id: Id96d4fdbb6889065f10a4a7e0c22a03ad9aa5fef Reviewed-on: https://skia-review.googlesource.com/107000 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- src/image/SkSurface_Gpu.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/image') diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 03780c099e..78dcd59e54 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -174,7 +174,7 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* data) const { bool mipmapped = rtc->asTextureProxy() ? GrMipMapped::kYes == rtc->asTextureProxy()->mipMapped() : false; - data->set(ctx->threadSafeProxy(), maxResourceCount, maxResourceBytes, + data->set(ctx->threadSafeProxy(), maxResourceBytes, rtc->origin(), rtc->width(), rtc->height(), rtc->colorSpaceInfo().config(), rtc->fsaaType(), rtc->numStencilSamples(), SkSurfaceCharacterization::Textureable(SkToBool(rtc->asTextureProxy())), @@ -188,8 +188,13 @@ bool SkSurface_Gpu::isCompatible(const SkSurfaceCharacterization& data) const { GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext(); GrContext* ctx = fDevice->context(); + if (!data.isValid()) { + return false; + } + // As long as the current state if the context allows for greater or equal resources, // we allow the DDL to be replayed. + // DDL TODO: should we just remove the resource check and ignore the cache limits on playback? int maxResourceCount; size_t maxResourceBytes; ctx->getResourceCacheLimits(&maxResourceCount, &maxResourceBytes); @@ -210,7 +215,6 @@ bool SkSurface_Gpu::isCompatible(const SkSurfaceCharacterization& data) const { } 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() && @@ -220,7 +224,7 @@ bool SkSurface_Gpu::isCompatible(const SkSurfaceCharacterization& data) const { } bool SkSurface_Gpu::onDraw(const SkDeferredDisplayList* ddl) { - if (!this->isCompatible(ddl->characterization())) { + if (!ddl || !this->isCompatible(ddl->characterization())) { return false; } -- cgit v1.2.3