Bug 1324604 - Only query IMPLEMENTATION_COLOR_READ_FORMAT/TYPE on actual GLES. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 19 Dec 2016 16:37:52 -0800
changeset 451328 a0ff545b82efbb8685e9b3602ba4bbb404f6adb4
parent 451327 98c821c59547eac41ae7eea3686546561035bb77
child 451329 e3c96dfeca388e314f6dff7cb09319f02bece10d
child 451676 975dd10ebcd368b748e93fa629e88ee04cfba70c
push id39126
push userbmo:jgilbert@mozilla.com
push dateTue, 20 Dec 2016 03:59:36 +0000
reviewersdaoshengmu
bugs1324604
milestone53.0a1
Bug 1324604 - Only query IMPLEMENTATION_COLOR_READ_FORMAT/TYPE on actual GLES. - r=daoshengmu MozReview-Commit-ID: 3KFbKZremf2
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextState.cpp
--- 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