Make rest of GrGpu::wrapBackend* methods take a GrColorType (take 2)
This CL is intended to further wean Ganesh off of using the GrBackendTexture's pixel config
TBR=bsalomon@google.com
Bug: skia:6718
Change-Id: Iedaa7811f9c4aac552f219c702627bc476325317
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228338
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 956d55b..cc76aa2 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -524,6 +524,7 @@
}
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
+ GrColorType grColorType,
GrSurfaceOrigin origin,
GrWrapOwnership ownership,
GrWrapCacheable cacheable,
@@ -541,13 +542,21 @@
return nullptr;
}
- SkASSERT(validate_backend_format_and_config(this->caps(), backendTex.getBackendFormat(),
- backendTex.config()));
+ const GrCaps* caps = this->caps();
+
+ SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
+ caps->getConfigFromBackendFormat(
+ backendTex.getBackendFormat(),
+ grColorType)));
+
+ SkASSERT(validate_backend_format_and_colortype(caps, grColorType,
+ backendTex.getBackendFormat()));
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
sk_sp<GrTexture> tex =
- resourceProvider->wrapBackendTexture(backendTex, ownership, cacheable, ioType);
+ resourceProvider->wrapBackendTexture(backendTex, grColorType,
+ ownership, cacheable, ioType);
if (!tex) {
return nullptr;
}
@@ -560,8 +569,7 @@
// Make sure we match how we created the proxy with SkBudgeted::kNo
SkASSERT(GrBudgetedType::kBudgeted != tex->resourcePriv().budgetedType());
- GrColorType colorType = GrPixelConfigToColorType(tex->config());
- GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType);
+ GrSwizzle texSwizzle = caps->getTextureSwizzle(tex->backendFormat(), grColorType);
return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin, texSwizzle));
}
@@ -619,8 +627,8 @@
}
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
- const GrBackendRenderTarget& backendRT, GrSurfaceOrigin origin, ReleaseProc releaseProc,
- ReleaseContext releaseCtx) {
+ const GrBackendRenderTarget& backendRT, GrColorType grColorType,
+ GrSurfaceOrigin origin, ReleaseProc releaseProc, ReleaseContext releaseCtx) {
if (this->isAbandoned()) {
return nullptr;
}
@@ -631,16 +639,15 @@
return nullptr;
}
- GrColorType colorType = GrPixelConfigToColorType(backendRT.config());
#ifdef SK_DEBUG
GrPixelConfig testConfig =
- this->caps()->validateBackendRenderTarget(backendRT, colorType);
+ this->caps()->validateBackendRenderTarget(backendRT, grColorType);
SkASSERT(testConfig != kUnknown_GrPixelConfig);
#endif
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
- sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendRenderTarget(backendRT);
+ sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendRenderTarget(backendRT, grColorType);
if (!rt) {
return nullptr;
}
@@ -654,15 +661,16 @@
// Make sure we match how we created the proxy with SkBudgeted::kNo
SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType());
- GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType);
- GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType);
+ GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), grColorType);
+ GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), grColorType);
return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle,
outSwizzle));
}
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
- const GrBackendTexture& backendTex, GrSurfaceOrigin origin, int sampleCnt) {
+ const GrBackendTexture& backendTex, GrColorType grColorType,
+ GrSurfaceOrigin origin, int sampleCnt) {
if (this->isAbandoned()) {
return nullptr;
}
@@ -673,13 +681,20 @@
return nullptr;
}
- SkASSERT(validate_backend_format_and_config(this->caps(), backendTex.getBackendFormat(),
- backendTex.config()));
+ const GrCaps* caps = this->caps();
+
+ SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
+ caps->getConfigFromBackendFormat(
+ backendTex.getBackendFormat(),
+ grColorType)));
+
+ SkASSERT(validate_backend_format_and_colortype(caps, grColorType,
+ backendTex.getBackendFormat()));
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
sk_sp<GrRenderTarget> rt =
- resourceProvider->wrapBackendTextureAsRenderTarget(backendTex, sampleCnt);
+ resourceProvider->wrapBackendTextureAsRenderTarget(backendTex, sampleCnt, grColorType);
if (!rt) {
return nullptr;
}
@@ -688,9 +703,8 @@
// This proxy should be unbudgeted because we're just wrapping an external resource
SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType());
- GrColorType colorType = GrPixelConfigToColorType(rt->config());
- GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType);
- GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType);
+ GrSwizzle texSwizzle = caps->getTextureSwizzle(rt->backendFormat(), grColorType);
+ GrSwizzle outSwizzle = caps->getOutputSwizzle(rt->backendFormat(), grColorType);
return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle,
outSwizzle));