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 <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-07-23 13:21:01 -04:00 committed by Skia Commit-Bot
parent 3ae30cc2e6
commit 1cd1ed8976
5 changed files with 24 additions and 16 deletions

View File

@ -146,7 +146,6 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
SkASSERT(fRefHelper->fBorrowingContextID == context->priv().contextID());
GrBackendFormat backendFormat = fBackendTexture.getBackendFormat();
SkASSERT(backendFormat.isValid());
@ -157,9 +156,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
return nullptr;
}
SkASSERT(GrCaps::AreConfigsCompatible(fBackendTexture.config(),
caps->getConfigFromBackendFormat(backendFormat,
grColorType)));
SkASSERT(GrCaps::AreConfigsCompatible(fBackendTexture.config(), config));
GrSurfaceDesc desc;
desc.fWidth = fBackendTexture.width();

View File

@ -322,6 +322,7 @@ sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTex
backendTex.getBackendFormat())) {
return nullptr;
}
return this->onWrapBackendTextureAsRenderTarget(backendTex, sampleCnt, colorType);
}

View File

@ -659,7 +659,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
static bool check_backend_texture(const GrBackendTexture& backendTex, const GrGLCaps& caps,
GrGLTexture::IDDesc* idDesc) {
GrGLTextureInfo info;
if (!backendTex.getGLTextureInfo(&info) || !info.fID) {
if (!backendTex.getGLTextureInfo(&info) || !info.fID || !info.fFormat) {
return false;
}
@ -690,9 +690,7 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
return nullptr;
}
if (!idDesc.fInfo.fFormat) {
idDesc.fInfo.fFormat = this->glCaps().configSizedInternalFormat(backendTex.config());
}
if (kBorrow_GrWrapOwnership == ownership) {
idDesc.fOwnership = GrBackendObjectOwnership::kBorrowed;
} else {
@ -727,9 +725,6 @@ sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
return nullptr;
}
if (!idDesc.fInfo.fFormat) {
idDesc.fInfo.fFormat = this->glCaps().configSizedInternalFormat(backendTex.config());
}
// We don't support rendering to a EXTERNAL texture.
if (GR_GL_TEXTURE_EXTERNAL == idDesc.fInfo.fTarget) {

View File

@ -56,6 +56,10 @@ bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendText
return false;
}
if (!ctx->priv().caps()->areColorTypeAndFormatCompatible(grCT, backendFormat)) {
return false;
}
*config = ctx->priv().caps()->getConfigFromBackendFormat(backendFormat, grCT);
return *config != kUnknown_GrPixelConfig;
}
@ -249,6 +253,7 @@ bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx, const GrBackendText
if (!backendFormat.isValid()) {
return false;
}
yuvaTexturesCopy[textureIndex].fConfig =
caps->getYUVAConfigFromBackendFormat(backendFormat);
if (yuvaTexturesCopy[textureIndex].fConfig == kUnknown_GrPixelConfig) {

View File

@ -409,6 +409,11 @@ static bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex
if (!backendFormat.isValid()) {
return false;
}
if (!ctx->priv().caps()->areColorTypeAndFormatCompatible(grCT, backendFormat)) {
return false;
}
*config = ctx->priv().caps()->getConfigFromBackendFormat(backendFormat, grCT);
if (*config == kUnknown_GrPixelConfig) {
return false;
@ -627,18 +632,22 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
return true;
}
bool validate_backend_render_target(GrContext* ctx, const GrBackendRenderTarget& rt,
bool validate_backend_render_target(const GrCaps* caps, const GrBackendRenderTarget& rt,
GrPixelConfig* config, GrColorType grCT) {
*config = ctx->priv().caps()->validateBackendRenderTarget(rt, grCT);
if (!caps->areColorTypeAndFormatCompatible(grCT, rt.getBackendFormat())) {
return false;
}
*config = caps->validateBackendRenderTarget(rt, grCT);
if (*config == kUnknown_GrPixelConfig) {
return false;
}
if (rt.sampleCnt() > 1) {
if (ctx->priv().caps()->maxRenderTargetSampleCount(*config) <= 1) {
if (caps->maxRenderTargetSampleCount(grCT, rt.getBackendFormat()) <= 1) {
return false;
}
} else if (!ctx->priv().caps()->isConfigRenderable(*config)) {
} else if (!caps->isFormatRenderable(grCT, rt.getBackendFormat())) {
return false;
}
@ -664,7 +673,8 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
}
GrBackendRenderTarget rtCopy = rt;
if (!validate_backend_render_target(context, rtCopy, &rtCopy.fConfig, grColorType)) {
if (!validate_backend_render_target(context->priv().caps(), rtCopy,
&rtCopy.fConfig, grColorType)) {
return nullptr;
}
if (!SkSurface_Gpu::Valid(context->priv().caps(), rtCopy.getBackendFormat())) {