Propagate GrRenderable flag to GrCaps::getBackendFormatFromColorType
This makes calling GrCaps::getBackendFormatFromColorType equivalent to calling GrContext::defaultBackendFormat
Change-Id: Ic402245fa0502920c47c2a29aadc4e559abdc09b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230416
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 48a24fe..e70917c 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -216,9 +216,9 @@
SkColorType ct = info.colorType();
GrColorType grCT = SkColorTypeToGrColorType(ct);
- GrBackendFormat format = this->caps()->getBackendFormatFromColorType(grCT);
+ GrBackendFormat format = this->caps()->getDefaultBackendFormat(grCT, renderable);
- if (!format.isValid() || !this->caps()->isFormatTexturable(grCT, format)) {
+ if (!format.isValid()) {
SkBitmap copy8888;
if (!copy8888.tryAllocPixels(info.makeColorType(kRGBA_8888_SkColorType)) ||
!srcImage->readPixels(copy8888.pixmap(), 0, 0)) {
@@ -228,7 +228,7 @@
srcImage = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
ct = kRGBA_8888_SkColorType;
grCT = GrColorType::kRGBA_8888;
- format = this->caps()->getBackendFormatFromColorType(grCT);
+ format = this->caps()->getDefaultBackendFormat(grCT, renderable);
if (!format.isValid()) {
return nullptr;
}
@@ -337,14 +337,11 @@
SkBudgeted::kYes, SkBackingFit::kExact);
}
- GrColorType grColorType = SkColorTypeToGrColorType(bitmap.info().colorType());
- GrBackendFormat format = this->caps()->getBackendFormatFromColorType(grColorType);
- if (!format.isValid()) {
- return nullptr;
- }
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
- if (!this->caps()->isFormatTexturable(grColorType, format)) {
+ GrColorType grColorType = SkColorTypeToGrColorType(bitmap.info().colorType());
+ GrBackendFormat format = this->caps()->getDefaultBackendFormat(grColorType, GrRenderable::kNo);
+ if (!format.isValid()) {
SkBitmap copy8888;
if (!copy8888.tryAllocPixels(bitmap.info().makeColorType(kRGBA_8888_SkColorType)) ||
!bitmap.readPixels(copy8888.pixmap())) {
@@ -354,13 +351,12 @@
baseLevel = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
desc.fConfig = kRGBA_8888_GrPixelConfig;
grColorType = GrColorType::kRGBA_8888;
- format = this->caps()->getBackendFormatFromColorType(grColorType);
+ format = this->caps()->getDefaultBackendFormat(grColorType, GrRenderable::kNo);
if (!format.isValid()) {
return nullptr;
}
}
-
SkPixmap pixmap;
SkAssertResult(baseLevel->peekPixels(&pixmap));
sk_sp<SkMipMap> mipmaps(SkMipMap::Build(pixmap, nullptr));
@@ -775,6 +771,10 @@
SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
(desc.fWidth > 0 && desc.fHeight > 0));
+ if (!format.isValid()) {
+ return nullptr;
+ }
+
if (desc.fWidth > this->caps()->maxTextureSize() ||
desc.fHeight > this->caps()->maxTextureSize()) {
return nullptr;
@@ -844,6 +844,10 @@
LazyInstantiateCallback&& callback, const GrBackendFormat& format, GrRenderable renderable,
int renderTargetSampleCnt, GrProtected isProtected, GrSurfaceOrigin origin,
GrPixelConfig config, const GrCaps& caps) {
+ if (!format.isValid()) {
+ return nullptr;
+ }
+
SkASSERT(renderTargetSampleCnt == 1 || renderable == GrRenderable::kYes);
SkASSERT(validate_backend_format_and_config(&caps, format, config));
GrSurfaceDesc desc;