Changeset 249786 in webkit
- Timestamp:
- Sep 11, 2019 4:28:37 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 8 deleted
- 38 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249782 r249786 1 2019-09-11 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Canvas: instrument WebGPUDevice instead of GPUCanvasContext 4 https://bugs.webkit.org/show_bug.cgi?id=201650 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/canvas/create-context-webgpu.html: 9 * inspector/canvas/create-context-webgpu-expected.txt: 10 * inspector/canvas/resources/create-context-utilities.js: 11 (createDetachedCanvas): 12 (createCSSCanvas): 13 (destroyCanvases): 14 15 * inspector/canvas/requestClientNodes.html: Added. 16 * inspector/canvas/requestClientNodes-expected.txt: Added. 17 * inspector/canvas/requestClientNodes-css.html: Renamed from LayoutTests/inspector/canvas/css-canvas-clients.html. 18 * inspector/canvas/requestClientNodes-css-expected.txt: Renamed from LayoutTests/inspector/canvas/css-canvas-clients-expected.txt. 19 * inspector/canvas/requestClientNodes-webgpu.html: Added. 20 * inspector/canvas/requestClientNodes-webgpu-expected.txt: Added. 21 22 * inspector/canvas/resolveContext-2d.html: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-2d.html. 23 * inspector/canvas/resolveContext-2d-expected.txt: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-2d-expected.txt. 24 * inspector/canvas/resolveContext-bitmaprenderer.html: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-bitmaprenderer.html. 25 * inspector/canvas/resolveContext-bitmaprenderer-expected.txt: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-bitmaprenderer-expected.txt. 26 * inspector/canvas/resolveContext-webgl.html: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-webgl.html. 27 * inspector/canvas/resolveContext-webgl-expected.txt: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-webgl-expected.txt. 28 * inspector/canvas/resolveContext-webgl2.html: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-webgl2.html. 29 * inspector/canvas/resolveContext-webgl2-expected.txt: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-webgl2-expected.txt. 30 * inspector/canvas/resolveContext-webgpu.html: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html. 31 * inspector/canvas/resolveContext-webgpu-expected.txt: Renamed from LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt. 32 33 * inspector/canvas/context-attributes-expected.txt: 34 35 * platform/gtk/TestExpectations: 36 * platform/ios/TestExpectations: 37 * platform/mac-wk1/TestExpectations: 38 * platform/mac/TestExpectations: 39 * platform/win/TestExpectations: 40 * platform/wincairo/TestExpectations: 41 * platform/wpe/TestExpectations: 42 1 43 2019-09-11 Chris Dumez <cdumez@apple.com> 2 44 -
trunk/LayoutTests/inspector/canvas/context-attributes-expected.txt
r249776 r249786 33 33 "premultipliedAlpha": true, 34 34 "preserveDrawingBuffer": false, 35 "powerPreference": "default", 35 36 "failIfMajorPerformanceCaveat": false 36 37 } … … 46 47 "premultipliedAlpha": true, 47 48 "preserveDrawingBuffer": false, 49 "powerPreference": "default", 48 50 "failIfMajorPerformanceCaveat": false 49 51 } -
trunk/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt
r249776 r249786 6 6 PASS: CanvasManager should have no canvases. 7 7 8 -- Running test case: Canvas.CreateContextWebGPU. Attached8 -- Running test case: Canvas.CreateContextWebGPU.Device 9 9 PASS: Canvas context should be Web GPU. 10 0: getContext - [native code]11 1: createAttachedCanvas - inspector/canvas/resources/create-context-utilities.js:4:3612 2: Global Code - [program code]13 3: evaluateWithScopeExtension - [native code]14 4: (anonymous function) - [native code]15 5: _wrapCall - [native code]16 10 17 11 PASS: Removed canvas has expected ID. 18 12 19 -- Running test case: Canvas.CreateContextWebGPU.Detached 20 PASS: Canvas context should be Web GPU. 21 0: getContext - [native code] 22 1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62 23 2: Global Code - [program code] 24 3: evaluateWithScopeExtension - [native code] 25 4: (anonymous function) - [native code] 26 5: _wrapCall - [native code] 13 -- Running test case: Canvas.CreateContextWebGPU.Canvas.Attached 14 PASS: Inspector canvas should not be created for attached GPUCanvasContext without connected WebGPUDevice. 27 15 28 PASS: Removed canvas has expected ID. 16 -- Running test case: Canvas.CreateContextWebGPU.Canvas.Detached 17 PASS: Inspector canvas should not be created for detached GPUCanvasContext without connected WebGPUDevice. 29 18 30 -- Running test case: Canvas.CreateContextWebGPU.CSSCanvas 31 Create CSS canvas from -webkit-canvas(css-canvas). 32 PASS: Canvas context should be Web GPU. 33 0: getCSSCanvasContext - [native code] 34 1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:18:47 35 2: Global Code - [program code] 36 3: evaluateWithScopeExtension - [native code] 37 4: (anonymous function) - [native code] 38 5: _wrapCall - [native code] 19 -- Running test case: Canvas.CreateContextWebGPU.Canvas.CSS 20 PASS: Inspector canvas should not be created for CSS GPUCanvasContext without connected WebGPUDevice. 39 21 40 PASS: Canvas name should equal the identifier passed to -webkit-canvas.41 -
trunk/LayoutTests/inspector/canvas/create-context-webgpu.html
r249776 r249786 9 9 window.internals.settings.setWebGPUEnabled(true); 10 10 11 function createDevice() { 12 function receivedDevice(device) { 13 window.contexts.push(device); 14 } 15 16 function receivedAdapter(adapter) { 17 adapter.requestDevice().then(receivedDevice); 18 } 19 20 navigator.gpu.requestAdapter().then(receivedAdapter); 21 } 22 11 23 function test() { 12 InspectorTest.debug();13 14 24 let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextWebGPU"); 15 25 16 26 InspectorTest.CreateContextUtilities.addSimpleTestCase({ 17 name: " Attached",18 expression: `create AttachedCanvas("gpu")`,27 name: "Device", 28 expression: `createDevice()`, 19 29 contextType: WI.Canvas.ContextType.WebGPU, 20 30 }); 21 31 22 InspectorTest.CreateContextUtilities.addSimpleTestCase({ 23 name: "Detached", 24 expression: `createDetachedCanvas("gpu")`, 25 contextType: WI.Canvas.ContextType.WebGPU, 32 suite.addTestCase({ 33 name: "Canvas.CreateContextWebGPU.Canvas.Attached", 34 description: "Ensure that attached GPUCanvasContext aren't tracked as a canvas, instead of the WebGPUDevice.", 35 async test() { 36 let created = false; 37 let listener = WI.canvasManager.addEventListener(WI.CanvasManager.Event.CanvasAdded, (event) => { 38 InspectorTest.assert(event.target.contextType === WI.Canvas.ContextType.WebGPU); 39 created = true; 40 }); 41 42 await InspectorTest.evaluateInPage(`createAttachedCanvas("gpu")`) 43 44 WI.canvasManager.removeEventListener(WI.CanvasManager.Event.CanvasAdded, listener); 45 46 InspectorTest.expectFalse(created, "Inspector canvas should not be created for attached GPUCanvasContext without connected WebGPUDevice."); 47 }, 26 48 }); 27 49 28 InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGPU); 50 suite.addTestCase({ 51 name: "Canvas.CreateContextWebGPU.Canvas.Detached", 52 description: "Ensure that detached GPUCanvasContext aren't tracked as a canvas, instead of the WebGPUDevice.", 53 async test() { 54 let created = false; 55 let listener = WI.canvasManager.addEventListener(WI.CanvasManager.Event.CanvasAdded, (event) => { 56 InspectorTest.assert(event.target.contextType === WI.Canvas.ContextType.WebGPU); 57 created = true; 58 }); 59 60 await InspectorTest.evaluateInPage(`createDetachedCanvas("gpu")`) 61 62 WI.canvasManager.removeEventListener(WI.CanvasManager.Event.CanvasAdded, listener); 63 64 InspectorTest.expectFalse(created, "Inspector canvas should not be created for detached GPUCanvasContext without connected WebGPUDevice."); 65 }, 66 }); 67 68 suite.addTestCase({ 69 name: "Canvas.CreateContextWebGPU.Canvas.CSS", 70 description: "Ensure that CSS GPUCanvasContext aren't tracked as a canvas, instead of the WebGPUDevice.", 71 async test() { 72 let created = false; 73 let listener = WI.canvasManager.addEventListener(WI.CanvasManager.Event.CanvasAdded, (event) => { 74 InspectorTest.assert(event.target.contextType === WI.Canvas.ContextType.WebGPU); 75 created = true; 76 }); 77 78 await InspectorTest.evaluateInPage(`createCSSCanvas("gpu", "css-canvas")`) 79 80 WI.canvasManager.removeEventListener(WI.CanvasManager.Event.CanvasAdded, listener); 81 82 InspectorTest.expectFalse(created, "Inspector canvas should not be created for CSS GPUCanvasContext without connected WebGPUDevice."); 83 }, 84 }); 29 85 30 86 suite.runTestCasesAndFinish(); -
trunk/LayoutTests/inspector/canvas/resolveContext-2d.html
r249785 r249786 12 12 function test() 13 13 { 14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC anvasContext2D");14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveContext2D"); 15 15 16 16 suite.addTestCase({ 17 name: `Canvas.resolveC anvasContext2D.validIdentifier`,17 name: `Canvas.resolveContext2D.validIdentifier`, 18 18 description: "Should return a valid object for the given canvas identifier.", 19 19 test(resolve, reject) { … … 25 25 26 26 const objectGroup = "test"; 27 CanvasAgent.resolveC anvasContext(canvas.identifier, objectGroup)27 CanvasAgent.resolveContext(canvas.identifier, objectGroup) 28 28 .then(({object}) => { 29 29 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 37 37 38 38 suite.addTestCase({ 39 name: "Canvas.resolveC anvasContext.invalidIdentifier",39 name: "Canvas.resolveContext.invalidIdentifier", 40 40 description: "Invalid canvas identifiers should cause an error.", 41 41 test(resolve, reject) { 42 42 const identifier = "DOES_NOT_EXIST"; 43 43 const objectGroup = "test"; 44 CanvasAgent.resolveC anvasContext(identifier, objectGroup, (error) => {44 CanvasAgent.resolveContext(identifier, objectGroup, (error) => { 45 45 InspectorTest.expectThat(error, "Should produce an error."); 46 46 InspectorTest.log("Error: " + error); … … 55 55 </head> 56 56 <body onload="load()"> 57 <p>Tests for the Canvas.resolveC anvasContext command for 2D contexts.</p>57 <p>Tests for the Canvas.resolveContext command for 2D contexts.</p> 58 58 </body> 59 59 </html> -
trunk/LayoutTests/inspector/canvas/resolveContext-bitmaprenderer.html
r249785 r249786 12 12 function test() 13 13 { 14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC anvasContextBitmapRenderer");14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextBitmapRenderer"); 15 15 16 16 suite.addTestCase({ 17 name: `Canvas.resolveC anvasContextBitmapRenderer.validIdentifier`,17 name: `Canvas.resolveContextBitmapRenderer.validIdentifier`, 18 18 description: "Should return a valid object for the given canvas identifier.", 19 19 test(resolve, reject) { … … 25 25 26 26 const objectGroup = "test"; 27 CanvasAgent.resolveC anvasContext(canvas.identifier, objectGroup)27 CanvasAgent.resolveContext(canvas.identifier, objectGroup) 28 28 .then(({object}) => { 29 29 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 39 39 </head> 40 40 <body onload="load()"> 41 <p>Tests for the Canvas.resolveC anvasContext command for BitmapRenderer contexts.</p>41 <p>Tests for the Canvas.resolveContext command for BitmapRenderer contexts.</p> 42 42 </body> 43 43 </html> -
trunk/LayoutTests/inspector/canvas/resolveContext-webgl.html
r249785 r249786 12 12 function test() 13 13 { 14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC anvasContextWebGL");14 let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextWebGL"); 15 15 16 16 suite.addTestCase({ 17 name: `Canvas.resolveC anvasContextWebGL.validIdentifier`,17 name: `Canvas.resolveContextWebGL.validIdentifier`, 18 18 description: "Should return a valid object for the given canvas identifier.", 19 19 test(resolve, reject) { … … 25 25 26 26 const objectGroup = "test"; 27 CanvasAgent.resolveC anvasContext(canvas.identifier, objectGroup)27 CanvasAgent.resolveContext(canvas.identifier, objectGroup) 28 28 .then(({object}) => { 29 29 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 39 39 </head> 40 40 <body onload="load()"> 41 <p>Tests for the Canvas.resolveC anvasContext command for WebGL contexts.</p>41 <p>Tests for the Canvas.resolveContext command for WebGL contexts.</p> 42 42 </body> 43 43 </html> -
trunk/LayoutTests/inspector/canvas/resolveContext-webgl2.html
r249785 r249786 15 15 function test() 16 16 { 17 let suite = InspectorTest.createAsyncSuite("Canvas.resolveC anvasContextWebGL2");17 let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextWebGL2"); 18 18 19 19 suite.addTestCase({ 20 name: `Canvas.resolveC anvasContextWebGL2.validIdentifier`,20 name: `Canvas.resolveContextWebGL2.validIdentifier`, 21 21 description: "Should return a valid object for the given canvas identifier.", 22 22 test(resolve, reject) { … … 28 28 29 29 const objectGroup = "test"; 30 CanvasAgent.resolveC anvasContext(canvas.identifier, objectGroup)30 CanvasAgent.resolveContext(canvas.identifier, objectGroup) 31 31 .then(({object}) => { 32 32 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`); … … 42 42 </head> 43 43 <body onload="load()"> 44 <p>Tests for the Canvas.resolveC anvasContext command for WebGL2 contexts.</p>44 <p>Tests for the Canvas.resolveContext command for WebGL2 contexts.</p> 45 45 </body> 46 46 </html> -
trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js
r249776 r249786 1 letcontexts = [];1 window.contexts = []; 2 2 3 3 function createAttachedCanvas(contextType) { … … 6 6 if (!context) 7 7 TestPage.addResult("FAIL: missing context for type " + contextType); 8 contexts.push(context);8 window.contexts.push(context); 9 9 } 10 10 … … 13 13 if (!context) 14 14 TestPage.addResult("FAIL: missing context for type " + contextType); 15 contexts.push(context);15 window.contexts.push(context); 16 16 } 17 17 … … 20 20 if (!context) 21 21 TestPage.addResult("FAIL: missing context for type " + contextType); 22 contexts.push();22 window.contexts.push(); 23 23 } 24 24 25 25 function destroyCanvases() { 26 for (let context of contexts) {26 for (let context of window.contexts) { 27 27 if (!context) 28 28 continue; … … 33 33 } 34 34 35 contexts = [];35 window.contexts = []; 36 36 37 37 // Force GC to make sure the canvas element is destroyed, otherwise the frontend -
trunk/LayoutTests/platform/gtk/TestExpectations
r249776 r249786 517 517 webkit.org/b/166536 inspector/canvas/recording-webgl2-snapshots.html [ Skip ] 518 518 webkit.org/b/166536 inspector/canvas/requestContent-webgl2.html [ Skip ] 519 webkit.org/b/166536 inspector/canvas/resolveC anvasContext-webgl2.html [ Skip ]519 webkit.org/b/166536 inspector/canvas/resolveContext-webgl2.html [ Skip ] 520 520 webkit.org/b/166536 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] 521 521 webkit.org/b/166536 webgl/2.0.0/ [ Skip ] … … 1151 1151 webkit.org/b/191005 webgpu/ [ Skip ] 1152 1152 webkit.org/b/191005 inspector/canvas/create-context-webgpu.html [ Skip ] 1153 webkit.org/b/191005 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 1153 webkit.org/b/191005 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 1154 webkit.org/b/191005 inspector/canvas/resolveContext-webgpu.html [ Skip ] 1154 1155 1155 1156 # No support for resource load statistics yet -
trunk/LayoutTests/platform/ios/TestExpectations
r249776 r249786 45 45 webgpu [ Skip ] 46 46 inspector/canvas/create-context-webgpu.html [ Skip ] 47 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 47 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 48 inspector/canvas/resolveContext-webgpu.html [ Skip ] 48 49 49 50 # Encrypted Media Extensions are not enabled -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r249776 r249786 47 47 webgpu [ Skip ] 48 48 inspector/canvas/create-context-webgpu.html [ Skip ] 49 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 49 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 50 inspector/canvas/resolveContext-webgpu.html [ Skip ] 50 51 51 52 # Media Stream API testing is not supported for WK1 yet. -
trunk/LayoutTests/platform/mac/TestExpectations
r249776 r249786 1033 1033 webkit.org/b/178028 inspector/canvas/create-context-2d.html [ Pass Timeout ] 1034 1034 webkit.org/b/174066 inspector/canvas/create-context-webgl2.html [ Pass Timeout ] 1035 webkit.org/b/174272 inspector/canvas/css-canvas-clients.html [ Pass Failure ]1036 1035 webkit.org/b/174066 inspector/canvas/recording-webgl2-frameCount.html [ Pass Failure Timeout ] 1037 1036 webkit.org/b/174066 inspector/canvas/recording-webgl2-full.html [ Pass Failure Timeout ] 1038 1037 webkit.org/b/174066 inspector/canvas/recording-webgl2-memoryLimit.html [ Pass Failure Timeout ] 1039 1038 webkit.org/b/174066 inspector/canvas/recording-webgl2-snapshots.html [ Pass Failure Timeout ] 1039 webkit.org/b/174272 inspector/canvas/requestClientNodes-css.html [ Pass Failure ] 1040 1040 webkit.org/b/174066 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Pass Failure Timeout ] 1041 1041 webkit.org/b/160048 [ Debug ] inspector/codemirror/prettyprinting-javascript.html [ Pass Timeout ] … … 1784 1784 webkit.org/b/199275 [ HighSierra ] webgpu [ Skip ] 1785 1785 webkit.org/b/199275 [ HighSierra ] inspector/canvas/create-context-webgpu.html [ Skip ] 1786 webkit.org/b/199275 [ HighSierra ] inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 1786 webkit.org/b/199275 [ HighSierra ] inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 1787 webkit.org/b/199275 [ HighSierra ] inspector/canvas/resolveContext-webgpu.html [ Skip ] 1787 1788 1788 1789 webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ] -
trunk/LayoutTests/platform/win/TestExpectations
r249776 r249786 2002 2002 inspector/canvas/requestContent-webgl2.html [ Skip ] 2003 2003 inspector/canvas/requestShaderSource.html [ Skip ] 2004 inspector/canvas/resolveC anvasContext-webgl.html [ Skip ]2005 inspector/canvas/resolveC anvasContext-webgl2.html [ Skip ]2004 inspector/canvas/resolveContext-webgl.html [ Skip ] 2005 inspector/canvas/resolveContext-webgl2.html [ Skip ] 2006 2006 inspector/canvas/shaderProgram-add-remove-webgl.html [ Skip ] 2007 2007 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] … … 4245 4245 webgpu [ Skip ] 4246 4246 inspector/canvas/create-context-webgpu.html [ Skip ] 4247 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 4247 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 4248 inspector/canvas/resolveContext-webgpu.html [ Skip ] 4248 4249 4249 4250 webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ] -
trunk/LayoutTests/platform/wincairo/TestExpectations
r249776 r249786 290 290 inspector/canvas/recording-webgl2.html [ Skip ] 291 291 inspector/canvas/recording-webgl2-snapshots.html [ Skip ] 292 inspector/canvas/resolveC anvasContext-webgl2.html [ Skip ]292 inspector/canvas/resolveContext-webgl2.html [ Skip ] 293 293 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] 294 294 webgl/webgl2-rendering-context-defined.html [ Skip ] … … 298 298 webgpu [ Skip ] 299 299 inspector/canvas/create-context-webgpu.html [ Skip ] 300 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 300 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 301 inspector/canvas/resolveContext-webgpu.html [ Skip ] 301 302 302 303 # WIRELESS_PLAYBACK_TARGET is disabled -
trunk/LayoutTests/platform/wpe/TestExpectations
r249776 r249786 303 303 webgpu [ Skip ] 304 304 inspector/canvas/create-context-webgpu.html [ Skip ] 305 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ] 305 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 306 inspector/canvas/resolveContext-webgpu.html [ Skip ] 306 307 307 308 # Skipped due to untestable DRM key system. ClearKey counterparts are tested instead. -
trunk/Source/JavaScriptCore/ChangeLog
r249780 r249786 1 2019-09-11 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Canvas: instrument WebGPUDevice instead of GPUCanvasContext 4 https://bugs.webkit.org/show_bug.cgi?id=201650 5 6 Reviewed by Joseph Pecoraro. 7 8 Most of the actual "work" done with Web GPU actually uses a `WebGPUDevice`. 9 10 A `GPUCanvasContext` is basically just a display "client" of the device, and isn't even 11 required (e.g. compute pipeline). We should treat the `GPUCanvasContext` almost like a 12 `-webkit-canvas` client of a `WebGPUDevice`. 13 14 * inspector/protocol/Canvas.json: 15 - Add `powerPreference` key to `ContextAttributes` type. 16 - Rename `requestCSSCanvasClientNodes` command to `requestClientNodes` for the above reason. 17 - Rename `cssCanvasClientNodesChanged` event to `clientNodesChanged` for the above reason. 18 - Rename `resolveCanvasContext` command to `resolveContext` since a `WebGPUDevice` isn't 19 really a "canvas". 20 1 21 2019-09-11 Yusuke Suzuki <ysuzuki@apple.com> 2 22 -
trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json
r249776 r249786 31 31 "description": "Drawing surface attributes.", 32 32 "properties": [ 33 { "name": "alpha", "type": "boolean", "optional": true }, 34 { "name": "depth", "type": "boolean", "optional": true }, 35 { "name": "stencil", "type": "boolean", "optional": true }, 36 { "name": "antialias", "type": "boolean", "optional": true }, 37 { "name": "premultipliedAlpha", "type": "boolean", "optional": true }, 38 { "name": "preserveDrawingBuffer", "type": "boolean", "optional": true }, 39 { "name": "failIfMajorPerformanceCaveat", "type": "boolean", "optional": true } 33 { "name": "alpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2, ImageBitmapRenderingContext" }, 34 { "name": "depth", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" }, 35 { "name": "stencil", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" }, 36 { "name": "antialias", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" }, 37 { "name": "premultipliedAlpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" }, 38 { "name": "preserveDrawingBuffer", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" }, 39 { "name": "failIfMajorPerformanceCaveat", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" }, 40 { "name": "powerPreference", "type": "string", "optional": true, "description": "WebGL, WebGL2, WebGPU" } 40 41 ] 41 42 }, … … 85 86 }, 86 87 { 87 "name": "requestC SSCanvasClientNodes",88 "description": "Gets all the nodes that are using this canvas via -webkit-canvas.",88 "name": "requestClientNodes", 89 "description": "Gets all <code>-webkit-canvas</code> nodes or active <code>HTMLCanvasElement</code> for a <code>WebGPUDevice</code>.", 89 90 "parameters": [ 90 91 { "name": "canvasId", "$ref": "CanvasId" } … … 95 96 }, 96 97 { 97 "name": "resolveC anvasContext",98 "description": "Resolves JavaScript canvas context object for given canvasId.",98 "name": "resolveContext", 99 "description": "Resolves JavaScript canvas/device context object for given canvasId.", 99 100 "parameters": [ 100 101 { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." }, … … 193 194 }, 194 195 { 195 "name": "c ssCanvasClientNodesChanged",196 "name": "clientNodesChanged", 196 197 "parameters": [ 197 198 { "name": "canvasId", "$ref": "CanvasId", "description": "Identifier of canvas that changed." } -
trunk/Source/WebCore/ChangeLog
r249781 r249786 1 2019-09-11 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Canvas: instrument WebGPUDevice instead of GPUCanvasContext 4 https://bugs.webkit.org/show_bug.cgi?id=201650 5 6 Reviewed by Joseph Pecoraro. 7 8 Most of the actual "work" done with Web GPU actually uses a `WebGPUDevice`. 9 10 A `GPUCanvasContext` is basically just a display "client" of the device, and isn't even 11 required (e.g. compute pipeline). We should treat the `GPUCanvasContext` almost like a 12 `-webkit-canvas` client of a `WebGPUDevice`. 13 14 Tests: inspector/canvas/create-context-webgpu.html 15 inspector/canvas/requestClientNodes-webgpu.html 16 inspector/canvas/resolveContext-webgpu.html 17 18 * Modules/webgpu/WebGPUAdapter.cpp: 19 (WebCore::WebGPUAdapter::requestDevice const): 20 Notify web inspector after a device is created. 21 22 * Modules/webgpu/WebGPUDevice.idl: 23 * Modules/webgpu/WebGPUDevice.h: 24 * Modules/webgpu/WebGPUDevice.cpp: 25 (WebCore::WebGPUDevice::instances): Added. 26 (WebCore::WebGPUDevice::instancesMutex): Added. 27 (WebCore::WebGPUDevice::~WebGPUDevice): Added. 28 Notify web inspector when the device is about to be destructed. 29 30 * Modules/webgpu/GPUCanvasContext.h: 31 * Modules/webgpu/GPUCanvasContext.cpp: 32 (WebCore::GPUCanvasContext::create): 33 (WebCore::GPUCanvasContext::configureSwapChain): 34 35 * inspector/InspectorCanvas.h: 36 * inspector/InspectorCanvas.cpp: 37 (WebCore::canvasIfContextMatchesDevice): Added. 38 (WebCore::InspectorCanvas::create): 39 (WebCore::InspectorCanvas::InspectorCanvas): 40 (WebCore::InspectorCanvas::canvasContext const): Added. 41 (WebCore::InspectorCanvas::canvasElement const): Added. 42 (WebCore::InspectorCanvas::isDeviceForCanvasContext const): Added. 43 (WebCore::InspectorCanvas::deviceContext const): Added. 44 (WebCore::InspectorCanvas::scriptExecutionContext const): Added. 45 (WebCore::InspectorCanvas::resolveContext const): Added. 46 (WebCore::InspectorCanvas::clientNodes const): Added. 47 (WebCore::InspectorCanvas::canvasChanged): 48 (WebCore::InspectorCanvas::resetRecordingData): 49 (WebCore::InspectorCanvas::recordAction): 50 (WebCore::InspectorCanvas::buildObjectForCanvas): 51 (WebCore::InspectorCanvas::releaseObjectForRecording): 52 (WebCore::InspectorCanvas::getCanvasContentAsDataURL): 53 (WebCore::InspectorCanvas::buildInitialState): 54 (WebCore::InspectorCanvas::canvasElement): Deleted. 55 * inspector/InspectorInstrumentation.cpp: 56 (WebCore::InspectorInstrumentation::didCreateWebGPUDeviceImpl): Added. 57 (WebCore::InspectorInstrumentation::willDestroyWebGPUDeviceImpl): Added. 58 (WebCore::InspectorInstrumentation::willConfigureSwapChainImpl): Added. 59 * inspector/InspectorInstrumentation.h: 60 (WebCore::InspectorInstrumentation::didCreateWebGPUDevice): Added. 61 (WebCore::InspectorInstrumentation::willDestroyWebGPUDevice): Added. 62 (WebCore::InspectorInstrumentation::willConfigureSwapChain): Added. 63 64 * inspector/agents/InspectorCanvasAgent.h: 65 * inspector/agents/InspectorCanvasAgent.cpp: 66 (WebCore::InspectorCanvasAgent::enable): 67 (WebCore::InspectorCanvasAgent::requestClientNodes): Added. 68 (WebCore::InspectorCanvasAgent::resolveContext): Added. 69 (WebCore::InspectorCanvasAgent::startRecording): 70 (WebCore::InspectorCanvasAgent::stopRecording): 71 (WebCore::InspectorCanvasAgent::frameNavigated): 72 (WebCore::InspectorCanvasAgent::didChangeCSSCanvasClientNodes): 73 (WebCore::InspectorCanvasAgent::didChangeCanvasMemory): 74 (WebCore::InspectorCanvasAgent::canvasDestroyed): 75 (WebCore::InspectorCanvasAgent::recordCanvasAction): 76 (WebCore::InspectorCanvasAgent::didFinishRecordingCanvasFrame): 77 (WebCore::InspectorCanvasAgent::didCreateWebGPUDevice): Added. 78 (WebCore::InspectorCanvasAgent::willDestroyWebGPUDevice): Added. 79 (WebCore::InspectorCanvasAgent::willConfigureSwapChain): Added. 80 (WebCore::InspectorCanvasAgent::clearCanvasData): 81 (WebCore::InspectorCanvasAgent::bindCanvas): 82 (WebCore::InspectorCanvasAgent::unbindCanvas): 83 (WebCore::InspectorCanvasAgent::findInspectorCanvas): 84 (WebCore::InspectorCanvasAgent::requestCSSCanvasClientNodes): Deleted. 85 (WebCore::contextAsScriptValue): Deleted. 86 (WebCore::InspectorCanvasAgent::resolveCanvasContext): Deleted. 87 88 * inspector/InspectorShaderProgram.cpp: 89 (WebCore::InspectorShaderProgram::context const): 90 1 91 2019-09-11 Chris Dumez <cdumez@apple.com> 2 92 -
trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp
r249776 r249786 42 42 auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas)); 43 43 context->suspendIfNeeded(); 44 45 InspectorInstrumentation::didCreateCanvasRenderingContext(*context);46 47 44 return context; 48 45 } … … 68 65 if (m_swapChain) 69 66 m_swapChain->destroy(); 70 67 68 InspectorInstrumentation::willConfigureSwapChain(*this, newSwapChain.get()); 69 71 70 m_swapChain = newSwapChain.copyRef(); 71 72 72 notifyCanvasContentChanged(); 73 73 } -
trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h
r249776 r249786 44 44 HTMLCanvasElement& canvas() const { return downcast<HTMLCanvasElement>(canvasBase()); } 45 45 46 WebGPUSwapChain* swapChain() const { return m_swapChain.get(); } 46 47 Ref<WebGPUSwapChain> configureSwapChain(const WebGPUSwapChainDescriptor&); 47 48 -
trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.cpp
r249776 r249786 30 30 31 31 #include "Document.h" 32 #include "InspectorInstrumentation.h" 32 33 #include "JSWebGPUDevice.h" 33 34 … … 47 48 { 48 49 document.postTask([protectedThis = makeRef(*this), promise = WTFMove(promise)] (ScriptExecutionContext& context) mutable { 49 if (auto device = WebGPUDevice::tryCreate(context, protectedThis.get())) 50 if (auto device = WebGPUDevice::tryCreate(context, protectedThis.get())) { 51 InspectorInstrumentation::didCreateWebGPUDevice(*device); 52 50 53 promise.resolve(device.releaseNonNull()); 51 else54 } else 52 55 promise.reject(); 53 56 }); -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r249776 r249786 48 48 #include "GPUTextureDescriptor.h" 49 49 #include "GPUUncapturedErrorEvent.h" 50 #include "InspectorInstrumentation.h" 50 51 #include "JSDOMConvertBufferSource.h" 51 52 #include "JSGPUOutOfMemoryError.h" … … 74 75 #include <JavaScriptCore/ConsoleMessage.h> 75 76 #include <memory> 77 #include <wtf/HashSet.h> 76 78 #include <wtf/IsoMallocInlines.h> 79 #include <wtf/Lock.h> 77 80 #include <wtf/MainThread.h> 81 #include <wtf/NeverDestroyed.h> 78 82 #include <wtf/Optional.h> 83 #include <wtf/Ref.h> 84 #include <wtf/RefPtr.h> 79 85 #include <wtf/Variant.h> 86 #include <wtf/Vector.h> 80 87 #include <wtf/text/WTFString.h> 81 88 … … 89 96 return adoptRef(new WebGPUDevice(context, WTFMove(adapter), device.releaseNonNull())); 90 97 return nullptr; 98 } 99 100 HashSet<WebGPUDevice*>& WebGPUDevice::instances(const LockHolder&) 101 { 102 static NeverDestroyed<HashSet<WebGPUDevice*>> instances; 103 return instances; 104 } 105 106 Lock& WebGPUDevice::instancesMutex() 107 { 108 static LazyNeverDestroyed<Lock> mutex; 109 static std::once_flag initializeMutex; 110 std::call_once(initializeMutex, [] { 111 mutex.construct(); 112 }); 113 return mutex.get(); 91 114 } 92 115 … … 101 124 { 102 125 ASSERT(m_scriptExecutionContext.isDocument()); 126 127 LockHolder lock(instancesMutex()); 128 instances(lock).add(this); 129 } 130 131 WebGPUDevice::~WebGPUDevice() 132 { 133 InspectorInstrumentation::willDestroyWebGPUDevice(*this); 134 135 LockHolder lock(instancesMutex()); 136 ASSERT(instances(lock).contains(this)); 137 instances(lock).remove(this); 103 138 } 104 139 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r249776 r249786 35 35 #include "WebGPUQueue.h" 36 36 #include "WebGPUSwapChainDescriptor.h" 37 #include <wtf/ Ref.h>37 #include <wtf/Forward.h> 38 38 #include <wtf/RefCounted.h> 39 #include <wtf/RefPtr.h>40 #include <wtf/Vector.h>41 39 #include <wtf/WeakPtr.h> 42 40 … … 81 79 WTF_MAKE_ISO_ALLOCATED(WebGPUDevice); 82 80 public: 81 virtual ~WebGPUDevice(); 82 83 83 static RefPtr<WebGPUDevice> tryCreate(ScriptExecutionContext&, Ref<const WebGPUAdapter>&&); 84 85 static HashSet<WebGPUDevice*>& instances(const LockHolder&); 86 static Lock& instancesMutex(); 84 87 85 88 const WebGPUAdapter& adapter() const { return m_adapter.get(); } … … 107 110 void popErrorScope(ErrorPromise&&); 108 111 112 ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; } 113 109 114 using RefCounted::ref; 110 115 using RefCounted::deref; … … 115 120 // EventTarget 116 121 EventTargetInterface eventTargetInterface() const final { return WebGPUDeviceEventTargetInterfaceType; } 117 ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }118 122 void refEventTarget() final { ref(); } 119 123 void derefEventTarget() final { deref(); } -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl
r249776 r249786 30 30 Conditional=WEBGPU, 31 31 EnabledAtRuntime=WebGPU, 32 InterfaceName=GPUDevice 32 InterfaceName=GPUDevice, 33 JSGenerateToJSObject, 33 34 ] interface WebGPUDevice : EventTarget { 34 35 readonly attribute WebGPUAdapter adapter; -
trunk/Source/WebCore/inspector/InspectorCanvas.cpp
r249776 r249786 34 34 #include "CanvasRenderingContext2D.h" 35 35 #include "Document.h" 36 #include "Element.h" 36 37 #include "FloatPoint.h" 37 38 #include "Gradient.h" … … 49 50 #include "JSCanvasLineCap.h" 50 51 #include "JSCanvasLineJoin.h" 52 #include "JSCanvasRenderingContext2D.h" 51 53 #include "JSCanvasTextAlign.h" 52 54 #include "JSCanvasTextBaseline.h" 53 55 #include "JSExecState.h" 56 #include "JSImageBitmapRenderingContext.h" 54 57 #include "JSImageSmoothingQuality.h" 55 58 #include "Path2D.h" … … 58 61 #include "SVGPathUtilities.h" 59 62 #include "StringAdaptors.h" 60 #if ENABLE(CSS_TYPED_OM)61 #include "TypedOMCSSImageValue.h"62 #endif63 #if ENABLE(WEBGL)64 #include "WebGLRenderingContext.h"65 #endif66 #if ENABLE(WEBGL2)67 #include "WebGL2RenderingContext.h"68 #endif69 #if ENABLE(WEBGPU)70 #include "GPUCanvasContext.h"71 #endif72 63 #include <JavaScriptCore/IdentifiersFactory.h> 73 64 #include <JavaScriptCore/ScriptCallStackFactory.h> 74 65 #include <wtf/Function.h> 75 66 67 #if ENABLE(CSS_TYPED_OM) 68 #include "TypedOMCSSImageValue.h" 69 #endif 70 71 #if ENABLE(WEBGL) 72 #include "JSWebGLRenderingContext.h" 73 #include "WebGLRenderingContext.h" 74 #endif 75 76 #if ENABLE(WEBGL2) 77 #include "JSWebGL2RenderingContext.h" 78 #include "WebGL2RenderingContext.h" 79 #endif 80 81 #if ENABLE(WEBGPU) 82 #include "GPUCanvasContext.h" 83 #include "JSWebGPUDevice.h" 84 #include "WebGPUDevice.h" 85 #endif 86 76 87 namespace WebCore { 77 88 78 89 using namespace Inspector; 79 90 91 #if ENABLE(WEBGPU) 92 static HTMLCanvasElement* canvasIfContextMatchesDevice(CanvasRenderingContext& context, WebGPUDevice& device) 93 { 94 if (is<GPUCanvasContext>(context)) { 95 auto& contextGPU = downcast<GPUCanvasContext>(context); 96 if (auto* webGPUSwapChain = contextGPU.swapChain()) { 97 if (auto* gpuSwapChain = webGPUSwapChain->swapChain()) { 98 if (gpuSwapChain == device.device().swapChain()) { 99 if (is<HTMLCanvasElement>(contextGPU.canvasBase())) 100 return &downcast<HTMLCanvasElement>(contextGPU.canvasBase()); 101 } 102 } 103 } 104 } 105 return nullptr; 106 } 107 #endif 108 80 109 Ref<InspectorCanvas> InspectorCanvas::create(CanvasRenderingContext& context) 81 110 { 82 111 return adoptRef(*new InspectorCanvas(context)); 83 112 } 113 114 #if ENABLE(WEBGPU) 115 Ref<InspectorCanvas> InspectorCanvas::create(WebGPUDevice& device) 116 { 117 return adoptRef(*new InspectorCanvas(device)); 118 } 119 #endif 84 120 85 121 InspectorCanvas::InspectorCanvas(CanvasRenderingContext& context) … … 87 123 , m_context(context) 88 124 { 89 } 90 91 HTMLCanvasElement* InspectorCanvas::canvasElement() 92 { 93 if (is<HTMLCanvasElement>(m_context.canvasBase())) 94 return &downcast<HTMLCanvasElement>(m_context.canvasBase()); 125 #if ENABLE(WEBGPU) 126 // The actual "context" for WebGPU is the `WebGPUDevice`, not the <canvas>. 127 ASSERT(!is<GPUCanvasContext>(context)); 128 #endif 129 } 130 131 #if ENABLE(WEBGPU) 132 InspectorCanvas::InspectorCanvas(WebGPUDevice& device) 133 : m_identifier("canvas:" + IdentifiersFactory::createIdentifier()) 134 , m_context(device) 135 { 136 } 137 #endif 138 139 CanvasRenderingContext* InspectorCanvas::canvasContext() const 140 { 141 if (auto* contextWrapper = WTF::get_if<std::reference_wrapper<CanvasRenderingContext>>(m_context)) 142 return &contextWrapper->get(); 95 143 return nullptr; 96 144 } 97 145 146 HTMLCanvasElement* InspectorCanvas::canvasElement() const 147 { 148 return WTF::switchOn(m_context, 149 [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> HTMLCanvasElement* { 150 auto& context = contextWrapper.get(); 151 if (is<HTMLCanvasElement>(context.canvasBase())) 152 return &downcast<HTMLCanvasElement>(context.canvasBase()); 153 return nullptr; 154 }, 155 #if ENABLE(WEBGPU) 156 [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) -> HTMLCanvasElement* { 157 auto& device = deviceWrapper.get(); 158 { 159 LockHolder lock(CanvasRenderingContext::instancesMutex()); 160 for (auto* canvasRenderingContext : CanvasRenderingContext::instances(lock)) { 161 if (auto* canvasElement = canvasIfContextMatchesDevice(*canvasRenderingContext, device)) 162 return canvasElement; 163 } 164 } 165 return nullptr; 166 }, 167 #endif 168 [] (Monostate) { 169 ASSERT_NOT_REACHED(); 170 return nullptr; 171 } 172 ); 173 return nullptr; 174 } 175 176 #if ENABLE(WEBGPU) 177 WebGPUDevice* InspectorCanvas::deviceContext() const 178 { 179 if (auto* deviceWrapper = WTF::get_if<std::reference_wrapper<WebGPUDevice>>(m_context)) 180 return &deviceWrapper->get(); 181 return nullptr; 182 } 183 184 bool InspectorCanvas::isDeviceForCanvasContext(CanvasRenderingContext& context) const 185 { 186 if (auto* device = deviceContext()) 187 return canvasIfContextMatchesDevice(context, *device); 188 return false; 189 } 190 #endif 191 192 ScriptExecutionContext* InspectorCanvas::scriptExecutionContext() const 193 { 194 return WTF::switchOn(m_context, 195 [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) { 196 auto& context = contextWrapper.get(); 197 return context.canvasBase().scriptExecutionContext(); 198 }, 199 #if ENABLE(WEBGPU) 200 [] (std::reference_wrapper<WebGPUDevice> deviceWrapper) { 201 auto& device = deviceWrapper.get(); 202 return device.scriptExecutionContext(); 203 }, 204 #endif 205 [] (Monostate) { 206 ASSERT_NOT_REACHED(); 207 return nullptr; 208 } 209 ); 210 } 211 212 JSC::JSValue InspectorCanvas::resolveContext(ExecState* exec) const 213 { 214 JSC::JSLockHolder lock(exec); 215 216 auto* globalObject = deprecatedGlobalObjectForPrototype(exec); 217 218 return WTF::switchOn(m_context, 219 [&] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) { 220 auto& context = contextWrapper.get(); 221 if (is<CanvasRenderingContext2D>(context)) 222 return toJS(exec, globalObject, downcast<CanvasRenderingContext2D>(context)); 223 if (is<ImageBitmapRenderingContext>(context)) 224 return toJS(exec, globalObject, downcast<ImageBitmapRenderingContext>(context)); 225 #if ENABLE(WEBGL) 226 if (is<WebGLRenderingContext>(context)) 227 return toJS(exec, globalObject, downcast<WebGLRenderingContext>(context)); 228 #endif 229 #if ENABLE(WEBGL2) 230 if (is<WebGL2RenderingContext>(context)) 231 return toJS(exec, globalObject, downcast<WebGL2RenderingContext>(context)); 232 #endif 233 return JSC::JSValue(); 234 }, 235 #if ENABLE(WEBGPU) 236 [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) { 237 return toJS(exec, globalObject, deviceWrapper.get()); 238 }, 239 #endif 240 [] (Monostate) { 241 ASSERT_NOT_REACHED(); 242 return JSC::JSValue(); 243 } 244 ); 245 } 246 247 HashSet<Element*> InspectorCanvas::clientNodes() const 248 { 249 return WTF::switchOn(m_context, 250 [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) { 251 auto& context = contextWrapper.get(); 252 return context.canvasBase().cssCanvasClients(); 253 }, 254 #if ENABLE(WEBGPU) 255 [&] (std::reference_wrapper<WebGPUDevice> deviceWrapper) { 256 auto& device = deviceWrapper.get(); 257 258 HashSet<Element*> canvasElementClients; 259 { 260 LockHolder lock(CanvasRenderingContext::instancesMutex()); 261 for (auto* canvasRenderingContext : CanvasRenderingContext::instances(lock)) { 262 if (auto* canvasElement = canvasIfContextMatchesDevice(*canvasRenderingContext, device)) 263 canvasElementClients.add(canvasElement); 264 } 265 } 266 return canvasElementClients; 267 }, 268 #endif 269 [] (Monostate) { 270 ASSERT_NOT_REACHED(); 271 return HashSet<Element*>(); 272 } 273 ); 274 } 275 98 276 void InspectorCanvas::canvasChanged() 99 277 { 100 if (!m_context.callTracingActive()) 278 auto* context = canvasContext(); 279 ASSERT(context); 280 281 if (!context->callTracingActive()) 101 282 return; 102 283 103 284 // Since 2D contexts are able to be fully reproduced in the frontend, we don't need snapshots. 104 if (is<CanvasRenderingContext2D>( m_context))285 if (is<CanvasRenderingContext2D>(context)) 105 286 return; 106 287 … … 122 303 m_contentChanged = false; 123 304 124 m_context.setCallTracingActive(false); 305 auto* context = canvasContext(); 306 ASSERT(context); 307 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 308 309 context->setCallTracingActive(false); 125 310 } 126 311 … … 192 377 m_currentActions->addItem(m_lastRecordedAction.get()); 193 378 194 if (is<ImageBitmapRenderingContext>(m_context) && shouldSnapshotBitmapRendererAction(name)) 379 auto* context = canvasContext(); 380 ASSERT(context); 381 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 382 383 if (is<ImageBitmapRenderingContext>(context) && shouldSnapshotBitmapRendererAction(name)) 195 384 m_contentChanged = true; 196 385 #if ENABLE(WEBGL) 197 else if (is<WebGLRenderingContext>( m_context) && shouldSnapshotWebGLAction(name))386 else if (is<WebGLRenderingContext>(context) && shouldSnapshotWebGLAction(name)) 198 387 m_contentChanged = true; 199 388 #endif 200 389 #if ENABLE(WEBGL2) 201 else if (is<WebGL2RenderingContext>( m_context) && shouldSnapshotWebGL2Action(name))390 else if (is<WebGL2RenderingContext>(context) && shouldSnapshotWebGL2Action(name)) 202 391 m_contentChanged = true; 203 392 #endif … … 251 440 Ref<Inspector::Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace) 252 441 { 253 Inspector::Protocol::Canvas::ContextType contextType; 254 if (is<CanvasRenderingContext2D>(m_context)) 255 contextType = Inspector::Protocol::Canvas::ContextType::Canvas2D; 256 else if (is<ImageBitmapRenderingContext>(m_context)) 257 contextType = Inspector::Protocol::Canvas::ContextType::BitmapRenderer; 442 using ContextTypeType = Optional<Inspector::Protocol::Canvas::ContextType>; 443 auto contextType = WTF::switchOn(m_context, 444 [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> ContextTypeType { 445 auto& context = contextWrapper.get(); 446 if (is<CanvasRenderingContext2D>(context)) 447 return Inspector::Protocol::Canvas::ContextType::Canvas2D; 448 if (is<ImageBitmapRenderingContext>(context)) 449 return Inspector::Protocol::Canvas::ContextType::BitmapRenderer; 258 450 #if ENABLE(WEBGL) 259 else if (is<WebGLRenderingContext>(m_context))260 contextType =Inspector::Protocol::Canvas::ContextType::WebGL;451 if (is<WebGLRenderingContext>(context)) 452 return Inspector::Protocol::Canvas::ContextType::WebGL; 261 453 #endif 262 454 #if ENABLE(WEBGL2) 263 else if (is<WebGL2RenderingContext>(m_context)) 264 contextType = Inspector::Protocol::Canvas::ContextType::WebGL2; 265 #endif 455 if (is<WebGL2RenderingContext>(context)) 456 return Inspector::Protocol::Canvas::ContextType::WebGL2; 457 #endif 458 return WTF::nullopt; 459 }, 266 460 #if ENABLE(WEBGPU) 267 else if (is<GPUCanvasContext>(m_context)) 268 contextType = Inspector::Protocol::Canvas::ContextType::WebGPU; 269 #endif 270 else { 461 [] (std::reference_wrapper<WebGPUDevice>) { 462 return Inspector::Protocol::Canvas::ContextType::WebGPU; 463 }, 464 #endif 465 [] (Monostate) { 466 ASSERT_NOT_REACHED(); 467 return WTF::nullopt; 468 } 469 ); 470 if (!contextType) { 271 471 ASSERT_NOT_REACHED(); 272 472 contextType = Inspector::Protocol::Canvas::ContextType::Canvas2D; … … 275 475 auto canvas = Inspector::Protocol::Canvas::Canvas::create() 276 476 .setCanvasId(m_identifier) 277 .setContextType(contextType )477 .setContextType(contextType.value()) 278 478 .release(); 279 479 … … 286 486 } 287 487 288 if (is<ImageBitmapRenderingContext>(m_context)) { 289 auto contextAttributes = Inspector::Protocol::Canvas::ContextAttributes::create() 290 .release(); 291 contextAttributes->setAlpha(downcast<ImageBitmapRenderingContext>(m_context).hasAlpha()); 488 using ContextAttributesType = RefPtr<Inspector::Protocol::Canvas::ContextAttributes>; 489 auto contextAttributes = WTF::switchOn(m_context, 490 [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> ContextAttributesType { 491 auto& context = contextWrapper.get(); 492 if (is<ImageBitmapRenderingContext>(context)) { 493 auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create() 494 .release(); 495 contextAttributesPayload->setAlpha(downcast<ImageBitmapRenderingContext>(context).hasAlpha()); 496 return WTFMove(contextAttributesPayload); 497 } 498 499 #if ENABLE(WEBGL) 500 if (is<WebGLRenderingContextBase>(context)) { 501 if (const auto& attributes = downcast<WebGLRenderingContextBase>(context).getContextAttributes()) { 502 auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create() 503 .release(); 504 contextAttributesPayload->setAlpha(attributes->alpha); 505 contextAttributesPayload->setDepth(attributes->depth); 506 contextAttributesPayload->setStencil(attributes->stencil); 507 contextAttributesPayload->setAntialias(attributes->antialias); 508 contextAttributesPayload->setPremultipliedAlpha(attributes->premultipliedAlpha); 509 contextAttributesPayload->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer); 510 switch (attributes->powerPreference) { 511 case WebGLPowerPreference::Default: 512 contextAttributesPayload->setPowerPreference("default"); 513 break; 514 case WebGLPowerPreference::LowPower: 515 contextAttributesPayload->setPowerPreference("low-power"); 516 break; 517 case WebGLPowerPreference::HighPerformance: 518 contextAttributesPayload->setPowerPreference("high-performance"); 519 break; 520 } 521 contextAttributesPayload->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat); 522 return WTFMove(contextAttributesPayload); 523 } 524 } 525 #endif 526 return nullptr; 527 }, 528 #if ENABLE(WEBGPU) 529 [] (std::reference_wrapper<WebGPUDevice> deviceWrapper) -> ContextAttributesType { 530 auto& device = deviceWrapper.get(); 531 if (const auto& options = device.adapter().options()) { 532 auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create() 533 .release(); 534 if (const auto& powerPreference = options->powerPreference) { 535 switch (powerPreference.value()) { 536 case GPUPowerPreference::LowPower: 537 contextAttributesPayload->setPowerPreference("low-power"); 538 break; 539 540 case GPUPowerPreference::HighPerformance: 541 contextAttributesPayload->setPowerPreference("high-performance"); 542 break; 543 } 544 } 545 return WTFMove(contextAttributesPayload); 546 } 547 return nullptr; 548 }, 549 #endif 550 [] (Monostate) { 551 ASSERT_NOT_REACHED(); 552 return nullptr; 553 } 554 ); 555 if (contextAttributes) 292 556 canvas->setContextAttributes(WTFMove(contextAttributes)); 293 }294 #if ENABLE(WEBGL)295 else if (is<WebGLRenderingContextBase>(m_context)) {296 if (Optional<WebGLContextAttributes> attributes = downcast<WebGLRenderingContextBase>(m_context).getContextAttributes()) {297 auto contextAttributes = Inspector::Protocol::Canvas::ContextAttributes::create()298 .release();299 contextAttributes->setAlpha(attributes->alpha);300 contextAttributes->setDepth(attributes->depth);301 contextAttributes->setStencil(attributes->stencil);302 contextAttributes->setAntialias(attributes->antialias);303 contextAttributes->setPremultipliedAlpha(attributes->premultipliedAlpha);304 contextAttributes->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer);305 contextAttributes->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat);306 canvas->setContextAttributes(WTFMove(contextAttributes));307 }308 }309 #endif310 557 311 558 // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations … … 330 577 ASSERT(!m_frames); 331 578 579 auto* context = canvasContext(); 580 ASSERT(context); 581 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 582 332 583 Inspector::Protocol::Recording::Type type; 333 if (is<CanvasRenderingContext2D>( m_context))584 if (is<CanvasRenderingContext2D>(context)) 334 585 type = Inspector::Protocol::Recording::Type::Canvas2D; 335 else if (is<ImageBitmapRenderingContext>( m_context))586 else if (is<ImageBitmapRenderingContext>(context)) 336 587 type = Inspector::Protocol::Recording::Type::CanvasBitmapRenderer; 337 588 #if ENABLE(WEBGL) 338 else if (is<WebGLRenderingContext>( m_context))589 else if (is<WebGLRenderingContext>(context)) 339 590 type = Inspector::Protocol::Recording::Type::CanvasWebGL; 340 591 #endif 341 592 #if ENABLE(WEBGL2) 342 else if (is<WebGL2RenderingContext>( m_context))593 else if (is<WebGL2RenderingContext>(context)) 343 594 type = Inspector::Protocol::Recording::Type::CanvasWebGL2; 344 595 #endif … … 365 616 String InspectorCanvas::getCanvasContentAsDataURL(ErrorString& errorString) 366 617 { 367 // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebMetal context;368 if (!is<CanvasRenderingContext2D>(m_context)369 #if ENABLE(WEBGL)370 && !is<WebGLRenderingContextBase>(m_context)371 #endif372 && !is<ImageBitmapRenderingContext>(m_context)) {373 errorString = "Unsupported canvas context type"_s;374 return emptyString();375 }376 377 // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations378 618 auto* node = canvasElement(); 379 619 if (!node) { 380 errorString = " Context isn't related to an HTMLCanvasElement"_s;620 errorString = "Missing HTMLCanvasElement of canvas for given canvasId"_s; 381 621 return emptyString(); 382 622 } 383 623 384 624 #if ENABLE(WEBGL) 385 if (is<WebGLRenderingContextBase>(m_context)) 386 downcast<WebGLRenderingContextBase>(m_context).setPreventBufferClearForInspector(true); 625 auto* context = node->renderingContext(); 626 if (is<WebGLRenderingContextBase>(context)) 627 downcast<WebGLRenderingContextBase>(*context).setPreventBufferClearForInspector(true); 387 628 #endif 388 629 … … 390 631 391 632 #if ENABLE(WEBGL) 392 if (is<WebGLRenderingContextBase>( m_context))393 downcast<WebGLRenderingContextBase>( m_context).setPreventBufferClearForInspector(false);633 if (is<WebGLRenderingContextBase>(context)) 634 downcast<WebGLRenderingContextBase>(*context).setPreventBufferClearForInspector(false); 394 635 #endif 395 636 … … 559 800 Ref<Inspector::Protocol::Recording::InitialState> InspectorCanvas::buildInitialState() 560 801 { 802 auto* context = canvasContext(); 803 ASSERT(context); 804 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 805 561 806 auto initialStatePayload = Inspector::Protocol::Recording::InitialState::create().release(); 562 807 563 808 auto attributesPayload = JSON::Object::create(); 564 attributesPayload->setInteger("width"_s, m_context.canvasBase().width());565 attributesPayload->setInteger("height"_s, m_context.canvasBase().height());809 attributesPayload->setInteger("width"_s, context->canvasBase().width()); 810 attributesPayload->setInteger("height"_s, context->canvasBase().height()); 566 811 567 812 auto statesPayload = JSON::ArrayOf<JSON::Object>::create(); … … 569 814 auto parametersPayload = JSON::ArrayOf<JSON::Value>::create(); 570 815 571 if (is<CanvasRenderingContext2D>( m_context)) {572 auto& context2d = downcast<CanvasRenderingContext2D>( m_context);816 if (is<CanvasRenderingContext2D>(context)) { 817 auto& context2d = downcast<CanvasRenderingContext2D>(*context); 573 818 for (auto& state : context2d.stateStack()) { 574 819 auto statePayload = JSON::Object::create(); … … 627 872 } 628 873 #if ENABLE(WEBGL) 629 else if (is<WebGLRenderingContextBase>( m_context)) {630 WebGLRenderingContextBase& contextWebGLBase = downcast<WebGLRenderingContextBase>(m_context);874 else if (is<WebGLRenderingContextBase>(context)) { 875 auto& contextWebGLBase = downcast<WebGLRenderingContextBase>(*context); 631 876 if (Optional<WebGLContextAttributes> webGLContextAttributes = contextWebGLBase.getContextAttributes()) { 632 877 auto webGLContextAttributesPayload = JSON::Object::create(); -
trunk/Source/WebCore/inspector/InspectorCanvas.h
r249776 r249786 27 27 28 28 #include "CallTracerTypes.h" 29 #include "CanvasRenderingContext.h" 29 30 #include <JavaScriptCore/InspectorProtocolObjects.h> 31 #include <JavaScriptCore/JSCInlines.h> 30 32 #include <JavaScriptCore/ScriptCallFrame.h> 31 33 #include <JavaScriptCore/ScriptCallStack.h> 32 34 #include <initializer_list> 35 #include <wtf/HashSet.h> 33 36 #include <wtf/Variant.h> 34 37 #include <wtf/Vector.h> 35 38 #include <wtf/text/WTFString.h> 39 40 #if ENABLE(WEBGPU) 41 #include "WebGPUDevice.h" 42 #endif 36 43 37 44 namespace WebCore { … … 39 46 class CanvasGradient; 40 47 class CanvasPattern; 41 class CanvasRenderingContext;48 class Element; 42 49 class HTMLCanvasElement; 43 50 class HTMLImageElement; … … 54 61 public: 55 62 static Ref<InspectorCanvas> create(CanvasRenderingContext&); 63 #if ENABLE(WEBGPU) 64 static Ref<InspectorCanvas> create(WebGPUDevice&); 65 #endif 56 66 57 const String& identifier() { return m_identifier; } 58 CanvasRenderingContext& context() { return m_context; } 67 const String& identifier() const { return m_identifier; } 59 68 60 HTMLCanvasElement* canvasElement(); 69 CanvasRenderingContext* canvasContext() const; 70 HTMLCanvasElement* canvasElement() const; 71 72 #if ENABLE(WEBGPU) 73 WebGPUDevice* deviceContext() const; 74 bool isDeviceForCanvasContext(CanvasRenderingContext&) const; 75 #endif 76 77 ScriptExecutionContext* scriptExecutionContext() const; 78 79 JSC::JSValue resolveContext(JSC::ExecState*) const; 80 81 HashSet<Element*> clientNodes() const; 61 82 62 83 void canvasChanged(); … … 88 109 private: 89 110 InspectorCanvas(CanvasRenderingContext&); 111 #if ENABLE(WEBGPU) 112 InspectorCanvas(WebGPUDevice&); 113 #endif 114 90 115 void appendActionSnapshotIfNeeded(); 91 116 … … 117 142 118 143 String m_identifier; 119 CanvasRenderingContext& m_context; 144 145 Variant< 146 std::reference_wrapper<CanvasRenderingContext>, 147 #if ENABLE(WEBGPU) 148 std::reference_wrapper<WebGPUDevice>, 149 #endif 150 Monostate 151 > m_context; 120 152 121 153 RefPtr<Inspector::Protocol::Recording::InitialState> m_initialState; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r249776 r249786 75 75 #include <wtf/StdLibExtras.h> 76 76 77 #if ENABLE(WEBGPU) 78 #include "WebGPUSwapChain.h" 79 #endif 80 77 81 namespace WebCore { 78 82 … … 1103 1107 #endif 1104 1108 1109 #if ENABLE(WEBGPU) 1110 void InspectorInstrumentation::didCreateWebGPUDeviceImpl(InstrumentingAgents& instrumentingAgents, WebGPUDevice& device) 1111 { 1112 if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1113 canvasAgent->didCreateWebGPUDevice(device); 1114 } 1115 1116 void InspectorInstrumentation::willDestroyWebGPUDeviceImpl(InstrumentingAgents& instrumentingAgents, WebGPUDevice& device) 1117 { 1118 if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1119 canvasAgent->willDestroyWebGPUDevice(device); 1120 } 1121 1122 void InspectorInstrumentation::willConfigureSwapChainImpl(InstrumentingAgents& instrumentingAgents, GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain) 1123 { 1124 if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1125 canvasAgent->willConfigureSwapChain(contextGPU, newSwapChain); 1126 } 1127 #endif 1128 1105 1129 #if ENABLE(RESOURCE_USAGE) 1106 1130 void InspectorInstrumentation::didHandleMemoryPressureImpl(InstrumentingAgents& instrumentingAgents, Critical critical) -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r249776 r249786 61 61 #endif 62 62 63 #if ENABLE(WEBGPU) 64 #include "GPUCanvasContext.h" 65 #include "WebGPUDevice.h" 66 #endif 67 63 68 namespace Inspector { 64 69 class ConsoleMessage; … … 93 98 class SharedBuffer; 94 99 class TimerBase; 100 class WebKitNamedFlow; 101 class WorkerInspectorProxy; 102 95 103 #if ENABLE(WEBGL) 96 104 class WebGLProgram; 97 105 #endif 98 class WebKitNamedFlow; 99 class WorkerInspectorProxy; 106 107 #if ENABLE(WEBGPU) 108 class WebGPUSwapChain; 109 #endif 100 110 101 111 enum class StorageType; … … 285 295 static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&); 286 296 #endif 297 #if ENABLE(WEBGPU) 298 static void didCreateWebGPUDevice(WebGPUDevice&); 299 static void willDestroyWebGPUDevice(WebGPUDevice&); 300 static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&); 301 #endif 287 302 288 303 static void networkStateChanged(Page&); … … 472 487 static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&); 473 488 #endif 489 #if ENABLE(WEBGPU) 490 static void didCreateWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&); 491 static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&); 492 static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&); 493 #endif 474 494 475 495 static void layerTreeDidChangeImpl(InstrumentingAgents&); … … 1396 1416 #endif 1397 1417 1418 #if ENABLE(WEBGPU) 1419 inline void InspectorInstrumentation::didCreateWebGPUDevice(WebGPUDevice& device) 1420 { 1421 FAST_RETURN_IF_NO_FRONTENDS(void()); 1422 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext())) 1423 didCreateWebGPUDeviceImpl(*instrumentingAgents, device); 1424 } 1425 1426 inline void InspectorInstrumentation::willDestroyWebGPUDevice(WebGPUDevice& device) 1427 { 1428 FAST_RETURN_IF_NO_FRONTENDS(void()); 1429 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext())) 1430 willDestroyWebGPUDeviceImpl(*instrumentingAgents, device); 1431 } 1432 1433 inline void InspectorInstrumentation::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain) 1434 { 1435 FAST_RETURN_IF_NO_FRONTENDS(void()); 1436 if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext())) 1437 willConfigureSwapChainImpl(*instrumentingAgents, contextGPU, newSwapChain); 1438 } 1439 #endif 1440 1398 1441 inline void InspectorInstrumentation::networkStateChanged(Page& page) 1399 1442 { -
trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp
r249776 r249786 56 56 WebGLRenderingContextBase& InspectorShaderProgram::context() const 57 57 { 58 ASSERT(is<WebGLRenderingContextBase>(m_canvas.context())); 59 return downcast<WebGLRenderingContextBase>(m_canvas.context()); 58 ASSERT(m_canvas.canvasContext()); 59 ASSERT(is<WebGLRenderingContextBase>(*m_canvas.canvasContext())); 60 return downcast<WebGLRenderingContextBase>(*m_canvas.canvasContext()); 60 61 } 61 62 -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
r249776 r249786 37 37 #include "InspectorDOMAgent.h" 38 38 #include "InstrumentingAgents.h" 39 #include "JSCanvasRenderingContext2D.h"40 39 #include "JSExecState.h" 41 #include "JSImageBitmapRenderingContext.h"42 40 #include "Microtasks.h" 43 41 #include "OffscreenCanvas.h" … … 53 51 54 52 #if ENABLE(WEBGL) 55 #include "JSWebGLRenderingContext.h"56 53 #include "WebGLProgram.h" 54 #include "WebGLRenderingContext.h" 55 #include "WebGLRenderingContextBase.h" 57 56 #include "WebGLShader.h" 58 57 #endif 59 58 60 59 #if ENABLE(WEBGL2) 61 #include " JSWebGL2RenderingContext.h"60 #include "WebGL2RenderingContext.h" 62 61 #endif 63 62 64 63 #if ENABLE(WEBGPU) 65 #include "JSGPUCanvasContext.h" 64 #include "GPUCanvasContext.h" 65 #include "WebGPUDevice.h" 66 66 #endif 67 67 … … 104 104 m_instrumentingAgents.setInspectorCanvasAgent(this); 105 105 106 const auto canvasExistsInCurrentPage = [&] (CanvasRenderingContext* canvasRenderingContext) { 107 if (!canvasRenderingContext) 108 return false; 109 110 auto* scriptExecutionContext = canvasRenderingContext->canvasBase().scriptExecutionContext(); 106 const auto existsInCurrentPage = [&] (ScriptExecutionContext* scriptExecutionContext) { 111 107 if (!is<Document>(scriptExecutionContext)) 112 108 return false; … … 119 115 { 120 116 LockHolder lock(CanvasRenderingContext::instancesMutex()); 121 for (auto* canvasRenderingContext : CanvasRenderingContext::instances(lock)) { 122 if (canvasExistsInCurrentPage(canvasRenderingContext)) 123 bindCanvas(*canvasRenderingContext, false); 117 for (auto* context : CanvasRenderingContext::instances(lock)) { 118 #if ENABLE(WEBGPU) 119 // The actual "context" for WebGPU is the `WebGPUDevice`, not the <canvas>. 120 if (is<GPUCanvasContext>(context)) 121 continue; 122 #endif 123 124 if (existsInCurrentPage(context->canvasBase().scriptExecutionContext())) 125 bindCanvas(*context, false); 124 126 } 125 127 } 128 129 #if ENABLE(WEBGPU) 130 { 131 LockHolder lock(WebGPUDevice::instancesMutex()); 132 for (auto* device : WebGPUDevice::instances(lock)) { 133 if (existsInCurrentPage(device->scriptExecutionContext())) 134 bindCanvas(*device, false); 135 } 136 } 137 #endif 126 138 127 139 #if ENABLE(WEBGL) 128 140 { 129 141 LockHolder lock(WebGLProgram::instancesMutex()); 130 for (auto& entry: WebGLProgram::instances(lock)) {131 if (c anvasExistsInCurrentPage(entry.value))132 didCreateProgram(* entry.value, *entry.key);142 for (auto& [program, contextWebGLBase] : WebGLProgram::instances(lock)) { 143 if (contextWebGLBase && existsInCurrentPage(contextWebGLBase->canvasBase().scriptExecutionContext())) 144 didCreateProgram(*contextWebGLBase, *program); 133 145 } 134 146 } … … 175 187 } 176 188 177 void InspectorCanvasAgent::requestCSSCanvasClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& result) 178 { 189 void InspectorCanvasAgent::requestClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& clientNodeIds) 190 { 191 auto* domAgent = m_instrumentingAgents.inspectorDOMAgent(); 192 if (!domAgent) { 193 errorString = "DOM domain must be enabled"_s; 194 return; 195 } 196 179 197 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 180 198 if (!inspectorCanvas) 181 199 return; 182 200 183 result = JSON::ArrayOf<int>::create(); 184 for (auto* client : inspectorCanvas->context().canvasBase().cssCanvasClients()) { 185 if (int documentNodeId = m_instrumentingAgents.inspectorDOMAgent()->boundNodeId(&client->document())) 186 result->addItem(m_instrumentingAgents.inspectorDOMAgent()->pushNodeToFrontend(errorString, documentNodeId, client)); 187 } 188 } 189 190 static JSC::JSValue contextAsScriptValue(JSC::ExecState& state, CanvasRenderingContext& context) 191 { 192 JSC::JSLockHolder lock(&state); 193 194 if (is<CanvasRenderingContext2D>(context)) 195 return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<CanvasRenderingContext2D>(context)); 196 #if ENABLE(WEBGL) 197 if (is<WebGLRenderingContext>(context)) 198 return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGLRenderingContext>(context)); 199 #endif 200 #if ENABLE(WEBGL2) 201 if (is<WebGL2RenderingContext>(context)) 202 return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGL2RenderingContext>(context)); 203 #endif 204 #if ENABLE(WEBGPU) 205 if (is<GPUCanvasContext>(context)) 206 return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<GPUCanvasContext>(context)); 207 #endif 208 if (is<ImageBitmapRenderingContext>(context)) 209 return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<ImageBitmapRenderingContext>(context)); 210 211 return { }; 212 } 213 214 void InspectorCanvasAgent::resolveCanvasContext(ErrorString& errorString, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) 201 clientNodeIds = JSON::ArrayOf<int>::create(); 202 for (auto& clientNode : inspectorCanvas->clientNodes()) { 203 if (auto documentNodeId = domAgent->boundNodeId(&clientNode->document())) 204 clientNodeIds->addItem(domAgent->pushNodeToFrontend(errorString, documentNodeId, clientNode)); 205 } 206 } 207 208 void InspectorCanvasAgent::resolveContext(ErrorString& errorString, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) 215 209 { 216 210 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId); … … 218 212 return; 219 213 220 auto & state = *inspectorCanvas->context().canvasBase().scriptExecutionContext()->execState();221 auto injectedScript = m_injectedScriptManager.injectedScriptFor( &state);214 auto* state = inspectorCanvas->scriptExecutionContext()->execState(); 215 auto injectedScript = m_injectedScriptManager.injectedScriptFor(state); 222 216 ASSERT(!injectedScript.hasNoValue()); 223 217 224 JSC::JSValue value = contextAsScriptValue(state, inspectorCanvas->context()); 218 JSC::JSValue value = inspectorCanvas->resolveContext(state); 219 225 220 if (!value) { 226 221 ASSERT_NOT_REACHED(); … … 247 242 return; 248 243 249 if (inspectorCanvas->context().callTracingActive()) { 244 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 245 246 auto* context = inspectorCanvas->canvasContext(); 247 if (!context) 248 return; 249 250 if (context->callTracingActive()) { 250 251 errorString = "Already recording canvas"_s; 251 252 return; … … 266 267 return; 267 268 268 if (!inspectorCanvas->context().callTracingActive()) { 269 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 270 271 auto* context = inspectorCanvas->canvasContext(); 272 if (!context) 273 return; 274 275 if (!context->callTracingActive()) { 269 276 errorString = "Not recording canvas"_s; 270 277 return; 271 278 } 272 279 273 didFinishRecordingCanvasFrame( inspectorCanvas->context(), true);280 didFinishRecordingCanvasFrame(*context, true); 274 281 } 275 282 … … 372 379 } 373 380 374 for (auto* inspectorCanvas : inspectorCanvases) { 375 String identifier = unbindCanvas(*inspectorCanvas); 376 m_frontendDispatcher->canvasRemoved(identifier); 377 } 381 for (auto* inspectorCanvas : inspectorCanvases) 382 unbindCanvas(*inspectorCanvas); 378 383 } 379 384 … … 391 396 return; 392 397 393 m_frontendDispatcher->c ssCanvasClientNodesChanged(inspectorCanvas->identifier());398 m_frontendDispatcher->clientNodesChanged(inspectorCanvas->identifier()); 394 399 } 395 400 … … 412 417 void InspectorCanvasAgent::didChangeCanvasMemory(CanvasRenderingContext& context) 413 418 { 414 auto inspectorCanvas = findInspectorCanvas(context); 419 RefPtr<InspectorCanvas> inspectorCanvas; 420 421 #if ENABLE(WEBGPU) 422 if (is<GPUCanvasContext>(context)) { 423 for (auto& item : m_identifierToInspectorCanvas.values()) { 424 if (item->isDeviceForCanvasContext(context)) { 425 inspectorCanvas = item; 426 break; 427 } 428 } 429 } 430 #endif 431 432 if (!inspectorCanvas) 433 inspectorCanvas = findInspectorCanvas(context); 434 415 435 ASSERT(inspectorCanvas); 416 436 if (!inspectorCanvas) … … 437 457 // covered by the initial microtask until the next frame. 438 458 if (!inspectorCanvas->currentFrameHasData()) { 439 if (auto* scriptExecutionContext = inspectorCanvas-> context().canvasBase().scriptExecutionContext()) {459 if (auto* scriptExecutionContext = inspectorCanvas->scriptExecutionContext()) { 440 460 auto& queue = MicrotaskQueue::mainThreadQueue(); 441 461 queue.append(makeUnique<ActiveDOMCallbackMicrotask>(queue, *scriptExecutionContext, [&, protectedInspectorCanvas = inspectorCanvas.copyRef()] { … … 445 465 } 446 466 447 if ( protectedInspectorCanvas->context().callTracingActive())448 didFinishRecordingCanvasFrame( protectedInspectorCanvas->context());467 if (canvasRenderingContext.callTracingActive()) 468 didFinishRecordingCanvasFrame(canvasRenderingContext); 449 469 })); 450 470 } … … 454 474 455 475 if (!inspectorCanvas->hasBufferSpace()) 456 didFinishRecordingCanvasFrame( inspectorCanvas->context(), true);476 didFinishRecordingCanvasFrame(canvasRenderingContext, true); 457 477 } 458 478 … … 482 502 return; 483 503 484 String identifier = unbindCanvas(*inspectorCanvas); 485 486 // WebCore::CanvasObserver::canvasDestroyed is called in response to the GC destroying the CanvasBase. 487 // Due to the single-process model used in WebKit1, the event must be dispatched from a timer to prevent 488 // the frontend from making JS allocations while the GC is still active. 489 m_removedCanvasIdentifiers.append(identifier); 490 491 if (!m_canvasDestroyedTimer.isActive()) 492 m_canvasDestroyedTimer.startOneShot(0_s); 504 unbindCanvas(*inspectorCanvas); 493 505 } 494 506 495 507 void InspectorCanvasAgent::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch) 496 508 { 509 if (!context.callTracingActive()) 510 return; 511 497 512 auto inspectorCanvas = findInspectorCanvas(context); 498 513 ASSERT(inspectorCanvas); 499 514 if (!inspectorCanvas) 500 return;501 502 if (!inspectorCanvas->context().callTracingActive())503 515 return; 504 516 … … 601 613 #endif 602 614 615 #if ENABLE(WEBGPU) 616 void InspectorCanvasAgent::didCreateWebGPUDevice(WebGPUDevice& device) 617 { 618 if (findInspectorCanvas(device)) { 619 ASSERT_NOT_REACHED(); 620 return; 621 } 622 623 bindCanvas(device, true); 624 } 625 626 void InspectorCanvasAgent::willDestroyWebGPUDevice(WebGPUDevice& device) 627 { 628 auto inspectorCanvas = findInspectorCanvas(device); 629 ASSERT(inspectorCanvas); 630 if (!inspectorCanvas) 631 return; 632 633 unbindCanvas(*inspectorCanvas); 634 } 635 636 void InspectorCanvasAgent::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain) 637 { 638 auto notifyDeviceForSwapChain = [&] (WebGPUSwapChain& webGPUSwapChain) { 639 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 640 if (auto* device = inspectorCanvas->deviceContext()) { 641 if (device->device().swapChain() == webGPUSwapChain.swapChain()) 642 m_frontendDispatcher->clientNodesChanged(inspectorCanvas->identifier()); 643 } 644 } 645 }; 646 647 if (auto* existingSwapChain = contextGPU.swapChain()) 648 notifyDeviceForSwapChain(*existingSwapChain); 649 650 notifyDeviceForSwapChain(newSwapChain); 651 } 652 #endif 653 603 654 void InspectorCanvasAgent::startRecording(InspectorCanvas& inspectorCanvas, Inspector::Protocol::Recording::Initiator initiator, RecordingOptions&& recordingOptions) 604 655 { 605 auto& canvasRenderingContext = inspectorCanvas.context(); 606 607 if (!is<CanvasRenderingContext2D>(canvasRenderingContext) 608 #if ENABLE(WEBGL) 609 && !is<WebGLRenderingContext>(canvasRenderingContext) 656 auto* context = inspectorCanvas.canvasContext(); 657 ASSERT(context); 658 // FIXME: <https://webkit.org/b/201651> Web Inspector: Canvas: support canvas recordings for WebGPUDevice 659 660 if (!is<CanvasRenderingContext2D>(context) 661 && !is<ImageBitmapRenderingContext>(context) 662 #if ENABLE(WEBGL) 663 && !is<WebGLRenderingContext>(context) 610 664 #endif 611 665 #if ENABLE(WEBGL2) 612 && !is<WebGL2RenderingContext>(c anvasRenderingContext)613 #endif 614 && !is<ImageBitmapRenderingContext>(canvasRenderingContext))615 return; 616 617 if (c anvasRenderingContext.callTracingActive())666 && !is<WebGL2RenderingContext>(context) 667 #endif 668 ) 669 return; 670 671 if (context->callTracingActive()) 618 672 return; 619 673 … … 625 679 if (recordingOptions.name) 626 680 inspectorCanvas.setRecordingName(recordingOptions.name.value()); 627 c anvasRenderingContext.setCallTracingActive(true);681 context->setCallTracingActive(true); 628 682 629 683 m_frontendDispatcher->recordingStarted(inspectorCanvas.identifier(), initiator); … … 643 697 void InspectorCanvasAgent::clearCanvasData() 644 698 { 645 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) 646 inspectorCanvas->context().canvasBase().removeObserver(*this); 699 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 700 if (auto* context = inspectorCanvas->canvasContext()) 701 context->canvasBase().removeObserver(*this); 702 } 647 703 648 704 m_identifierToInspectorCanvas.clear(); … … 661 717 m_identifierToInspectorCanvas.set(inspectorCanvas->identifier(), inspectorCanvas.copyRef()); 662 718 663 inspectorCanvas->context().canvasBase().addObserver(*this);719 context.canvasBase().addObserver(*this); 664 720 665 721 m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(captureBacktrace)); 666 722 667 723 #if ENABLE(WEBGL) 668 if (is<WebGLRenderingContextBase>( inspectorCanvas->context())) {669 WebGLRenderingContextBase& contextWebGL = downcast<WebGLRenderingContextBase>(inspectorCanvas->context());724 if (is<WebGLRenderingContextBase>(context)) { 725 auto& contextWebGL = downcast<WebGLRenderingContextBase>(context); 670 726 if (Optional<Vector<String>> extensions = contextWebGL.getSupportedExtensions()) { 671 727 for (const String& extension : *extensions) { … … 680 736 } 681 737 682 String InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas) 738 #if ENABLE(WEBGPU) 739 InspectorCanvas& InspectorCanvasAgent::bindCanvas(WebGPUDevice& device, bool captureBacktrace) 740 { 741 auto inspectorCanvas = InspectorCanvas::create(device); 742 m_identifierToInspectorCanvas.set(inspectorCanvas->identifier(), inspectorCanvas.copyRef()); 743 744 m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(captureBacktrace)); 745 746 return inspectorCanvas; 747 } 748 #endif 749 750 void InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas) 683 751 { 684 752 #if ENABLE(WEBGL) … … 693 761 #endif 694 762 695 inspectorCanvas.context().canvasBase().removeObserver(*this); 763 if (auto* context = inspectorCanvas.canvasContext()) 764 context->canvasBase().removeObserver(*this); 696 765 697 766 String identifier = inspectorCanvas.identifier(); 698 767 m_identifierToInspectorCanvas.remove(identifier); 699 768 700 return identifier; 769 // This can be called in response to GC. Due to the single-process model used in WebKit1, the 770 // event must be dispatched from a timer to prevent the frontend from making JS allocations 771 // while the GC is still active. 772 m_removedCanvasIdentifiers.append(identifier); 773 774 if (!m_canvasDestroyedTimer.isActive()) 775 m_canvasDestroyedTimer.startOneShot(0_s); 701 776 } 702 777 … … 714 789 { 715 790 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 716 if ( &inspectorCanvas->context() == &context)791 if (inspectorCanvas->canvasContext() == &context) 717 792 return inspectorCanvas; 718 793 } 719 794 return nullptr; 720 795 } 796 797 #if ENABLE(WEBGPU) 798 RefPtr<InspectorCanvas> InspectorCanvasAgent::findInspectorCanvas(WebGPUDevice& device) 799 { 800 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 801 if (inspectorCanvas->deviceContext() == &device) 802 return inspectorCanvas; 803 } 804 return nullptr; 805 } 806 #endif 721 807 722 808 #if ENABLE(WEBGL) -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h
r249776 r249786 54 54 class WebGLRenderingContextBase; 55 55 #endif 56 #if ENABLE(WEBGPU) 57 class GPUCanvasContext; 58 class WebGPUDevice; 59 class WebGPUSwapChain; 60 #endif 56 61 57 62 typedef String ErrorString; … … 74 79 void requestNode(ErrorString&, const String& canvasId, int* nodeId); 75 80 void requestContent(ErrorString&, const String& canvasId, String* content); 76 void requestC SSCanvasClientNodes(ErrorString&, const String& canvasId, RefPtr<JSON::ArrayOf<int>>&);77 void resolveC anvasContext(ErrorString&, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>&);81 void requestClientNodes(ErrorString&, const String& canvasId, RefPtr<JSON::ArrayOf<int>>&); 82 void resolveContext(ErrorString&, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>&); 78 83 void setRecordingAutoCaptureFrameCount(ErrorString&, int count); 79 84 void startRecording(ErrorString&, const String& canvasId, const int* frameCount, const int* memoryLimit); … … 93 98 void didChangeCSSCanvasClientNodes(CanvasBase&); 94 99 void didCreateCanvasRenderingContext(CanvasRenderingContext&); 95 void willDestroyCanvasRenderingContext(CanvasRenderingContext&);96 100 void didChangeCanvasMemory(CanvasRenderingContext&); 97 101 void recordCanvasAction(CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { }); … … 104 108 bool isShaderProgramDisabled(WebGLProgram&); 105 109 bool isShaderProgramHighlighted(WebGLProgram&); 110 #endif 111 #if ENABLE(WEBGPU) 112 void didCreateWebGPUDevice(WebGPUDevice&); 113 void willDestroyWebGPUDevice(WebGPUDevice&); 114 void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&); 106 115 #endif 107 116 … … 117 126 void clearCanvasData(); 118 127 InspectorCanvas& bindCanvas(CanvasRenderingContext&, bool captureBacktrace); 119 String unbindCanvas(InspectorCanvas&); 128 #if ENABLE(WEBGPU) 129 InspectorCanvas& bindCanvas(WebGPUDevice&, bool captureBacktrace); 130 #endif 131 void unbindCanvas(InspectorCanvas&); 120 132 RefPtr<InspectorCanvas> assertInspectorCanvas(ErrorString&, const String& canvasId); 121 133 RefPtr<InspectorCanvas> findInspectorCanvas(CanvasRenderingContext&); 134 #if ENABLE(WEBGPU) 135 RefPtr<InspectorCanvas> findInspectorCanvas(WebGPUDevice&); 136 #endif 137 122 138 #if ENABLE(WEBGL) 123 139 String unbindProgram(InspectorShaderProgram&); -
trunk/Source/WebInspectorUI/ChangeLog
r249776 r249786 1 2019-09-11 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Canvas: instrument WebGPUDevice instead of GPUCanvasContext 4 https://bugs.webkit.org/show_bug.cgi?id=201650 5 6 Reviewed by Joseph Pecoraro. 7 8 Most of the actual "work" done with Web GPU actually uses a `WebGPUDevice`. 9 10 A `GPUCanvasContext` is basically just a display "client" of the device, and isn't even 11 required (e.g. compute pipeline). We should treat the `GPUCanvasContext` almost like a 12 `-webkit-canvas` client of a `WebGPUDevice`. 13 14 * UserInterface/Protocol/CanvasObserver.js: 15 (WI.CanvasObserver.prototype.clientNodesChanged): Added. 16 (WI.CanvasObserver.prototype.cssCanvasClientNodesChanged): 17 * UserInterface/Controllers/CanvasManager.js: 18 (WI.CanvasManager.prototype.clientNodesChanged): Added. 19 (WI.CanvasManager.prototype.cssCanvasClientNodesChanged): Deleted. 20 * UserInterface/Models/Canvas.js: 21 (WI.Canvas.resetUniqueDisplayNameNumbers): 22 (WI.Canvas.prototype.get displayName): 23 (WI.Canvas.prototype.requestNode): 24 (WI.Canvas.prototype.requestClientNodes): Added. 25 (WI.Canvas.prototype.requestSize): 26 (WI.Canvas.prototype.clientNodesChanged): Added. 27 (WI.Canvas.prototype.requestCSSCanvasClientNodes): Deleted. 28 (WI.Canvas.prototype.cssCanvasClientNodesChanged): Deleted. 29 30 * UserInterface/Protocol/RemoteObject.js: 31 (WI.RemoteObject.resolveCanvasContext): 32 33 * UserInterface/Views/CanvasContentView.js: 34 (WI.CanvasContentView.prototype.attached): 35 (WI.CanvasContentView.prototype._refreshPixelSize): 36 * UserInterface/Views/CanvasDetailsSidebarPanel.js: 37 (WI.CanvasDetailsSidebarPanel.prototype.set canvas): 38 (WI.CanvasDetailsSidebarPanel.prototype.initialLayout): 39 (WI.CanvasDetailsSidebarPanel.prototype.layout): 40 (WI.CanvasDetailsSidebarPanel.prototype._refreshSourceSection): 41 (WI.CanvasDetailsSidebarPanel.prototype._refreshClientsSection): Added. 42 (WI.CanvasDetailsSidebarPanel.prototype._refreshCSSCanvasSection): Deleted. 43 * UserInterface/Views/CanvasOverviewContentView.js: 44 (WI.CanvasOverviewContentView.prototype._contentViewMouseEnter): 45 * UserInterface/Views/CanvasTreeElement.js: 46 (WI.CanvasTreeElement.prototype._handleMouseOver): 47 48 * Localizations/en.lproj/localizedStrings.js: 49 1 50 2019-09-11 Truitt Savell <tsavell@apple.com> 2 51 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r249776 r249786 195 195 localizedStrings["CPU Usage"] = "CPU Usage"; 196 196 localizedStrings["CSP Hash"] = "CSP Hash"; 197 localizedStrings["CSS"] = "CSS";198 197 localizedStrings["CSS Canvas"] = "CSS Canvas"; 199 198 localizedStrings["CSS Changes:"] = "CSS Changes:"; … … 247 246 localizedStrings["Click to view variable value\nShift-click to replace variable with value"] = "Click to view variable value\nShift-click to replace variable with value"; 248 247 localizedStrings["Clickable"] = "Clickable"; 248 localizedStrings["Clients"] = "Clients"; 249 249 localizedStrings["Close"] = "Close"; 250 250 localizedStrings["Close %s timeline view"] = "Close %s timeline view"; … … 346 346 localizedStrings["Detached"] = "Detached"; 347 347 localizedStrings["Details"] = "Details"; 348 localizedStrings["Device %d"] = "Device %d"; 348 349 localizedStrings["Device Settings"] = "Device Settings"; 349 350 localizedStrings["Diagnoses common accessibility problems affecting screen readers and other assistive technology."] = "Diagnoses common accessibility problems affecting screen readers and other assistive technology."; -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
r249776 r249786 185 185 } 186 186 187 c ssCanvasClientNodesChanged(canvasIdentifier)188 { 189 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 190 console.assert(canvas); 191 if (!canvas) 192 return; 193 194 canvas.c ssCanvasClientNodesChanged();187 clientNodesChanged(canvasIdentifier) 188 { 189 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 190 console.assert(canvas); 191 if (!canvas) 192 return; 193 194 canvas.clientNodesChanged(); 195 195 } 196 196 -
trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js
r249776 r249786 42 42 this._backtrace = backtrace || []; 43 43 44 this._c ssCanvasClientNodes = null;44 this._clientNodes = null; 45 45 this._shaderProgramCollection = new WI.ShaderProgramCollection; 46 46 this._recordingCollection = new WI.RecordingCollection; … … 114 114 static resetUniqueDisplayNameNumbers() 115 115 { 116 WI.Canvas._nextUniqueDisplayNameNumber = 1; 116 Canvas._nextContextUniqueDisplayNameNumber = 1; 117 Canvas._nextDeviceUniqueDisplayNameNumber = 1; 117 118 } 118 119 … … 161 162 } 162 163 164 if (this._contextType === Canvas.ContextType.WebGPU) { 165 if (!this._uniqueDisplayNameNumber) 166 this._uniqueDisplayNameNumber = Canvas._nextDeviceUniqueDisplayNameNumber++; 167 return WI.UIString("Device %d").format(this._uniqueDisplayNameNumber); 168 } 169 163 170 if (!this._uniqueDisplayNameNumber) 164 this._uniqueDisplayNameNumber = this.constructor._nextUniqueDisplayNameNumber++;171 this._uniqueDisplayNameNumber = Canvas._nextContextUniqueDisplayNameNumber++; 165 172 return WI.UIString("Canvas %d").format(this._uniqueDisplayNameNumber); 166 173 } … … 172 179 WI.domManager.ensureDocument(); 173 180 174 CanvasAgent.requestNode(this._identifier).then((result) => { 175 this._domNode = WI.domManager.nodeForId(result.nodeId); 176 if (!this._domNode) { 177 reject(`No DOM node for identifier: ${result.nodeId}.`); 181 CanvasAgent.requestNode(this._identifier, (error, nodeId) => { 182 if (error) { 183 resolve(null); 178 184 return; 179 185 } 186 187 this._domNode = WI.domManager.nodeForId(nodeId); 188 if (!this._domNode) { 189 resolve(null); 190 return; 191 } 192 180 193 resolve(this._domNode); 181 }) .catch(reject);194 }); 182 195 }); 183 196 } 184 185 197 return this._requestNodePromise; 186 198 } … … 191 203 } 192 204 193 requestC SSCanvasClientNodes(callback)194 { 195 if ( !this._cssCanvasName) {196 callback( []);205 requestClientNodes(callback) 206 { 207 if (this._clientNodes) { 208 callback(this._clientNodes); 197 209 return; 198 210 } 199 211 200 if (this._cssCanvasClientNodes) {201 callback(this._cssCanvasClientNodes);202 return;203 }204 205 212 WI.domManager.ensureDocument(); 206 213 207 CanvasAgent.requestCSSCanvasClientNodes(this._identifier,(error, clientNodeIds) => {214 let wrappedCallback = (error, clientNodeIds) => { 208 215 if (error) { 209 216 callback([]); … … 212 219 213 220 clientNodeIds = Array.isArray(clientNodeIds) ? clientNodeIds : []; 214 this._cssCanvasClientNodes = clientNodeIds.map((clientNodeId) => WI.domManager.nodeForId(clientNodeId)); 215 callback(this._cssCanvasClientNodes); 216 }); 221 this._clientNodes = clientNodeIds.map((clientNodeId) => WI.domManager.nodeForId(clientNodeId)); 222 callback(this._clientNodes); 223 }; 224 225 // COMPATIBILITY (iOS 13): Canvas.requestCSSCanvasClientNodes was renamed to Canvas.requestClientNodes. 226 if (!CanvasAgent.requestClientNodes) { 227 CanvasAgent.requestCSSCanvasClientNodes(this._identifier, wrappedCallback); 228 return; 229 } 230 231 CanvasAgent.requestClientNodes(this._identifier, wrappedCallback); 217 232 } 218 233 … … 246 261 247 262 return this.requestNode().then((domNode) => { 263 if (!domNode) 264 return null; 265 248 266 let size = calculateSize(domNode); 249 267 if (!isNaN(size.width) && !isNaN(size.height)) … … 328 346 } 329 347 330 c ssCanvasClientNodesChanged()348 clientNodesChanged() 331 349 { 332 350 // Called from WI.CanvasManager. 333 351 334 if (!this._cssCanvasName) 335 return; 336 337 this._cssCanvasClientNodes = null; 338 339 this.dispatchEventToListeners(WI.Canvas.Event.CSSCanvasClientNodesChanged); 352 this._clientNodes = null; 353 354 this.dispatchEventToListeners(Canvas.Event.ClientNodesChanged); 340 355 } 341 356 … … 403 418 }; 404 419 405 WI.Canvas._nextUniqueDisplayNameNumber = 1; 420 WI.Canvas._nextContextUniqueDisplayNameNumber = 1; 421 WI.Canvas._nextDeviceUniqueDisplayNameNumber = 1; 406 422 407 423 WI.Canvas.FrameURLCookieKey = "canvas-frame-url"; … … 427 443 MemoryChanged: "canvas-memory-changed", 428 444 ExtensionEnabled: "canvas-extension-enabled", 429 C SSCanvasClientNodesChanged: "canvas-css-canvas-client-nodes-changed",445 ClientNodesChanged: "canvas-client-nodes-changed", 430 446 RecordingStarted: "canvas-recording-started", 431 447 RecordingProgress: "canvas-recording-progress", -
trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js
r249776 r249786 43 43 } 44 44 45 c ssCanvasClientNodesChanged(canvasId)45 clientNodesChanged(canvasId) 46 46 { 47 WI.canvasManager.c ssCanvasClientNodesChanged(canvasId);47 WI.canvasManager.clientNodesChanged(canvasId); 48 48 } 49 49 … … 77 77 WI.canvasManager.programDeleted(programId); 78 78 } 79 80 // COMPATIBILITY (iOS 13): Canvas.events.cssCanvasClientNodesChanged was renamed to Canvas.events.clientNodesChanged. 81 cssCanvasClientNodesChanged(canvasId) 82 { 83 WI.canvasManager.clientNodesChanged(canvasId); 84 } 79 85 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js
r249776 r249786 164 164 console.assert(typeof callback === "function"); 165 165 166 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup, (error, object) =>{166 function wrapCallback(error, object) { 167 167 if (error || !object) 168 168 callback(null); 169 169 else 170 170 callback(WI.RemoteObject.fromPayload(object, WI.mainTarget)); 171 }); 171 } 172 173 // COMPATIBILITY (iOS 13): Canvas.resolveCanvasContext was renamed to Canvas.resolveContext. 174 if (!CanvasAgent.resolveContext) { 175 CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup, wrapCallback); 176 return; 177 } 178 179 CanvasAgent.resolveContext(canvas.identifier, objectGroup, wrapCallback); 172 180 } 173 181 -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js
r249776 r249786 211 211 212 212 this.representedObject.requestNode().then((node) => { 213 if (!node) 214 return; 215 213 216 console.assert(!this._canvasNode || this._canvasNode === node); 214 217 if (this._canvasNode === node) … … 282 285 }; 283 286 284 this.representedObject.requestSize() 285 .then((size) => { 287 this.representedObject.requestSize().then((size) => { 286 288 updatePixelSize(size); 287 })288 .catch((error) => {289 updatePixelSize(null);290 289 }); 291 290 } -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js
r249776 r249786 79 79 this._canvas.removeEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this); 80 80 this._canvas.removeEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this); 81 this._canvas.removeEventListener(WI.Canvas.Event.C SSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this);81 this._canvas.removeEventListener(WI.Canvas.Event.ClientNodesChanged, this._refreshClientsSection, this); 82 82 } 83 83 … … 87 87 this._canvas.addEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this); 88 88 this._canvas.addEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this); 89 this._canvas.addEventListener(WI.Canvas.Event.C SSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this);89 this._canvas.addEventListener(WI.Canvas.Event.ClientNodesChanged, this._refreshClientsSection, this); 90 90 } 91 91 … … 112 112 this._widthRow = new WI.DetailsSectionSimpleRow(WI.UIString("Width")); 113 113 this._heightRow = new WI.DetailsSectionSimpleRow(WI.UIString("Height")); 114 this._d atachedRow = new WI.DetailsSectionSimpleRow(WI.UIString("Detached"));114 this._detachedRow = new WI.DetailsSectionSimpleRow(WI.UIString("Detached")); 115 115 116 116 let sourceSection = new WI.DetailsSection("canvas-source", WI.UIString("Source")); 117 sourceSection.groups = [new WI.DetailsSectionGroup([this._nodeRow, this._cssCanvasRow, this._widthRow, this._heightRow, this._d atachedRow])];117 sourceSection.groups = [new WI.DetailsSectionGroup([this._nodeRow, this._cssCanvasRow, this._widthRow, this._heightRow, this._detachedRow])]; 118 118 this._sections.push(sourceSection); 119 119 … … 129 129 this._sections.push(this._extensionsSection); 130 130 131 this._c ssCanvasClientsRow = new WI.DetailsSectionSimpleRow(WI.UIString("Nodes"));132 133 this._c ssCanvasSection = new WI.DetailsSection("canvas-css", WI.UIString("CSS"));134 this._c ssCanvasSection.groups = [new WI.DetailsSectionGroup([this._cssCanvasClientsRow])];135 this._c ssCanvasSection.element.hidden = true;136 this._sections.push(this._c ssCanvasSection);131 this._clientNodesRow = new WI.DetailsSectionSimpleRow(WI.UIString("Nodes")); 132 133 this._clientsSection = new WI.DetailsSection("canvas-clients", WI.UIString("Clients")); 134 this._clientsSection.groups = [new WI.DetailsSectionGroup([this._clientNodesRow])]; 135 this._clientsSection.element.hidden = true; 136 this._sections.push(this._clientsSection); 137 137 138 138 const selectable = false; … … 169 169 this._refreshAttributesSection(); 170 170 this._refreshExtensionsSection(); 171 this._refreshC SSCanvasSection();171 this._refreshClientsSection(); 172 172 this._refreshBacktraceSection(); 173 173 } … … 195 195 return; 196 196 197 this._nodeRow.value = this._canvas.cssCanvasName ? null : emDash; 197 let hideNode = this._canvas.cssCanvasName || this._canvas.contextType === WI.Canvas.ContextType.WebGPU; 198 199 this._nodeRow.value = hideNode ? null : emDash; 198 200 this._cssCanvasRow.value = this._canvas.cssCanvasName || null; 199 201 this._widthRow.value = emDash; 200 202 this._heightRow.value = emDash; 201 this._d atachedRow.value = null;203 this._detachedRow.value = null; 202 204 203 205 this._canvas.requestNode().then((node) => { 206 if (!node) { 207 this._nodeRow.value = null; 208 return; 209 } 210 204 211 if (node !== this._node) { 205 212 if (this._node) { … … 216 223 } 217 224 218 if (! this._canvas.cssCanvasName)225 if (!hideNode) { 219 226 this._nodeRow.value = WI.linkifyNodeReference(this._node); 227 228 if (!this._node.parentNode) 229 this._detachedRow.value = WI.UIString("Yes"); 230 } 220 231 221 232 let setRowValueIfValidAttributeValue = (row, attribute) => { … … 249 260 }); 250 261 } 251 252 if (!this._canvas.cssCanvasName && !this._node.parentNode)253 this._datachedRow.value = WI.UIString("Yes");254 262 }); 255 263 } … … 296 304 } 297 305 298 _refreshC SSCanvasSection()306 _refreshClientsSection() 299 307 { 300 308 if (!this.didInitialLayout) 301 309 return; 302 310 303 if (!this._canvas.cssCanvasName ) {304 this._c ssCanvasSection.element.hidden = true;305 return; 306 } 307 308 this._c ssCanvasClientsRow.value = emDash;309 310 this._c ssCanvasSection.element.hidden = false;311 312 this._canvas.requestC SSCanvasClientNodes((cssCanvasClientNodes) => {313 if (!c ssCanvasClientNodes.length)311 if (!this._canvas.cssCanvasName && this._canvas.contextType !== WI.Canvas.ContextType.WebGPU) { 312 this._clientsSection.element.hidden = true; 313 return; 314 } 315 316 this._clientNodesRow.value = emDash; 317 318 this._clientsSection.element.hidden = false; 319 320 this._canvas.requestClientNodes((clientNodes) => { 321 if (!clientNodes.length) 314 322 return; 315 323 316 324 let fragment = document.createDocumentFragment(); 317 for (let clientNode of c ssCanvasClientNodes)325 for (let clientNode of clientNodes) 318 326 fragment.appendChild(WI.linkifyNodeReference(clientNode)); 319 this._c ssCanvasClientsRow.value = fragment;327 this._clientNodesRow.value = fragment; 320 328 }); 321 329 } -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js
r249776 r249786 192 192 193 193 let canvas = contentView.representedObject; 194 if (canvas.cssCanvasName ) {195 canvas.requestC SSCanvasClientNodes((cssCanvasClientNodes) => {196 WI.domManager.highlightDOMNodeList(c ssCanvasClientNodes.map((node) => node.id));194 if (canvas.cssCanvasName || canvas.contextType === WI.Canvas.ContextType.WebGPU) { 195 canvas.requestClientNodes((clientNodes) => { 196 WI.domManager.highlightDOMNodeList(clientNodes.map((node) => node.id)); 197 197 }); 198 198 return; -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js
r249776 r249786 116 116 _handleMouseOver(event) 117 117 { 118 if (this.representedObject.cssCanvasName ) {119 this.representedObject.requestC SSCanvasClientNodes((cssCanvasClientNodes) => {120 WI.domManager.highlightDOMNodeList(c ssCanvasClientNodes.map((node) => node.id), "all");118 if (this.representedObject.cssCanvasName || this.representedObject.contextType === WI.Canvas.ContextType.WebGPU) { 119 this.representedObject.requestClientNodes((clientNodes) => { 120 WI.domManager.highlightDOMNodeList(clientNodes.map((node) => node.id)); 121 121 }); 122 122 } else { … … 125 125 return; 126 126 127 WI.domManager.highlightDOMNode(node.id , "all");127 WI.domManager.highlightDOMNode(node.id); 128 128 }); 129 129 }
Note: See TracChangeset
for help on using the changeset viewer.