Bug 943596 - The shader editor highlighting acts weirdly when there's a custom framebuffer attachment on the default renderbuffer, r=rcampbell, a=bajaj
authorVictor Porof <vporof@mozilla.com>
Wed, 27 Nov 2013 09:08:52 +0200
changeset 167602 08765e9093b641236718d09e1f131c82abca6985
parent 167601 103c94b8e10f9ccce8b537a12cdd57c91bfe69b2
child 167603 f0cb5125f9704baa6a9c608f45dc4a5d11bba751
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell, bajaj
bugs943596
milestone27.0a2
Bug 943596 - The shader editor highlighting acts weirdly when there's a custom framebuffer attachment on the default renderbuffer, r=rcampbell, a=bajaj
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);