aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-10-31 15:25:14 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-01 14:10:50 +0000
commit2d59d2f9c5ad642f1b81dc53fa2077c70f341c4d (patch)
tree21313d367376b51debf1a6f7992cb037d26044dd /src/gpu
parenteb4157c5380f719b3cbbd87acd61407f058563b0 (diff)
Update GrTextureMaker to handle mips when copying for npot
Bug: skia: Change-Id: I4b5ea3b8fadf207aef521404c4e9205df23ef3c8 Reviewed-on: https://skia-review.googlesource.com/65900 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrTextureMaker.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index a60a745696..e234180d4b 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -45,32 +45,50 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerSt
GrSurfaceOrigin origOrigin;
GrUniqueKey copyKey;
this->makeCopyKey(copyParams, &copyKey, dstColorSpace);
+ sk_sp<GrTextureProxy> cachedProxy;
if (copyKey.isValid()) {
if (original) {
origOrigin = original->origin();
} else {
origOrigin = kTopLeft_GrSurfaceOrigin;
}
- sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findOrCreateProxyByUniqueKey(
- copyKey, origOrigin));
- if (result) {
- return result;
+ cachedProxy = fContext->resourceProvider()->findOrCreateProxyByUniqueKey(copyKey,
+ origOrigin);
+ if (cachedProxy && (!willBeMipped || GrMipMapped::kYes == cachedProxy->mipMapped())) {
+ return cachedProxy;
}
}
sk_sp<GrTextureProxy> result;
if (original) {
- result = CopyOnGpu(fContext, std::move(original), nullptr, copyParams, willBeMipped);
+ result = std::move(original);
+ } else if (cachedProxy) {
+ result = cachedProxy;
} else {
- result = this->generateTextureProxyForParams(copyParams, willBeMipped, dstColorSpace);
+ // Since we will be copying this texture there is no reason to make it mipped
+ result = this->refOriginalTextureProxy(false, dstColorSpace,
+ AllowedTexGenType::kAny);
+ }
+ if (!result) {
+ return nullptr;
}
+ result = CopyOnGpu(fContext, std::move(result), nullptr, copyParams, willBeMipped);
+
if (!result) {
return nullptr;
}
if (copyKey.isValid()) {
SkASSERT(result->origin() == origOrigin);
+ if (cachedProxy) {
+ SkASSERT(GrMipMapped::kYes == result->mipMapped() &&
+ GrMipMapped::kNo == cachedProxy->mipMapped());
+ // If we had a cachedProxy, that means there already is a proxy in the cache which
+ // matches the key, but it does not have mip levels and we require them. Thus we must
+ // remove the unique key from that proxy.
+ fContext->resourceProvider()->removeUniqueKeyFromProxy(copyKey, cachedProxy.get());
+ }
fContext->resourceProvider()->assignUniqueKeyToProxy(copyKey, result.get());
this->didCacheCopy(copyKey);
}