Add GrCaps::isFormatCompressed
This is part of trying to remove uses of GrPixelConfig from the proxy provider Change-Id: I12d085cfbff86d0e44829ce3ee36744b937b804e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230576 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
8eb4d74d95
commit
8ff8bccf77
@ -156,6 +156,7 @@ public:
|
||||
}
|
||||
|
||||
virtual bool isFormatSRGB(const GrBackendFormat&) const = 0;
|
||||
virtual bool isFormatCompressed(const GrBackendFormat&) const = 0;
|
||||
|
||||
virtual bool isFormatTexturable(GrColorType, const GrBackendFormat&) const = 0;
|
||||
virtual bool isConfigTexturable(GrPixelConfig) const = 0;
|
||||
|
@ -440,12 +440,13 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected,
|
||||
GrInternalSurfaceFlags surfaceFlags) {
|
||||
if (GrPixelConfigIsCompressed(desc.fConfig)) {
|
||||
const GrCaps* caps = this->caps();
|
||||
|
||||
if (caps->isFormatCompressed(format)) {
|
||||
// Deferred proxies for compressed textures are not supported.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const GrCaps* caps = this->caps();
|
||||
GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
|
||||
|
||||
SkASSERT(GrCaps::AreConfigsCompatible(desc.fConfig,
|
||||
@ -483,14 +484,16 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format
|
||||
sk_sp<GrTextureProxy> GrProxyProvider::createCompressedTextureProxy(
|
||||
int width, int height, SkBudgeted budgeted, SkImage::CompressionType compressionType,
|
||||
sk_sp<SkData> data) {
|
||||
GrBackendFormat format = this->caps()->getBackendFormatFromCompressionType(compressionType);
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fConfig = GrCompressionTypePixelConfig(compressionType);
|
||||
desc.fWidth = width;
|
||||
desc.fHeight = height;
|
||||
|
||||
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
|
||||
GrColorType grColorType = GrCompressionTypeClosestColorType(compressionType);
|
||||
GrBackendFormat format = this->caps()->getBackendFormatFromCompressionType(compressionType);
|
||||
|
||||
if (!this->caps()->isFormatTexturable(grColorType, format)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,10 @@ bool GrDawnCaps::isFormatSRGB(const GrBackendFormat& format) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GrDawnCaps::isFormatCompressed(const GrBackendFormat& format) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GrDawnCaps::isConfigTexturable(GrPixelConfig config) const {
|
||||
switch (config) {
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
|
@ -17,7 +17,9 @@ class GrDawnCaps : public GrCaps {
|
||||
public:
|
||||
GrDawnCaps(const GrContextOptions& contextOptions);
|
||||
|
||||
bool isFormatSRGB(const GrBackendFormat& format) const override;
|
||||
bool isFormatSRGB(const GrBackendFormat&) const override;
|
||||
bool isFormatCompressed(const GrBackendFormat&) const override;
|
||||
|
||||
bool isFormatTexturable(GrColorType, const GrBackendFormat& format) const override;
|
||||
bool isFormatCopyable(GrColorType, const GrBackendFormat& format) const override;
|
||||
|
||||
|
@ -3777,6 +3777,13 @@ bool GrGLCaps::isFormatSRGB(const GrBackendFormat& format) const {
|
||||
return GrGLBackendFormatToGLFormat(format) == GrGLFormat::kSRGB8_ALPHA8;
|
||||
}
|
||||
|
||||
bool GrGLCaps::isFormatCompressed(const GrBackendFormat& format) const {
|
||||
GrGLFormat grGLFormat = GrGLBackendFormatToGLFormat(format);
|
||||
|
||||
return grGLFormat == GrGLFormat::kCOMPRESSED_RGB8_ETC2 ||
|
||||
grGLFormat == GrGLFormat::kCOMPRESSED_ETC1_RGB8;
|
||||
}
|
||||
|
||||
bool GrGLCaps::isFormatTexturable(GrColorType ct, GrGLFormat format) const {
|
||||
const FormatInfo& info = this->getFormatInfo(format);
|
||||
// Currently we conflate texturable to mean the format itself is texturable in a draw and that
|
||||
|
@ -108,7 +108,8 @@ public:
|
||||
GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
|
||||
const GrGLInterface* glInterface);
|
||||
|
||||
bool isFormatSRGB(const GrBackendFormat& format) const override;
|
||||
bool isFormatSRGB(const GrBackendFormat&) const override;
|
||||
bool isFormatCompressed(const GrBackendFormat&) const override;
|
||||
|
||||
bool isFormatTexturable(GrColorType, const GrBackendFormat&) const override;
|
||||
|
||||
|
@ -46,6 +46,11 @@ public:
|
||||
return *format.getMockColorType() == GrColorType::kRGBA_8888_SRGB;
|
||||
}
|
||||
|
||||
// Mock caps doesn't support any compressed formats right now
|
||||
bool isFormatCompressed(const GrBackendFormat&) const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isFormatTexturable(GrColorType, const GrBackendFormat& format) const override {
|
||||
if (!format.getMockColorType()) {
|
||||
return false;
|
||||
|
@ -26,7 +26,8 @@ public:
|
||||
GrMtlCaps(const GrContextOptions& contextOptions, id<MTLDevice> device,
|
||||
MTLFeatureSet featureSet);
|
||||
|
||||
bool isFormatSRGB(const GrBackendFormat& format) const override;
|
||||
bool isFormatSRGB(const GrBackendFormat&) const override;
|
||||
bool isFormatCompressed(const GrBackendFormat&) const override;
|
||||
|
||||
bool isFormatTexturable(GrColorType, const GrBackendFormat&) const override;
|
||||
bool isConfigTexturable(GrPixelConfig config) const override;
|
||||
|
@ -274,6 +274,20 @@ bool GrMtlCaps::isFormatSRGB(const GrBackendFormat& format) const {
|
||||
return format_is_srgb(static_cast<MTLPixelFormat>(*format.getMtlFormat()));
|
||||
}
|
||||
|
||||
bool GrMtlCaps::isFormatCompressed(const GrBackendFormat& format) const {
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
return false;
|
||||
#else
|
||||
if (!format.getMtlFormat()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MTLPixelFormat mtlFormat = static_cast<MTLPixelFormat>(*format.getMtlFormat());
|
||||
|
||||
return mtlFormat == MTLPixelFormatETC2_RGB8;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GrMtlCaps::isFormatTexturable(GrColorType, const GrBackendFormat& format) const {
|
||||
if (!format.getMtlFormat()) {
|
||||
return false;
|
||||
|
@ -778,6 +778,17 @@ bool GrVkCaps::isFormatSRGB(const GrBackendFormat& format) const {
|
||||
return format_is_srgb(*format.getVkFormat());
|
||||
}
|
||||
|
||||
bool GrVkCaps::isFormatCompressed(const GrBackendFormat& format) const {
|
||||
if (!format.getVkFormat()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VkFormat vkFormat = *format.getVkFormat();
|
||||
SkASSERT(GrVkFormatIsSupported(vkFormat));
|
||||
|
||||
return vkFormat == VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
|
||||
}
|
||||
|
||||
bool GrVkCaps::isFormatTexturable(GrColorType, const GrBackendFormat& format) const {
|
||||
if (!format.getVkFormat()) {
|
||||
return false;
|
||||
|
@ -32,7 +32,9 @@ public:
|
||||
uint32_t instanceVersion, uint32_t physicalDeviceVersion,
|
||||
const GrVkExtensions& extensions, GrProtected isProtected = GrProtected::kNo);
|
||||
|
||||
bool isFormatSRGB(const GrBackendFormat& format) const override;
|
||||
bool isFormatSRGB(const GrBackendFormat&) const override;
|
||||
bool isFormatCompressed(const GrBackendFormat&) const override;
|
||||
|
||||
|
||||
bool isFormatTexturable(GrColorType, const GrBackendFormat&) const override;
|
||||
bool isVkFormatTexturable(VkFormat) const;
|
||||
|
@ -116,8 +116,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
||||
GrPixelConfig config = static_cast<GrPixelConfig>(c);
|
||||
|
||||
// We don't round trip correctly going from pixelConfig to colorType to
|
||||
// backendFormat with the RGBX config.
|
||||
if (config == kRGB_888X_GrPixelConfig) {
|
||||
// backendFormat with the RGBX and ETC1 configs.
|
||||
if (config == kRGB_888X_GrPixelConfig || config == kRGB_ETC1_GrPixelConfig) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user