Index: src/gpu/gl/GrGLCaps.h |
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h |
index db60ad273a3c98c396e92138f8cc6d165904066e..e9fe6b6e7106f87fb099c1a483271c258056c1a5 100644 |
--- a/src/gpu/gl/GrGLCaps.h |
+++ b/src/gpu/gl/GrGLCaps.h |
@@ -29,24 +29,6 @@ class GrGLCaps : public GrCaps { |
public: |
typedef GrGLStencilAttachment::Format StencilFormat; |
- /** Provides information about the mappiing from GrPixelConfig to GL formats. */ |
- struct ConfigFormats { |
- ConfigFormats() { |
- // Inits to known bad GL enum values. |
- memset(this, 0xAB, sizeof(ConfigFormats)); |
- } |
- GrGLenum fBaseInternalFormat; |
- GrGLenum fSizedInternalFormat; |
- GrGLenum fExternalFormat; |
- GrGLenum fExternalType; |
- |
- // The <format> parameter to use for glTexImage and glTexSubImage. |
- // This is usually the same as fExternalFormat except for kSRGBA on some GL contexts. |
- GrGLenum fExternalFormatForTexImage; |
- // Either the base or sized internal format depending on the GL and config. |
- GrGLenum fInternalFormatTexImage; |
- }; |
- |
/** |
* The type of MSAA for FBOs supported. Different extensions have different |
* semantics of how / when a resolve is performed. |
@@ -138,16 +120,22 @@ public: |
} |
} |
- /** Returns conversions to various GL format parameters for a GrPixelCfonig. */ |
- const ConfigFormats& configGLFormats(GrPixelConfig config) const { |
- return fConfigTable[config].fFormats; |
- } |
- |
/** Returns the mapping between GrPixelConfig components and GL internal format components. */ |
const GrSwizzle& configSwizzle(GrPixelConfig config) const { |
return fConfigTable[config].fSwizzle; |
} |
+ bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, |
+ GrGLenum* internalFormat, GrGLenum* externalFormat, |
+ GrGLenum* externalType) const; |
+ |
+ bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const; |
+ |
+ bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, |
+ GrGLenum* externalFormat, GrGLenum* externalType) const; |
+ |
+ bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const; |
+ |
/** |
* 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 |
@@ -290,14 +278,10 @@ public: |
bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } |
/// Can we call glDisable(GL_MULTISAMPLE)? |
- bool multisampleDisableSupport() const { |
- return fMultisampleDisableSupport; |
- } |
+ bool multisampleDisableSupport() const { return fMultisampleDisableSupport; } |
/// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. |
- bool useNonVBOVertexAndIndexDynamicData() const { |
- return fUseNonVBOVertexAndIndexDynamicData; |
- } |
+ bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; } |
/// Does ReadPixels support the provided format/type combo? |
bool readPixelsSupported(const GrGLInterface* intf, |
@@ -334,6 +318,17 @@ public: |
const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); } |
private: |
+ enum ExternalFormatUsage { |
+ kTexImage_ExternalFormatUsage, |
+ kOther_ExternalFormatUsage, |
+ |
+ kLast_ExternalFormatUsage = kOther_ExternalFormatUsage |
+ }; |
+ static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1; |
+ bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig, |
+ ExternalFormatUsage usage, GrGLenum* externalFormat, |
+ GrGLenum* externalType) const; |
+ |
void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*); |
void initGLSL(const GrGLContextInfo&); |
bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); |
@@ -396,13 +391,36 @@ private: |
GrGLenum fType; |
}; |
+ struct ConfigFormats { |
+ ConfigFormats() { |
+ // Inits to known bad GL enum values. |
+ memset(this, 0xAB, sizeof(ConfigFormats)); |
+ } |
+ GrGLenum fBaseInternalFormat; |
+ GrGLenum fSizedInternalFormat; |
+ |
+ /** The external format and type are to be used when uploading/downloading data using this |
+ config where both the CPU data and GrSurface are the same config. To get the external |
+ format and type when converting between configs while copying to/from memory use |
+ getExternalFormat(). |
+ The kTexImage external format is usually the same as kOther except for kSRGBA on some |
+ GL contexts. */ |
+ GrGLenum fExternalFormat[kExternalFormatUsageCnt]; |
+ GrGLenum fExternalType; |
+ |
+ |
+ // Either the base or sized internal format depending on the GL and config. |
+ GrGLenum fInternalFormatTexImage; |
+ GrGLenum fInternalFormatRenderbuffer; |
+ }; |
+ |
struct ConfigInfo { |
ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {} |
- ConfigFormats fFormats; |
- |
FormatType fFormatType; |
+ ConfigFormats fFormats; |
+ |
// On ES contexts there are restrictions on type type/format that may be used for |
// ReadPixels. One is implicitly specified by the current FBO's format. The other is |
// queryable. This stores the queried option (lazily). |