From 9e9ea910924c7a6830527c40fb6f34240c094a09 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 10 Jul 2019 15:34:37 -0400 Subject: [PATCH] Try GrGLSizedInternalFormat enum Change-Id: I970fe3547caf4fa363f20aa8246b293a19c4ba8c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226225 Commit-Queue: Brian Salomon Reviewed-by: Greg Daniel --- include/private/GrGLTypesPriv.h | 33 ++++++++ src/gpu/gl/GrGLCaps.cpp | 140 +++++++------------------------- src/gpu/gl/GrGLCaps.h | 30 +++---- src/gpu/gl/GrGLUtil.cpp | 30 ------- src/gpu/gl/GrGLUtil.h | 38 ++++++++- 5 files changed, 114 insertions(+), 157 deletions(-) diff --git a/include/private/GrGLTypesPriv.h b/include/private/GrGLTypesPriv.h index 2562e5483d..3a672e1df9 100644 --- a/include/private/GrGLTypesPriv.h +++ b/include/private/GrGLTypesPriv.h @@ -11,6 +11,39 @@ #ifndef GrGLTypesPriv_DEFINED #define GrGLTypesPriv_DEFINED +// These are the GL sized internal formats we support as an enum. Naming convention is the GL +// name with "k" substituted for the initial "GL_". +enum class GrGLSizedInternalFormat { + kUnknown, + + kRGBA8, + kR8, + kALPHA8, + kLUMINANCE8, + kBGRA8, + kRGB565, + kRGBA16F, + kR16F, + kRGB8, + kRG8, + kRGB10_A2, + kRGBA4, + kRGBA32F, + kRG32F, + kSRGB8_ALPHA8, + kCOMPRESSED_RGB8_ETC2, + kCOMPRESSED_ETC1_RGB8, + kR16, + kRG16, + kRGBA16, + kRG16F, + + kLast = kRG16F +}; + +static constexpr int kGrGLSizedInternalFormatCount = + static_cast(GrGLSizedInternalFormat::kLast) + 1; + class GrGLTextureParameters : public SkNVRefCnt { public: // We currently consider texture parameters invalid on all textures diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 72425aac77..ad5741862d 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -1374,53 +1374,6 @@ bool GrGLCaps::getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memo return true; } -const GrGLCaps::FormatInfo& GrGLCaps::getFormatInfo(GrGLenum glFormat) const { - GrGLCaps* nonConstThis = const_cast(this); - return nonConstThis->getFormatInfo(glFormat); -} - -GrGLCaps::FormatInfo& GrGLCaps::getFormatInfo(GrGLenum glFormat) { - // These are all the valid sized formats that we support in Skia. They are roughly ordered from - // most frequently used to least to improve look up times in arrays. - static constexpr GrGLenum kGLFormats[] = { - GR_GL_RGBA8, - GR_GL_R8, - GR_GL_ALPHA8, - GR_GL_LUMINANCE8, - GR_GL_BGRA8, - GR_GL_RGB565, - GR_GL_RGBA16F, - GR_GL_R16F, - GR_GL_RGB8, - GR_GL_RG8, - GR_GL_RGB10_A2, - GR_GL_RGBA4, - GR_GL_RGBA32F, - GR_GL_RG32F, - GR_GL_SRGB8_ALPHA8, - GR_GL_COMPRESSED_RGB8_ETC2, - GR_GL_COMPRESSED_ETC1_RGB8, - GR_GL_R16, - GR_GL_RG16, - // Experimental (for Y416 and mutant P016/P010) - GR_GL_RGBA16, - GR_GL_RG16F, - }; - static_assert(SK_ARRAY_COUNT(kGLFormats) == GrGLCaps::kNumGLFormats, - "Size of GLFormats array must match static value in header"); - - SkASSERT(GrGLFormatIsSupported(glFormat)); - - for (size_t i = 0; i < SK_ARRAY_COUNT(kGLFormats); ++i) { - if (kGLFormats[i] == glFormat) { - return fFormatTable[i]; - } - } - SK_ABORT("Invalid GL format"); - static FormatInfo kInvalidFormat; - return kInvalidFormat; -} - void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, const GrGLInterface* gli, const FormatWorkarounds& formatWorkarounds) { @@ -1551,7 +1504,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGBA8 { - FormatInfo& info = this->getFormatInfo(GR_GL_RGBA8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA8); info.fFlags = FormatInfo::kTextureable_Flag; if (GR_IS_GR_GL(standard)) { info.fFlags |= msaaRenderFlags; @@ -1587,7 +1540,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // R8 { - FormatInfo& info = this->getFormatInfo(GR_GL_R8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kR8); if (textureRedSupport) { info.fFlags |= FormatInfo::kTextureable_Flag | msaaRenderFlags; } @@ -1618,7 +1571,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, bool alpha8IsValidForGLES = GR_IS_GR_GL_ES(standard) && version < GR_GL_VER(3, 0); bool alpha8IsValidForWebGL = GR_IS_GR_WEBGL(standard); - FormatInfo& info = this->getFormatInfo(GR_GL_ALPHA8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kALPHA8); if (alpha8IsValidForGL || alpha8IsValidForGLES || alpha8IsValidForWebGL) { info.fFlags = FormatInfo::kTextureable_Flag; } @@ -1644,7 +1597,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // LUMINANCE8 { - FormatInfo& info = this->getFormatInfo(GR_GL_LUMINANCE8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kLUMINANCE8); bool supportsLum = (GR_IS_GR_GL(standard) && version <= GR_GL_VER(3, 0)) || (GR_IS_GR_GL_ES(standard) && version < GR_GL_VER(3, 0)) || (GR_IS_GR_WEBGL(standard)); @@ -1677,7 +1630,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // BGRA8 { - FormatInfo& info = this->getFormatInfo(GR_GL_BGRA8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kBGRA8); // TexStorage requires using a sized internal format and BGRA8 is only supported if we have // the GL_APPLE_texture_format_BGRA8888 extension or if we have GL_EXT_texture_storage and // GL_EXT_texture_format_BGRA8888. @@ -1724,7 +1677,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGB565 { - FormatInfo& info = this->getFormatInfo(GR_GL_RGB565); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGB565); info.fFlags = FormatInfo::kTextureable_Flag; if (GR_IS_GR_GL(standard)) { if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { @@ -1755,7 +1708,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGBA16F { - FormatInfo& info = this->getFormatInfo(GR_GL_RGBA16F); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA16F); if (hasFP16Textures) { info.fFlags = FormatInfo::kTextureable_Flag; // ES requires 3.2 or EXT_color_buffer_half_float. @@ -1785,7 +1738,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // R16F { - FormatInfo& info = this->getFormatInfo(GR_GL_R16F); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kR16F); if (textureRedSupport && hasFP16Textures) { info.fFlags = FormatInfo::kTextureable_Flag; if (halfFPRenderTargetSupport == HalfFPRenderTargetSupport::kAll) { @@ -1808,7 +1761,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGB8 { - FormatInfo& info = this->getFormatInfo(GR_GL_RGB8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGB8); info.fFlags = FormatInfo::kTextureable_Flag; if (GR_IS_GR_GL(standard)) { // Even in OpenGL 4.6 GL_RGB8 is required to be color renderable but not required to be @@ -1844,7 +1797,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RG8 { - FormatInfo& info = this->getFormatInfo(GR_GL_RG8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRG8); if (textureRedSupport) { info.fFlags |= FormatInfo::kTextureable_Flag | msaaRenderFlags; if (texStorageSupported && @@ -1864,7 +1817,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGB10_A2 { - FormatInfo& info = this->getFormatInfo(GR_GL_RGB10_A2); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGB10_A2); if (GR_IS_GR_GL(standard) || (GR_IS_GR_GL_ES(standard) && version >= GR_GL_VER(3, 0))) { info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags; @@ -1887,7 +1840,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGBA4 { - FormatInfo& info = this->getFormatInfo(GR_GL_RGBA4); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA4); info.fFlags = FormatInfo::kTextureable_Flag; if (GR_IS_GR_GL(standard)) { if (version >= GR_GL_VER(4, 2)) { @@ -1911,13 +1864,13 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // RGBA32F { - //FormatInfo& info = this->getFormatInfo(GR_GL_RGBA32F); + // FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA32F); // We don't allow texturing or rendering to this format } // SRGB8_ALPHA8 { - FormatInfo& info = this->getFormatInfo(GR_GL_SRGB8_ALPHA8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kSRGB8_ALPHA8); if (fSRGBSupport) { uint32_t srgbRenderFlags = formatWorkarounds.fDisableSRGBRenderWithMSAAForMacAMD ? nonMSAARenderFlags @@ -1941,7 +1894,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // COMPRESSED_RGB8_ETC2 { - FormatInfo& info = this->getFormatInfo(GR_GL_COMPRESSED_RGB8_ETC2); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kCOMPRESSED_RGB8_ETC2); if (GR_IS_GR_GL(standard)) { if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compatibility")) { info.fFlags = FormatInfo::kTextureable_Flag; @@ -1958,7 +1911,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // COMPRESSED_ETC1_RGB8 { - FormatInfo& info = this->getFormatInfo(GR_GL_COMPRESSED_ETC1_RGB8); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kCOMPRESSED_ETC1_RGB8); if (GR_IS_GR_GL_ES(standard)) { if (ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture")) { info.fFlags = FormatInfo::kTextureable_Flag; @@ -1970,7 +1923,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // GR_GL_R16 { - FormatInfo& info = this->getFormatInfo(GR_GL_R16); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kR16); if (r16AndRG1616Supported) { info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags; } @@ -1986,7 +1939,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, // GR_GL_RG16 { - FormatInfo& info = this->getFormatInfo(GR_GL_RG16); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRG16); if (r16AndRG1616Supported) { info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags; } @@ -2021,7 +1974,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, } } // No WebGL support - FormatInfo& info = this->getFormatInfo(GR_GL_RGBA16); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA16); if (rgba16161616Supported) { info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags; } @@ -2060,7 +2013,7 @@ void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions, } } - FormatInfo& info = this->getFormatInfo(GR_GL_RG16F); + FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRG16F); if (rg16fTexturesSupported) { info.fFlags |= FormatInfo::kTextureable_Flag; } @@ -3582,30 +3535,12 @@ bool GrGLCaps::onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget& b return fbInfo.fFBOID != 0; } -static bool format_is_srgb(GrGLenum format) { - SkASSERT(GrGLFormatIsSupported(format)); - - switch (format) { - case GR_GL_SRGB8_ALPHA8: - return true; - default: - return false; - } -} - bool GrGLCaps::isFormatSRGB(const GrBackendFormat& format) const { - if (!format.getGLFormat()) { - return false; - } - - return format_is_srgb(*format.getGLFormat()); + return GrGLBackendFormatToSizedInternalFormat(format) == GrGLSizedInternalFormat::kSRGB8_ALPHA8; } -bool GrGLCaps::isGLFormatTexturable(GrColorType ct, GrGLenum glFormat) const { - if (!GrGLFormatIsSupported(glFormat)) { - return false; - } - const FormatInfo& info = this->getFormatInfo(glFormat); +bool GrGLCaps::isFormatTexturable(GrColorType ct, GrGLSizedInternalFormat format) const { + const FormatInfo& info = this->getFormatInfo(format); // Currently we conflate texturable to mean the format itself is texturable in a draw and that // we are able to upload data of the passed in colortype to it. return SkToBool(info.fFlags & FormatInfo::kTextureable_Flag) && @@ -3613,11 +3548,7 @@ bool GrGLCaps::isGLFormatTexturable(GrColorType ct, GrGLenum glFormat) const { } bool GrGLCaps::isFormatTexturable(GrColorType ct, const GrBackendFormat& format) const { - const GrGLenum* glFormat = format.getGLFormat(); - if (!glFormat) { - return false; - } - return this->isGLFormatTexturable(ct, *glFormat); + return this->isFormatTexturable(ct, GrGLBackendFormatToSizedInternalFormat(format)); } int GrGLCaps::getRenderTargetSampleCount(int requestedCount, GrColorType grCT, @@ -3682,31 +3613,20 @@ int GrGLCaps::maxRenderTargetSampleCount(GrPixelConfig config) const { return count; } -bool GrGLCaps::canGLFormatBeFBOColorAttachment(GrGLenum glFormat) const { - if (!GrGLFormatIsSupported(glFormat)) { - return false; - } - return SkToBool(this->getFormatInfo(glFormat).fFlags & FormatInfo::kFBOColorAttachment_Flag); +bool GrGLCaps::canFormatBeFBOColorAttachment(GrGLSizedInternalFormat format) const { + return SkToBool(this->getFormatInfo(format).fFlags & FormatInfo::kFBOColorAttachment_Flag); } -bool GrGLCaps::isFormatCopyable(GrColorType, const GrBackendFormat& format) const { - const GrGLenum* glFormat = format.getGLFormat(); - if (!glFormat || !GrGLFormatIsSupported(*glFormat)) { - return false; - } +bool GrGLCaps::isFormatCopyable(GrColorType ct, const GrBackendFormat& format) const { // In GL we have three ways to be able to copy. CopyTexImage, blit, and draw. CopyTexImage // requires the src to be an FBO attachment, blit requires both src and dst to be FBO // attachments, and draw requires the dst to be an FBO attachment. Thus to copy from and to // the same config, we need that config to be bindable to an FBO. - return this->canGLFormatBeFBOColorAttachment(*glFormat); + return this->canFormatBeFBOColorAttachment(GrGLBackendFormatToSizedInternalFormat(format)); } -bool GrGLCaps::glFormatSupportsTexStorage(GrGLenum glFormat) const { - if (!GrGLFormatIsSupported(glFormat)) { - return false; - } - - return SkToBool(this->getFormatInfo(glFormat).fFlags & FormatInfo::kCanUseTexStorage_Flag); +bool GrGLCaps::formatSupportsTexStorage(GrGLSizedInternalFormat format) const { + return SkToBool(this->getFormatInfo(format).fFlags & FormatInfo::kCanUseTexStorage_Flag); } // A near clone of format_color_type_valid_pair diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 91b01d1017..18fed86542 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -10,12 +10,14 @@ #define GrGLCaps_DEFINED #include +#include "include/private/GrGLTypesPriv.h" #include "include/private/SkChecksum.h" #include "include/private/SkTArray.h" #include "include/private/SkTHash.h" #include "src/gpu/GrCaps.h" #include "src/gpu/GrSwizzle.h" #include "src/gpu/gl/GrGLStencilAttachment.h" +#include "src/gpu/gl/GrGLUtil.h" class GrGLContextInfo; class GrGLRenderTarget; @@ -113,7 +115,7 @@ public: bool isConfigTexturable(GrPixelConfig config) const override { GrGLenum glFormat = this->configSizedInternalFormat(config); GrColorType ct = GrPixelConfigToColorType(config); - return this->isGLFormatTexturable(ct, glFormat); + return this->isFormatTexturable(ct, GrGLSizedInternalFormatFromGLenum(glFormat)); } int getRenderTargetSampleCount(int requestedCount, @@ -132,14 +134,14 @@ public: return this->canConfigBeFBOColorAttachment(config); } - bool canGLFormatBeFBOColorAttachment(GrGLenum glFormat) const; + bool canFormatBeFBOColorAttachment(GrGLSizedInternalFormat) const; bool canConfigBeFBOColorAttachment(GrPixelConfig config) const { GrGLenum format = this->configSizedInternalFormat(config); if (!format) { return false; } - return this->canGLFormatBeFBOColorAttachment(format); + return this->canFormatBeFBOColorAttachment(GrGLSizedInternalFormatFromGLenum(format)); } bool configSupportsTexStorage(GrPixelConfig config) const { @@ -147,7 +149,7 @@ public: if (!format) { return false; } - return this->glFormatSupportsTexStorage(format); + return this->formatSupportsTexStorage(GrGLSizedInternalFormatFromGLenum(format)); } GrGLenum configSizedInternalFormat(GrPixelConfig config) const { @@ -167,11 +169,6 @@ public: void getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const; void getSizedInternalFormat(GrPixelConfig config, GrGLenum* internalFormat) const; - /** The format to use read/write a texture as an image in a shader */ - GrGLenum getImageFormat(GrPixelConfig config) const { - return fConfigTable[config].fFormats.fSizedInternalFormat; - } - /** * Gets an array of legal stencil formats. These formats are not guaranteed * to be supported by the driver but are legal GLenum names given the GL @@ -483,8 +480,8 @@ private: GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat&, GrColorType) const override; bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const override; - bool isGLFormatTexturable(GrColorType, GrGLenum glFormat) const; - bool glFormatSupportsTexStorage(GrGLenum glFormat) const; + bool isFormatTexturable(GrColorType, GrGLSizedInternalFormat) const; + bool formatSupportsTexStorage(GrGLSizedInternalFormat) const; GrGLStandard fStandard; @@ -649,11 +646,14 @@ private: SkSTArray<1, ColorTypeInfo> fColorTypeInfos; }; - static const size_t kNumGLFormats = 21; - FormatInfo fFormatTable[kNumGLFormats]; + FormatInfo fFormatTable[kGrGLSizedInternalFormatCount]; - FormatInfo& getFormatInfo(GrGLenum glFormat); - const FormatInfo& getFormatInfo(GrGLenum glFormat) const; + FormatInfo& getFormatInfo(GrGLSizedInternalFormat format) { + return fFormatTable[static_cast(format)]; + } + const FormatInfo& getFormatInfo(GrGLSizedInternalFormat format) const { + return fFormatTable[static_cast(format)]; + } typedef GrCaps INHERITED; }; diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index 0efeac67cd..9bd95b15eb 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -660,33 +660,3 @@ size_t GrGLBytesPerFormat(GrGLenum glFormat) { SK_ABORT("Invalid GL format"); return 0; } - -bool GrGLFormatIsSupported(GrGLenum format) { - switch (format) { - case GR_GL_LUMINANCE8: - case GR_GL_ALPHA8: - case GR_GL_R8: - case GR_GL_RGB565: - case GR_GL_RGBA4: - case GR_GL_RG8: - case GR_GL_R16F: - case GR_GL_R16: - case GR_GL_RGB8: - case GR_GL_RGBA8: - case GR_GL_SRGB8_ALPHA8: - case GR_GL_BGRA8: - case GR_GL_RGB10_A2: - case GR_GL_RG16: - case GR_GL_RGBA16F: - case GR_GL_RG32F: - case GR_GL_RGBA32F: - case GR_GL_COMPRESSED_RGB8_ETC2: - case GR_GL_COMPRESSED_ETC1_RGB8: - // Experimental (for Y416 and mutant P016/P010) - case GR_GL_RG16F: - case GR_GL_RGBA16: - return true; - default: - return false; - } -} diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 967077653a..d1494a8e1a 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -274,6 +274,42 @@ void GrGLClearErr(const GrGLInterface* gl); // call glGetError without doing a redundant error check or logging. #define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError() +static constexpr GrGLSizedInternalFormat GrGLSizedInternalFormatFromGLenum(GrGLenum glFormat) { + switch (glFormat) { + case GR_GL_RGBA8: return GrGLSizedInternalFormat::kRGBA8; + case GR_GL_R8: return GrGLSizedInternalFormat::kR8; + case GR_GL_ALPHA8: return GrGLSizedInternalFormat::kALPHA8; + case GR_GL_LUMINANCE8: return GrGLSizedInternalFormat::kLUMINANCE8; + case GR_GL_BGRA8: return GrGLSizedInternalFormat::kBGRA8; + case GR_GL_RGB565: return GrGLSizedInternalFormat::kRGB565; + case GR_GL_RGBA16F: return GrGLSizedInternalFormat::kRGBA16F; + case GR_GL_R16F: return GrGLSizedInternalFormat::kR16F; + case GR_GL_RGB8: return GrGLSizedInternalFormat::kRGB8; + case GR_GL_RG8: return GrGLSizedInternalFormat::kRG8; + case GR_GL_RGB10_A2: return GrGLSizedInternalFormat::kRGB10_A2; + case GR_GL_RGBA4: return GrGLSizedInternalFormat::kRGBA4; + case GR_GL_RGBA32F: return GrGLSizedInternalFormat::kRGBA32F; + case GR_GL_RG32F: return GrGLSizedInternalFormat::kRG32F; + case GR_GL_SRGB8_ALPHA8: return GrGLSizedInternalFormat::kSRGB8_ALPHA8; + case GR_GL_COMPRESSED_RGB8_ETC2: return GrGLSizedInternalFormat::kCOMPRESSED_RGB8_ETC2; + case GR_GL_COMPRESSED_ETC1_RGB8: return GrGLSizedInternalFormat::kCOMPRESSED_ETC1_RGB8; + case GR_GL_R16: return GrGLSizedInternalFormat::kR16; + case GR_GL_RG16: return GrGLSizedInternalFormat::kRG16; + case GR_GL_RGBA16: return GrGLSizedInternalFormat::kRGBA16; + case GR_GL_RG16F: return GrGLSizedInternalFormat::kRG16F; + + default: return GrGLSizedInternalFormat::kUnknown; + } +} + +static inline GrGLSizedInternalFormat GrGLBackendFormatToSizedInternalFormat( + const GrBackendFormat& format) { + if (const GrGLenum* glFormat = format.getGLFormat()) { + return GrGLSizedInternalFormatFromGLenum(*glFormat); + } + return GrGLSizedInternalFormat::kUnknown; +} + GrGLenum GrToGLStencilFunc(GrStencilTest test); /** @@ -288,6 +324,4 @@ bool GrGLFormatToCompressionType(GrGLenum glFormat, SkImage::CompressionType*); size_t GrGLBytesPerFormat(GrGLenum glFormat); -bool GrGLFormatIsSupported(GrGLenum format); - #endif