Reduce GrCaps' reliance on GrPixelConfig
By itself this CL isn't all that compelling but I believe we need some intermediate path to wean ourselves off of GrPixelConfig. In particular, I believe isFormatTexturable will not need an SkColorType parameter in the future.
This is pulled out of:
https://skia-review.googlesource.com/c/skia/+/222781/ (Add bridge between GrContext::createBackendTexture and SkSurface::MakeFromBackendTexture)
which adds SkSurface::isCompatible - so the SkSurface_Gpu::isCompatible calls have been removed from this CL.
Change-Id: I6c2b8a2c4af98c1437b92c58513f34014e551b2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223188
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index d19871f..aa52c00 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -210,14 +210,14 @@
}
const SkImageInfo& info = srcImage->imageInfo();
- GrPixelConfig config = SkImageInfo2GrPixelConfig(info);
+ SkColorType ct = info.colorType();
- if (kUnknown_GrPixelConfig == config) {
+ GrBackendFormat format = this->caps()->getBackendFormatFromColorType(ct);
+ if (!format.isValid()) {
return nullptr;
}
- SkColorType ct = info.colorType();
- if (!this->caps()->isConfigTexturable(config)) {
+ if (!this->caps()->isFormatTexturable(ct, format)) {
SkBitmap copy8888;
if (!copy8888.tryAllocPixels(info.makeColorType(kRGBA_8888_SkColorType)) ||
!srcImage->readPixels(copy8888.pixmap(), 0, 0)) {
@@ -225,22 +225,25 @@
}
copy8888.setImmutable();
srcImage = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
- config = kRGBA_8888_GrPixelConfig;
ct = kRGBA_8888_SkColorType;
- }
-
- GrBackendFormat format = this->caps()->getBackendFormatFromColorType(ct);
- if (!format.isValid()) {
- return nullptr;
+ format = this->caps()->getBackendFormatFromColorType(ct);
+ if (!format.isValid()) {
+ return nullptr;
+ }
}
if (SkToBool(descFlags & kRenderTarget_GrSurfaceFlag)) {
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, config);
+ sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, ct, format);
if (!sampleCnt) {
return nullptr;
}
}
+ GrPixelConfig config = SkColorType2GrPixelConfig(ct);
+ if (kUnknown_GrPixelConfig == config) {
+ return nullptr;
+ }
+
GrSurfaceDesc desc;
desc.fWidth = srcImage->width();
desc.fHeight = srcImage->height();
@@ -328,9 +331,13 @@
}
SkColorType colorType = bitmap.info().colorType();
+ GrBackendFormat format = this->caps()->getBackendFormatFromColorType(colorType);
+ if (!format.isValid()) {
+ return nullptr;
+ }
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
- if (!this->caps()->isConfigTexturable(desc.fConfig)) {
+ if (!this->caps()->isFormatTexturable(colorType, format)) {
SkBitmap copy8888;
if (!copy8888.tryAllocPixels(bitmap.info().makeColorType(kRGBA_8888_SkColorType)) ||
!bitmap.readPixels(copy8888.pixmap())) {
@@ -340,12 +347,12 @@
baseLevel = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
desc.fConfig = kRGBA_8888_GrPixelConfig;
colorType = kRGBA_8888_SkColorType;
+ format = this->caps()->getBackendFormatFromColorType(colorType);
+ if (!format.isValid()) {
+ return nullptr;
+ }
}
- const GrBackendFormat format = this->caps()->getBackendFormatFromColorType(colorType);
- if (!format.isValid()) {
- return nullptr;
- }
SkPixmap pixmap;
SkAssertResult(baseLevel->peekPixels(&pixmap));