Use mipmapping/protected to lookup scratch textures.
Include protected in scratch key.
Change-Id: I0dfc58c9f54e8279a39adf4bad808b7e0e72cba2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241397
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 8408873..82a0d12 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -124,9 +124,10 @@
GrRenderable renderable,
int renderTargetSampleCnt,
SkBudgeted budgeted,
+ GrMipMapped mipMapped,
GrProtected isProtected) {
sk_sp<GrTexture> tex(this->refScratchTexture(desc, format, renderable, renderTargetSampleCnt,
- isProtected));
+ mipMapped, isProtected));
if (tex && SkBudgeted::kNo == budgeted) {
tex->resourcePriv().makeUnbudgeted();
}
@@ -223,9 +224,9 @@
// Compressed textures are read-only so they don't support re-use for scratch.
// TODO: Support GrMipMapped::kYes in scratch texture lookup here.
- if (!GrPixelConfigIsCompressed(desc.fConfig) && mipMapped == GrMipMapped::kNo) {
+ if (!GrPixelConfigIsCompressed(desc.fConfig)) {
sk_sp<GrTexture> tex = this->getExactScratch(
- desc, format, renderable, renderTargetSampleCnt, budgeted, isProtected);
+ desc, format, renderable, renderTargetSampleCnt, budgeted, mipMapped, isProtected);
if (tex) {
return tex;
}
@@ -288,7 +289,7 @@
copyDesc.fHeight = MakeApprox(desc.fHeight);
if (auto tex = this->refScratchTexture(copyDesc, format, renderable, renderTargetSampleCnt,
- isProtected)) {
+ GrMipMapped::kNo, isProtected)) {
return tex;
}
@@ -300,6 +301,7 @@
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
+ GrMipMapped mipMapped,
GrProtected isProtected) {
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
@@ -311,7 +313,8 @@
// to fall back to making a new texture.
if (fGpu->caps()->reuseScratchTextures() || renderable == GrRenderable::kYes) {
GrScratchKey key;
- GrTexturePriv::ComputeScratchKey(desc, renderable, renderTargetSampleCnt, &key);
+ GrTexturePriv::ComputeScratchKey(desc.fConfig, desc.fWidth, desc.fHeight, renderable,
+ renderTargetSampleCnt, mipMapped, isProtected, &key);
GrGpuResource* resource = fCache->findAndRefScratchResource(key);
if (resource) {
fGpu->stats()->incNumScratchTexturesReused();