Bug 1324604 - Only query IMPLEMENTATION_COLOR_READ_FORMAT/TYPE on actual GLES. - r=daoshengmu
MozReview-Commit-ID: 3KFbKZremf2
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -1462,17 +1462,17 @@ ValidateReadPixelsFormatAndType(const we
}
if (pi.type == LOCAL_GL_UNSIGNED_INT_24_8) {
webgl->ErrorInvalidEnum("readPixels: Invalid type: 0x%04x", pi.type);
return false;
}
MOZ_ASSERT(gl->IsCurrent());
- if (gl->IsSupported(gl::GLFeature::ES2_compatibility)) {
+ if (gl->IsGLES()) {
const auto auxFormat = gl->GetIntAs<GLenum>(LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT);
const auto auxType = gl->GetIntAs<GLenum>(LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE);
if (auxFormat && auxType &&
pi.format == auxFormat && pi.type == auxType)
{
return true;
}
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -397,32 +397,37 @@ WebGLContext::GetParameter(JSContext* cx
case LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE: {
const webgl::FormatUsageInfo* usage;
uint32_t width, height;
if (!ValidateCurFBForRead(funcName, &usage, &width, &height))
return JS::NullValue();
GLint i = 0;
- if (gl->IsSupported(gl::GLFeature::ES2_compatibility)) {
+ if (gl->IsGLES()) {
+ // ES2_compatibility always returns UNSIGNED_BYTE here, so
+ // branch on actual IsGLES().
+ // Also OSX+NV generates an error here.
gl->fGetIntegerv(pname, &i);
} else {
i = LOCAL_GL_UNSIGNED_BYTE;
}
-
return JS::NumberValue(uint32_t(i));
}
case LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT: {
const webgl::FormatUsageInfo* usage;
uint32_t width, height;
if (!ValidateCurFBForRead(funcName, &usage, &width, &height))
return JS::NullValue();
GLint i = 0;
- if (gl->IsSupported(gl::GLFeature::ES2_compatibility)) {
+ if (gl->IsGLES()) {
+ // ES2_compatibility always returns UNSIGNED_BYTE here, so
+ // branch on actual IsGLES().
+ // Also OSX+NV generates an error here.
gl->fGetIntegerv(pname, &i);
} else {
i = LOCAL_GL_RGBA;
}
// OpenGL ES 3.0.4 p112 Table 3.2 shows that read format SRGB_ALPHA is
// not supported. And if internal format of fbo is SRGB8_ALPHA8, then
// IMPLEMENTATION_COLOR_READ_FORMAT is SRGB_ALPHA which is not supported