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/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 5bc4b1d..6b49fa5 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -226,19 +226,29 @@
}
sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
+ GrColorType colorType,
GrWrapOwnership ownership, GrWrapCacheable cacheable,
GrIOType ioType) {
SkASSERT(ioType != kWrite_GrIOType);
this->handleDirtyContext();
- SkASSERT(this->caps());
- if (!this->caps()->isConfigTexturable(backendTex.config())) {
+
+ const GrCaps* caps = this->caps();
+ SkASSERT(caps);
+
+ if (!caps->isFormatTexturable(colorType, backendTex.getBackendFormat())) {
return nullptr;
}
- if (backendTex.width() > this->caps()->maxTextureSize() ||
- backendTex.height() > this->caps()->maxTextureSize()) {
+ if (backendTex.width() > caps->maxTextureSize() ||
+ backendTex.height() > caps->maxTextureSize()) {
return nullptr;
}
- return this->onWrapBackendTexture(backendTex, ownership, cacheable, ioType);
+
+ SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
+ caps->getConfigFromBackendFormat(
+ backendTex.getBackendFormat(),
+ colorType)));
+
+ return this->onWrapBackendTexture(backendTex, colorType, ownership, cacheable, ioType);
}
sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
@@ -272,25 +282,47 @@
return tex;
}
-sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) {
- if (0 == this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), backendRT.config())) {
+sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
+ GrColorType colorType) {
+ this->handleDirtyContext();
+
+ const GrCaps* caps = this->caps();
+
+ SkASSERT(GrCaps::AreConfigsCompatible(backendRT.config(),
+ caps->getConfigFromBackendFormat(
+ backendRT.getBackendFormat(),
+ colorType)));
+
+ if (0 == caps->getRenderTargetSampleCount(backendRT.sampleCnt(), colorType,
+ backendRT.getBackendFormat())) {
return nullptr;
}
- this->handleDirtyContext();
- return this->onWrapBackendRenderTarget(backendRT);
+
+ return this->onWrapBackendRenderTarget(backendRT, colorType);
}
-sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
- int sampleCnt) {
- if (0 == this->caps()->getRenderTargetSampleCount(sampleCnt, tex.config())) {
- return nullptr;
- }
- int maxSize = this->caps()->maxTextureSize();
- if (tex.width() > maxSize || tex.height() > maxSize) {
- return nullptr;
- }
+sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& backendTex,
+ int sampleCnt,
+ GrColorType colorType) {
this->handleDirtyContext();
- return this->onWrapBackendTextureAsRenderTarget(tex, sampleCnt);
+
+ const GrCaps* caps = this->caps();
+
+ int maxSize = caps->maxTextureSize();
+ if (backendTex.width() > maxSize || backendTex.height() > maxSize) {
+ return nullptr;
+ }
+
+ SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
+ caps->getConfigFromBackendFormat(
+ backendTex.getBackendFormat(),
+ colorType)));
+
+ if (0 == caps->getRenderTargetSampleCount(sampleCnt, colorType,
+ backendTex.getBackendFormat())) {
+ return nullptr;
+ }
+ return this->onWrapBackendTextureAsRenderTarget(backendTex, sampleCnt, colorType);
}
sk_sp<GrRenderTarget> GrGpu::wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo& imageInfo,