aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-27 19:31:41 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-27 19:31:41 +0000
commit1d89c93b2a61a9679f444b19b6fce4325ae7df65 (patch)
tree9a64e0e4786926e85b6e3a1a73058f0e003dc43e /src/gpu/gl
parent7f581a97288ee6802d3c4f47a292def1712425b4 (diff)
Added ReadPixels format-supported check to GL Caps
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp37
-rw-r--r--src/gpu/gl/GrGLCaps.h6
2 files changed, 43 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index ec125b7712..125e387fb0 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -35,6 +35,7 @@ void GrGLCaps::reset() {
fTexStorageSupport = false;
fTextureRedSupport = false;
fImagingSupport = false;
+ fTwoFormatLimit = false;
}
GrGLCaps::GrGLCaps(const GrGLCaps& caps) {
@@ -63,6 +64,7 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
fTexStorageSupport = caps.fTexStorageSupport;
fTextureRedSupport = caps.fTextureRedSupport;
fImagingSupport = caps.fImagingSupport;
+ fTwoFormatLimit = caps.fTwoFormatLimit;
return *this;
}
@@ -151,10 +153,44 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
fImagingSupport = kDesktop_GrGLBinding == binding &&
ctxInfo.hasExtension("GL_ARB_imaging");
+ // ES 2 only guarantees RGBA/uchar + one other format/type combo for
+ // ReadPixels. The other format has to checked at run-time since it
+ // can change based on which render target is bound
+ fTwoFormatLimit = kES2_GrGLBinding == binding;
+
this->initFSAASupport(ctxInfo);
this->initStencilFormats(ctxInfo);
}
+bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
+ GrGLenum format,
+ GrGLenum type) const {
+ if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
+ // ES 2 guarantees this format is supported
+ true;
+ }
+
+ if (!fTwoFormatLimit) {
+ // not limited by ES 2's constraints
+ return true;
+ }
+
+ int otherFormat = GR_GL_RGBA;
+ int otherType = GR_GL_UNSIGNED_BYTE;
+
+ // The other supported format/type combo supported for ReadPixels
+ // can change based on which render target is bound
+ GR_GL_GetIntegerv(intf,
+ GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
+ &otherFormat);
+
+ GR_GL_GetIntegerv(intf,
+ GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
+ &otherType);
+
+ return otherFormat == format && otherType == type;
+}
+
namespace {
int coverage_mode_compare(const GrGLCaps::MSAACoverageMode* left,
const GrGLCaps::MSAACoverageMode* right) {
@@ -378,5 +414,6 @@ void GrGLCaps::print() const {
(fPackRowLengthSupport ? "YES": "NO"));
GrPrintf("Pack Flip Y support: %s\n",
(fPackFlipYSupport ? "YES": "NO"));
+ GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
}
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index ec75a53428..322e7339f7 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -214,6 +214,11 @@ public:
/// Is GL_ARB_IMAGING supported
bool imagingSupport() const { return fImagingSupport; }
+ // Does ReadPixels support the provided format/type combo?
+ bool readPixelsSupported(const GrGLInterface* intf,
+ GrGLenum format,
+ GrGLenum type) const;
+
private:
/**
* Maintains a bit per GrPixelConfig. It is used to avoid redundantly
@@ -285,6 +290,7 @@ private:
bool fTexStorageSupport : 1;
bool fTextureRedSupport : 1;
bool fImagingSupport : 1;
+ bool fTwoFormatLimit : 1;
};
#endif