WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-175059-20170802181417.patch (text/plain), 59.66 KB, created by
Matt Baker
on 2017-08-02 18:14:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Matt Baker
Created:
2017-08-02 18:14:18 PDT
Size:
59.66 KB
patch
obsolete
>Subversion Revision: 220135 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index deef0f6b9f3646249acaef4cc63e8a1629dc9b3b..cc5e1d7286f27354faf2a67102a88f04ae7a8b79 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,14 @@ >+2017-08-02 Matt Baker <mattbaker@apple.com> >+ >+ Web Inspector: Instrument WebGLProgram created/deleted >+ https://bugs.webkit.org/show_bug.cgi?id=175059 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Extend the Canvas protocol with types/events for tracking WebGLPrograms. >+ >+ * inspector/protocol/Canvas.json: >+ > 2017-08-01 Filip Pizlo <fpizlo@apple.com> > > Bmalloc and GC should put auxiliaries (butterflies, typed array backing stores) in a gigacage (separate multi-GB VM region) >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 03419914c2a6322ecdf38f67babd6da1ea6edd12..776aacf35a6dc6492119e1c1d81f6c657b14bbe2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,63 @@ >+2017-08-02 Matt Baker <mattbaker@apple.com> >+ >+ Web Inspector: Instrument WebGLProgram created/deleted >+ https://bugs.webkit.org/show_bug.cgi?id=175059 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ > 2017-08-01 Brian Burg <bburg@apple.com> > > HTML file input elements do not support file extensions in the "accept" attribute >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 891430790c409ce5c3b5e29e7190408151b2bd40..bdcb5f86cee7428f26b643bff8688c32895ce081 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,45 @@ >+2017-08-02 Matt Baker <mattbaker@apple.com> >+ >+ Web Inspector: Instrument WebGLProgram created/deleted >+ https://bugs.webkit.org/show_bug.cgi?id=175059 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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: >+ > 2017-08-01 Devin Rousso <drousso@apple.com> > > Web Inspector: simplify WebInspector with WI >diff --git a/Source/JavaScriptCore/inspector/protocol/Canvas.json b/Source/JavaScriptCore/inspector/protocol/Canvas.json >index 85e19f41e467b3ed4f271e749aa407443c93e592..38587197b1d6b779d6b7d6b3d12d58fa24f31ca1 100644 >--- a/Source/JavaScriptCore/inspector/protocol/Canvas.json >+++ b/Source/JavaScriptCore/inspector/protocol/Canvas.json >@@ -9,6 +9,11 @@ > "description": "Unique canvas identifier." > }, > { >+ "id": "ProgramId", >+ "type": "string", >+ "description": "Unique shader program identifier." >+ }, >+ { > "id": "ContextType", > "type": "string", > "enum": ["canvas-2d", "webgl", "webgl2", "webgpu"], >@@ -142,6 +147,19 @@ > { "name": "canvasId", "$ref": "CanvasId" }, > { "name": "recording", "$ref": "Recording.Recording" } > ] >+ }, >+ { >+ "name": "programCreated", >+ "parameters": [ >+ { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." }, >+ { "name": "programId", "$ref": "ProgramId", "description": "Program identifier." } >+ ] >+ }, >+ { >+ "name": "programDeleted", >+ "parameters": [ >+ { "name": "programId", "$ref": "ProgramId", "description": "Program identifier." } >+ ] > } > ] > } >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 74af4351f14a44d9c707971359ba61c5aa20dcb0..03607302f53e91bfa3ccf0bbcd9fe8fdc141555e 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1957,6 +1957,7 @@ set(WebCore_SOURCES > inspector/InspectorNodeFinder.cpp > inspector/InspectorOverlay.cpp > inspector/InspectorPageAgent.cpp >+ inspector/InspectorShaderProgram.cpp > inspector/InspectorStyleSheet.cpp > inspector/InspectorTimelineAgent.cpp > inspector/InspectorWorkerAgent.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 135c6d31ea60a103715f07312453fcc4b1d6bf6c..ec1f7395e2443a23f973755cc307ea4294b1c388 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2864,6 +2864,8 @@ > 6A22E8731F1042C400F546C3 /* InspectorCanvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A22E8721F1042C400F546C3 /* InspectorCanvas.cpp */; }; > 6A32D7CE1A16D8C000412F0B /* InspectorCanvasAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */; }; > 6A4B6D6519D22519006F11D3 /* InspectorCanvasAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */; }; >+ 6A72798B1F16C29C003F39B8 /* InspectorShaderProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A7279881F16C29B003F39B8 /* InspectorShaderProgram.h */; }; >+ 6A72798C1F16C29C003F39B8 /* InspectorShaderProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A7279891F16C29B003F39B8 /* InspectorShaderProgram.cpp */; }; > 6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; }; >@@ -10668,6 +10670,8 @@ > 6A22E8721F1042C400F546C3 /* InspectorCanvas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvas.cpp; sourceTree = "<group>"; }; > 6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasAgent.h; sourceTree = "<group>"; }; > 6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasAgent.cpp; sourceTree = "<group>"; }; >+ 6A7279881F16C29B003F39B8 /* InspectorShaderProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorShaderProgram.h; sourceTree = "<group>"; }; >+ 6A7279891F16C29B003F39B8 /* InspectorShaderProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorShaderProgram.cpp; sourceTree = "<group>"; }; > 6B3480920EEF50D400AC1B41 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; }; > 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; }; > 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; }; >@@ -17203,6 +17207,8 @@ > A518225517E2A0D400A9BA1D /* InspectorOverlayPage.js */, > 4F6FDD621341DEDD001F8EE3 /* InspectorPageAgent.cpp */, > 4F6FDD631341DEDD001F8EE3 /* InspectorPageAgent.h */, >+ 6A7279891F16C29B003F39B8 /* InspectorShaderProgram.cpp */, >+ 6A7279881F16C29B003F39B8 /* InspectorShaderProgram.h */, > 82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */, > 82AB1770125C826700C5069D /* InspectorStyleSheet.h */, > 754133A9102E00F400075D00 /* InspectorTimelineAgent.cpp */, >@@ -27681,6 +27687,7 @@ > 504AACCE1834455900E3D9BC /* InspectorNodeFinder.h in Headers */, > 0F03C0751884805500A5F8CA /* InspectorOverlay.h in Headers */, > 4F6FDD651341DEDD001F8EE3 /* InspectorPageAgent.h in Headers */, >+ 6A72798B1F16C29C003F39B8 /* InspectorShaderProgram.h in Headers */, > 82AB1774125C826700C5069D /* InspectorStyleSheet.h in Headers */, > 754133A8102E00E800075D00 /* InspectorTimelineAgent.h in Headers */, > A593CF8B1840535200BFCE27 /* InspectorWebAgentBase.h in Headers */, >@@ -31653,6 +31660,7 @@ > 504AACCD1834455900E3D9BC /* InspectorNodeFinder.cpp in Sources */, > 7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */, > 4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */, >+ 6A72798C1F16C29C003F39B8 /* InspectorShaderProgram.cpp in Sources */, > 82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */, > 754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */, > A54A0C5D1DB6D9C00017A90B /* InspectorWorkerAgent.cpp in Sources */, >diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >index 1a8873a1a21abefeab327520e58c4cf2235050af..31d05d197f4098fb9503405d653d8cec234df48d 100644 >--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >@@ -1502,6 +1502,9 @@ RefPtr<WebGLProgram> WebGLRenderingContextBase::createProgram() > return nullptr; > auto program = WebGLProgram::create(*this); > addSharedObject(program.get()); >+ >+ InspectorInstrumentation::didCreateProgram(*this, program.get()); >+ > return WTFMove(program); > } > >@@ -1572,6 +1575,9 @@ void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) > > void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) > { >+ ASSERT(program); >+ InspectorInstrumentation::willDeleteProgram(*this, *program); >+ > deleteObject(program); > // We don't reset m_currentProgram to 0 here because the deletion of the > // current program is delayed. >diff --git a/Source/WebCore/inspector/InspectorCanvasAgent.cpp b/Source/WebCore/inspector/InspectorCanvasAgent.cpp >index 664a8eb9ed7265322b91ea542b053739a76ef270..01e6c1ed4214128aad5b093762c35e1ed8712ad7 100644 >--- a/Source/WebCore/inspector/InspectorCanvasAgent.cpp >+++ b/Source/WebCore/inspector/InspectorCanvasAgent.cpp >@@ -38,6 +38,7 @@ > #include "MainFrame.h" > #include "ScriptState.h" > #include "StringAdaptors.h" >+#include "WebGLProgram.h" > #include <inspector/IdentifiersFactory.h> > #include <inspector/InjectedScript.h> > #include <inspector/InjectedScriptManager.h> >@@ -94,6 +95,11 @@ void InspectorCanvasAgent::enable(ErrorString&) > > for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) > m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(m_instrumentingAgents)); >+ >+ for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) { >+ auto& inspectorCanvas = inspectorProgram->canvas(); >+ m_frontendDispatcher->programCreated(inspectorCanvas.identifier(), inspectorProgram->identifier()); >+ } > } > > void InspectorCanvasAgent::disable(ErrorString&) >@@ -270,7 +276,7 @@ void InspectorCanvasAgent::frameNavigated(Frame& frame) > } > > Vector<InspectorCanvas*> inspectorCanvases; >- for (RefPtr<InspectorCanvas>& inspectorCanvas : m_identifierToInspectorCanvas.values()) { >+ for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { > if (inspectorCanvas->canvas().document().frame() == &frame) > inspectorCanvases.append(inspectorCanvas.get()); > } >@@ -417,6 +423,32 @@ void InspectorCanvasAgent::didFinishRecordingCanvasFrame(HTMLCanvasElement& canv > inspectorCanvas->resetRecordingData(); > } > >+void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program) >+{ >+ auto* inspectorCanvas = findInspectorCanvas(context.canvas()); >+ ASSERT(inspectorCanvas); >+ if (!inspectorCanvas) >+ return; >+ >+ auto inspectorProgram = InspectorShaderProgram::create(program, *inspectorCanvas); >+ String programIdentifier = inspectorProgram->identifier(); >+ m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram)); >+ >+ if (m_enabled) >+ m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier); >+} >+ >+void InspectorCanvasAgent::willDeleteProgram(WebGLProgram& program) >+{ >+ auto* inspectorProgram = findInspectorProgram(program); >+ if (!inspectorProgram) >+ return; >+ >+ String identifier = unbindProgram(*inspectorProgram); >+ if (m_enabled) >+ m_frontendDispatcher->programDeleted(identifier); >+} >+ > void InspectorCanvasAgent::canvasDestroyedTimerFired() > { > if (!m_removedCanvasIdentifiers.size()) >@@ -446,6 +478,7 @@ void InspectorCanvasAgent::clearCanvasData() > inspectorCanvas->canvas().removeObserver(*this); > > m_identifierToInspectorCanvas.clear(); >+ m_identifierToInspectorProgram.clear(); > m_canvasToCSSCanvasName.clear(); > m_removedCanvasIdentifiers.clear(); > >@@ -460,12 +493,31 @@ String InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas) > { > ASSERT(!m_canvasToCSSCanvasName.contains(&inspectorCanvas.canvas())); > >+ Vector<InspectorShaderProgram*> programsToRemove; >+ for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) { >+ if (&inspectorProgram->canvas() == &inspectorCanvas) >+ programsToRemove.append(inspectorProgram.get()); >+ } >+ >+ for (auto* inspectorProgram : programsToRemove) >+ unbindProgram(*inspectorProgram); >+ > String identifier = inspectorCanvas.identifier(); > m_identifierToInspectorCanvas.remove(identifier); > > return identifier; > } > >+String InspectorCanvasAgent::unbindProgram(InspectorShaderProgram& inspectorProgram) >+{ >+ ASSERT(inspectorProgram.context()); >+ >+ String identifier = inspectorProgram.identifier(); >+ m_identifierToInspectorProgram.remove(identifier); >+ >+ return identifier; >+} >+ > InspectorCanvas* InspectorCanvasAgent::assertInspectorCanvas(ErrorString& errorString, const String& identifier) > { > RefPtr<InspectorCanvas> inspectorCanvas = m_identifierToInspectorCanvas.get(identifier); >@@ -487,4 +539,25 @@ InspectorCanvas* InspectorCanvasAgent::findInspectorCanvas(HTMLCanvasElement& ca > return nullptr; > } > >+InspectorShaderProgram* InspectorCanvasAgent::assertInspectorProgram(ErrorString& errorString, const String& identifier) >+{ >+ RefPtr<InspectorShaderProgram> inspectorProgram = m_identifierToInspectorProgram.get(identifier); >+ if (!inspectorProgram) { >+ errorString = ASCIILiteral("No shader program for given identifier."); >+ return nullptr; >+ } >+ >+ return inspectorProgram.get(); >+} >+ >+InspectorShaderProgram* InspectorCanvasAgent::findInspectorProgram(WebGLProgram& program) >+{ >+ for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) { >+ if (&inspectorProgram->program() == &program) >+ return inspectorProgram.get(); >+ } >+ >+ return nullptr; >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/inspector/InspectorCanvasAgent.h b/Source/WebCore/inspector/InspectorCanvasAgent.h >index d88c2faba3f081215d00795fb0dcdbbcc4aab139..cc2e048425520e0c57e90204f9873627fe5a0fa6 100644 >--- a/Source/WebCore/inspector/InspectorCanvasAgent.h >+++ b/Source/WebCore/inspector/InspectorCanvasAgent.h >@@ -28,6 +28,7 @@ > #include "CallTracerTypes.h" > #include "HTMLCanvasElement.h" > #include "InspectorCanvas.h" >+#include "InspectorShaderProgram.h" > #include "InspectorWebAgentBase.h" > #include "Timer.h" > #include <inspector/InspectorBackendDispatchers.h> >@@ -44,6 +45,7 @@ class InjectedScriptManager; > namespace WebCore { > > class CanvasRenderingContext; >+class WebGLProgram; > class WebGLRenderingContextBase; > > typedef String ErrorString; >@@ -77,6 +79,8 @@ public: > void didChangeCanvasMemory(HTMLCanvasElement&); > void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { }); > void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false); >+ void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&); >+ void willDeleteProgram(WebGLProgram&); > > // CanvasObserver > void canvasChanged(HTMLCanvasElement&, const FloatRect&) override { } >@@ -88,14 +92,18 @@ private: > void canvasRecordingTimerFired(); > void clearCanvasData(); > String unbindCanvas(InspectorCanvas&); >- InspectorCanvas* assertInspectorCanvas(ErrorString&, const String&); >+ String unbindProgram(InspectorShaderProgram&); >+ InspectorCanvas* assertInspectorCanvas(ErrorString&, const String& identifier); > InspectorCanvas* findInspectorCanvas(HTMLCanvasElement&); >+ InspectorShaderProgram* assertInspectorProgram(ErrorString&, const String& identifier); >+ InspectorShaderProgram* findInspectorProgram(WebGLProgram&); > > std::unique_ptr<Inspector::CanvasFrontendDispatcher> m_frontendDispatcher; > RefPtr<Inspector::CanvasBackendDispatcher> m_backendDispatcher; > Inspector::InjectedScriptManager& m_injectedScriptManager; > > HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas; >+ HashMap<String, RefPtr<InspectorShaderProgram>> m_identifierToInspectorProgram; > HashMap<HTMLCanvasElement*, String> m_canvasToCSSCanvasName; > Vector<String> m_removedCanvasIdentifiers; > Timer m_canvasDestroyedTimer; >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp >index c7492c93976b56e4adc1911540b9115c2bb70899..4ae8a3741ee928a37b17160b2591683fecb0e75b 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp >+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp >@@ -978,42 +978,56 @@ void InspectorInstrumentation::didSendWebSocketFrameImpl(InstrumentingAgents& in > } > #endif > >-void InspectorInstrumentation::didCreateCSSCanvasImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement, const String& name) >+void InspectorInstrumentation::didCreateCSSCanvasImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement, const String& name) > { >- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) > canvasAgent->didCreateCSSCanvas(canvasElement, name); > } > >-void InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement) >+void InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement) > { >- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) > canvasAgent->didChangeCSSCanvasClientNodes(canvasElement); > } > >-void InspectorInstrumentation::didCreateCanvasRenderingContextImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement) >+void InspectorInstrumentation::didCreateCanvasRenderingContextImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement) > { >- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) > canvasAgent->didCreateCanvasRenderingContext(canvasElement); > } > >-void InspectorInstrumentation::didChangeCanvasMemoryImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement) >+void InspectorInstrumentation::didChangeCanvasMemoryImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement) > { >- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) > canvasAgent->didChangeCanvasMemory(canvasElement); > } > >-void InspectorInstrumentation::recordCanvasActionImpl(InstrumentingAgents* instrumentingAgents, CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters) >+void InspectorInstrumentation::recordCanvasActionImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters) > { >- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) > canvasAgent->recordCanvasAction(canvasRenderingContext, name, WTFMove(parameters)); > } > >-void InspectorInstrumentation::didFinishRecordingCanvasFrameImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement, bool forceDispatch) >+void InspectorInstrumentation::didFinishRecordingCanvasFrameImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement, bool forceDispatch) > { >- if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) > canvasAgent->didFinishRecordingCanvasFrame(canvasElement, forceDispatch); > } > >+#if ENABLE(WEBGL) >+void InspectorInstrumentation::didCreateProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& context, WebGLProgram& program) >+{ >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) >+ canvasAgent->didCreateProgram(context, program); >+} >+ >+void InspectorInstrumentation::willDeleteProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program) >+{ >+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) >+ canvasAgent->willDeleteProgram(program); >+} >+#endif >+ > #if ENABLE(RESOURCE_USAGE) > void InspectorInstrumentation::didHandleMemoryPressureImpl(InstrumentingAgents& instrumentingAgents, Critical critical) > { >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h >index 88dd931eb8dad18b4de804e57555c29d975095c8..cc5ef922deaffc7816da0f9b044b7bbc482f0ce5 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.h >+++ b/Source/WebCore/inspector/InspectorInstrumentation.h >@@ -45,6 +45,7 @@ > #include "InspectorInstrumentationCookie.h" > #include "Page.h" > #include "StorageArea.h" >+#include "WebGLRenderingContextBase.h" > #include "WorkerGlobalScope.h" > #include "WorkerInspectorController.h" > #include <wtf/MemoryPressureHandler.h> >@@ -82,7 +83,7 @@ class ScriptExecutionContext; > class SecurityOrigin; > class ShadowRoot; > class URL; >-class WebGLRenderingContextBase; >+class WebGLProgram; > class WebKitNamedFlow; > class WorkerInspectorProxy; > >@@ -235,6 +236,11 @@ public: > static void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { }); > static void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false); > >+#if ENABLE(WEBGL) >+ static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&); >+ static void willDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&); >+#endif >+ > static void networkStateChanged(Page&); > static void updateApplicationCacheStatus(Frame*); > >@@ -390,12 +396,16 @@ private: > static void networkStateChangedImpl(InstrumentingAgents&); > static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&); > >- static void didCreateCSSCanvasImpl(InstrumentingAgents*, HTMLCanvasElement&, const String&); >- static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents*, HTMLCanvasElement&); >- static void didCreateCanvasRenderingContextImpl(InstrumentingAgents*, HTMLCanvasElement&); >- static void didChangeCanvasMemoryImpl(InstrumentingAgents*, HTMLCanvasElement&); >- static void recordCanvasActionImpl(InstrumentingAgents*, CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { }); >- static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents*, HTMLCanvasElement&, bool forceDispatch = false); >+ static void didCreateCSSCanvasImpl(InstrumentingAgents&, HTMLCanvasElement&, const String&); >+ static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents&, HTMLCanvasElement&); >+ static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, HTMLCanvasElement&); >+ static void didChangeCanvasMemoryImpl(InstrumentingAgents&, HTMLCanvasElement&); >+ static void recordCanvasActionImpl(InstrumentingAgents&, CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { }); >+ static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, HTMLCanvasElement&, bool forceDispatch = false); >+#if ENABLE(WEBGL) >+ static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&); >+ static void willDeleteProgramImpl(InstrumentingAgents&, WebGLProgram&); >+#endif > > static void layerTreeDidChangeImpl(InstrumentingAgents&); > static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&); >@@ -1099,43 +1109,57 @@ inline void InspectorInstrumentation::didHandleMemoryPressure(Page& page, Critic > inline void InspectorInstrumentation::didCreateCSSCanvas(HTMLCanvasElement& canvasElement, const String& name) > { > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) >- didCreateCSSCanvasImpl(instrumentingAgents, canvasElement, name); >+ didCreateCSSCanvasImpl(*instrumentingAgents, canvasElement, name); > } > > inline void InspectorInstrumentation::didChangeCSSCanvasClientNodes(HTMLCanvasElement& canvasElement) > { > FAST_RETURN_IF_NO_FRONTENDS(void()); > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) >- didChangeCSSCanvasClientNodesImpl(instrumentingAgents, canvasElement); >+ didChangeCSSCanvasClientNodesImpl(*instrumentingAgents, canvasElement); > } > > inline void InspectorInstrumentation::didCreateCanvasRenderingContext(HTMLCanvasElement& canvasElement) > { > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) >- didCreateCanvasRenderingContextImpl(instrumentingAgents, canvasElement); >+ didCreateCanvasRenderingContextImpl(*instrumentingAgents, canvasElement); > } > > inline void InspectorInstrumentation::didChangeCanvasMemory(HTMLCanvasElement& canvasElement) > { > FAST_RETURN_IF_NO_FRONTENDS(void()); > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) >- didChangeCanvasMemoryImpl(instrumentingAgents, canvasElement); >+ didChangeCanvasMemoryImpl(*instrumentingAgents, canvasElement); > } > > inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters) > { > FAST_RETURN_IF_NO_FRONTENDS(void()); > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasRenderingContext.canvas().document())) >- recordCanvasActionImpl(instrumentingAgents, canvasRenderingContext, name, WTFMove(parameters)); >+ recordCanvasActionImpl(*instrumentingAgents, canvasRenderingContext, name, WTFMove(parameters)); > } > > inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(HTMLCanvasElement& canvasElement, bool forceDispatch) > { > FAST_RETURN_IF_NO_FRONTENDS(void()); > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) >- didFinishRecordingCanvasFrameImpl(instrumentingAgents, canvasElement, forceDispatch); >+ didFinishRecordingCanvasFrameImpl(*instrumentingAgents, canvasElement, forceDispatch); >+} >+ >+#if ENABLE(WEBGL) >+inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program) >+{ >+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document())) >+ didCreateProgramImpl(*instrumentingAgents, context, program); > } > >+inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& context, WebGLProgram& program) >+{ >+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document())) >+ willDeleteProgramImpl(*instrumentingAgents, program); >+} >+#endif >+ > inline void InspectorInstrumentation::networkStateChanged(Page& page) > { > FAST_RETURN_IF_NO_FRONTENDS(void()); >diff --git a/Source/WebCore/inspector/InspectorShaderProgram.cpp b/Source/WebCore/inspector/InspectorShaderProgram.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..dd4dbbe161eb416d79a5778d8e1469a84cfe0793 >--- /dev/null >+++ b/Source/WebCore/inspector/InspectorShaderProgram.cpp >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "InspectorShaderProgram.h" >+ >+#include "HTMLCanvasElement.h" >+#include "InspectorCanvas.h" >+#include "WebGLProgram.h" >+#include "WebGLRenderingContextBase.h" >+#include <inspector/IdentifiersFactory.h> >+ >+using namespace Inspector; >+ >+namespace WebCore { >+ >+Ref<InspectorShaderProgram> InspectorShaderProgram::create(WebGLProgram& program, InspectorCanvas& inspectorCanvas) >+{ >+ return adoptRef(*new InspectorShaderProgram(program, inspectorCanvas)); >+} >+ >+InspectorShaderProgram::InspectorShaderProgram(WebGLProgram& program, InspectorCanvas& inspectorCanvas) >+ : m_identifier("program:" + IdentifiersFactory::createIdentifier()) >+ , m_program(program) >+ , m_canvas(inspectorCanvas) >+{ >+} >+ >+WebGLRenderingContextBase* InspectorShaderProgram::context() const >+{ >+ auto* context = m_canvas.canvas().renderingContext(); >+ ASSERT(context && is<WebGLRenderingContextBase>(context)); >+ return downcast<WebGLRenderingContextBase>(context); >+} >+ >+} // namespace WebCore >+ >diff --git a/Source/WebCore/inspector/InspectorShaderProgram.h b/Source/WebCore/inspector/InspectorShaderProgram.h >new file mode 100644 >index 0000000000000000000000000000000000000000..b9ddd4477f73f02a54487bc84dfddf8f1da31671 >--- /dev/null >+++ b/Source/WebCore/inspector/InspectorShaderProgram.h >@@ -0,0 +1,58 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <inspector/InspectorProtocolObjects.h> >+#include <inspector/InspectorValues.h> >+ >+namespace WebCore { >+ >+class InspectorCanvas; >+class WebGLProgram; >+class WebGLRenderingContextBase; >+ >+typedef String ErrorString; >+ >+class InspectorShaderProgram final : public RefCounted<InspectorShaderProgram> { >+public: >+ static Ref<InspectorShaderProgram> create(WebGLProgram&, InspectorCanvas&); >+ >+ const String& identifier() const { return m_identifier; } >+ InspectorCanvas& canvas() const { return m_canvas; } >+ WebGLRenderingContextBase* context() const; >+ WebGLProgram& program() const { return m_program; } >+ >+ ~InspectorShaderProgram() { } >+ >+private: >+ InspectorShaderProgram(WebGLProgram&, InspectorCanvas&); >+ >+ String m_identifier; >+ WebGLProgram& m_program; >+ InspectorCanvas& m_canvas; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js b/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js >index cc5d0a58a26b2055aa94ee4b76d5a880cd06413b..25cd346628be9e43e8cbdf3764b16891828d84da 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js >@@ -32,6 +32,8 @@ WI.CanvasManager = class CanvasManager extends WI.Object > WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this); > > this._canvasIdentifierMap = new Map; >+ this._shaderProgramIdentifierMap = new Map; >+ this._canvasShaderProgramMap = new Map; > > if (window.CanvasAgent) > CanvasAgent.enable(); >@@ -44,6 +46,11 @@ WI.CanvasManager = class CanvasManager extends WI.Object > return [...this._canvasIdentifierMap.values()]; > } > >+ get shaderPrograms() >+ { >+ return [...this._shaderProgramIdentifierMap.values()]; >+ } >+ > canvasAdded(canvasPayload) > { > // Called from WI.CanvasObserver. >@@ -67,6 +74,14 @@ WI.CanvasManager = class CanvasManager extends WI.Object > if (!canvas) > return; > >+ let programs = this._canvasShaderProgramMap.take(canvas); >+ if (programs) { >+ for (let program of programs) { >+ this._shaderProgramIdentifierMap.delete(program.identifier); >+ this._dispatchShaderProgramRemoved(program); >+ } >+ } >+ > canvas.frame.canvasCollection.remove(canvas); > > this.dispatchEventToListeners(WI.CanvasManager.Event.CanvasWasRemoved, {canvas}); >@@ -111,6 +126,50 @@ WI.CanvasManager = class CanvasManager extends WI.Object > this.dispatchEventToListeners(WI.CanvasManager.Event.RecordingFinished, {canvas, recording}); > } > >+ programCreated(canvasIdentifier, programIdentifier) >+ { >+ // Called from WI.CanvasObserver. >+ >+ let canvas = this._canvasIdentifierMap.get(canvasIdentifier); >+ console.assert(canvas); >+ if (!canvas) >+ return; >+ >+ console.assert(!this._shaderProgramIdentifierMap.has(programIdentifier), `ShaderProgram already exists with id ${programIdentifier}.`); >+ >+ let program = new WI.ShaderProgram(programIdentifier, canvas); >+ this._shaderProgramIdentifierMap.set(program.identifier, program); >+ >+ let programs = this._canvasShaderProgramMap.get(canvas); >+ if (!programs) { >+ programs = []; >+ this._canvasShaderProgramMap.set(canvas, programs); >+ } >+ >+ programs.push(program); >+ >+ this.dispatchEventToListeners(WI.CanvasManager.Event.ShaderProgramAdded, {program}); >+ } >+ >+ programDeleted(programIdentifier) >+ { >+ // Called from WI.CanvasObserver. >+ >+ let program = this._shaderProgramIdentifierMap.take(programIdentifier); >+ console.assert(program); >+ if (!program) >+ return; >+ >+ let programs = this._canvasShaderProgramMap.get(program.canvas); >+ >+ programs.remove(program); >+ >+ if (!programs.length) >+ this._canvasShaderProgramMap.delete(program.canvas); >+ >+ this._dispatchShaderProgramRemoved(program); >+ } >+ > // Private > > _mainResourceDidChange(event) >@@ -121,11 +180,19 @@ WI.CanvasManager = class CanvasManager extends WI.Object > > WI.Canvas.resetUniqueDisplayNameNumbers(); > >+ this._shaderProgramIdentifierMap.clear(); >+ this._canvasShaderProgramMap.clear(); >+ > if (this._canvasIdentifierMap.size) { > this._canvasIdentifierMap.clear(); > this.dispatchEventToListeners(WI.CanvasManager.Event.Cleared); > } > } >+ >+ _dispatchShaderProgramRemoved(program) >+ { >+ this.dispatchEventToListeners(WI.CanvasManager.Event.ShaderProgramRemoved, {program}); >+ } > }; > > WI.CanvasManager.Event = { >@@ -133,4 +200,6 @@ WI.CanvasManager.Event = { > CanvasWasAdded: "canvas-manager-canvas-was-added", > CanvasWasRemoved: "canvas-manager-canvas-was-removed", > RecordingFinished: "canvas-managger-recording-finished", >+ ShaderProgramAdded: "canvas-manager-shader-program-added", >+ ShaderProgramRemoved: "canvas-manager-shader-program-removed", > }; >diff --git a/Source/WebInspectorUI/UserInterface/Main.html b/Source/WebInspectorUI/UserInterface/Main.html >index 980ca253f788cb230b31d1fa165aad32c8968e14..12176eeb6bec2645e8493a4b93f9f0f364b33690 100644 >--- a/Source/WebInspectorUI/UserInterface/Main.html >+++ b/Source/WebInspectorUI/UserInterface/Main.html >@@ -399,6 +399,7 @@ > <script src="Models/ScriptInstrument.js"></script> > <script src="Models/ScriptSyntaxTree.js"></script> > <script src="Models/ScriptTimelineRecord.js"></script> >+ <script src="Models/ShaderProgram.js"></script> > <script src="Models/SourceCodePosition.js"></script> > <script src="Models/SourceCodeRevision.js"></script> > <script src="Models/SourceCodeSearchMatchObject.js"></script> >diff --git a/Source/WebInspectorUI/UserInterface/Models/Canvas.js b/Source/WebInspectorUI/UserInterface/Models/Canvas.js >index d547a2f16e4f10233298fb2f3e244efb6b3824e0..d676f4fa81b386ef65b8a80105509f1928150e2c 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/Canvas.js >+++ b/Source/WebInspectorUI/UserInterface/Models/Canvas.js >@@ -42,6 +42,8 @@ WI.Canvas = class Canvas extends WI.Object > this._memoryCost = memoryCost || NaN; > > this._cssCanvasClientNodes = null; >+ >+ this._nextShaderProgramDisplayNumber = 1; > } > > // Static >@@ -224,6 +226,13 @@ WI.Canvas = class Canvas extends WI.Object > > this.dispatchEventToListeners(WI.Canvas.Event.CSSCanvasClientNodesChanged); > } >+ >+ nextShaderProgramDisplayNumber() >+ { >+ // Called from WI.ShaderProgram. >+ >+ return this._nextShaderProgramDisplayNumber++; >+ } > }; > > WI.Canvas._nextUniqueDisplayNameNumber = 1; >diff --git a/Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js b/Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js >new file mode 100644 >index 0000000000000000000000000000000000000000..71cb42a4884cafe9b11817f64574ccdc8539d81e >--- /dev/null >+++ b/Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+WI.ShaderProgram = class ShaderProgram extends WI.Object >+{ >+ constructor(identifier, canvas) >+ { >+ super(); >+ >+ console.assert(identifier); >+ console.assert(canvas instanceof WI.Canvas); >+ >+ this._identifier = identifier; >+ this._canvas = canvas; >+ this._uniqueDisplayNumber = canvas.nextShaderProgramDisplayNumber(); >+ } >+ >+ // Public >+ >+ get identifier() { return this._identifier; } >+ get canvas() { return this._canvas; } >+ >+ get displayName() >+ { >+ return WI.UIString("Program %d").format(this._uniqueDisplayNumber); >+ } >+}; >+ >+WI.ShaderProgram.Event = { >+ ProgramLinked: "shader-program-program-linked", >+ ShaderCompiled: "shader-program-shader-compiled", >+}; >diff --git a/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js b/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js >index b7c5f2fe5f11d09f09c419e856c50afd00575900..ded281fb3fa2dcb8f44dd7fe42427fb60a4afe61 100644 >--- a/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js >+++ b/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js >@@ -51,4 +51,14 @@ WI.CanvasObserver = class CanvasObserver > { > WI.canvasManager.recordingFinished(canvasId, recording); > } >+ >+ programCreated(canvasId, programId) >+ { >+ WI.canvasManager.programCreated(canvasId, programId); >+ } >+ >+ programDeleted(programId) >+ { >+ WI.canvasManager.programDeleted(programId); >+ } > }; >diff --git a/Source/WebInspectorUI/UserInterface/Test.html b/Source/WebInspectorUI/UserInterface/Test.html >index 6a31845d66392c93a88b26cc6db295f99874fa23..641a0e7358e1ad9d58b850268917a065c7f8dca7 100644 >--- a/Source/WebInspectorUI/UserInterface/Test.html >+++ b/Source/WebInspectorUI/UserInterface/Test.html >@@ -168,6 +168,7 @@ > <script src="Models/ScriptInstrument.js"></script> > <script src="Models/ScriptSyntaxTree.js"></script> > <script src="Models/ScriptTimelineRecord.js"></script> >+ <script src="Models/ShaderProgram.js"></script> > <script src="Models/SourceCodeRevision.js"></script> > <script src="Models/SourceCodeTimeline.js"></script> > <script src="Models/SourceMapResource.js"></script> >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 6e9c39a2a36309f2e4feec0c0498364e4e26a0d8..ce14fba475fcea98ca8fca99275835f09b5d7c48 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,32 @@ >+2017-08-02 Matt Baker <mattbaker@apple.com> >+ >+ Web Inspector: Instrument WebGLProgram created/deleted >+ https://bugs.webkit.org/show_bug.cgi?id=175059 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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: >+ > 2017-08-02 Matt Lewis <jlewis3@apple.com> > > Added new expectations folders and moved expectations to correct folders. >diff --git a/LayoutTests/inspector/canvas/resources/shaderProgram-utilities.js b/LayoutTests/inspector/canvas/resources/shaderProgram-utilities.js >new file mode 100644 >index 0000000000000000000000000000000000000000..b5ae46f8d31722458e592af8aea462bb4ad8d207 >--- /dev/null >+++ b/LayoutTests/inspector/canvas/resources/shaderProgram-utilities.js >@@ -0,0 +1,102 @@ >+let context; >+let program; >+ >+function createProgram(contextType) { >+ context = document.createElement("canvas").getContext(contextType); >+ program = context.createProgram(); >+} >+ >+function deleteProgram() { >+ context.deleteProgram(program); >+ program = null; >+} >+ >+function deleteContext() { >+ context = null; >+ // Force GC to make sure the canvas element is destroyed, otherwise the frontend >+ // does not receive WI.CanvasManager.Event.CanvasWasRemoved events. >+ setTimeout(() => { GCController.collect(); }, 0); >+} >+ >+TestPage.registerInitializer(() => { >+ let suite = null; >+ >+ function awaitProgramAdded() { >+ return WI.canvasManager.awaitEvent(WI.CanvasManager.Event.ShaderProgramAdded) >+ .then((event) => { >+ let program = event.data.program; >+ InspectorTest.expectThat(program instanceof WI.ShaderProgram, "Added ShaderProgram."); >+ InspectorTest.expectThat(program.canvas instanceof WI.Canvas, "ShaderProgram should have a parent Canvas."); >+ return program; >+ }); >+ } >+ >+ function awaitProgramRemoved() { >+ return WI.canvasManager.awaitEvent(WI.CanvasManager.Event.ShaderProgramRemoved) >+ .then((event) => { >+ let program = event.data.program; >+ InspectorTest.expectThat(program instanceof WI.ShaderProgram, "Removed ShaderProgram."); >+ InspectorTest.expectThat(program.canvas instanceof WI.Canvas, "ShaderProgram should have a parent Canvas."); >+ return program; >+ }); >+ } >+ >+ window.initializeTestSuite = function(contextType) { >+ suite = InspectorTest.createAsyncSuite(`Canvas.ShaderProgram.${contextType}`); >+ >+ suite.addTestCase({ >+ name: `${suite.name}.reloadPage`, >+ description: "Check that ShaderProgramAdded is sent for a program created before CanvasAgent is enabled.", >+ test(resolve, reject) { >+ awaitProgramAdded().then(resolve, reject); >+ >+ InspectorTest.reloadPage(); >+ } >+ }); >+ >+ return suite; >+ } >+ >+ window.addSimpleTestCase = function(contextType) { >+ suite.addTestCase({ >+ name: `${suite.name}.ShaderProgramAdded`, >+ description: "Check that added/removed events are sent.", >+ test(resolve, reject) { >+ awaitProgramAdded() >+ .then((addedProgram) => { >+ awaitProgramRemoved() >+ .then((removedProgram) => { >+ InspectorTest.expectEqual(removedProgram, addedProgram, "Removed the previously added ShaderProgram."); >+ }) >+ .then(resolve, reject); >+ >+ InspectorTest.evaluateInPage(`deleteProgram()`); >+ }); >+ >+ InspectorTest.evaluateInPage(`createProgram("${contextType}")`); >+ } >+ }); >+ } >+ >+ window.addParentCanvasRemovedTestCase = function(contextType) { >+ suite.addTestCase({ >+ name: `${suite.name}.ParentCanvasRemoved`, >+ description: "Check that the ShaderProgram is removed before it's parent Canvas.", >+ test(resolve, reject) { >+ Promise.race([ >+ awaitProgramRemoved() >+ .then(() => { >+ InspectorTest.pass("Removed ShaderProgram before Canvas."); >+ resolve(); >+ }), >+ WI.canvasManager.awaitEvent(WI.CanvasManager.Event.CanvasWasRemoved) >+ .then(reject) >+ ]) >+ .catch(() => { InspectorTest.fail("Removed Canvas before ShaderProgram."); }); >+ >+ InspectorTest.evaluateInPage(`createProgram("${contextType}")`); >+ InspectorTest.evaluateInPage(`deleteContext()`); >+ } >+ }); >+ } >+}); >diff --git a/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl-expected.txt b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..cdeb985d2cbbdc68a0b45eadba2c67a06f0db654 >--- /dev/null >+++ b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl-expected.txt >@@ -0,0 +1,20 @@ >+Test that CanvasManager tracks creation and destruction of WebGL shader programs. >+ >+ >+== Running test suite: Canvas.ShaderProgram.webgl >+-- Running test case: Canvas.ShaderProgram.webgl.reloadPage >+PASS: Added ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+ >+-- Running test case: Canvas.ShaderProgram.webgl.ShaderProgramAdded >+PASS: Added ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+PASS: Removed ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+PASS: Removed the previously added ShaderProgram. >+ >+-- Running test case: Canvas.ShaderProgram.webgl.ParentCanvasRemoved >+PASS: Removed ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+PASS: Removed ShaderProgram before Canvas. >+ >diff --git a/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl.html b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl.html >new file mode 100644 >index 0000000000000000000000000000000000000000..2ce79f2ca7a7eef6ccac07cc3489be1ae845ca0a >--- /dev/null >+++ b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl.html >@@ -0,0 +1,23 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/inspector-test.js"></script> >+<script src="resources/shaderProgram-utilities.js"></script> >+<script> >+function test() { >+ let suite = initializeTestSuite("webgl"); >+ >+ addSimpleTestCase("webgl"); >+ addParentCanvasRemovedTestCase("webgl"); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Test that CanvasManager tracks creation and destruction of WebGL shader programs.</p> >+</body> >+<script> >+ createProgram("webgl"); >+</script> >+</html> >diff --git a/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2-expected.txt b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..4b9d2911de9f317354202f3f0262cc3ce9c57b03 >--- /dev/null >+++ b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2-expected.txt >@@ -0,0 +1,20 @@ >+Test that CanvasManager tracks creation and destruction of WebGL2 shader programs. >+ >+ >+== Running test suite: Canvas.ShaderProgram.webgl2 >+-- Running test case: Canvas.ShaderProgram.webgl2.reloadPage >+PASS: Added ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+ >+-- Running test case: Canvas.ShaderProgram.webgl2.ShaderProgramAdded >+PASS: Added ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+PASS: Removed ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+PASS: Removed the previously added ShaderProgram. >+ >+-- Running test case: Canvas.ShaderProgram.webgl2.ParentCanvasRemoved >+PASS: Removed ShaderProgram. >+PASS: ShaderProgram should have a parent Canvas. >+PASS: Removed ShaderProgram before Canvas. >+ >diff --git a/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2.html b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2.html >new file mode 100644 >index 0000000000000000000000000000000000000000..263ffcac0b9b3f750091d82d3b87dbd803a79132 >--- /dev/null >+++ b/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2.html >@@ -0,0 +1,26 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/inspector-test.js"></script> >+<script src="resources/shaderProgram-utilities.js"></script> >+<script> >+if (window.internals) >+ internals.settings.setWebGL2Enabled(true); >+ >+function test() { >+ let suite = initializeTestSuite("webgl2"); >+ >+ addSimpleTestCase("webgl2"); >+ addParentCanvasRemovedTestCase("webgl2"); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Test that CanvasManager tracks creation and destruction of WebGL2 shader programs.</p> >+</body> >+<script> >+ createProgram("webgl2"); >+</script> >+</html> >diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations >index 20ad0d27a3b4e603eff39042e9b0c4c94ad030d5..74a7ee8d7d4f7550b4e74ce156d6f37cc8352ba0 100644 >--- a/LayoutTests/platform/gtk/TestExpectations >+++ b/LayoutTests/platform/gtk/TestExpectations >@@ -591,6 +591,7 @@ webkit.org/b/166536 fast/canvas/webgl/webgl2-texture-upload-enums.html [ Skip ] > webkit.org/b/166536 inspector/canvas/create-context-webgl2.html [ Skip ] > webkit.org/b/166536 inspector/canvas/requestContent-webgl2.html [ Skip ] > webkit.org/b/166536 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ] >+webkit.org/b/166536 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] > > # These tests reference specific fonts on Mac port. > Bug(GTK) fast/text/font-weights.html [ WontFix ] >diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations >index dd108202c5bb7c349dd00ef0623850903eac11a5..20d55b39e014df113aa77fd57ca0eedad8479348 100644 >--- a/LayoutTests/platform/mac/TestExpectations >+++ b/LayoutTests/platform/mac/TestExpectations >@@ -1138,6 +1138,7 @@ webkit.org/b/148119 [ Yosemite ] fast/text/trak-optimizeLegibility.html [ Failur > webkit.org/b/174066 inspector/canvas/create-context-webgl2.html [ Pass Timeout ] > webkit.org/b/174066 inspector/canvas/create-context-webgpu.html [ Pass Timeout ] > webkit.org/b/174272 inspector/canvas/css-canvas-clients.html [ Pass Timeout ] >+webkit.org/b/174066 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Pass Timeout ] > webkit.org/b/170615 inspector/codemirror/prettyprinting-css.html [ Pass Timeout ] > webkit.org/b/153460 inspector/codemirror/prettyprinting-css-rules.html [ Pass Timeout ] > webkit.org/b/160048 [ Debug ] inspector/codemirror/prettyprinting-javascript.html [ Pass Timeout ] >diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations >index e73c2a813ac291865751b4f6fe44b3ca8c38fbba..d87247b329be5faf84db8f95dd5e11f4e37a3e6f 100644 >--- a/LayoutTests/platform/win/TestExpectations >+++ b/LayoutTests/platform/win/TestExpectations >@@ -1913,6 +1913,8 @@ inspector/canvas/requestContent-webgl.html [ Skip ] > inspector/canvas/requestContent-webgl2.html [ Skip ] > inspector/canvas/resolveCanvasContext-webgl.html [ Skip ] > inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ] >+inspector/canvas/shaderProgram-add-remove-webgl.html [ Skip ] >+inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] > ################################################################################ > ################# End WebGL Issues ####################### > ################################################################################
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 175059
:
316919
|
316921
|
316925
|
316926
|
316930
|
316932
|
316938
|
316944
|
316998
|
317023
|
317037
|
317054
|
317081
|
317090
|
317091