Remove GrPixelConfig from GrSurface and GrSurfaceProxy.
This also requires us to compute a scratch key from backend format instead of config.
Bug: skia:6718
Change-Id: I6bf4c5ba8188e354ddc5307ebf2ca10080df27cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265768
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 1f6b398..dfe8e6a 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -34,13 +34,12 @@
// So fully lazy proxies are created with width and height < 0. Regular lazy proxies must be
// created with positive widths and heights. The width and height are set to 0 only after a
// failed instantiation. The former must be "approximate" fit while the latter can be either.
- return desc.fConfig != kUnknown_GrPixelConfig &&
- ((desc.fWidth < 0 && desc.fHeight < 0 && SkBackingFit::kApprox == fit) ||
+ return ((desc.fWidth < 0 && desc.fHeight < 0 && SkBackingFit::kApprox == fit) ||
(desc.fWidth > 0 && desc.fHeight > 0));
}
static bool is_valid_non_lazy(const GrSurfaceDesc& desc) {
- return desc.fWidth > 0 && desc.fHeight > 0 && desc.fConfig != kUnknown_GrPixelConfig;
+ return desc.fWidth > 0 && desc.fHeight > 0;
}
#endif
@@ -57,7 +56,6 @@
UseAllocator useAllocator)
: fSurfaceFlags(surfaceFlags)
, fFormat(format)
- , fConfig(desc.fConfig)
, fDimensions{desc.fWidth, desc.fHeight}
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
@@ -84,7 +82,6 @@
UseAllocator useAllocator)
: fSurfaceFlags(surfaceFlags)
, fFormat(format)
- , fConfig(desc.fConfig)
, fDimensions{desc.fWidth, desc.fHeight}
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
@@ -108,7 +105,6 @@
: fTarget(std::move(surface))
, fSurfaceFlags(fTarget->surfacePriv().flags())
, fFormat(fTarget->backendFormat())
- , fConfig(fTarget->config())
, fDimensions(fTarget->dimensions())
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
@@ -139,7 +135,6 @@
GrSurfaceDesc desc;
desc.fWidth = fDimensions.width();
desc.fHeight = fDimensions.height();
- desc.fConfig = fConfig;
sk_sp<GrSurface> surface;
if (SkBackingFit::kApprox == fFit) {
@@ -222,7 +217,7 @@
fTarget = nullptr;
}
-void GrSurfaceProxy::computeScratchKey(GrScratchKey* key) const {
+void GrSurfaceProxy::computeScratchKey(const GrCaps& caps, GrScratchKey* key) const {
SkASSERT(!this->isFullyLazy());
GrRenderable renderable = GrRenderable::kNo;
int sampleCount = 1;
@@ -237,8 +232,8 @@
mipMapped = tp->mipMapped();
}
- GrTexturePriv::ComputeScratchKey(this->config(), this->backingStoreDimensions(), renderable,
- sampleCount, mipMapped, fIsProtected, key);
+ GrTexturePriv::ComputeScratchKey(caps, this->backendFormat(), this->backingStoreDimensions(),
+ renderable, sampleCount, mipMapped, fIsProtected, key);
}
void GrSurfaceProxy::setLastRenderTask(GrRenderTask* renderTask) {
@@ -318,10 +313,6 @@
if (config == kUnknown_GrPixelConfig) {
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
- desc.fConfig = config;
GrSurfaceOrigin origin = src->origin();
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
@@ -467,7 +458,7 @@
#ifdef SK_DEBUG
void GrSurfaceProxy::validateSurface(const GrSurface* surface) {
- SkASSERT(surface->config() == fConfig);
+ SkASSERT(surface->backendFormat() == fFormat);
this->onValidateSurface(surface);
}