Web Inspector: Instrument WebGLProgram created/deleted
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Aug 2017 22:31:44 +0000 (22:31 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Aug 2017 22:31:44 +0000 (22:31 +0000)
commit32cb8c1ef9d5331a8b2e9eabac18d165a2198db3
tree19036179a8c107697ee1df7b07623e933cb7c6e3
parent859bececee4b76ffc5c98a9b3b086ddea497bf23
Web Inspector: Instrument WebGLProgram created/deleted
https://bugs.webkit.org/show_bug.cgi?id=175059

Reviewed by Devin Rousso.

Source/JavaScriptCore:

Extend the Canvas protocol with types/events for tracking WebGLPrograms.

* inspector/protocol/Canvas.json:

Source/WebCore:

Tests: inspector/canvas/shaderProgram-add-remove-webgl.html
       inspector/canvas/shaderProgram-add-remove-webgl2.html

This patch adds instrumentation to WebGLRenderingContextBase for tracking
WebGLPrograms. A new helper class, InspectorShaderProgram, is used by
the CanvasAgent to hold related data.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::createProgram):
(WebCore::WebGLRenderingContextBase::deleteProgram):

* inspector/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::enable):
(WebCore::InspectorCanvasAgent::frameNavigated):
(WebCore::InspectorCanvasAgent::didCreateProgram):
(WebCore::InspectorCanvasAgent::willDeleteProgram):
(WebCore::InspectorCanvasAgent::clearCanvasData):
(WebCore::InspectorCanvasAgent::unbindCanvas):
(WebCore::InspectorCanvasAgent::unbindProgram):
(WebCore::InspectorCanvasAgent::assertInspectorProgram):
(WebCore::InspectorCanvasAgent::findInspectorProgram):
* inspector/InspectorCanvasAgent.h:

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didCreateCSSCanvasImpl):
(WebCore::InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl):
(WebCore::InspectorInstrumentation::didCreateCanvasRenderingContextImpl):
(WebCore::InspectorInstrumentation::didChangeCanvasMemoryImpl):
(WebCore::InspectorInstrumentation::recordCanvasActionImpl):
(WebCore::InspectorInstrumentation::didFinishRecordingCanvasFrameImpl):
(WebCore::InspectorInstrumentation::didCreateProgramImpl):
(WebCore::InspectorInstrumentation::willDeleteProgramImpl):

* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::recordCanvasActionImpl):
(WebCore::InspectorInstrumentation::didCreateCSSCanvas):
(WebCore::InspectorInstrumentation::didChangeCSSCanvasClientNodes):
(WebCore::InspectorInstrumentation::didCreateCanvasRenderingContext):
(WebCore::InspectorInstrumentation::didChangeCanvasMemory):
(WebCore::InspectorInstrumentation::recordCanvasAction):
(WebCore::InspectorInstrumentation::didFinishRecordingCanvasFrame):
(WebCore::InspectorInstrumentation::didCreateProgram):
(WebCore::InspectorInstrumentation::willDeleteProgram):

* inspector/InspectorShaderProgram.cpp: Added.
(WebCore::InspectorShaderProgram::create):
(WebCore::InspectorShaderProgram::InspectorShaderProgram):
(WebCore::InspectorShaderProgram::context const):
* inspector/InspectorShaderProgram.h: Added.

Source/WebInspectorUI:

This patch adds frontend support for shader program instrumentation.
The frontend creates a ShaderProgram model object for each WebGLProgram.
Since only canvases with a WebGL context have programs, the Canvas model
object does not contain any logic specific to programs. CanvasManager
dispatches program added/removed events, and the parent Canvas can be
accessed from ShaderProgram but not the other way around.

* UserInterface/Controllers/CanvasManager.js:
(WI.CanvasManager):
(WI.CanvasManager.prototype.get shaderPrograms):
(WI.CanvasManager.prototype.canvasRemoved):
(WI.CanvasManager.prototype.programCreated):
(WI.CanvasManager.prototype.programDeleted):
(WI.CanvasManager.prototype._mainResourceDidChange):
(WI.CanvasManager.prototype._dispatchShaderProgramRemoved):

* UserInterface/Main.html:

* UserInterface/Models/Canvas.js:
(WI.Canvas.prototype.nextShaderProgramDisplayNumber):
(WI.Canvas):

* UserInterface/Models/ShaderProgram.js: Added.
(WI.ShaderProgram):
(WI.ShaderProgram.prototype.get identifier):
(WI.ShaderProgram.prototype.get canvas):
(WI.ShaderProgram.prototype.get displayName):

* UserInterface/Protocol/CanvasObserver.js:
(WI.CanvasObserver.prototype.programCreated):
(WI.CanvasObserver.prototype.programDeleted):
(WI.CanvasObserver):

* UserInterface/Test.html:

LayoutTests:

Add tests for CanvasManager shader program events and ShaderProgram model object.
WebGL and WebGL2 contexts are tested separately based on platform support.

* inspector/canvas/resources/shaderProgram-utilities.js: Added.
(createProgram):
(deleteProgram):
(deleteContext):
(TestPage.registerInitializer.awaitProgramAdded):
(TestPage.registerInitializer):
(TestPage.registerInitializer.window.initializeTestSuite):
(TestPage.registerInitializer.window.addSimpleTestCase):
(TestPage.registerInitializer.window.addParentCanvasRemovedTestCase):

* inspector/canvas/shaderProgram-add-remove-webgl-expected.txt: Added.
* inspector/canvas/shaderProgram-add-remove-webgl.html: Added.
* inspector/canvas/shaderProgram-add-remove-webgl2-expected.txt: Added.
* inspector/canvas/shaderProgram-add-remove-webgl2.html: Added.

* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220233 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/canvas/resources/shaderProgram-utilities.js [new file with mode: 0644]
LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl-expected.txt [new file with mode: 0644]
LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl.html [new file with mode: 0644]
LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2-expected.txt [new file with mode: 0644]
LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2.html [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Canvas.json
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/inspector/InspectorCanvasAgent.cpp
Source/WebCore/inspector/InspectorCanvasAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorShaderProgram.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorShaderProgram.h [new file with mode: 0644]
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Models/Canvas.js
Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js
Source/WebInspectorUI/UserInterface/Test.html