From db3b979ba18e11052c4f88856dacc0bb7799525a Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 12 Jun 2018 15:18:00 -0400 Subject: [PATCH] Fix IsFunctionallyExact Bug: 849034 Change-Id: Icfef534433495e5ad5ab1f3abad05957a0e70a31 Reviewed-on: https://skia-review.googlesource.com/134333 Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- src/core/SkSpecialImage.cpp | 1 + src/gpu/GrProxyProvider.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index 256ef0f6d6..0c6ec5c484 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -461,6 +461,7 @@ public: 0 == subset->fLeft && 0 == subset->fTop && fTextureProxy->width() == subset->width() && fTextureProxy->height() == subset->height()) { + fTextureProxy->priv().exactify(); // The existing GrTexture is already tight so reuse it in the SkImage return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace); } diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index a2b97d173a..a1f14df3e9 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -625,7 +625,15 @@ sk_sp GrProxyProvider::createFullyLazyProxy(LazyInstantiateCallb } bool GrProxyProvider::IsFunctionallyExact(GrSurfaceProxy* proxy) { - return proxy->priv().isExact() || (SkIsPow2(proxy->width()) && SkIsPow2(proxy->height())); + const bool isInstantiated = proxy->priv().isInstantiated(); + // A proxy is functionally exact if: + // it is exact (obvs) + // when it is instantiated it will be exact (i.e., power of two dimensions) + // it is already instantiated and the proxy covers the entire backing surface + return proxy->priv().isExact() || + (!isInstantiated && SkIsPow2(proxy->width()) && SkIsPow2(proxy->height())) || + (isInstantiated && proxy->worstCaseWidth() == proxy->width() && + proxy->worstCaseHeight() == proxy->height()); } void GrProxyProvider::processInvalidProxyUniqueKey(const GrUniqueKey& key) {