Add 'webglcontextchanged' WebGLContextEvent
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Feb 2017 15:47:23 +0000 (15:47 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Feb 2017 15:47:23 +0000 (15:47 +0000)
commitf09707d191f67f7ef842a61b5f0845501cd66f8f
treed85f20030dcaf70be1ecec2148a818c7ebf50911
parent46bbefa4e8ce99b711d7689b4bbd60799f7eac61
Add 'webglcontextchanged' WebGLContextEvent
https://bugs.webkit.org/show_bug.cgi?id=168595
<rdar://problem/30604254>

Reviewed by Antoine Quint.

Source/WebCore:

Add a new event that is dispatched when the GraphicsContext3D
notices that the active GPU has changed.

Test: fast/canvas/webgl/webglcontextchangedevent.html

* dom/EventNames.h: Add 'webglcontextchanged'.
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::dispatchContextChangedEvent): Dispatch the new event.
(WebCore::WebGLRenderingContextBase::simulateContextChanged): Tell the GraphicsContext3D to
pretend there was a GPU switch. This is called from Internals for testing.
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLRenderingContextBase.idl: Export the interface so Internals can see it.

* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::simulateContextChanged): Tell the GraphicsContext3DManager
that it should pretend a GPU change has happened, which causes it to notify all the
active contexts.
* platform/graphics/GraphicsContext3D.h:

* platform/graphics/mac/GraphicsContext3DMac.mm:
(WebCore::GraphicsContext3DManager::updateAllContexts): Tell the GraphicsContext3Ds
to tell their WebGLRenderingContexts to dispatch an event.
(WebCore::GraphicsContext3D::simulateContextChanged): Fake the display change.
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::dispatchContextChangedNotification): Tell the WebGLRenderingContext
that a change has occurred, and that it should dispatch an event. This is a layering
violation which will need to be fixed (although with other communication from GC3D back
to WebGL).
* testing/Internals.cpp:
(WebCore::Internals::simulateWebGLContextChanged):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Add a new webglcontextchanged event. This test only
runs on Cocoa platforms at the moment, because it
needs GraphicsContext3D to keep track of all
active contexts in order to dispatch events.

* fast/canvas/webgl/webglcontextchangedevent-expected.txt: Added.
* fast/canvas/webgl/webglcontextchangedevent.html: Added.
* platform/gtk/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/webglcontextchangedevent-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/EventNames.h
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/html/canvas/WebGLRenderingContextBase.idl
Source/WebCore/platform/graphics/GraphicsContext3D.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl