Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 836080f

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Remove some unneeded colortype format validation checks in ProxyProvider.
These checks are no longer needed as we have enough checks in other parts of the code now. Additionally we want to remove any GrColorType and format compatibility checks in proxy provider since proxies will not have knowledge of color types in the future. This also lets us get ride of some used of GrPixelConfig. Change-Id: Ice835cba69ff783fd7e7d9b57321882b1e50093a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248803 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
1 parent b50cc81 commit 836080f

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

src/gpu/GrProxyProvider.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -428,24 +428,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxyFromBitmap(const SkBitmap& bit
428428
return proxy;
429429
}
430430

431-
#ifdef SK_DEBUG
432-
static bool validate_backend_format_and_config(const GrCaps* caps,
433-
const GrBackendFormat& format,
434-
GrPixelConfig config) {
435-
if (kUnknown_GrPixelConfig == config) {
436-
return false;
437-
}
438-
if (GrPixelConfigIsCompressed(config)) {
439-
// We have no way to verify these at the moment.
440-
return true;
441-
}
442-
443-
GrColorType grCT = GrPixelConfigToColorType(config);
444-
445-
return caps->areColorTypeAndFormatCompatible(grCT, format);
446-
}
447-
#endif
448-
449431
sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format,
450432
const GrSurfaceDesc& desc,
451433
GrRenderable renderable,
@@ -468,11 +450,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format
468450

469451
SkASSERT(GrCaps::AreConfigsCompatible(desc.fConfig,
470452
caps->getConfigFromBackendFormat(format, colorType)));
471-
// TODO: This check should be removed once we get the swizzle outside of GrProxyProvider and
472-
// either pass them to the proxy or store the on some view object.
473-
if (!caps->areColorTypeAndFormatCompatible(colorType, format)) {
474-
return nullptr;
475-
}
476453

477454
if (GrMipMapped::kYes == mipMapped) {
478455
// SkMipMap doesn't include the base level in the level count so we have to add 1
@@ -570,8 +547,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture
570547

571548
const GrCaps* caps = this->caps();
572549

573-
SkASSERT(caps->areColorTypeAndFormatCompatible(grColorType, backendTex.getBackendFormat()));
574-
575550
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
576551

577552
sk_sp<GrTexture> tex =
@@ -611,8 +586,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
611586

612587
const GrCaps* caps = this->caps();
613588

614-
SkASSERT(caps->areColorTypeAndFormatCompatible(colorType, backendTex.getBackendFormat()));
615-
616589
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
617590

618591
// TODO: This should have been checked and validated before getting into GrProxyProvider.
@@ -660,8 +633,6 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
660633

661634
const GrCaps* caps = this->caps();
662635

663-
SkASSERT(caps->areColorTypeAndFormatCompatible(grColorType, backendRT.getBackendFormat()));
664-
665636
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
666637

667638
sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendRenderTarget(backendRT, grColorType);
@@ -700,8 +671,6 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
700671

701672
const GrCaps* caps = this->caps();
702673

703-
SkASSERT(caps->areColorTypeAndFormatCompatible(grColorType, backendTex.getBackendFormat()));
704-
705674
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
706675

707676
sk_sp<GrRenderTarget> rt =
@@ -786,8 +755,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&&
786755
return nullptr;
787756
}
788757

789-
SkASSERT(validate_backend_format_and_config(this->caps(), format, desc.fConfig));
790-
791758
GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
792759
GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType);
793760
GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType);
@@ -846,8 +813,6 @@ sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
846813
return nullptr;
847814
}
848815

849-
SkASSERT(validate_backend_format_and_config(this->caps(), format, desc.fConfig));
850-
851816
GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
852817
GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(format, colorType);
853818
GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(format, colorType);
@@ -885,7 +850,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::MakeFullyLazyProxy(LazyInstantiateCallbac
885850
}
886851

887852
SkASSERT(renderTargetSampleCnt == 1 || renderable == GrRenderable::kYes);
888-
SkASSERT(validate_backend_format_and_config(&caps, format, config));
889853
GrSurfaceDesc desc;
890854
GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNone;
891855
desc.fWidth = -1;

src/gpu/GrRenderTargetContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ void GrRenderTargetContext::validate() const {
162162
SkASSERT(fRenderTargetProxy);
163163
fRenderTargetProxy->validate(fContext);
164164

165+
SkASSERT(fContext->priv().caps()->areColorTypeAndFormatCompatible(
166+
this->colorInfo().colorType(), fRenderTargetProxy->backendFormat()));
167+
165168
if (fOpsTask && !fOpsTask->isClosed()) {
166169
SkASSERT(fRenderTargetProxy->getLastRenderTask() == fOpsTask.get());
167170
}

src/gpu/GrTextureContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "src/gpu/GrAuditTrail.h"
1111
#include "src/gpu/GrContextPriv.h"
1212
#include "src/gpu/GrDrawingManager.h"
13+
#include "src/gpu/GrRecordingContextPriv.h"
1314

1415
#define ASSERT_SINGLE_OWNER \
1516
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
@@ -29,6 +30,8 @@ GrTextureContext::GrTextureContext(GrRecordingContext* context,
2930
void GrTextureContext::validate() const {
3031
SkASSERT(fTextureProxy);
3132
fTextureProxy->validate(fContext);
33+
SkASSERT(fContext->priv().caps()->areColorTypeAndFormatCompatible(
34+
this->colorInfo().colorType(), fTextureProxy->backendFormat()));
3235
}
3336
#endif
3437

0 commit comments

Comments
 (0)