Web Inspector: tint all pixels drawn by shader program when hovering ShaderProgramTre...
authorwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Mar 2018 05:14:49 +0000 (05:14 +0000)
committerwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Mar 2018 05:14:49 +0000 (05:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175223

Reviewed by Matt Baker.

Source/JavaScriptCore:

* inspector/protocol/Canvas.json:
Add `setShaderProgramHighlighted` command that will cause a blend to be applied to the
canvas if the given shader program is active immediately before `drawArrays` or `drawElements`
is called. The blend is removed and the previous value is applied once the draw is complete.

Source/WebCore:

Test: inspector/canvas/setShaderProgramHighlighted.html

* html/canvas/InspectorShaderProgram.h:
(WebCore::InspectorShaderProgram::highlighted):
(WebCore::InspectorShaderProgram::setHighlighted):

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::InspectorScopedShaderProgramHighlight::InspectorScopedShaderProgramHighlight):
(WebCore::InspectorScopedShaderProgramHighlight::~InspectorScopedShaderProgramHighlight):
(WebCore::InspectorScopedShaderProgramHighlight::showHighlight):
(WebCore::InspectorScopedShaderProgramHighlight::hideHighlight):
(WebCore::InspectorScopedShaderProgramHighlight::saveBlendValue):
(WebCore::InspectorScopedShaderProgramHighlight::hasBufferBinding):
(WebCore::InspectorScopedShaderProgramHighlight::hasFramebufferParameterAttachment):
(WebCore::WebGLRenderingContextBase::drawArrays):
(WebCore::WebGLRenderingContextBase::drawElements):
If the current shader program has been marked as highlighted, apply a blend right before
`drawArrays` and `drawElements` is called, tinting the resulting pixels so that they are
visually distinguished from pixels drawn by other shader programs.

* inspector/InspectorCanvasAgent.h:
* inspector/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::setShaderProgramHighlighted):
(WebCore::InspectorCanvasAgent::isShaderProgramHighlighted):

* inspector/InspectorInstrumentation.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::isShaderProgramHighlighted):
(WebCore::InspectorInstrumentation::isShaderProgramHighlightedImpl):

Source/WebInspectorUI:

* UserInterface/Models/ShaderProgram.js:
(WI.ShaderProgram):
(WI.ShaderProgram.prototype.showHighlight):
(WI.ShaderProgram.prototype.hideHighlight):

* UserInterface/Views/ShaderProgramTreeElement.js:
(WI.ShaderProgramTreeElement.prototype.onattach):
(WI.ShaderProgramTreeElement.prototype._handleMouseOver):
(WI.ShaderProgramTreeElement.prototype._handleMouseOut):
Whenever a ShaderProgramTreeElement is hovered, highlight the corresponding shader program
by tinting the pixels it draws via a blend.

LayoutTests:

* inspector/canvas/setShaderProgramHighlighted-expected.txt: Added.
* inspector/canvas/setShaderProgramHighlighted.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230127 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/canvas/setShaderProgramHighlighted-expected.txt [new file with mode: 0644]
LayoutTests/inspector/canvas/setShaderProgramHighlighted.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Canvas.json
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorShaderProgram.h
Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
Source/WebCore/inspector/agents/InspectorCanvasAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js
Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js

index d14e205..833f9d4 100644 (file)
@@ -1,3 +1,13 @@
+2018-03-30  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: tint all pixels drawn by shader program when hovering ShaderProgramTreeElement
+        https://bugs.webkit.org/show_bug.cgi?id=175223
+
+        Reviewed by Matt Baker.
+
+        * inspector/canvas/setShaderProgramHighlighted-expected.txt: Added.
+        * inspector/canvas/setShaderProgramHighlighted.html: Added.
+
 2018-03-30  Ryan Haddad  <ryanhaddad@apple.com>
 
         Skip http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
diff --git a/LayoutTests/inspector/canvas/setShaderProgramHighlighted-expected.txt b/LayoutTests/inspector/canvas/setShaderProgramHighlighted-expected.txt
new file mode 100644 (file)
index 0000000..2b64c6e
--- /dev/null
@@ -0,0 +1,20 @@
+Test highlighting of shader programs.
+
+
+== Running test suite: Canvas.setShaderProgramHighlighted
+-- Running test case: Canvas.setShaderProgramHighlighted.highlightedDrawArrays
+data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACWCAYAAABkW7XSAAAAAXNSR0IArs4c6QAAB4NJREFUeAHt3DGOW1UUgGEnlKmHCokeJFZAxT6QaNhHCsQa2AEFFFSIBaSAhiJSGqQUEwkJlIoeaRhQDp7E9vgdz3v2Pe98SOgO9rV973ee/pJHm83m5vZf/xAgQGB4gcfDn9ABCRAg8EZAsDwKBAiUERCsMqNyUAIEBMszQIBAGQHBKjMqByVAQLA8AwQIlBEQrDKjclACBATLM0CAQBkBwSozKgclQECwPAMECJQREKwyo3JQAgQEyzNAgEAZAcEqMyoHJUBAsDwDBAiUERCsMqNyUAIEBMszQIBAGQHBKjMqByVAQLA8AwQIlBEQrDKjclACBATLM0CAQBkBwSozKgclQECwPAMECJQREKwyo3JQAgQEyzNAgEAZAcEqMyoHJUBAsDwDBAiUERCsMqNyUAIEBMszQIBAGQHBKjMqByVAQLA8AwQIlBEQrDKjclACBATLM0CAQBkBwSozKgclQECwPAMECJQREKwyo3JQAgQEyzNAgEAZAcFKjOrDTz59ndhuKwECMwu8d/t9T2f+ztV+3Te/X//4wUefv/7jt1+f/PXnqyervaiLERhU4NHtuW4GPdtwx/r275vv4lA/f//y6oevv/j4+vmzq3jNSoDAsgKClfC9G6z4mHCFhJXA8gKClT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CsBJ1gJrEG3Ctegg5l4LMGaCPXvNsFKYA2+VbgGH9CB4wnWAZh9LwvWPpXarwlXrfkJVmJegpXAKrZVuGoMTLAScxKsBFbRrcI19uAEKzEfwUpgFd8qXGMOULAScxGsBNZKtgrXWIMUrMQ8BCuBtbKtwjXGQAUrMQfBSmCtdKtwXXawgpXwF6wE1sq3CtdlBixYCXfBSmA12Spc5x20YCW8BSuB1WyrcJ1n4IKVcBasBFbTrcK17OAFK+ErWAms5luFa5kHQLASroKVwLL1PwHhmvdBEKyEp2AlsGx9S0C43uI4+T8EK0EnWAksW/cKCNdelskvCtZkKv8/rASVrUcEhOsI0IG3BesAzL6XP/vyqxf7XvcagVMFXv7y0/vXz59dnfr5bp8TrG4Td18ChQUeFz67oxMg0ExAsJoN3HUJVBYQrMrTc3YCzQQEq9nAXZdAZQHBqjw9ZyfQTECwmg3cdQlUFhCsytNzdgLNBASr2cBdl0BlAcGqPD1nJ9BMQLCaDdx1CVQWEKzK03N2As0EBKvZwF2XQGUBwao8PWcn0ExAsJoN3HUJVBYQrMrTc3YCzQQEq9nAXZdAZQHBqjw9ZyfQTECwmg3cdQlUFhCsytNzdgLNBASr2cBdl0BlAcGqPD1nJ9BMQLCaDdx1CVQWEKzK03N2As0EBKvZwF2XQGUBwao8PWcn0ExAsJoN3HUJVBYQrMrTc3YCzQQEq9nAXZdAZQHBqjw9ZyfQTECwmg3cdQlUFhCsytNzdgLNBASr2cBdl0BlAcGqPD1nJ9BMQLCaDdx1CVQWEKzK03N2As0EBKvZwF2XQGWBfwDSnDm7TAr3vgAAAABJRU5ErkJggg==
+
+-- Running test case: Canvas.setShaderProgramHighlighted.highlightedDrawElements
+data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACWCAYAAABkW7XSAAAAAXNSR0IArs4c6QAABp1JREFUeAHt1MFtFUkQgGEbEQ1hbA4cCIADMXCFGPZAXJCOsQQW5vkZP7/qru6q+VZa7WLc0zVfjf7bm5ubu/t//UOAAIHtBd5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QMAAAAASUVORK5CYII=
+
+-- Running test case: Canvas.setShaderProgramHighlighted.unhighlightedDrawArrays
+data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACWCAYAAABkW7XSAAAAAXNSR0IArs4c6QAAB4lJREFUeAHt3GtSG1kMgFEnlYV5a14Z7IyYFDeAXy01bVvqPlSlGoxMLkd3vpo/M792u93b8Y8PAgQIlBf4Xf6EDkiAAIEPAcFyFQgQaCMgWG1W5aAECAiWO0CAQBsBwWqzKgclQECw3AECBNoICFabVTkoAQKC5Q4QINBGQLDarMpBCRAQLHeAAIE2AoLVZlUOSoCAYLkDBAi0ERCsNqtyUAIEBMsdIECgjYBgtVmVgxIgIFjuAAECbQQEq82qHJQAAcFyBwgQaCMgWG1W5aAECAiWO0CAQBsBwWqzKgclQECw3AECBNoICFabVTkoAQKC5Q4QINBGQLDarMpBCRAQLHeAAIE2AoLVZlUOSoCAYLkDBAi0ERCsNqtyUAIEBMsdIECgjYBgtVmVgxIgIFjuAAECbQQEq82qHJQAAcFyBwgQaCMgWG1W5aAECAiWO0CAQBsBwUqsar/fJ6aNEiCwtIBgJURfXl5273+EK4FmlMDCAm/Hn+dPwODty8cxXG/HcHELuLlf/vla8A7AjGJ+6dX/T4XL/YneH3OL3JVFfsgm/k3jf6UufCJc7pEgPeQOPOQvWUXQLnTq7CXhcp+E66534K4/fBWhGhfwrE43XhAu92rcG89F78KiP2xVgTq9aDf6dPVbwuV+nd4jX//oTvzozasO1OnFulqlwDeEyz07vU++nnUnZr1pU6EaFyvQpckR4XLfxn3ynHUXZr1JsCbTdHtAuNw7wZp1B2a9SbBu9yj8XeFy/4QrdQdSw5sM1bhQ4QrNGBQu93DcM8+bd+HmNzcdqNOLM6ND6bcIl/t4eu98/e1OfPtCoG78t3Hp+vzgDcLlXgrV+R349YFyfPiYEjj2Z2pk8e+/vr7uDofD7v3pg8DWBQQrcQOeEaxxPOEaEp5bFhCsxPafGaxxTOEaEp5bFBCsxNYrBGscV7iGhOeW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h+sYx+wvBStAJVgLL6EUB4brIEn5RsMJU/n9YCSqjEwLCNQF05dt/rrzu5QsCh8PhwqteIjBPYL/f/3vje7x8xAT8G1bMyRQBAgUEfhc4gyMQIEAgJCBYISZDBAhUEBCsCltwBgIEQgKCFWIyRIBABQHBqrAFZyBAICQgWCEmQwQIVBAQrApbcAYCBEICghViMkSAQAUBwaqwBWcgQCAkIFghJkMECFQQEKwKW3AGAgRCAoIVYjJEgEAFAcGqsAVnIEAgJCBYISZDBAhUEBCsCltwBgIEQgKCFWIyRIBABQHBqrAFZyBAICQgWCEmQwQIVBAQrApbcAYCBEICghViMkSAQAUBwaqwBWcgQCAkIFghJkMECFQQEKwKW3AGAgRCAoIVYjJEgEAFAcGqsAVnIEAgJCBYISZDBAhUEBCsCltwBgIEQgKCFWIyRIBABQHBqrAFZyBAICQgWCEmQwQIVBAQrApbcAYCBEICghViMkSAQAUBwaqwBWcgQCAkIFghJkMECFQQEKwKW3AGAgRCAoIVYjJEgEAFgb/VewCWguWlCQAAAABJRU5ErkJggg==
+
+-- Running test case: Canvas.setShaderProgramHighlighted.unhighlightedDrawElements
+data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACWCAYAAABkW7XSAAAAAXNSR0IArs4c6QAABodJREFUeAHt1I1OG0kQhVGI9r2BJyesEhQCJhhXT3XfnhNptcG4f+bU5Lu/u7t7fvnPHwIECCwv8GP5G7ogAQIEfgsIlleBAIEYAcGKGZWLEiAgWN4BAgRiBAQrZlQuSoCAYHkHCBCIERCsmFG5KAECguUdIEAgRkCwYkblogQICJZ3gACBGAHBihmVixIgIFjeAQIEYgQEK2ZULkqAgGB5BwgQiBEQrJhRuSgBAoLlHSBAIEZAsGJG5aIECAiWd4AAgRgBwYoZlYsSICBY3gECBGIEBCtmVC5KgIBgeQcIEIgREKyYUbkoAQKC5R0gQCBGQLBiRuWiBAgIlneAAIEYAcGKGZWLEiAgWN4BAgRiBAQrZlQuSoCAYHkHCBCIERCsmFG5KAECguUd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+cedhOofOH61vYBghYxYqEIG5ZqHCgjWobz1zYWqbmiHfQQEa9FZCtWig3GtqQKCNZX/4+FC9dHEJwReBQTrVWLy/4Vq8gAcHyEgWJPHJFSTB+D4KAHBmjQuoZoE79hoAcFqHp9QNYM7bisBwWoap1A1QTtmawHBOni8QnUwsO1PJSBYB41bqA6Cte2pBQRr8PiFajCo7Qi8ERCsNxiVvwpVRc9aAtcJCNZ1Tp9+S6g+pfELAsMFBOtGUqG6Ec4yAgUBwfomnlB9E8zXCQwUEKwbMZ+enm5caRkBArcK3L8sfL51sXUECBDoFPjReZizCBAgUBEQrIqetQQItAoIViu3wwgQqAgIVkXPWgIEWgUEq5XbYQQIVAQEq6JnLQECrQKC1crtMAIEKgKCVdGzlgCBVgHBauV2GAECFQHBquhZS4BAq4BgtXI7jACBioBgVfSsJUCgVUCwWrkdRoBARUCwKnrWEiDQKiBYrdwOI0CgIiBYFT1rCRBoFRCsVm6HESBQERCsip61BAi0CghWK7fDCBCoCAhWRc9aAgRaBQSrldthBAhUBASromctAQKtAoLVyu0wAgQqAoJV0bOWAIFWAcFq5XYYAQIVAcGq6FlLgECrgGC1cjuMAIGKgGBV9KwlQKBVQLBauR1GgEBFQLAqetYSINAqIFit3A4jQKAiIFgVPWsJEGgVEKxWbocRIFAREKyKnrUECLQKCFYrt8MIEKgICFZFz1oCBFoFfgJUguTj1eIlHgAAAABJRU5ErkJggg==
+
+-- Running test case: Canvas.setShaderProgramHighlighted.invalidProgramId
+PASS: Should produce an error.
+Error: No shader program for given identifier.
+
diff --git a/LayoutTests/inspector/canvas/setShaderProgramHighlighted.html b/LayoutTests/inspector/canvas/setShaderProgramHighlighted.html
new file mode 100644 (file)
index 0000000..d82dca8
--- /dev/null
@@ -0,0 +1,158 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script src="resources/shaderProgram-utilities.js"></script>
+<script id="vertex-shader" type="x-shader/x-vertex">
+    attribute vec3 position;
+    void main(void) {
+        gl_Position = vec4(position, 1.0);
+    }
+</script>
+<script id="fragment-shader" type="x-shader/x-fragment">
+    precision mediump float;
+
+    void main(void) {
+        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
+    }
+</script>
+<script>
+function load() {
+    createProgram("webgl");
+    linkProgram("vertex-shader", "fragment-shader");
+    context.useProgram(program);
+
+    clearContext();
+
+    runTest();
+}
+
+function clearContext() {
+    context.clearColor(0.0, 0.0, 0.0, 1.0);
+    context.clear(context.COLOR_BUFFER_BIT);
+}
+
+function drawArrays() {
+    clearContext();
+
+    let vertexes = [
+        -0.5,  0.5,  0.0,
+        -0.5, -0.5,  0.0,
+         0.5, -0.5,  0.0,
+    ];
+    let vertexBuffer = context.createBuffer();
+    context.bindBuffer(context.ARRAY_BUFFER, vertexBuffer);
+    context.bufferData(context.ARRAY_BUFFER, new Float32Array(vertexes), context.STATIC_DRAW);
+
+    let position = context.getAttribLocation(program, "position");
+    context.vertexAttribPointer(position, 3, context.FLOAT, false, 0, 0);
+    context.enableVertexAttribArray(position);
+
+    context.drawArrays(context.TRIANGLES, 0, 3);
+}
+
+function drawElements() {
+    clearContext();
+
+    let vertexes = [
+         0.5,  0.5,  0.0,
+        -0.5, -0.5,  0.0,
+         0.5, -0.5,  0.0,
+    ];
+    let vertexBuffer = context.createBuffer();
+    context.bindBuffer(context.ARRAY_BUFFER, vertexBuffer);
+    context.bufferData(context.ARRAY_BUFFER, new Float32Array(vertexes), context.STATIC_DRAW);
+
+    let indexes = [0, 1, 2];
+    let indexBuffer = context.createBuffer();
+    context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexBuffer);
+    context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexes), context.STATIC_DRAW);
+
+    let position = context.getAttribLocation(program, "position");
+    context.vertexAttribPointer(position, 3, context.FLOAT, false, 0, 0);
+    context.enableVertexAttribArray(position);
+
+    context.drawElements(context.TRIANGLES, indexes.length, context.UNSIGNED_SHORT, 0);
+}
+
+function test() {
+    let suite = InspectorTest.createAsyncSuite("Canvas.setShaderProgramHighlighted");
+
+    let shaderProgram = WI.canvasManager.shaderPrograms[0];
+    let originalContent = null;
+
+    function validTest({name, highlighted, evaluateString}) {
+        suite.addTestCase({
+            name,
+            test(resolve, reject) {
+                CanvasAgent.setShaderProgramHighlighted(shaderProgram.identifier, highlighted, (error) => {
+                    if (error) {
+                        reject(error);
+                        return;
+                    }
+
+                    InspectorTest.evaluateInPage(evaluateString, (error) => {
+                        if (error) {
+                            reject(error);
+                            return;
+                        }
+
+                        CanvasAgent.requestContent(shaderProgram.canvas.identifier)
+                        .then(({content}) => InspectorTest.log(content))
+                        .then(resolve, reject);
+                    });
+                });
+            }
+        });
+    }
+
+    validTest({
+        name: "Canvas.setShaderProgramHighlighted.highlightedDrawArrays",
+        highlighted: true,
+        evaluateString: `drawArrays()`,
+    });
+
+    validTest({
+        name: "Canvas.setShaderProgramHighlighted.highlightedDrawElements",
+        highlighted: true,
+        evaluateString: `drawElements()`,
+    });
+
+    validTest({
+        name: "Canvas.setShaderProgramHighlighted.unhighlightedDrawArrays",
+        highlighted: false,
+        evaluateString: `drawArrays()`,
+    });
+
+    validTest({
+        name: "Canvas.setShaderProgramHighlighted.unhighlightedDrawElements",
+        highlighted: false,
+        evaluateString: `drawElements()`,
+    });
+
+    suite.addTestCase({
+        name: "Canvas.setShaderProgramHighlighted.invalidProgramId",
+        description: "Invalid program identifiers should cause an error.",
+        test(resolve, reject) {
+            const programId = "INVALID_PROGRAM_ID";
+            const highlighted = false;
+            CanvasAgent.setShaderProgramHighlighted(programId, highlighted, (error) => {
+                InspectorTest.expectThat(error, "Should produce an error.");
+                InspectorTest.log("Error: " + error);
+                resolve();
+            });
+        }
+    });
+
+    CanvasAgent.requestContent(shaderProgram.canvas.identifier, (error, content) => {
+        originalContent = content;
+
+        suite.runTestCasesAndFinish();
+    });
+}
+</script>
+</head>
+<body onload="load()">
+    <p>Test highlighting of shader programs.</p>
+</body>
+</html>
index 1428fe0..d2fe8a4 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-30  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: tint all pixels drawn by shader program when hovering ShaderProgramTreeElement
+        https://bugs.webkit.org/show_bug.cgi?id=175223
+
+        Reviewed by Matt Baker.
+
+        * inspector/protocol/Canvas.json:
+        Add `setShaderProgramHighlighted` command that will cause a blend to be applied to the
+        canvas if the given shader program is active immediately before `drawArrays` or `drawElements`
+        is called. The blend is removed and the previous value is applied once the draw is complete.
+
 2018-03-30  JF Bastien  <jfbastien@apple.com>
 
         WebAssembly: support DataView compilation
index 8bab3b5..8f78d93 100644 (file)
                 { "name": "programId", "$ref": "ProgramId" },
                 { "name": "disabled", "type": "boolean" }
             ]
+        },
+        {
+            "name": "setShaderProgramHighlighted",
+            "description": "Enable/disable highlighting of the given shader program.",
+            "parameters": [
+                { "name": "programId", "$ref": "ProgramId" },
+                { "name": "highlighted", "type": "boolean" }
+            ]
         }
     ],
     "events": [
index 9b0948c..fdd694f 100644 (file)
@@ -1,3 +1,40 @@
+2018-03-30  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: tint all pixels drawn by shader program when hovering ShaderProgramTreeElement
+        https://bugs.webkit.org/show_bug.cgi?id=175223
+
+        Reviewed by Matt Baker.
+
+        Test: inspector/canvas/setShaderProgramHighlighted.html
+
+        * html/canvas/InspectorShaderProgram.h:
+        (WebCore::InspectorShaderProgram::highlighted):
+        (WebCore::InspectorShaderProgram::setHighlighted):
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::InspectorScopedShaderProgramHighlight::InspectorScopedShaderProgramHighlight):
+        (WebCore::InspectorScopedShaderProgramHighlight::~InspectorScopedShaderProgramHighlight):
+        (WebCore::InspectorScopedShaderProgramHighlight::showHighlight):
+        (WebCore::InspectorScopedShaderProgramHighlight::hideHighlight):
+        (WebCore::InspectorScopedShaderProgramHighlight::saveBlendValue):
+        (WebCore::InspectorScopedShaderProgramHighlight::hasBufferBinding):
+        (WebCore::InspectorScopedShaderProgramHighlight::hasFramebufferParameterAttachment):
+        (WebCore::WebGLRenderingContextBase::drawArrays):
+        (WebCore::WebGLRenderingContextBase::drawElements):
+        If the current shader program has been marked as highlighted, apply a blend right before
+        `drawArrays` and `drawElements` is called, tinting the resulting pixels so that they are
+        visually distinguished from pixels drawn by other shader programs.
+
+        * inspector/InspectorCanvasAgent.h:
+        * inspector/InspectorCanvasAgent.cpp:
+        (WebCore::InspectorCanvasAgent::setShaderProgramHighlighted):
+        (WebCore::InspectorCanvasAgent::isShaderProgramHighlighted):
+
+        * inspector/InspectorInstrumentation.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::isShaderProgramHighlighted):
+        (WebCore::InspectorInstrumentation::isShaderProgramHighlightedImpl):
+
 2018-03-30  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Extra zoom mode] Adopt list view controller UI for numeric input types
index 3aaa47e..9078a45 100644 (file)
@@ -393,6 +393,123 @@ private:
     WebGLRenderingContextBase* m_context;
 };
 
+class InspectorScopedShaderProgramHighlight {
+public:
+    InspectorScopedShaderProgramHighlight(WebGLRenderingContextBase& context, WebGLProgram* program)
+        : m_context(context)
+        , m_program(program)
+    {
+        showHightlight();
+    }
+
+    ~InspectorScopedShaderProgramHighlight()
+    {
+        hideHighlight();
+    }
+
+private:
+    void showHightlight()
+    {
+        if (!m_program || LIKELY(!InspectorInstrumentation::isShaderProgramHighlighted(m_context, *m_program)))
+            return;
+
+        if (hasBufferBinding(GraphicsContext3D::FRAMEBUFFER_BINDING)) {
+            if (!hasBufferBinding(GraphicsContext3D::RENDERBUFFER_BINDING))
+                return;
+            if (hasFramebufferParameterAttachment(GraphicsContext3D::DEPTH_ATTACHMENT))
+                return;
+            if (hasFramebufferParameterAttachment(GraphicsContext3D::STENCIL_ATTACHMENT))
+                return;
+#if ENABLE(WEBGL2)
+            if (hasFramebufferParameterAttachment(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT))
+                return;
+#endif
+        }
+
+        saveBlendValue(GraphicsContext3D::BLEND_COLOR, m_savedBlend.color);
+        saveBlendValue(GraphicsContext3D::BLEND_EQUATION_RGB, m_savedBlend.equationRGB);
+        saveBlendValue(GraphicsContext3D::BLEND_EQUATION_ALPHA, m_savedBlend.equationAlpha);
+        saveBlendValue(GraphicsContext3D::BLEND_SRC_RGB, m_savedBlend.srcRGB);
+        saveBlendValue(GraphicsContext3D::BLEND_SRC_ALPHA, m_savedBlend.srcAlpha);
+        saveBlendValue(GraphicsContext3D::BLEND_DST_RGB, m_savedBlend.dstRGB);
+        saveBlendValue(GraphicsContext3D::BLEND_DST_ALPHA, m_savedBlend.dstAlpha);
+        saveBlendValue(GraphicsContext3D::BLEND, m_savedBlend.enabled);
+
+        static const GC3Dfloat red = 111.0 / 255.0;
+        static const GC3Dfloat green = 168.0 / 255.0;
+        static const GC3Dfloat blue = 220.0 / 255.0;
+        static const GC3Dfloat alpha = 2.0 / 3.0;
+
+        m_context.enable(GraphicsContext3D::BLEND);
+        m_context.blendColor(red, green, blue, alpha);
+        m_context.blendEquation(GraphicsContext3D::FUNC_ADD);
+        m_context.blendFunc(GraphicsContext3D::CONSTANT_COLOR, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
+
+        m_didApply = true;
+    }
+
+    void hideHighlight()
+    {
+        if (!m_didApply)
+            return;
+
+        if (!m_savedBlend.enabled)
+            m_context.disable(GraphicsContext3D::BLEND);
+
+        const RefPtr<Float32Array>& color = m_savedBlend.color;
+        m_context.blendColor(color->item(0), color->item(1), color->item(2), color->item(3));
+        m_context.blendEquationSeparate(m_savedBlend.equationRGB, m_savedBlend.equationAlpha);
+        m_context.blendFuncSeparate(m_savedBlend.srcRGB, m_savedBlend.dstRGB, m_savedBlend.srcAlpha, m_savedBlend.dstAlpha);
+
+        m_savedBlend.color = nullptr;
+
+        m_didApply = false;
+    }
+
+    template <typename T>
+    void saveBlendValue(GC3Denum attachment, T& destination)
+    {
+        WebGLAny param = m_context.getParameter(attachment);
+        if (WTF::holds_alternative<T>(param))
+            destination = WTF::get<T>(param);
+    }
+
+    bool hasBufferBinding(GC3Denum pname)
+    {
+        WebGLAny binding = m_context.getParameter(pname);
+        if (pname == GraphicsContext3D::FRAMEBUFFER_BINDING)
+            return WTF::holds_alternative<RefPtr<WebGLFramebuffer>>(binding) && WTF::get<RefPtr<WebGLFramebuffer>>(binding);
+        if (pname == GraphicsContext3D::RENDERBUFFER_BINDING)
+            return WTF::holds_alternative<RefPtr<WebGLRenderbuffer>>(binding) && WTF::get<RefPtr<WebGLRenderbuffer>>(binding);
+        return false;
+    }
+
+    bool hasFramebufferParameterAttachment(GC3Denum attachment)
+    {
+        WebGLAny attachmentParameter = m_context.getFramebufferAttachmentParameter(GraphicsContext3D::FRAMEBUFFER, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
+        if (!WTF::holds_alternative<unsigned>(attachmentParameter))
+            return false;
+        if (WTF::get<unsigned>(attachmentParameter) != static_cast<unsigned>(GraphicsContext3D::RENDERBUFFER))
+            return false;
+        return true;
+    }
+
+    struct {
+        RefPtr<Float32Array> color;
+        unsigned equationRGB { 0 };
+        unsigned equationAlpha { 0 };
+        unsigned srcRGB { 0 };
+        unsigned srcAlpha { 0 };
+        unsigned dstRGB { 0 };
+        unsigned dstAlpha { 0 };
+        bool enabled { false };
+    } m_savedBlend;
+
+    WebGLRenderingContextBase& m_context;
+    WebGLProgram* m_program { nullptr };
+    bool m_didApply { false };
+};
+
 static bool isHighPerformanceContext(const RefPtr<GraphicsContext3D>& context)
 {
     return context->powerPreferenceUsedForCreation() == WebGLPowerPreference::HighPerformance;
@@ -2132,7 +2249,11 @@ void WebGLRenderingContextBase::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsiz
     if (!isGLES2NPOTStrict())
         usesFallbackTexture = checkTextureCompleteness("drawArrays", true);
 
-    m_context->drawArrays(mode, first, count);
+    {
+        InspectorScopedShaderProgramHighlight scopedHighlight(*this, m_currentProgram.get());
+
+        m_context->drawArrays(mode, first, count);
+    }
 
     if (!isGLES2Compliant() && vertexAttrib0Simulated)
         restoreStatesAfterVertexAttrib0Simulation();
@@ -2169,7 +2290,11 @@ void WebGLRenderingContextBase::drawElements(GC3Denum mode, GC3Dsizei count, GC3
     if (!isGLES2NPOTStrict())
         usesFallbackTexture = checkTextureCompleteness("drawElements", true);
 
-    m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset));
+    {
+        InspectorScopedShaderProgramHighlight scopedHighlight(*this, m_currentProgram.get());
+
+        m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset));
+    }
 
     if (!isGLES2Compliant() && vertexAttrib0Simulated)
         restoreStatesAfterVertexAttrib0Simulation();
index 1753d1a..ff8cacc 100644 (file)
@@ -1001,6 +1001,13 @@ bool InspectorInstrumentation::isShaderProgramDisabledImpl(InstrumentingAgents&
         return canvasAgent->isShaderProgramDisabled(program);
     return false;
 }
+
+bool InspectorInstrumentation::isShaderProgramHighlightedImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
+{
+    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
+        return canvasAgent->isShaderProgramHighlighted(program);
+    return false;
+}
 #endif
 
 #if ENABLE(RESOURCE_USAGE)
index 6121ac4..8f93f45 100644 (file)
@@ -262,6 +262,7 @@ public:
     static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
     static void willDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&);
     static bool isShaderProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
+    static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
 #endif
 
     static void networkStateChanged(Page&);
@@ -432,6 +433,7 @@ private:
     static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
     static void willDeleteProgramImpl(InstrumentingAgents&, WebGLProgram&);
     static bool isShaderProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
+    static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
 #endif
 
     static void layerTreeDidChangeImpl(InstrumentingAgents&);
@@ -1260,6 +1262,14 @@ inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingCont
         return isShaderProgramDisabledImpl(*instrumentingAgents, program);
     return false;
 }
+
+inline bool InspectorInstrumentation::isShaderProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
+{
+    FAST_RETURN_IF_NO_FRONTENDS(false);
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
+        return isShaderProgramHighlightedImpl(*instrumentingAgents, program);
+    return false;
+}
 #endif
 
 inline void InspectorInstrumentation::networkStateChanged(Page& page)
index 1b8b78b..9467e84 100644 (file)
@@ -49,6 +49,9 @@ public:
     bool disabled() const { return m_disabled; }
     void setDisabled(bool disabled) { m_disabled = disabled; }
 
+    bool highlighted() const { return m_highlighted; }
+    void setHighlighted(bool value) { m_highlighted = value; }
+
     ~InspectorShaderProgram() = default;
 
 private:
@@ -59,6 +62,7 @@ private:
     InspectorCanvas& m_canvas;
 
     bool m_disabled { false };
+    bool m_highlighted { false };
 };
 
 } // namespace WebCore
index 83c545e..a7fec81 100644 (file)
@@ -364,6 +364,21 @@ void InspectorCanvasAgent::setShaderProgramDisabled(ErrorString& errorString, co
 #endif
 }
 
+void InspectorCanvasAgent::setShaderProgramHighlighted(ErrorString& errorString, const String& programId, bool highlighted)
+{
+#if ENABLE(WEBGL)
+    auto* inspectorProgram = assertInspectorProgram(errorString, programId);
+    if (!inspectorProgram)
+        return;
+
+    inspectorProgram->setHighlighted(highlighted);
+#else
+    UNUSED_PARAM(programId);
+    UNUSED_PARAM(highlighted);
+    errorString = ASCIILiteral("WebGL is not supported.");
+#endif
+}
+
 void InspectorCanvasAgent::frameNavigated(Frame& frame)
 {
     if (frame.isMainFrame()) {
@@ -608,6 +623,15 @@ bool InspectorCanvasAgent::isShaderProgramDisabled(WebGLProgram& program)
 
     return inspectorProgram->disabled();
 }
+
+bool InspectorCanvasAgent::isShaderProgramHighlighted(WebGLProgram& program)
+{
+    auto* inspectorProgram = findInspectorProgram(program);
+    if (!inspectorProgram)
+        return false;
+
+    return inspectorProgram->highlighted();
+}
 #endif
 
 void InspectorCanvasAgent::canvasDestroyedTimerFired()
index 775d2d6..547f0a2 100644 (file)
@@ -78,6 +78,7 @@ public:
     void requestShaderSource(ErrorString&, const String& programId, const String& shaderType, String*) override;
     void updateShader(ErrorString&, const String& programId, const String& shaderType, const String& source) override;
     void setShaderProgramDisabled(ErrorString&, const String& programId, bool disabled) override;
+    void setShaderProgramHighlighted(ErrorString&, const String& programId, bool highlighted) override;
 
     // InspectorInstrumentation
     void frameNavigated(Frame&);
@@ -93,6 +94,7 @@ public:
     void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
     void willDeleteProgram(WebGLProgram&);
     bool isShaderProgramDisabled(WebGLProgram&);
+    bool isShaderProgramHighlighted(WebGLProgram&);
 #endif
 
     // CanvasObserver
index ab87cf0..3d55dfd 100644 (file)
@@ -1,3 +1,22 @@
+2018-03-30  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: tint all pixels drawn by shader program when hovering ShaderProgramTreeElement
+        https://bugs.webkit.org/show_bug.cgi?id=175223
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Models/ShaderProgram.js:
+        (WI.ShaderProgram):
+        (WI.ShaderProgram.prototype.showHighlight):
+        (WI.ShaderProgram.prototype.hideHighlight):
+
+        * UserInterface/Views/ShaderProgramTreeElement.js:
+        (WI.ShaderProgramTreeElement.prototype.onattach):
+        (WI.ShaderProgramTreeElement.prototype._handleMouseOver):
+        (WI.ShaderProgramTreeElement.prototype._handleMouseOut):
+        Whenever a ShaderProgramTreeElement is hovered, highlight the corresponding shader program
+        by tinting the pixels it draws via a blend.
+
 2018-03-27  Timothy Hatcher  <timothy@apple.com>
 
         Web Inspector: Modernize some utility functions
index f11a51d..f4191f4 100644 (file)
@@ -79,6 +79,22 @@ WI.ShaderProgram = class ShaderProgram
         });
     }
 
+    showHighlight()
+    {
+        const highlighted = true;
+        CanvasAgent.setShaderProgramHighlighted(this._identifier, highlighted, (error) => {
+            console.assert(!error, error);
+        });
+    }
+
+    hideHighlight()
+    {
+        const highlighted = false;
+        CanvasAgent.setShaderProgramHighlighted(this._identifier, highlighted, (error) => {
+            console.assert(!error, error);
+        });
+    }
+
     // Private
 
     _requestShaderSource(shaderType, callback)
index 79d4d0f..92da682 100644 (file)
@@ -40,6 +40,14 @@ WI.ShaderProgramTreeElement = class ShaderProgramTreeElement extends WI.GeneralT
 
     // Protected
 
+    onattach()
+    {
+        super.onattach();
+
+        this.element.addEventListener("mouseover", this._handleMouseOver.bind(this));
+        this.element.addEventListener("mouseout", this._handleMouseOut.bind(this));
+    }
+
     selectOnMouseDown(event)
     {
         if (this._statusElement.contains(event.target))
@@ -57,4 +65,14 @@ WI.ShaderProgramTreeElement = class ShaderProgramTreeElement extends WI.GeneralT
             this._disabledImageElement.title = this.representedObject.disabled ? WI.UIString("Enable Program") : WI.UIString("Disable Program");
         });
     }
+
+    _handleMouseOver(event)
+    {
+        this.representedObject.showHighlight();
+    }
+
+    _handleMouseOut(event)
+    {
+        this.representedObject.hideHighlight();
+    }
 };