Diff
Modified: trunk/LayoutTests/ChangeLog (212636 => 212637)
--- trunk/LayoutTests/ChangeLog 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/LayoutTests/ChangeLog 2017-02-20 15:47:23 UTC (rev 212637)
@@ -1,3 +1,21 @@
+2017-02-20 Dean Jackson <d...@apple.com>
+
+ Add 'webglcontextchanged' WebGLContextEvent
+ https://bugs.webkit.org/show_bug.cgi?id=168595
+ <rdar://problem/30604254>
+
+ Reviewed by Antoine Quint.
+
+ 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:
+
2017-02-20 Carlos Garcia Campos <cgar...@igalia.com>
Unreviewed GTK+ gardening. Fix tests reporting missing results.
Added: trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent-expected.txt (0 => 212637)
--- trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent-expected.txt 2017-02-20 15:47:23 UTC (rev 212637)
@@ -0,0 +1,8 @@
+
+We should see three changed events.
+
+Saw webglcontextchanged event.
+
+Saw webglcontextchanged event.
+
+Saw webglcontextchanged event.
Property changes on: trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent-expected.txt
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Added: trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html (0 => 212637)
--- trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html 2017-02-20 15:47:23 UTC (rev 212637)
@@ -0,0 +1,50 @@
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+function log(msg)
+{
+ let p = document.createElement("p");
+ p.textContent = msg;
+ document.body.appendChild(p);
+}
+
+function runTest()
+{
+ if (!window.internals) {
+ log("This test must run inside DRT/WKTR.");
+ return;
+ }
+
+ log("We should see three changed events.");
+
+ let changedEventsSeen = 0;
+
+ let handleChangedEvent = (event) => {
+ log("Saw webglcontextchanged event.");
+ changedEventsSeen++;
+ if (changedEventsSeen == 3)
+ testRunner.notifyDone();
+ }
+
+ document.querySelectorAll("canvas").forEach((c) =>
+ {
+ c.addEventListener("webglcontextchanged", handleChangedEvent, false);
+ let gl = c.getContext("webgl");
+ gl.clearColor(1, 0, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ });
+
+ let gl = document.querySelector("canvas").getContext("webgl");
+ window.internals.simulateWebGLContextChanged(gl);
+}
+
+
+window.addEventListener("load", runTest, false);
+</script>
+
+<canvas></canvas>
+<canvas></canvas>
+<canvas></canvas>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (212636 => 212637)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2017-02-20 15:47:23 UTC (rev 212637)
@@ -665,6 +665,9 @@
# This requires a specific font on Mac
fast/text/hidpi-text-selection-gap-between-words.html [ Skip ]
+# webglcontextchanged event not supported
+fast/canvas/webgl/webglcontextchangedevent.html [ Skip ]
+
# Test requires hardcoded font names, which I do not have for this port.
fast/text/han-generic-font-families.html [ WontFix ]
fast/text/hangul-generic-font-families.html [ WontFix ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (212636 => 212637)
--- trunk/LayoutTests/platform/win/TestExpectations 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/LayoutTests/platform/win/TestExpectations 2017-02-20 15:47:23 UTC (rev 212637)
@@ -3784,3 +3784,6 @@
# WebCrypto tests are failing.
webkit.org/b/165090 imported/w3c/WebCryptoAPI [ Skip ]
+
+# webglcontextchanged event not supported
+fast/canvas/webgl/webglcontextchangedevent.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (212636 => 212637)
--- trunk/Source/WebCore/ChangeLog 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/ChangeLog 2017-02-20 15:47:23 UTC (rev 212637)
@@ -1,3 +1,44 @@
+2017-02-20 Dean Jackson <d...@apple.com>
+
+ Add 'webglcontextchanged' WebGLContextEvent
+ https://bugs.webkit.org/show_bug.cgi?id=168595
+ <rdar://problem/30604254>
+
+ Reviewed by Antoine Quint.
+
+ 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:
+
2017-02-19 Dean Jackson <d...@apple.com>
Activate/deactivate high performance GPU when requested
Modified: trunk/Source/WebCore/dom/EventNames.h (212636 => 212637)
--- trunk/Source/WebCore/dom/EventNames.h 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/dom/EventNames.h 2017-02-20 15:47:23 UTC (rev 212637)
@@ -242,6 +242,7 @@
macro(volumechange) \
macro(waiting) \
macro(waitingforkey) \
+ macro(webglcontextchanged) \
macro(webglcontextcreationerror) \
macro(webglcontextlost) \
macro(webglcontextrestored) \
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (212636 => 212637)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2017-02-20 15:47:23 UTC (rev 212637)
@@ -5631,6 +5631,17 @@
canvas().dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, emptyString()));
}
+void WebGLRenderingContextBase::dispatchContextChangedEvent()
+{
+ canvas().dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextchangedEvent, false, true, emptyString()));
+}
+
+void WebGLRenderingContextBase::simulateContextChanged()
+{
+ if (m_context)
+ m_context->simulateContextChanged();
+}
+
String WebGLRenderingContextBase::ensureNotNull(const String& text) const
{
if (text.isNull())
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (212636 => 212637)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2017-02-20 15:47:23 UTC (rev 212637)
@@ -340,6 +340,8 @@
void recycleContext();
void forceRestoreContext();
void loseContextImpl(LostContextMode);
+ void dispatchContextChangedEvent();
+ WEBCORE_EXPORT void simulateContextChanged();
GraphicsContext3D* graphicsContext3D() const { return m_context.get(); }
WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); }
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl (212636 => 212637)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl 2017-02-20 15:47:23 UTC (rev 212637)
@@ -51,6 +51,7 @@
DoNotCheckConstants,
JSCustomMarkFunction,
NoInterfaceObject,
+ ExportMacro=WEBCORE_EXPORT,
] interface WebGLRenderingContextBase {
// back-reference to the canvas
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp (212636 => 212637)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp 2017-02-20 15:47:23 UTC (rev 212637)
@@ -659,6 +659,10 @@
void GraphicsContext3D::setContextVisibility(bool)
{
}
+
+void GraphicsContext3D::simulateContextChanged()
+{
+}
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (212636 => 212637)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2017-02-20 15:47:23 UTC (rev 212637)
@@ -1133,6 +1133,9 @@
void forceContextLost();
void recycleContext();
+ void dispatchContextChangedNotification();
+ void simulateContextChanged();
+
void paintRenderingResultsToCanvas(ImageBuffer*);
RefPtr<ImageData> paintRenderingResultsToImageData();
bool paintCompositedResultsToCanvas(ImageBuffer*);
@@ -1427,7 +1430,8 @@
friend class GraphicsContext3DPrivate;
std::unique_ptr<GraphicsContext3DPrivate> m_private;
#endif
-
+
+ // FIXME: Layering violation.
WebGLRenderingContextBase* m_webglContext;
bool m_isForWebGL2 { false };
Modified: trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm (212636 => 212637)
--- trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm 2017-02-20 15:47:23 UTC (rev 212637)
@@ -189,8 +189,10 @@
void GraphicsContext3DManager::updateAllContexts()
{
#if PLATFORM(MAC)
- for (auto* context : m_contexts)
+ for (auto* context : m_contexts) {
context->updateCGLContext();
+ context->dispatchContextChangedNotification();
+ }
#endif
}
@@ -720,6 +722,11 @@
{
}
+void GraphicsContext3D::simulateContextChanged()
+{
+ manager().updateAllContexts();
}
+}
+
#endif // ENABLE(GRAPHICS_CONTEXT_3D)
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (212636 => 212637)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 2017-02-20 15:47:23 UTC (rev 212637)
@@ -1895,6 +1895,14 @@
#endif
}
+void GraphicsContext3D::dispatchContextChangedNotification()
+{
+#if ENABLE(WEBGL)
+ if (m_webglContext)
+ m_webglContext->dispatchContextChangedEvent();
+#endif
+}
+
void GraphicsContext3D::texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
{
makeContextCurrent();
Modified: trunk/Source/WebCore/testing/Internals.cpp (212636 => 212637)
--- trunk/Source/WebCore/testing/Internals.cpp 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/testing/Internals.cpp 2017-02-20 15:47:23 UTC (rev 212637)
@@ -134,6 +134,7 @@
#include "UserMediaController.h"
#include "ViewportArguments.h"
#include "WebCoreJSClientData.h"
+#include "WebGLRenderingContextBase.h"
#include "WorkerThread.h"
#include "WritingDirection.h"
#include "XMLHttpRequest.h"
@@ -3712,4 +3713,12 @@
document.page()->setAsRunningUserScripts();
}
+#if ENABLE(WEBGL)
+void Internals::simulateWebGLContextChanged(WebGLRenderingContextBase& context)
+{
+ context.simulateContextChanged();
+}
+#endif
+
+
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.h (212636 => 212637)
--- trunk/Source/WebCore/testing/Internals.h 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/testing/Internals.h 2017-02-20 15:47:23 UTC (rev 212637)
@@ -71,6 +71,7 @@
class StyleSheet;
class TimeRanges;
class TypeConversions;
+class WebGLRenderingContextBase;
class XMLHttpRequest;
class Internals final : public RefCounted<Internals>, private ContextDestructionObserver {
@@ -531,6 +532,10 @@
void setAsRunningUserScripts(Document&);
+#if ENABLE(WEBGL)
+ void simulateWebGLContextChanged(WebGLRenderingContextBase&);
+#endif
+
private:
explicit Internals(Document&);
Document* contextDocument() const;
Modified: trunk/Source/WebCore/testing/Internals.idl (212636 => 212637)
--- trunk/Source/WebCore/testing/Internals.idl 2017-02-20 15:30:24 UTC (rev 212636)
+++ trunk/Source/WebCore/testing/Internals.idl 2017-02-20 15:47:23 UTC (rev 212637)
@@ -504,4 +504,6 @@
[CallWith=Document] void setAsRunningUserScripts();
void disableTileSizeUpdateDelay();
+
+ [Conditional=WEBGL] void simulateWebGLContextChanged(WebGLRenderingContextBase context);
};