Bug 943596 - The shader editor highlighting acts weirdly when there's a custom framebuffer attachment on the default renderbuffer, r=rcampbell
authorVictor Porof <vporof@mozilla.com>
Wed, 27 Nov 2013 09:08:52 +0200
changeset 157670 b9250086cf18f4aa70e58aa1c3013dee63c671cc
parent 157669 9f446888b2d2318bde2761089bfc4a01a1c811c6
child 157671 a92a5ed04e6ab0b6fc91106de56eda14c288a372
push id3694
push uservporof@mozilla.com
push dateWed, 27 Nov 2013 07:38:03 +0000
treeherderfx-team@b9250086cf18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell
bugs943596
milestone28.0a1
Bug 943596 - The shader editor highlighting acts weirdly when there's a custom framebuffer attachment on the default renderbuffer, r=rcampbell
toolkit/devtools/server/actors/webgl.js
--- a/toolkit/devtools/server/actors/webgl.js
+++ b/toolkit/devtools/server/actors/webgl.js
@@ -1175,27 +1175,30 @@ WebGLProxy.prototype = {
     let gl = this._gl;
     return gl.getRenderbufferParameter(gl.RENDERBUFFER, gl[name]);
   },
 
   /**
    * Returns the framebuffer property value for the specified WebGL parameter.
    * If no framebuffer binding is available, null is returned.
    *
+   * @param string type
+   *        The framebuffer object attachment point, for example "COLOR_ATTACHMENT0".
    * @param string name
-   *        The WebGL parameter name, for example "BLEND_COLOR".
+   *        The WebGL parameter name, for example "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME".
+   *        If unspecified, defaults to "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE".
    * @return any
    *         The corresponding parameter's value.
    */
-  _getFramebufferAttachmentParameter: function(type, name) {
+  _getFramebufferAttachmentParameter: function(type, name = "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE") {
     if (!this._getParameter("FRAMEBUFFER_BINDING")) {
       return null;
     }
     let gl = this._gl;
-    return gl.getFramebufferAttachmentParameter(gl.RENDERBUFFER, gl[type], gl[name]);
+    return gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl[type], gl[name]);
   },
 
   /**
    * Returns the shader objects attached to a program object.
    *
    * @param WebGLProgram program
    *        The program for which to retrieve the attached shaders.
    * @return array
@@ -1276,19 +1279,29 @@ WebGLProxy.prototype = {
   },
 
   /**
    * Enables color blending based on the geometry highlight tint.
    */
   _enableHighlighting: function() {
     let gl = this._gl;
 
-    // Avoid changing the blending params when rendering to a depth texture.
-    let format = this._getRenderbufferParameter("RENDERBUFFER_INTERNAL_FORMAT");
-    if (format == gl.DEPTH_COMPONENT16) {
+    // Avoid changing the blending params when "rendering to texture".
+
+    // Check drawing to a custom framebuffer bound to the default renderbuffer.
+    let hasFramebuffer = this._getParameter("FRAMEBUFFER_BINDING");
+    let hasRenderbuffer = this._getParameter("RENDERBUFFER_BINDING");
+    if (hasFramebuffer && !hasRenderbuffer) {
+      return;
+    }
+
+    // Check drawing to a depth or stencil component of the framebuffer.
+    let writesDepth = this._getFramebufferAttachmentParameter("DEPTH_ATTACHMENT");
+    let writesStencil = this._getFramebufferAttachmentParameter("STENCIL_ATTACHMENT");
+    if (writesDepth || writesStencil) {
       return;
     }
 
     // Non-premultiplied alpha blending based on a predefined constant color.
     // Simply using gl.colorMask won't work, because we want non-tinted colors
     // to be drawn as black, not ignored.
     gl.enable(gl.BLEND);
     gl.blendColor.apply(gl, this.highlightTint);