Remove various uses of GrPixelConfig from GrSurfaceProxy.

Bug: skia:6718
Change-Id: I96e15f92a7a8db2b2a1445baa83c67dd25cc2a96
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264423
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-01-14 16:44:18 -05:00 committed by Skia Commit-Bot
parent 1fa54044ef
commit c71c796f3a
6 changed files with 14 additions and 23 deletions

View File

@ -276,14 +276,8 @@ bool GrCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src
if (dst->readOnly()) {
return false;
}
// Currently we only ever do copies where the configs are the same. This check really should be
// checking if the backend formats, color types, and swizzle are compatible. Our copy always
// copies exact byte to byte from src to dst so when need to check the if we do this, the dst
// has the expected values stored in the right places taking the swizzle into account. For now
// we can be more restrictive and just make sure the configs are the same and if we generalize
// copies and swizzles more in the future this can be updated.
if (this->makeConfigSpecific(dst->config(), dst->backendFormat()) !=
this->makeConfigSpecific(src->config(), src->backendFormat())) {
if (dst->backendFormat() != src->backendFormat()) {
return false;
}
return this->onCanCopySurface(dst, src, srcRect, dstPoint);

View File

@ -50,7 +50,6 @@ void GrProgramInfo::validate(bool flushTime) const {
const GrBackendFormat& format = dynamicPrimProcTextures[s]->backendFormat();
GrTextureType type = dynamicPrimProcTextures[s]->backendFormat().textureType();
GrPixelConfig config = dynamicPrimProcTextures[s]->config();
for (int m = 1; m < fNumDynamicStateArrays; ++m) {
dynamicPrimProcTextures = this->dynamicPrimProcTextures(m);
@ -59,7 +58,6 @@ void GrProgramInfo::validate(bool flushTime) const {
SkASSERT(testProxy->asTextureProxy());
SkASSERT(testProxy->backendFormat() == format);
SkASSERT(testProxy->backendFormat().textureType() == type);
SkASSERT(testProxy->config() == config);
}
}
}

View File

@ -187,12 +187,13 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
// fContext->vaildaPMUPMConversionExists()).
GrBackendFormat defaultRGBAFormat = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
GrColorType srcColorType = this->colorInfo().colorType();
bool canvas2DFastPath = unpremul && !needColorConversion &&
(GrColorType::kRGBA_8888 == dstInfo.colorType() ||
GrColorType::kBGRA_8888 == dstInfo.colorType()) &&
SkToBool(srcProxy->asTextureProxy()) &&
(srcProxy->config() == kRGBA_8888_GrPixelConfig ||
srcProxy->config() == kBGRA_8888_GrPixelConfig) &&
(srcColorType == GrColorType::kRGBA_8888 ||
srcColorType == GrColorType::kBGRA_8888) &&
defaultRGBAFormat.isValid() &&
direct->priv().validPMUPMConversionExists();
@ -339,14 +340,15 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
auto rgbaDefaultFormat = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
GrColorType dstColorType = this->colorInfo().colorType();
// For canvas2D putImageData performance we have a special code path for unpremul RGBA_8888 srcs
// that are premultiplied on the GPU. This is kept as narrow as possible for now.
bool canvas2DFastPath = !caps->avoidWritePixelsFastPath() && premul && !needColorConversion &&
(srcInfo.colorType() == GrColorType::kRGBA_8888 ||
srcInfo.colorType() == GrColorType::kBGRA_8888) &&
SkToBool(this->asRenderTargetContext()) &&
(dstProxy->config() == kRGBA_8888_GrPixelConfig ||
dstProxy->config() == kBGRA_8888_GrPixelConfig) &&
(dstColorType == GrColorType::kRGBA_8888 ||
dstColorType == GrColorType::kBGRA_8888) &&
rgbaDefaultFormat.isValid() &&
direct->priv().validPMUPMConversionExists();
@ -483,9 +485,8 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S
SkASSERT(src->backendFormat().textureType() != GrTextureType::kExternal);
SkASSERT(src->origin() == this->asSurfaceProxy()->origin());
SkASSERT(caps->makeConfigSpecific(src->config(), src->backendFormat()) ==
caps->makeConfigSpecific(this->asSurfaceProxy()->config(),
this->asSurfaceProxy()->backendFormat()));
SkASSERT(src->textureSwizzle() == this->asSurfaceProxy()->textureSwizzle());
SkASSERT(src->backendFormat() == this->asSurfaceProxy()->backendFormat());
if (!caps->canCopySurface(this->asSurfaceProxy(), src, srcRect, dstPoint)) {
return false;

View File

@ -151,8 +151,7 @@ bool GrTextureProxy::ProxiesAreCompatibleAsDynamicState(const GrSurfaceProxy* fi
const GrSurfaceProxy* second) {
// In order to be compatible, the proxies should also have the same texture type. This is
// checked explicitly since the GrBackendFormat == operator does not compare texture type
return first->config() == second->config() &&
first->backendFormat().textureType() == second->backendFormat().textureType() &&
return first->backendFormat().textureType() == second->backendFormat().textureType() &&
first->backendFormat() == second->backendFormat();
}

View File

@ -231,7 +231,7 @@ std::unique_ptr<GrRenderTargetContext> GrCCAtlas::makeRenderTargetContext(
#ifdef SK_DEBUG
auto backingRT = backingTexture->asRenderTarget();
SkASSERT(backingRT);
SkASSERT(backingRT->config() == fTextureProxy->config());
SkASSERT(backingRT->backendFormat() == fTextureProxy->backendFormat());
SkASSERT(backingRT->numSamples() == fTextureProxy->asRenderTargetProxy()->numSamples());
SkASSERT(backingRT->width() == fWidth);
SkASSERT(backingRT->height() == fHeight);

View File

@ -549,10 +549,9 @@ private:
new(&fViewCountPairs[++p])ViewCountPair({set[q].fProxyView.detachProxy(), 0});
curProxy = fViewCountPairs[p].fProxy.get();
SkASSERT(curProxy->backendFormat().textureType() ==
fViewCountPairs[0].fProxy->backendFormat().textureType());
SkASSERT(GrTextureProxy::ProxiesAreCompatibleAsDynamicState(
curProxy, fViewCountPairs[0].fProxy.get()));
SkASSERT(fMetadata.fSwizzle == set[q].fProxyView.swizzle());
SkASSERT(curProxy->config() == fViewCountPairs[0].fProxy->config());
} // else another quad referencing the same proxy
SkMatrix ctm = viewMatrix;