Skip to content

Commit 1cd1ed8

Browse files
rphilliSkia Commit-Bot
authored andcommitted
Stop using GrBackendSurface's pixel config
Note: I'll follow this up with a separate CL that removes the pixel config Bug: skia:6718 Change-Id: If069afa95bd51d5d6b24089fd3a8526e4d982820 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228257 Reviewed-by: Brian Salomon <[email protected]> Commit-Queue: Robert Phillips <[email protected]>
1 parent 3ae30cc commit 1cd1ed8

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/gpu/GrBackendTextureImageGenerator.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
146146

147147
SkASSERT(fRefHelper->fBorrowingContextID == context->priv().contextID());
148148

149-
150149
GrBackendFormat backendFormat = fBackendTexture.getBackendFormat();
151150
SkASSERT(backendFormat.isValid());
152151

@@ -157,9 +156,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
157156
return nullptr;
158157
}
159158

160-
SkASSERT(GrCaps::AreConfigsCompatible(fBackendTexture.config(),
161-
caps->getConfigFromBackendFormat(backendFormat,
162-
grColorType)));
159+
SkASSERT(GrCaps::AreConfigsCompatible(fBackendTexture.config(), config));
163160

164161
GrSurfaceDesc desc;
165162
desc.fWidth = fBackendTexture.width();

src/gpu/GrGpu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTex
322322
backendTex.getBackendFormat())) {
323323
return nullptr;
324324
}
325+
325326
return this->onWrapBackendTextureAsRenderTarget(backendTex, sampleCnt, colorType);
326327
}
327328

src/gpu/gl/GrGLGpu.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
659659
static bool check_backend_texture(const GrBackendTexture& backendTex, const GrGLCaps& caps,
660660
GrGLTexture::IDDesc* idDesc) {
661661
GrGLTextureInfo info;
662-
if (!backendTex.getGLTextureInfo(&info) || !info.fID) {
662+
if (!backendTex.getGLTextureInfo(&info) || !info.fID || !info.fFormat) {
663663
return false;
664664
}
665665

@@ -690,9 +690,7 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
690690
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
691691
return nullptr;
692692
}
693-
if (!idDesc.fInfo.fFormat) {
694-
idDesc.fInfo.fFormat = this->glCaps().configSizedInternalFormat(backendTex.config());
695-
}
693+
696694
if (kBorrow_GrWrapOwnership == ownership) {
697695
idDesc.fOwnership = GrBackendObjectOwnership::kBorrowed;
698696
} else {
@@ -727,9 +725,6 @@ sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
727725
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
728726
return nullptr;
729727
}
730-
if (!idDesc.fInfo.fFormat) {
731-
idDesc.fInfo.fFormat = this->glCaps().configSizedInternalFormat(backendTex.config());
732-
}
733728

734729
// We don't support rendering to a EXTERNAL texture.
735730
if (GR_GL_TEXTURE_EXTERNAL == idDesc.fInfo.fTarget) {

src/image/SkImage_GpuBase.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendText
5656
return false;
5757
}
5858

59+
if (!ctx->priv().caps()->areColorTypeAndFormatCompatible(grCT, backendFormat)) {
60+
return false;
61+
}
62+
5963
*config = ctx->priv().caps()->getConfigFromBackendFormat(backendFormat, grCT);
6064
return *config != kUnknown_GrPixelConfig;
6165
}
@@ -249,6 +253,7 @@ bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx, const GrBackendText
249253
if (!backendFormat.isValid()) {
250254
return false;
251255
}
256+
252257
yuvaTexturesCopy[textureIndex].fConfig =
253258
caps->getYUVAConfigFromBackendFormat(backendFormat);
254259
if (yuvaTexturesCopy[textureIndex].fConfig == kUnknown_GrPixelConfig) {

src/image/SkSurface_Gpu.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ static bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex
409409
if (!backendFormat.isValid()) {
410410
return false;
411411
}
412+
413+
if (!ctx->priv().caps()->areColorTypeAndFormatCompatible(grCT, backendFormat)) {
414+
return false;
415+
}
416+
412417
*config = ctx->priv().caps()->getConfigFromBackendFormat(backendFormat, grCT);
413418
if (*config == kUnknown_GrPixelConfig) {
414419
return false;
@@ -627,18 +632,22 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
627632
return true;
628633
}
629634

630-
bool validate_backend_render_target(GrContext* ctx, const GrBackendRenderTarget& rt,
635+
bool validate_backend_render_target(const GrCaps* caps, const GrBackendRenderTarget& rt,
631636
GrPixelConfig* config, GrColorType grCT) {
632-
*config = ctx->priv().caps()->validateBackendRenderTarget(rt, grCT);
637+
if (!caps->areColorTypeAndFormatCompatible(grCT, rt.getBackendFormat())) {
638+
return false;
639+
}
640+
641+
*config = caps->validateBackendRenderTarget(rt, grCT);
633642
if (*config == kUnknown_GrPixelConfig) {
634643
return false;
635644
}
636645

637646
if (rt.sampleCnt() > 1) {
638-
if (ctx->priv().caps()->maxRenderTargetSampleCount(*config) <= 1) {
647+
if (caps->maxRenderTargetSampleCount(grCT, rt.getBackendFormat()) <= 1) {
639648
return false;
640649
}
641-
} else if (!ctx->priv().caps()->isConfigRenderable(*config)) {
650+
} else if (!caps->isFormatRenderable(grCT, rt.getBackendFormat())) {
642651
return false;
643652
}
644653

@@ -664,7 +673,8 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
664673
}
665674

666675
GrBackendRenderTarget rtCopy = rt;
667-
if (!validate_backend_render_target(context, rtCopy, &rtCopy.fConfig, grColorType)) {
676+
if (!validate_backend_render_target(context->priv().caps(), rtCopy,
677+
&rtCopy.fConfig, grColorType)) {
668678
return nullptr;
669679
}
670680
if (!SkSurface_Gpu::Valid(context->priv().caps(), rtCopy.getBackendFormat())) {

0 commit comments

Comments
 (0)