GrPixelConfig is DEAD!!!!!
Bug: skia:6718 Change-Id: Iecad0943b428f7f0e22b45c4cdc7798df00f3e84 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265982 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
60ff65114c
commit
4cb293392c
@ -45,58 +45,6 @@ static inline constexpr size_t GrAlignTo(size_t x, size_t alignment) {
|
|||||||
return (x + alignment - 1) & ~(alignment - 1);
|
return (x + alignment - 1) & ~(alignment - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pixel configurations. This type conflates texture formats, CPU pixel formats, and
|
|
||||||
* premultipliedness. We are moving away from it towards SkColorType and backend API (GL, Vulkan)
|
|
||||||
* texture formats in the public API. Right now this mostly refers to texture formats as we're
|
|
||||||
* migrating.
|
|
||||||
*/
|
|
||||||
enum GrPixelConfig {
|
|
||||||
kUnknown_GrPixelConfig,
|
|
||||||
kAlpha_8_GrPixelConfig,
|
|
||||||
kAlpha_8_as_Alpha_GrPixelConfig,
|
|
||||||
kAlpha_8_as_Red_GrPixelConfig,
|
|
||||||
kGray_8_GrPixelConfig,
|
|
||||||
kGray_8_as_Lum_GrPixelConfig,
|
|
||||||
kGray_8_as_Red_GrPixelConfig,
|
|
||||||
kRGB_565_GrPixelConfig,
|
|
||||||
kRGBA_4444_GrPixelConfig,
|
|
||||||
kRGBA_8888_GrPixelConfig,
|
|
||||||
kRGB_888_GrPixelConfig,
|
|
||||||
kRGB_888X_GrPixelConfig,
|
|
||||||
kRG_88_GrPixelConfig,
|
|
||||||
kBGRA_8888_GrPixelConfig,
|
|
||||||
kSRGBA_8888_GrPixelConfig,
|
|
||||||
kRGBA_1010102_GrPixelConfig,
|
|
||||||
kAlpha_half_GrPixelConfig,
|
|
||||||
kAlpha_half_as_Lum_GrPixelConfig,
|
|
||||||
kAlpha_half_as_Red_GrPixelConfig,
|
|
||||||
kRGBA_half_GrPixelConfig,
|
|
||||||
kRGBA_half_Clamped_GrPixelConfig,
|
|
||||||
kRGB_ETC1_GrPixelConfig,
|
|
||||||
kBC1_RGB8_UNORM_GrPixelConfig,
|
|
||||||
kBC1_RGBA8_UNORM_GrPixelConfig,
|
|
||||||
kAlpha_16_GrPixelConfig,
|
|
||||||
kRG_1616_GrPixelConfig,
|
|
||||||
kRGBA_16161616_GrPixelConfig,
|
|
||||||
kRG_half_GrPixelConfig,
|
|
||||||
|
|
||||||
kLast_GrPixelConfig = kRG_half_GrPixelConfig
|
|
||||||
};
|
|
||||||
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
|
|
||||||
|
|
||||||
// Aliases for pixel configs that match skia's byte order.
|
|
||||||
#ifndef SK_CPU_LENDIAN
|
|
||||||
#error "Skia gpu currently assumes little endian"
|
|
||||||
#endif
|
|
||||||
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
|
|
||||||
static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfig;
|
|
||||||
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
|
||||||
static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfig;
|
|
||||||
#else
|
|
||||||
#error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Geometric primitives used for drawing.
|
* Geometric primitives used for drawing.
|
||||||
*/
|
*/
|
||||||
@ -1192,113 +1140,6 @@ static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct) {
|
|||||||
SkUNREACHABLE;
|
SkUNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr GrColorType GrPixelConfigToColorType(GrPixelConfig config) {
|
|
||||||
switch (config) {
|
|
||||||
case kUnknown_GrPixelConfig:
|
|
||||||
return GrColorType::kUnknown;
|
|
||||||
case kAlpha_8_GrPixelConfig:
|
|
||||||
return GrColorType::kAlpha_8;
|
|
||||||
case kGray_8_GrPixelConfig:
|
|
||||||
return GrColorType::kGray_8;
|
|
||||||
case kRGB_565_GrPixelConfig:
|
|
||||||
return GrColorType::kBGR_565;
|
|
||||||
case kRGBA_4444_GrPixelConfig:
|
|
||||||
return GrColorType::kABGR_4444;
|
|
||||||
case kRGBA_8888_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_8888;
|
|
||||||
case kRGB_888_GrPixelConfig:
|
|
||||||
return GrColorType::kRGB_888x;
|
|
||||||
case kRGB_888X_GrPixelConfig:
|
|
||||||
return GrColorType::kRGB_888x;
|
|
||||||
case kRG_88_GrPixelConfig:
|
|
||||||
return GrColorType::kRG_88;
|
|
||||||
case kBGRA_8888_GrPixelConfig:
|
|
||||||
return GrColorType::kBGRA_8888;
|
|
||||||
case kSRGBA_8888_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_8888_SRGB;
|
|
||||||
case kRGBA_1010102_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_1010102;
|
|
||||||
case kAlpha_half_GrPixelConfig:
|
|
||||||
return GrColorType::kAlpha_F16;
|
|
||||||
case kRGBA_half_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_F16;
|
|
||||||
case kRGBA_half_Clamped_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_F16_Clamped;
|
|
||||||
|
|
||||||
// We may need a roughly equivalent color type for a compressed textures. This should be
|
|
||||||
// the logical format for decompressing the data into.
|
|
||||||
case kRGB_ETC1_GrPixelConfig:
|
|
||||||
case kBC1_RGB8_UNORM_GrPixelConfig:
|
|
||||||
return GrColorType::kRGB_888x;
|
|
||||||
case kBC1_RGBA8_UNORM_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_8888;
|
|
||||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
|
||||||
return GrColorType::kAlpha_8;
|
|
||||||
case kAlpha_8_as_Red_GrPixelConfig:
|
|
||||||
return GrColorType::kAlpha_8;
|
|
||||||
case kAlpha_half_as_Lum_GrPixelConfig: // fall through
|
|
||||||
case kAlpha_half_as_Red_GrPixelConfig:
|
|
||||||
return GrColorType::kAlpha_F16;
|
|
||||||
case kGray_8_as_Lum_GrPixelConfig:
|
|
||||||
return GrColorType::kGray_8;
|
|
||||||
case kGray_8_as_Red_GrPixelConfig:
|
|
||||||
return GrColorType::kGray_8;
|
|
||||||
case kAlpha_16_GrPixelConfig:
|
|
||||||
return GrColorType::kAlpha_16;
|
|
||||||
case kRG_1616_GrPixelConfig:
|
|
||||||
return GrColorType::kRG_1616;
|
|
||||||
case kRGBA_16161616_GrPixelConfig:
|
|
||||||
return GrColorType::kRGBA_16161616;
|
|
||||||
case kRG_half_GrPixelConfig:
|
|
||||||
return GrColorType::kRG_F16;
|
|
||||||
}
|
|
||||||
SkUNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr GrPixelConfig GrColorTypeToPixelConfig(GrColorType colorType) {
|
|
||||||
switch (colorType) {
|
|
||||||
case GrColorType::kUnknown: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_8: return kAlpha_8_GrPixelConfig;
|
|
||||||
case GrColorType::kGray_8: return kGray_8_GrPixelConfig;
|
|
||||||
case GrColorType::kBGR_565: return kRGB_565_GrPixelConfig;
|
|
||||||
case GrColorType::kABGR_4444: return kRGBA_4444_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_8888: return kRGBA_8888_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_8888_SRGB: return kSRGBA_8888_GrPixelConfig;
|
|
||||||
case GrColorType::kRGB_888x: return kRGB_888_GrPixelConfig;
|
|
||||||
case GrColorType::kRG_88: return kRG_88_GrPixelConfig;
|
|
||||||
case GrColorType::kBGRA_8888: return kBGRA_8888_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_1010102: return kRGBA_1010102_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_F32: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_F16: return kAlpha_half_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_F16: return kRGBA_half_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_F16_Clamped: return kRGBA_half_Clamped_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_8xxx: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_F32xxx: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kGray_8xxx: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_16: return kAlpha_16_GrPixelConfig;
|
|
||||||
case GrColorType::kRG_1616: return kRG_1616_GrPixelConfig;
|
|
||||||
case GrColorType::kRGBA_16161616: return kRGBA_16161616_GrPixelConfig;
|
|
||||||
case GrColorType::kRG_F16: return kRG_half_GrPixelConfig;
|
|
||||||
case GrColorType::kRGB_888: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kR_8: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kR_16: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kR_F16: return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kGray_F16: return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
SkUNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr GrPixelConfig GrCompressionTypeToPixelConfig(SkImage::CompressionType compression) {
|
|
||||||
switch (compression) {
|
|
||||||
case SkImage::CompressionType::kNone: return kUnknown_GrPixelConfig;
|
|
||||||
case SkImage::CompressionType::kETC2_RGB8_UNORM: return kRGB_ETC1_GrPixelConfig;
|
|
||||||
case SkImage::CompressionType::kBC1_RGB8_UNORM: return kBC1_RGB8_UNORM_GrPixelConfig;
|
|
||||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM: return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkUNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr bool GrCompressionTypeIsOpaque(SkImage::CompressionType compression) {
|
static constexpr bool GrCompressionTypeIsOpaque(SkImage::CompressionType compression) {
|
||||||
switch (compression) {
|
switch (compression) {
|
||||||
case SkImage::CompressionType::kNone: return true;
|
case SkImage::CompressionType::kNone: return true;
|
||||||
|
@ -354,47 +354,6 @@ GrCaps::SupportedRead GrCaps::supportedReadPixelsColorType(GrColorType srcColorT
|
|||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
|
||||||
bool GrCaps::AreConfigsCompatible(GrPixelConfig genericConfig, GrPixelConfig specificConfig) {
|
|
||||||
bool compatible = false;
|
|
||||||
|
|
||||||
switch (genericConfig) {
|
|
||||||
case kAlpha_8_GrPixelConfig:
|
|
||||||
compatible = kAlpha_8_GrPixelConfig == specificConfig || // here bc of the mock context
|
|
||||||
kAlpha_8_as_Alpha_GrPixelConfig == specificConfig ||
|
|
||||||
kAlpha_8_as_Red_GrPixelConfig == specificConfig;
|
|
||||||
break;
|
|
||||||
case kGray_8_GrPixelConfig:
|
|
||||||
compatible = kGray_8_GrPixelConfig == specificConfig || // here bc of the mock context
|
|
||||||
kGray_8_as_Lum_GrPixelConfig == specificConfig ||
|
|
||||||
kGray_8_as_Red_GrPixelConfig == specificConfig;
|
|
||||||
break;
|
|
||||||
case kAlpha_half_GrPixelConfig:
|
|
||||||
compatible = kAlpha_half_GrPixelConfig == specificConfig || // bc of the mock context
|
|
||||||
kAlpha_half_as_Red_GrPixelConfig == specificConfig ||
|
|
||||||
kAlpha_half_as_Lum_GrPixelConfig == specificConfig;
|
|
||||||
break;
|
|
||||||
case kRGB_888_GrPixelConfig:
|
|
||||||
compatible = kRGB_888_GrPixelConfig == specificConfig ||
|
|
||||||
kRGB_888X_GrPixelConfig == specificConfig;
|
|
||||||
break;
|
|
||||||
case kRGBA_8888_GrPixelConfig:
|
|
||||||
compatible = kRGBA_8888_GrPixelConfig == specificConfig ||
|
|
||||||
kBGRA_8888_GrPixelConfig == specificConfig;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
compatible = genericConfig == specificConfig;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!compatible) {
|
|
||||||
SkDebugf("Configs are not compatible: %d %d\n", genericConfig, specificConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
return compatible;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GrBackendFormat GrCaps::getDefaultBackendFormat(GrColorType grColorType,
|
GrBackendFormat GrCaps::getDefaultBackendFormat(GrColorType grColorType,
|
||||||
GrRenderable renderable) const {
|
GrRenderable renderable) const {
|
||||||
GrBackendFormat format = this->onGetDefaultBackendFormat(grColorType, renderable);
|
GrBackendFormat format = this->onGetDefaultBackendFormat(grColorType, renderable);
|
||||||
|
@ -398,20 +398,6 @@ public:
|
|||||||
return this->onAreColorTypeAndFormatCompatible(grCT, format);
|
return this->onAreColorTypeAndFormatCompatible(grCT, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: it seems like we could pass the full SkImageInfo and validate its colorSpace too
|
|
||||||
// Returns kUnknown if a valid config could not be determined.
|
|
||||||
GrPixelConfig getConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType grCT) const {
|
|
||||||
if (GrColorType::kUnknown == grCT) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->onGetConfigFromBackendFormat(format, grCT);
|
|
||||||
}
|
|
||||||
GrPixelConfig getConfigFromCompressedBackendFormat(const GrBackendFormat& format) const {
|
|
||||||
return this->onGetConfigFromCompressedBackendFormat(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special method only for YUVA images. Returns a colortype that matches the backend format or
|
* Special method only for YUVA images. Returns a colortype that matches the backend format or
|
||||||
* kUnknown if a colortype could not be determined.
|
* kUnknown if a colortype could not be determined.
|
||||||
@ -446,17 +432,6 @@ public:
|
|||||||
|
|
||||||
const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; }
|
const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a possibly generic GrPixelConfig and a backend format return a specific
|
|
||||||
* GrPixelConfig.
|
|
||||||
*/
|
|
||||||
GrPixelConfig makeConfigSpecific(GrPixelConfig config, const GrBackendFormat& format) const {
|
|
||||||
auto ct = GrPixelConfigToColorType(config);
|
|
||||||
auto result = this->getConfigFromBackendFormat(format, ct);
|
|
||||||
SkASSERT(config == result || AreConfigsCompatible(config, result));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds fields to the key to represent the sampler that will be created for the passed
|
* Adds fields to the key to represent the sampler that will be created for the passed
|
||||||
* in parameters. Currently this extra keying is only needed when building a vulkan pipeline
|
* in parameters. Currently this extra keying is only needed when building a vulkan pipeline
|
||||||
@ -468,13 +443,6 @@ public:
|
|||||||
|
|
||||||
virtual GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const = 0;
|
virtual GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const = 0;
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
|
||||||
// This is just a debugging entry point until we're weaned off of GrPixelConfig. It
|
|
||||||
// should be used to verify that the pixel config from user-level code (the genericConfig)
|
|
||||||
// is compatible with a pixel config we've computed from scratch (the specificConfig).
|
|
||||||
static bool AreConfigsCompatible(GrPixelConfig genericConfig, GrPixelConfig specificConfig);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
struct TestFormatColorTypeCombination {
|
struct TestFormatColorTypeCombination {
|
||||||
GrColorType fColorType;
|
GrColorType fColorType;
|
||||||
@ -580,17 +548,12 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType ct) const = 0;
|
|
||||||
virtual GrPixelConfig onGetConfigFromCompressedBackendFormat(const GrBackendFormat&) const = 0;
|
|
||||||
|
|
||||||
virtual bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const = 0;
|
virtual bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const = 0;
|
||||||
|
|
||||||
virtual SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType,
|
virtual SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType,
|
||||||
const GrBackendFormat& srcFormat,
|
const GrBackendFormat& srcFormat,
|
||||||
GrColorType dstColorType) const = 0;
|
GrColorType dstColorType) const = 0;
|
||||||
|
|
||||||
|
|
||||||
bool fSuppressPrints : 1;
|
bool fSuppressPrints : 1;
|
||||||
bool fWireframeMode : 1;
|
bool fWireframeMode : 1;
|
||||||
|
|
||||||
|
@ -134,9 +134,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy(
|
|||||||
|
|
||||||
if (this->caps()->isFormatCompressed(format)) {
|
if (this->caps()->isFormatCompressed(format)) {
|
||||||
// TODO: Allow this to go to GrResourceProvider::createCompressedTexture() once we no longer
|
// TODO: Allow this to go to GrResourceProvider::createCompressedTexture() once we no longer
|
||||||
// rely on GrColorType to get to GrPixelConfig. Currently this will cause
|
// rely on GrColorType to get a swizzle for the proxy.
|
||||||
// makeConfigSpecific() to assert because GrColorTypeToPixelConfig() never returns a
|
|
||||||
// compressed GrPixelConfig.
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
|
@ -231,67 +231,6 @@ SkColor4f SkColor4fPrepForDst(SkColor4f color, const GrColorInfo& colorInfo) {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GrPixelConfig SkColorType2GrPixelConfig(const SkColorType type) {
|
|
||||||
switch (type) {
|
|
||||||
case kUnknown_SkColorType:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
case kAlpha_8_SkColorType:
|
|
||||||
return kAlpha_8_GrPixelConfig;
|
|
||||||
case kRGB_565_SkColorType:
|
|
||||||
return kRGB_565_GrPixelConfig;
|
|
||||||
case kARGB_4444_SkColorType:
|
|
||||||
return kRGBA_4444_GrPixelConfig;
|
|
||||||
case kRGBA_8888_SkColorType:
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
case kRGB_888x_SkColorType:
|
|
||||||
return kRGB_888_GrPixelConfig;
|
|
||||||
case kBGRA_8888_SkColorType:
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
case kRGBA_1010102_SkColorType:
|
|
||||||
return kRGBA_1010102_GrPixelConfig;
|
|
||||||
case kRGB_101010x_SkColorType:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
case kGray_8_SkColorType:
|
|
||||||
return kGray_8_GrPixelConfig;
|
|
||||||
case kRGBA_F16Norm_SkColorType:
|
|
||||||
return kRGBA_half_Clamped_GrPixelConfig;
|
|
||||||
case kRGBA_F16_SkColorType:
|
|
||||||
return kRGBA_half_GrPixelConfig;
|
|
||||||
case kRGBA_F32_SkColorType:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
case kR8G8_unorm_SkColorType:
|
|
||||||
return kRG_88_GrPixelConfig;
|
|
||||||
case kR16G16_unorm_SkColorType:
|
|
||||||
return kRG_1616_GrPixelConfig;
|
|
||||||
case kA16_unorm_SkColorType:
|
|
||||||
return kAlpha_16_GrPixelConfig;
|
|
||||||
case kA16_float_SkColorType:
|
|
||||||
return kAlpha_half_GrPixelConfig;
|
|
||||||
case kR16G16_float_SkColorType:
|
|
||||||
return kRG_half_GrPixelConfig;
|
|
||||||
case kR16G16B16A16_unorm_SkColorType:
|
|
||||||
return kRGBA_16161616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
SkUNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
|
|
||||||
return SkColorType2GrPixelConfig(info.colorType());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
|
|
||||||
SkColorType ct = GrColorTypeToSkColorType(GrPixelConfigToColorType(config));
|
|
||||||
if (kUnknown_SkColorType != ct) {
|
|
||||||
if (ctOut) {
|
|
||||||
*ctOut = ct;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static inline bool blend_requires_shader(const SkBlendMode mode) {
|
static inline bool blend_requires_shader(const SkBlendMode mode) {
|
||||||
return SkBlendMode::kDst != mode;
|
return SkBlendMode::kDst != mode;
|
||||||
}
|
}
|
||||||
@ -462,7 +401,6 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SK_IGNORE_GPU_DITHER
|
#ifndef SK_IGNORE_GPU_DITHER
|
||||||
// Conservative default, in case GrPixelConfigToColorType() fails.
|
|
||||||
GrColorType ct = dstColorInfo.colorType();
|
GrColorType ct = dstColorInfo.colorType();
|
||||||
if (SkPaintPriv::ShouldDither(skPaint, GrColorTypeToSkColorType(ct)) &&
|
if (SkPaintPriv::ShouldDither(skPaint, GrColorTypeToSkColorType(ct)) &&
|
||||||
grPaint->numColorFragmentProcessors() > 0) {
|
grPaint->numColorFragmentProcessors() > 0) {
|
||||||
|
@ -126,10 +126,6 @@ bool SkPaintToGrPaintWithTexture(GrRecordingContext*,
|
|||||||
// Misc Sk to Gr type conversions
|
// Misc Sk to Gr type conversions
|
||||||
|
|
||||||
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
|
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
|
||||||
GrPixelConfig SkColorType2GrPixelConfig(const SkColorType);
|
|
||||||
GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info);
|
|
||||||
|
|
||||||
bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*);
|
|
||||||
|
|
||||||
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,
|
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,
|
||||||
SkFilterQuality paintFilterQuality,
|
SkFilterQuality paintFilterQuality,
|
||||||
|
@ -48,48 +48,6 @@ bool GrDawnCaps::isFormatTexturable(const GrBackendFormat& format) const {
|
|||||||
return format.asDawnFormat(&dawnFormat);
|
return format.asDawnFormat(&dawnFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPixelConfig GrDawnCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType colorType) const {
|
|
||||||
wgpu::TextureFormat dawnFormat;
|
|
||||||
if (!format.asDawnFormat(&dawnFormat)) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
switch (colorType) {
|
|
||||||
case GrColorType::kUnknown:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_8:
|
|
||||||
if (wgpu::TextureFormat::R8Unorm == dawnFormat) {
|
|
||||||
return kAlpha_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888:
|
|
||||||
if (wgpu::TextureFormat::RGBA8Unorm == dawnFormat) {
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
} else if (wgpu::TextureFormat::BGRA8Unorm == dawnFormat) {
|
|
||||||
// FIXME: This shouldn't be necessary, but on some platforms (Mac)
|
|
||||||
// Skia byte order is RGBA, while preferred swap format is BGRA.
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGB_888x:
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGRA_8888:
|
|
||||||
if (wgpu::TextureFormat::BGRA8Unorm == dawnFormat) {
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
} else if (wgpu::TextureFormat::RGBA8Unorm == dawnFormat) {
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig GrDawnCaps::onGetConfigFromCompressedBackendFormat(const GrBackendFormat&) const {
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GrSwizzle get_swizzle(const GrBackendFormat& format, GrColorType colorType,
|
static GrSwizzle get_swizzle(const GrBackendFormat& format, GrColorType colorType,
|
||||||
bool forOutput) {
|
bool forOutput) {
|
||||||
switch (colorType) {
|
switch (colorType) {
|
||||||
|
@ -75,9 +75,6 @@ private:
|
|||||||
}
|
}
|
||||||
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
||||||
|
|
||||||
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override;
|
|
||||||
GrPixelConfig onGetConfigFromCompressedBackendFormat(const GrBackendFormat&) const override;
|
|
||||||
|
|
||||||
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
||||||
|
|
||||||
SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType,
|
SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType,
|
||||||
|
@ -189,11 +189,9 @@ sk_sp<GrTexture> GrDawnGpu::onWrapBackendTexture(const GrBackendTexture& backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkISize dimensions = { backendTex.width(), backendTex.height() };
|
SkISize dimensions = { backendTex.width(), backendTex.height() };
|
||||||
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
|
|
||||||
colorType);
|
|
||||||
GrMipMapsStatus status = GrMipMapsStatus::kNotAllocated;
|
GrMipMapsStatus status = GrMipMapsStatus::kNotAllocated;
|
||||||
return GrDawnTexture::MakeWrapped(this, dimensions, config, GrRenderable::kNo, 1, status,
|
return GrDawnTexture::MakeWrapped(this, dimensions, GrRenderable::kNo, 1, status, cacheable,
|
||||||
cacheable, info);
|
info);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTexture> GrDawnGpu::onWrapCompressedBackendTexture(const GrBackendTexture& backendTex,
|
sk_sp<GrTexture> GrDawnGpu::onWrapCompressedBackendTexture(const GrBackendTexture& backendTex,
|
||||||
@ -213,16 +211,14 @@ sk_sp<GrTexture> GrDawnGpu::onWrapRenderableBackendTexture(const GrBackendTextur
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkISize dimensions = { tex.width(), tex.height() };
|
SkISize dimensions = { tex.width(), tex.height() };
|
||||||
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(tex.getBackendFormat(),
|
|
||||||
colorType);
|
|
||||||
sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, tex.getBackendFormat());
|
sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, tex.getBackendFormat());
|
||||||
if (sampleCnt < 1) {
|
if (sampleCnt < 1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrMipMapsStatus status = GrMipMapsStatus::kNotAllocated;
|
GrMipMapsStatus status = GrMipMapsStatus::kNotAllocated;
|
||||||
return GrDawnTexture::MakeWrapped(this, dimensions, config, GrRenderable::kYes, sampleCnt,
|
return GrDawnTexture::MakeWrapped(this, dimensions, GrRenderable::kYes, sampleCnt, status,
|
||||||
status, cacheable, info);
|
cacheable, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt,
|
sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt,
|
||||||
@ -233,10 +229,8 @@ sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendRenderTarget(const GrBackendRender
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkISize dimensions = { rt.width(), rt.height() };
|
SkISize dimensions = { rt.width(), rt.height() };
|
||||||
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(rt.getBackendFormat(),
|
|
||||||
colorType);
|
|
||||||
int sampleCnt = 1;
|
int sampleCnt = 1;
|
||||||
return GrDawnRenderTarget::MakeWrapped(this, dimensions, config, sampleCnt, info);
|
return GrDawnRenderTarget::MakeWrapped(this, dimensions, sampleCnt, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
|
sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
|
||||||
@ -248,14 +242,12 @@ sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendTextureAsRenderTarget(const GrBack
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkISize dimensions = { tex.width(), tex.height() };
|
SkISize dimensions = { tex.width(), tex.height() };
|
||||||
GrPixelConfig config = this->caps()->getConfigFromBackendFormat(tex.getBackendFormat(),
|
|
||||||
colorType);
|
|
||||||
sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, tex.getBackendFormat());
|
sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, tex.getBackendFormat());
|
||||||
if (sampleCnt < 1) {
|
if (sampleCnt < 1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GrDawnRenderTarget::MakeWrapped(this, dimensions, config, sampleCnt, info);
|
return GrDawnRenderTarget::MakeWrapped(this, dimensions, sampleCnt, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrStencilAttachment* GrDawnGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
|
GrStencilAttachment* GrDawnGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
|
||||||
|
@ -13,19 +13,17 @@
|
|||||||
|
|
||||||
GrDawnRenderTarget::GrDawnRenderTarget(GrDawnGpu* gpu,
|
GrDawnRenderTarget::GrDawnRenderTarget(GrDawnGpu* gpu,
|
||||||
const SkISize& dimensions,
|
const SkISize& dimensions,
|
||||||
GrPixelConfig config,
|
|
||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
const GrDawnImageInfo& info)
|
const GrDawnImageInfo& info)
|
||||||
: GrSurface(gpu, dimensions, config, GrProtected::kNo)
|
: GrSurface(gpu, dimensions, GrProtected::kNo)
|
||||||
, GrRenderTarget(gpu, dimensions, config, sampleCnt, GrProtected::kNo)
|
, GrRenderTarget(gpu, dimensions, sampleCnt, GrProtected::kNo)
|
||||||
, fInfo(info) {}
|
, fInfo(info) {}
|
||||||
|
|
||||||
sk_sp<GrDawnRenderTarget> GrDawnRenderTarget::MakeWrapped(GrDawnGpu* gpu,
|
sk_sp<GrDawnRenderTarget> GrDawnRenderTarget::MakeWrapped(GrDawnGpu* gpu,
|
||||||
const SkISize& dimensions,
|
const SkISize& dimensions,
|
||||||
GrPixelConfig config,
|
|
||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
const GrDawnImageInfo& info) {
|
const GrDawnImageInfo& info) {
|
||||||
sk_sp<GrDawnRenderTarget> rt(new GrDawnRenderTarget(gpu, dimensions, config, sampleCnt, info));
|
sk_sp<GrDawnRenderTarget> rt(new GrDawnRenderTarget(gpu, dimensions, sampleCnt, info));
|
||||||
rt->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
rt->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,7 @@ class GrDawnGpu;
|
|||||||
class GrDawnRenderTarget: public GrRenderTarget {
|
class GrDawnRenderTarget: public GrRenderTarget {
|
||||||
public:
|
public:
|
||||||
static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*, const SkISize& dimensions,
|
static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*, const SkISize& dimensions,
|
||||||
GrPixelConfig config, int sampleCnt,
|
int sampleCnt, const GrDawnImageInfo&);
|
||||||
const GrDawnImageInfo&);
|
|
||||||
|
|
||||||
~GrDawnRenderTarget() override;
|
~GrDawnRenderTarget() override;
|
||||||
|
|
||||||
@ -32,7 +31,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
GrDawnRenderTarget(GrDawnGpu* gpu,
|
GrDawnRenderTarget(GrDawnGpu* gpu,
|
||||||
const SkISize& dimensions,
|
const SkISize& dimensions,
|
||||||
GrPixelConfig config,
|
|
||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
const GrDawnImageInfo& info);
|
const GrDawnImageInfo& info);
|
||||||
|
|
||||||
|
@ -14,19 +14,17 @@
|
|||||||
|
|
||||||
GrDawnTexture::GrDawnTexture(GrDawnGpu* gpu,
|
GrDawnTexture::GrDawnTexture(GrDawnGpu* gpu,
|
||||||
const SkISize& dimensions,
|
const SkISize& dimensions,
|
||||||
GrPixelConfig config,
|
|
||||||
wgpu::TextureView textureView,
|
wgpu::TextureView textureView,
|
||||||
const GrDawnImageInfo& info,
|
const GrDawnImageInfo& info,
|
||||||
GrMipMapsStatus mipMapsStatus)
|
GrMipMapsStatus mipMapsStatus)
|
||||||
: GrSurface(gpu, dimensions, config, GrProtected::kNo)
|
: GrSurface(gpu, dimensions, GrProtected::kNo)
|
||||||
, GrTexture(gpu, dimensions, config, GrProtected::kNo, GrTextureType::k2D, mipMapsStatus)
|
, GrTexture(gpu, dimensions, GrProtected::kNo, GrTextureType::k2D, mipMapsStatus)
|
||||||
, fInfo(info)
|
, fInfo(info)
|
||||||
, fTextureView(textureView) {}
|
, fTextureView(textureView) {}
|
||||||
|
|
||||||
sk_sp<GrDawnTexture> GrDawnTexture::Make(GrDawnGpu* gpu, const SkISize& dimensions,
|
sk_sp<GrDawnTexture> GrDawnTexture::Make(GrDawnGpu* gpu, const SkISize& dimensions,
|
||||||
GrPixelConfig config, wgpu::TextureFormat format,
|
wgpu::TextureFormat format, GrRenderable renderable,
|
||||||
GrRenderable renderable, int sampleCnt,
|
int sampleCnt, SkBudgeted budgeted, int mipLevels,
|
||||||
SkBudgeted budgeted, int mipLevels,
|
|
||||||
GrMipMapsStatus status) {
|
GrMipMapsStatus status) {
|
||||||
bool renderTarget = renderable == GrRenderable::kYes;
|
bool renderTarget = renderable == GrRenderable::kYes;
|
||||||
wgpu::TextureDescriptor textureDesc;
|
wgpu::TextureDescriptor textureDesc;
|
||||||
@ -67,14 +65,13 @@ sk_sp<GrDawnTexture> GrDawnTexture::Make(GrDawnGpu* gpu, const SkISize& dimensio
|
|||||||
if (renderTarget) {
|
if (renderTarget) {
|
||||||
result = sk_sp<GrDawnTextureRenderTarget>(new GrDawnTextureRenderTarget(gpu,
|
result = sk_sp<GrDawnTextureRenderTarget>(new GrDawnTextureRenderTarget(gpu,
|
||||||
dimensions,
|
dimensions,
|
||||||
config,
|
|
||||||
textureView,
|
textureView,
|
||||||
sampleCnt,
|
sampleCnt,
|
||||||
info,
|
info,
|
||||||
status));
|
status));
|
||||||
} else {
|
} else {
|
||||||
result = sk_sp<GrDawnTexture>(
|
result = sk_sp<GrDawnTexture>(
|
||||||
new GrDawnTexture(gpu, dimensions, config, textureView, info, status));
|
new GrDawnTexture(gpu, dimensions, textureView, info, status));
|
||||||
}
|
}
|
||||||
result->registerWithCache(budgeted);
|
result->registerWithCache(budgeted);
|
||||||
return result;
|
return result;
|
||||||
@ -85,9 +82,8 @@ GrBackendFormat GrDawnTexture::backendFormat() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDawnTexture> GrDawnTexture::MakeWrapped(GrDawnGpu* gpu, const SkISize& dimensions,
|
sk_sp<GrDawnTexture> GrDawnTexture::MakeWrapped(GrDawnGpu* gpu, const SkISize& dimensions,
|
||||||
GrPixelConfig config, GrRenderable renderable,
|
GrRenderable renderable, int sampleCnt,
|
||||||
int sampleCnt, GrMipMapsStatus status,
|
GrMipMapsStatus status, GrWrapCacheable cacheable,
|
||||||
GrWrapCacheable cacheable,
|
|
||||||
const GrDawnImageInfo& info) {
|
const GrDawnImageInfo& info) {
|
||||||
wgpu::TextureView textureView = info.fTexture.CreateView();
|
wgpu::TextureView textureView = info.fTexture.CreateView();
|
||||||
if (!textureView) {
|
if (!textureView) {
|
||||||
|
@ -16,14 +16,13 @@ struct GrDawnImageInfo;
|
|||||||
|
|
||||||
class GrDawnTexture : public GrTexture {
|
class GrDawnTexture : public GrTexture {
|
||||||
public:
|
public:
|
||||||
static sk_sp<GrDawnTexture> Make(GrDawnGpu*, const SkISize& dimensions, GrPixelConfig config,
|
static sk_sp<GrDawnTexture> Make(GrDawnGpu*, const SkISize& dimensions,
|
||||||
wgpu::TextureFormat format, GrRenderable, int sampleCnt,
|
wgpu::TextureFormat format, GrRenderable, int sampleCnt,
|
||||||
SkBudgeted, int mipLevels, GrMipMapsStatus);
|
SkBudgeted, int mipLevels, GrMipMapsStatus);
|
||||||
|
|
||||||
static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, const SkISize& dimensions,
|
static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, const SkISize& dimensions,
|
||||||
GrPixelConfig config, GrRenderable, int sampleCnt,
|
GrRenderable, int sampleCnt, GrMipMapsStatus,
|
||||||
GrMipMapsStatus, GrWrapCacheable,
|
GrWrapCacheable, const GrDawnImageInfo&);
|
||||||
const GrDawnImageInfo&);
|
|
||||||
|
|
||||||
~GrDawnTexture() override;
|
~GrDawnTexture() override;
|
||||||
|
|
||||||
@ -39,8 +38,8 @@ public:
|
|||||||
wgpu::Texture texture() const { return fInfo.fTexture; }
|
wgpu::Texture texture() const { return fInfo.fTexture; }
|
||||||
wgpu::TextureView textureView() const { return fTextureView; }
|
wgpu::TextureView textureView() const { return fTextureView; }
|
||||||
protected:
|
protected:
|
||||||
GrDawnTexture(GrDawnGpu*, const SkISize& dimensions, GrPixelConfig config, wgpu::TextureView,
|
GrDawnTexture(GrDawnGpu*, const SkISize& dimensions, wgpu::TextureView, const GrDawnImageInfo&,
|
||||||
const GrDawnImageInfo&, GrMipMapsStatus);
|
GrMipMapsStatus);
|
||||||
|
|
||||||
GrDawnGpu* getDawnGpu() const;
|
GrDawnGpu* getDawnGpu() const;
|
||||||
|
|
||||||
|
@ -14,14 +14,13 @@
|
|||||||
|
|
||||||
GrDawnTextureRenderTarget::GrDawnTextureRenderTarget(GrDawnGpu* gpu,
|
GrDawnTextureRenderTarget::GrDawnTextureRenderTarget(GrDawnGpu* gpu,
|
||||||
const SkISize& dimensions,
|
const SkISize& dimensions,
|
||||||
GrPixelConfig config,
|
|
||||||
wgpu::TextureView textureView,
|
wgpu::TextureView textureView,
|
||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
const GrDawnImageInfo& info,
|
const GrDawnImageInfo& info,
|
||||||
GrMipMapsStatus mipMapsStatus)
|
GrMipMapsStatus mipMapsStatus)
|
||||||
: GrSurface(gpu, dimensions, config, GrProtected::kNo)
|
: GrSurface(gpu, dimensions, GrProtected::kNo)
|
||||||
, GrDawnTexture(gpu, dimensions, config, textureView, info, mipMapsStatus)
|
, GrDawnTexture(gpu, dimensions, textureView, info, mipMapsStatus)
|
||||||
, GrDawnRenderTarget(gpu, dimensions, config, sampleCnt, info) {}
|
, GrDawnRenderTarget(gpu, dimensions, sampleCnt, info) {}
|
||||||
|
|
||||||
bool GrDawnTextureRenderTarget::canAttemptStencilAttachment() const {
|
bool GrDawnTextureRenderTarget::canAttemptStencilAttachment() const {
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,6 @@ class GrDawnTextureRenderTarget : public GrDawnTexture, public GrDawnRenderTarge
|
|||||||
public:
|
public:
|
||||||
GrDawnTextureRenderTarget(GrDawnGpu* gpu,
|
GrDawnTextureRenderTarget(GrDawnGpu* gpu,
|
||||||
const SkISize& dimensions,
|
const SkISize& dimensions,
|
||||||
GrPixelConfig config,
|
|
||||||
const wgpu::TextureView textureView,
|
const wgpu::TextureView textureView,
|
||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
const GrDawnImageInfo& info,
|
const GrDawnImageInfo& info,
|
||||||
|
@ -1772,7 +1772,7 @@ void GrGLCaps::initFormatTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
// requires the src and dst be bindable to FBOs. However, we can't do this in the current
|
// requires the src and dst be bindable to FBOs. However, we can't do this in the current
|
||||||
// world since some devices (e.g. chromium & angle) require the formats in glBlitFramebuffer
|
// world since some devices (e.g. chromium & angle) require the formats in glBlitFramebuffer
|
||||||
// to match. We don't have a way to really check this during resolve since we only actually
|
// to match. We don't have a way to really check this during resolve since we only actually
|
||||||
// have one GrPixelConfig and one GrBackendFormat that is shared by the GrGLRenderTarget.
|
// have GrBackendFormat that is shared by the GrGLRenderTarget.
|
||||||
// Once we break those up into different surface we can revisit doing this change.
|
// Once we break those up into different surface we can revisit doing this change.
|
||||||
if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
|
if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
|
||||||
info.fInternalFormatForRenderbuffer = GR_GL_RGBA8;
|
info.fInternalFormatForRenderbuffer = GR_GL_RGBA8;
|
||||||
@ -4136,137 +4136,6 @@ bool GrGLCaps::formatSupportsTexStorage(GrGLFormat format) const {
|
|||||||
return SkToBool(this->getFormatInfo(format).fFlags & FormatInfo::kUseTexStorage_Flag);
|
return SkToBool(this->getFormatInfo(format).fFlags & FormatInfo::kUseTexStorage_Flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GrPixelConfig validate_sized_format(GrGLFormat format,
|
|
||||||
GrColorType ct,
|
|
||||||
GrGLStandard standard) {
|
|
||||||
switch (ct) {
|
|
||||||
case GrColorType::kUnknown:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_8:
|
|
||||||
if (format == GrGLFormat::kALPHA8) {
|
|
||||||
return kAlpha_8_as_Alpha_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kR8) {
|
|
||||||
return kAlpha_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGR_565:
|
|
||||||
if (format == GrGLFormat::kRGB565) {
|
|
||||||
return kRGB_565_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kABGR_4444:
|
|
||||||
if (format == GrGLFormat::kRGBA4) {
|
|
||||||
return kRGBA_4444_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888:
|
|
||||||
if (format == GrGLFormat::kRGBA8) {
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kCOMPRESSED_RGBA8_BC1) {
|
|
||||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888_SRGB:
|
|
||||||
if (format == GrGLFormat::kSRGB8_ALPHA8) {
|
|
||||||
return kSRGBA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGB_888x:
|
|
||||||
if (format == GrGLFormat::kRGB8) {
|
|
||||||
return kRGB_888_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kRGBA8) {
|
|
||||||
return kRGB_888X_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kCOMPRESSED_RGB8_ETC2 ||
|
|
||||||
format == GrGLFormat::kCOMPRESSED_ETC1_RGB8) {
|
|
||||||
return kRGB_ETC1_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kCOMPRESSED_RGB8_BC1) {
|
|
||||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_88:
|
|
||||||
if (format == GrGLFormat::kRG8) {
|
|
||||||
return kRG_88_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGRA_8888:
|
|
||||||
if (format == GrGLFormat::kRGBA8) {
|
|
||||||
if (GR_IS_GR_GL(standard)) {
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
} else if (format == GrGLFormat::kBGRA8) {
|
|
||||||
if (GR_IS_GR_GL_ES(standard) || GR_IS_GR_WEBGL(standard)) {
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_1010102:
|
|
||||||
if (format == GrGLFormat::kRGB10_A2) {
|
|
||||||
return kRGBA_1010102_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kGray_8:
|
|
||||||
if (format == GrGLFormat::kLUMINANCE8) {
|
|
||||||
return kGray_8_as_Lum_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kR8) {
|
|
||||||
return kGray_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_F16:
|
|
||||||
if (format == GrGLFormat::kLUMINANCE16F) {
|
|
||||||
return kAlpha_half_as_Lum_GrPixelConfig;
|
|
||||||
} else if (format == GrGLFormat::kR16F) {
|
|
||||||
return kAlpha_half_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16:
|
|
||||||
if (format == GrGLFormat::kRGBA16F) {
|
|
||||||
return kRGBA_half_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16_Clamped:
|
|
||||||
if (format == GrGLFormat::kRGBA16F) {
|
|
||||||
return kRGBA_half_Clamped_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_16:
|
|
||||||
if (format == GrGLFormat::kR16) {
|
|
||||||
return kAlpha_16_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_1616:
|
|
||||||
if (format == GrGLFormat::kRG16) {
|
|
||||||
return kRG_1616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_16161616:
|
|
||||||
if (format == GrGLFormat::kRGBA16) {
|
|
||||||
return kRGBA_16161616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_F16:
|
|
||||||
if (format == GrGLFormat::kRG16F) {
|
|
||||||
return kRG_half_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// These have no equivalent config:
|
|
||||||
case GrColorType::kRGBA_F32:
|
|
||||||
case GrColorType::kAlpha_8xxx:
|
|
||||||
case GrColorType::kAlpha_F32xxx:
|
|
||||||
case GrColorType::kGray_8xxx:
|
|
||||||
case GrColorType::kRGB_888:
|
|
||||||
case GrColorType::kR_8:
|
|
||||||
case GrColorType::kR_16:
|
|
||||||
case GrColorType::kR_F16:
|
|
||||||
case GrColorType::kGray_F16:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkDebugf("GL format/colorType mismatch - glFormat: %d colorType: %d standard: %d\n",
|
|
||||||
format, ct, standard);
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GrGLCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
bool GrGLCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
||||||
const GrBackendFormat& format) const {
|
const GrBackendFormat& format) const {
|
||||||
GrGLFormat glFormat = format.asGLFormat();
|
GrGLFormat glFormat = format.asGLFormat();
|
||||||
@ -4286,32 +4155,12 @@ bool GrGLCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPixelConfig GrGLCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType ct) const {
|
|
||||||
return validate_sized_format(format.asGLFormat(), ct, fStandard);
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig GrGLCaps::onGetConfigFromCompressedBackendFormat(const GrBackendFormat& f) const {
|
|
||||||
GrGLFormat glFormat = f.asGLFormat();
|
|
||||||
|
|
||||||
if (glFormat == GrGLFormat::kCOMPRESSED_RGB8_ETC2 ||
|
|
||||||
glFormat == GrGLFormat::kCOMPRESSED_ETC1_RGB8) {
|
|
||||||
return kRGB_ETC1_GrPixelConfig;
|
|
||||||
} else if (glFormat == GrGLFormat::kCOMPRESSED_RGB8_BC1) {
|
|
||||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
|
||||||
} else if (glFormat == GrGLFormat::kCOMPRESSED_RGBA8_BC1) {
|
|
||||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrColorType GrGLCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
|
GrColorType GrGLCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
|
||||||
bool isAlphaChannel) const {
|
bool isAlphaChannel) const {
|
||||||
switch (format.asGLFormat()) {
|
switch (format.asGLFormat()) {
|
||||||
case GrGLFormat::kLUMINANCE8: // <missing kAlpha_8_as_Lum>/kGray_8_as_Lum_GrPixelConfig
|
case GrGLFormat::kLUMINANCE8:
|
||||||
case GrGLFormat::kR8: // kAlpha_8_as_Red_GrPixelConfig/kGray_8_as_Red_GrPixelConfig
|
case GrGLFormat::kR8:
|
||||||
case GrGLFormat::kALPHA8: // kAlpha_8_as_Alpha_GrPixelConfig/<missing kGray_8_as_Alpha>
|
case GrGLFormat::kALPHA8:
|
||||||
return isAlphaChannel ? GrColorType::kAlpha_8
|
return isAlphaChannel ? GrColorType::kAlpha_8
|
||||||
: GrColorType::kGray_8;
|
: GrColorType::kGray_8;
|
||||||
case GrGLFormat::kRG8: return GrColorType::kRG_88;
|
case GrGLFormat::kRG8: return GrColorType::kRG_88;
|
||||||
|
@ -475,8 +475,6 @@ private:
|
|||||||
bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
|
bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
|
||||||
const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
|
const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
|
||||||
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
||||||
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override;
|
|
||||||
GrPixelConfig onGetConfigFromCompressedBackendFormat(const GrBackendFormat&) const override;
|
|
||||||
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
||||||
|
|
||||||
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
|
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
|
||||||
|
@ -194,28 +194,6 @@ private:
|
|||||||
return GrBackendFormat::MakeMock(ct, SkImage::CompressionType::kNone);
|
return GrBackendFormat::MakeMock(ct, SkImage::CompressionType::kNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType) const override {
|
|
||||||
SkImage::CompressionType compression = format.asMockCompressionType();
|
|
||||||
if (compression != SkImage::CompressionType::kNone) {
|
|
||||||
// This emulates the behavior of the other backends which validate
|
|
||||||
// the format w/ the colorType
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GrColorTypeToPixelConfig(format.asMockColorType());
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig onGetConfigFromCompressedBackendFormat(const GrBackendFormat& f) const override {
|
|
||||||
SkImage::CompressionType compression = f.asMockCompressionType();
|
|
||||||
if (compression != SkImage::CompressionType::kNone) {
|
|
||||||
return GrCompressionTypeToPixelConfig(compression);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This emulates the behavior of the other backends
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool onAreColorTypeAndFormatCompatible(GrColorType ct,
|
bool onAreColorTypeAndFormatCompatible(GrColorType ct,
|
||||||
const GrBackendFormat& format) const override {
|
const GrBackendFormat& format) const override {
|
||||||
if (ct == GrColorType::kUnknown) {
|
if (ct == GrColorType::kUnknown) {
|
||||||
|
@ -111,8 +111,6 @@ private:
|
|||||||
bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
|
bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
|
||||||
const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
|
const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
|
||||||
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
||||||
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override;
|
|
||||||
GrPixelConfig onGetConfigFromCompressedBackendFormat(const GrBackendFormat&) const override;
|
|
||||||
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
||||||
|
|
||||||
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
|
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
|
||||||
|
@ -870,128 +870,6 @@ bool GrMtlCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat, GrColorType ct) {
|
|
||||||
MTLPixelFormat format = static_cast<MTLPixelFormat>(grFormat);
|
|
||||||
switch (ct) {
|
|
||||||
case GrColorType::kUnknown:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
case GrColorType::kAlpha_8:
|
|
||||||
if (MTLPixelFormatA8Unorm == format) {
|
|
||||||
return kAlpha_8_as_Alpha_GrPixelConfig;
|
|
||||||
} else if (MTLPixelFormatR8Unorm == format) {
|
|
||||||
return kAlpha_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef SK_BUILD_FOR_MAC
|
|
||||||
case GrColorType::kBGR_565:
|
|
||||||
case GrColorType::kABGR_4444:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
#else
|
|
||||||
case GrColorType::kBGR_565:
|
|
||||||
if (MTLPixelFormatB5G6R5Unorm == format) {
|
|
||||||
return kRGB_565_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kABGR_4444:
|
|
||||||
if (MTLPixelFormatABGR4Unorm == format) {
|
|
||||||
return kRGBA_4444_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case GrColorType::kRGBA_8888:
|
|
||||||
if (MTLPixelFormatRGBA8Unorm == format) {
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
#ifdef SK_BUILD_FOR_MAC
|
|
||||||
else if (MTLPixelFormatBC1_RGBA == format) {
|
|
||||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888_SRGB:
|
|
||||||
if (MTLPixelFormatRGBA8Unorm_sRGB == format) {
|
|
||||||
return kSRGBA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGB_888x:
|
|
||||||
if (MTLPixelFormatRGBA8Unorm == format) {
|
|
||||||
return kRGB_888X_GrPixelConfig;
|
|
||||||
}
|
|
||||||
#ifdef SK_BUILD_FOR_IOS
|
|
||||||
else if (MTLPixelFormatETC2_RGB8 == format) {
|
|
||||||
return kRGB_ETC1_GrPixelConfig;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_88:
|
|
||||||
if (MTLPixelFormatRG8Unorm == format) {
|
|
||||||
return kRG_88_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGRA_8888:
|
|
||||||
if (MTLPixelFormatBGRA8Unorm == format) {
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_1010102:
|
|
||||||
if (MTLPixelFormatRGB10A2Unorm == format) {
|
|
||||||
return kRGBA_1010102_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kGray_8:
|
|
||||||
if (MTLPixelFormatR8Unorm == format) {
|
|
||||||
return kGray_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_F16:
|
|
||||||
if (MTLPixelFormatR16Float == format) {
|
|
||||||
return kAlpha_half_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16:
|
|
||||||
if (MTLPixelFormatRGBA16Float == format) {
|
|
||||||
return kRGBA_half_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16_Clamped:
|
|
||||||
if (MTLPixelFormatRGBA16Float == format) {
|
|
||||||
return kRGBA_half_Clamped_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_16:
|
|
||||||
if (MTLPixelFormatR16Unorm == format) {
|
|
||||||
return kAlpha_16_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_1616:
|
|
||||||
if (MTLPixelFormatRG16Unorm == format) {
|
|
||||||
return kRG_1616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_16161616:
|
|
||||||
if (MTLPixelFormatRGBA16Unorm == format) {
|
|
||||||
return kRGBA_16161616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_F16:
|
|
||||||
if (MTLPixelFormatRG16Float == format) {
|
|
||||||
return kRG_half_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F32:
|
|
||||||
case GrColorType::kAlpha_8xxx:
|
|
||||||
case GrColorType::kAlpha_F32xxx:
|
|
||||||
case GrColorType::kGray_8xxx:
|
|
||||||
case GrColorType::kRGB_888:
|
|
||||||
case GrColorType::kR_8:
|
|
||||||
case GrColorType::kR_16:
|
|
||||||
case GrColorType::kR_F16:
|
|
||||||
case GrColorType::kGray_F16:
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
SkUNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GrMtlCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
bool GrMtlCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
||||||
const GrBackendFormat& format) const {
|
const GrBackendFormat& format) const {
|
||||||
MTLPixelFormat mtlFormat = GrBackendFormatAsMTLPixelFormat(format);
|
MTLPixelFormat mtlFormat = GrBackendFormatAsMTLPixelFormat(format);
|
||||||
@ -1004,25 +882,6 @@ bool GrMtlCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPixelConfig GrMtlCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType ct) const {
|
|
||||||
return validate_sized_format(GrBackendFormatAsMTLPixelFormat(format), ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig GrMtlCaps::onGetConfigFromCompressedBackendFormat(const GrBackendFormat& f) const {
|
|
||||||
|
|
||||||
switch (GrBackendFormatAsMTLPixelFormat(f)) {
|
|
||||||
#ifdef SK_BUILD_FOR_IOS
|
|
||||||
case MTLPixelFormatETC2_RGB8: return kRGB_ETC1_GrPixelConfig;
|
|
||||||
#else
|
|
||||||
case MTLPixelFormatBC1_RGBA: return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
#endif
|
|
||||||
default: return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkUNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrColorType GrMtlCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
|
GrColorType GrMtlCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
|
||||||
bool isAlphaChannel) const {
|
bool isAlphaChannel) const {
|
||||||
switch (GrBackendFormatAsMTLPixelFormat(format)) {
|
switch (GrBackendFormatAsMTLPixelFormat(format)) {
|
||||||
|
@ -31,11 +31,6 @@
|
|||||||
class GrMtlGpu;
|
class GrMtlGpu;
|
||||||
class GrSurface;
|
class GrSurface;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Metal texture format for the given GrPixelConfig
|
|
||||||
*/
|
|
||||||
bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a id<MTLTexture> to the MTLTexture pointed at by the const void*.
|
* Returns a id<MTLTexture> to the MTLTexture pointed at by the const void*.
|
||||||
*/
|
*/
|
||||||
|
@ -22,108 +22,6 @@
|
|||||||
|
|
||||||
#define PRINT_MSL 0 // print out the MSL code generated
|
#define PRINT_MSL 0 // print out the MSL code generated
|
||||||
|
|
||||||
bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) {
|
|
||||||
MTLPixelFormat dontCare;
|
|
||||||
if (!format) {
|
|
||||||
format = &dontCare;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (config) {
|
|
||||||
case kUnknown_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kRGBA_8888_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA8Unorm;
|
|
||||||
return true;
|
|
||||||
case kRGB_888_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA8Unorm;
|
|
||||||
return true;
|
|
||||||
case kRGB_888X_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA8Unorm;
|
|
||||||
return true;
|
|
||||||
case kRG_88_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRG8Unorm;
|
|
||||||
return true;
|
|
||||||
case kBGRA_8888_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatBGRA8Unorm;
|
|
||||||
return true;
|
|
||||||
case kSRGBA_8888_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA8Unorm_sRGB;
|
|
||||||
return true;
|
|
||||||
case kRGBA_1010102_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGB10A2Unorm;
|
|
||||||
return true;
|
|
||||||
case kRGB_565_GrPixelConfig:
|
|
||||||
#ifdef SK_BUILD_FOR_IOS
|
|
||||||
*format = MTLPixelFormatB5G6R5Unorm;
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
case kRGBA_4444_GrPixelConfig:
|
|
||||||
#ifdef SK_BUILD_FOR_IOS
|
|
||||||
*format = MTLPixelFormatABGR4Unorm;
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
case kAlpha_8_GrPixelConfig: // fall through
|
|
||||||
case kAlpha_8_as_Red_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatR8Unorm;
|
|
||||||
return true;
|
|
||||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatA8Unorm;
|
|
||||||
return true;
|
|
||||||
case kGray_8_GrPixelConfig: // fall through
|
|
||||||
case kGray_8_as_Red_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatR8Unorm;
|
|
||||||
return true;
|
|
||||||
case kGray_8_as_Lum_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kRGBA_half_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA16Float;
|
|
||||||
return true;
|
|
||||||
case kRGBA_half_Clamped_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA16Float;
|
|
||||||
return true;
|
|
||||||
case kAlpha_half_GrPixelConfig: // fall through
|
|
||||||
case kAlpha_half_as_Red_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatR16Float;
|
|
||||||
return true;
|
|
||||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kRGB_ETC1_GrPixelConfig:
|
|
||||||
#ifdef SK_BUILD_FOR_IOS
|
|
||||||
*format = MTLPixelFormatETC2_RGB8;
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
case kBC1_RGB8_UNORM_GrPixelConfig:
|
|
||||||
// Even Mac desktops only support the RGBA variant
|
|
||||||
return false;
|
|
||||||
case kBC1_RGBA8_UNORM_GrPixelConfig:
|
|
||||||
#ifdef SK_BUILD_FOR_IOS
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
*format = MTLPixelFormatBC1_RGBA;
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
case kAlpha_16_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatR16Unorm;
|
|
||||||
return true;
|
|
||||||
case kRG_1616_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRG16Unorm;
|
|
||||||
return true;
|
|
||||||
case kRGBA_16161616_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRGBA16Unorm;
|
|
||||||
return true;
|
|
||||||
case kRG_half_GrPixelConfig:
|
|
||||||
*format = MTLPixelFormatRG16Float;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
SK_ABORT("Unexpected config");
|
|
||||||
}
|
|
||||||
|
|
||||||
MTLTextureDescriptor* GrGetMTLTextureDescriptor(id<MTLTexture> mtlTexture) {
|
MTLTextureDescriptor* GrGetMTLTextureDescriptor(id<MTLTexture> mtlTexture) {
|
||||||
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];
|
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];
|
||||||
texDesc.textureType = mtlTexture.textureType;
|
texDesc.textureType = mtlTexture.textureType;
|
||||||
|
@ -1528,167 +1528,6 @@ bool GrVkCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GrPixelConfig validate_image_info(VkFormat format, GrColorType ct, bool hasYcbcrConversion) {
|
|
||||||
if (hasYcbcrConversion) {
|
|
||||||
if (GrVkFormatNeedsYcbcrSampler(format)) {
|
|
||||||
return kRGB_888X_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format may be undefined for external images, which are required to have YCbCr conversion.
|
|
||||||
if (VK_FORMAT_UNDEFINED == format) {
|
|
||||||
// We don't actually care what the color type or config are since we won't use those
|
|
||||||
// values for external textures. However, for read pixels we will draw to a non ycbcr
|
|
||||||
// texture of this config so we set RGBA here for that.
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VK_FORMAT_UNDEFINED == format) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ct) {
|
|
||||||
case GrColorType::kUnknown:
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_8:
|
|
||||||
if (VK_FORMAT_R8_UNORM == format) {
|
|
||||||
return kAlpha_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGR_565:
|
|
||||||
if (VK_FORMAT_R5G6B5_UNORM_PACK16 == format) {
|
|
||||||
return kRGB_565_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kABGR_4444:
|
|
||||||
if (VK_FORMAT_B4G4R4A4_UNORM_PACK16 == format ||
|
|
||||||
VK_FORMAT_R4G4B4A4_UNORM_PACK16 == format) {
|
|
||||||
return kRGBA_4444_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888:
|
|
||||||
if (VK_FORMAT_R8G8B8A8_UNORM == format) {
|
|
||||||
return kRGBA_8888_GrPixelConfig;
|
|
||||||
} else if (VK_FORMAT_BC1_RGBA_UNORM_BLOCK == format) {
|
|
||||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888_SRGB:
|
|
||||||
if (VK_FORMAT_R8G8B8A8_SRGB == format) {
|
|
||||||
return kSRGBA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGB_888x:
|
|
||||||
if (VK_FORMAT_R8G8B8_UNORM == format) {
|
|
||||||
return kRGB_888_GrPixelConfig;
|
|
||||||
} else if (VK_FORMAT_R8G8B8A8_UNORM == format) {
|
|
||||||
return kRGB_888X_GrPixelConfig;
|
|
||||||
} else if (VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK == format) {
|
|
||||||
return kRGB_ETC1_GrPixelConfig;
|
|
||||||
} else if (VK_FORMAT_BC1_RGB_UNORM_BLOCK == format) {
|
|
||||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_88:
|
|
||||||
if (VK_FORMAT_R8G8_UNORM == format) {
|
|
||||||
return kRG_88_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGRA_8888:
|
|
||||||
if (VK_FORMAT_B8G8R8A8_UNORM == format) {
|
|
||||||
return kBGRA_8888_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_1010102:
|
|
||||||
if (VK_FORMAT_A2B10G10R10_UNORM_PACK32 == format) {
|
|
||||||
return kRGBA_1010102_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kGray_8:
|
|
||||||
if (VK_FORMAT_R8_UNORM == format) {
|
|
||||||
return kGray_8_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_F16:
|
|
||||||
if (VK_FORMAT_R16_SFLOAT == format) {
|
|
||||||
return kAlpha_half_as_Red_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16:
|
|
||||||
if (VK_FORMAT_R16G16B16A16_SFLOAT == format) {
|
|
||||||
return kRGBA_half_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16_Clamped:
|
|
||||||
if (VK_FORMAT_R16G16B16A16_SFLOAT == format) {
|
|
||||||
return kRGBA_half_Clamped_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_16:
|
|
||||||
if (VK_FORMAT_R16_UNORM == format) {
|
|
||||||
return kAlpha_16_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_1616:
|
|
||||||
if (VK_FORMAT_R16G16_UNORM == format) {
|
|
||||||
return kRG_1616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_16161616:
|
|
||||||
if (VK_FORMAT_R16G16B16A16_UNORM == format) {
|
|
||||||
return kRGBA_16161616_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_F16:
|
|
||||||
if (VK_FORMAT_R16G16_SFLOAT == format) {
|
|
||||||
return kRG_half_GrPixelConfig;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// These have no equivalent:
|
|
||||||
case GrColorType::kRGBA_F32:
|
|
||||||
case GrColorType::kAlpha_8xxx:
|
|
||||||
case GrColorType::kAlpha_F32xxx:
|
|
||||||
case GrColorType::kGray_8xxx:
|
|
||||||
case GrColorType::kRGB_888:
|
|
||||||
case GrColorType::kR_8:
|
|
||||||
case GrColorType::kR_16:
|
|
||||||
case GrColorType::kR_F16:
|
|
||||||
case GrColorType::kGray_F16:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig GrVkCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
|
||||||
GrColorType ct) const {
|
|
||||||
VkFormat vkFormat;
|
|
||||||
if (!format.asVkFormat(&vkFormat)) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
const GrVkYcbcrConversionInfo* ycbcrInfo = format.getVkYcbcrConversionInfo();
|
|
||||||
SkASSERT(ycbcrInfo);
|
|
||||||
return validate_image_info(vkFormat, ct, ycbcrInfo->isValid());
|
|
||||||
}
|
|
||||||
|
|
||||||
GrPixelConfig GrVkCaps::onGetConfigFromCompressedBackendFormat(const GrBackendFormat& f) const {
|
|
||||||
VkFormat vkFormat;
|
|
||||||
if (!f.asVkFormat(&vkFormat)) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vkFormat == VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK) {
|
|
||||||
return kRGB_ETC1_GrPixelConfig;
|
|
||||||
} else if (vkFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) {
|
|
||||||
return kBC1_RGB8_UNORM_GrPixelConfig;
|
|
||||||
} else if (vkFormat == VK_FORMAT_BC1_RGBA_UNORM_BLOCK) {
|
|
||||||
return kBC1_RGBA8_UNORM_GrPixelConfig;
|
|
||||||
}
|
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrColorType GrVkCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
|
GrColorType GrVkCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
|
||||||
bool isAlphaChannel) const {
|
bool isAlphaChannel) const {
|
||||||
VkFormat vkFormat;
|
VkFormat vkFormat;
|
||||||
|
@ -226,9 +226,6 @@ private:
|
|||||||
const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
|
const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
|
||||||
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
GrBackendFormat onGetDefaultBackendFormat(GrColorType, GrRenderable) const override;
|
||||||
|
|
||||||
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override;
|
|
||||||
GrPixelConfig onGetConfigFromCompressedBackendFormat(const GrBackendFormat&) const override;
|
|
||||||
|
|
||||||
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override;
|
||||||
|
|
||||||
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
|
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat&,
|
||||||
|
Loading…
Reference in New Issue
Block a user