REGRESSION(r233325): [GTK] Broke 40 animations tests
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2018 06:54:12 +0000 (06:54 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2018 06:54:12 +0000 (06:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187264

Reviewed by Žan Doberšek.

Source/WebCore:

This is because DocumentAnimationScheduler uses DisplayRefreshMonitor, that is only used by GTK port when
accelerated compositing is enabled. Add a GTK display refresh monitor implementation to be used as the default.

* PlatformGTK.cmake: Add new file to compilation.
* platform/graphics/DisplayRefreshMonitor.cpp:
(WebCore::DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor): Create DisplayRefreshMonitorGtk in GTK.
* platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp: Added.
(WebCore::DisplayRefreshMonitorGtk::DisplayRefreshMonitorGtk):
(WebCore::DisplayRefreshMonitorGtk::~DisplayRefreshMonitorGtk):
(WebCore::onFrameClockUpdate):
(WebCore::DisplayRefreshMonitorGtk::requestRefreshCallback):
(WebCore::DisplayRefreshMonitorGtk::displayLinkFired):
* platform/graphics/gtk/DisplayRefreshMonitorGtk.h: Added.
(WebCore::DisplayRefreshMonitorGtk::create):

Source/WebKit:

Use a different PlatformDisplayID for compositing in the GTK port. This way, when entering AC a window screen
changed is emitted and the GTK default display refresh monitor is destroyed, ensuring the one created by the
threaded compositor is used.

* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::create): Remove unused WebPage parameter and add PlatformDisplayID.
(WebKit::ThreadedCompositor::ThreadedCompositor): Create the display refresh monitor with the given displayID.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp:
(WebKit::ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor): Pass the given displayID to the parent constructor.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h:
(WebKit::ThreadedDisplayRefreshMonitor::create): Add PlatformDisplayID parameter.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Use compositingDisplayID when
creating the threaded compositor and notify about the window screen change.
(WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable): Use primaryDisplayID when leaving AC and
compositingDisplayID when re-entering.

LayoutTests:

Remove expectations for tests that are passing now.

* platform/gtk/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233512 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/PlatformGTK.cmake
Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp
Source/WebCore/platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gtk/DisplayRefreshMonitorGtk.h [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp
Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp

index dbd2a47..0002bfd 100644 (file)
@@ -1,3 +1,14 @@
+2018-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        REGRESSION(r233325): [GTK] Broke 40 animations tests
+        https://bugs.webkit.org/show_bug.cgi?id=187264
+
+        Reviewed by Žan Doberšek.
+
+        Remove expectations for tests that are passing now.
+
+        * platform/gtk/TestExpectations:
+
 2018-07-04  Antti Koivisto  <antti@apple.com>
 
         Reparse user stylesheets when _useSystemAppearance changes
index 25d8802..3e222d1 100644 (file)
@@ -1177,7 +1177,6 @@ webkit.org/b/186219 fast/forms/textarea-placeholder-wrapping.html [ ImageOnlyFai
 # This seems to be testing Apple-specific behavior?
 css3/color-filters/color-filter-ignore-semantic.html [ ImageOnlyFailure ]
 
-webkit.org/b/187044 animations/transition-and-animation-1.html [ Failure ]
 webkit.org/b/187044 webanimations/opacity-animation-yields-compositing-span.html [ Failure Timeout ]
 
 webkit.org/b/187041 imported/mozilla/css-animations/test_animation-pausing.html [ Failure Timeout ]
@@ -2333,41 +2332,6 @@ webkit.org/b/186253 http/tests/security/contentSecurityPolicy/media-src-allowed.
 
 webkit.org/b/186341 fast/animation/css-animation-resuming-when-visible-with-style-change.html [ Timeout Failure Pass ]
 webkit.org/b/186252 legacy-animation-engine/css3/filters/backdrop/animation.html [ Timeout ]
-webkit.org/b/186662 animations/transition-and-animation-3.html [ Timeout ]
-webkit.org/b/186853 imported/mozilla/css-transitions/test_element-get-animations.html [ Timeout ]
-
-webkit.org/b/187264 animations/transition-and-animation-2.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/cancel.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/pause.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/pending.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/play.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/playbackRate.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/ready.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/startTime.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html [ Failure ]
-webkit.org/b/187264 imported/w3c/web-platform-tests/web-animations/timing-model/timelines/document-timelines.html [ Failure ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_animation-cancel.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_animation-computed-timing.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_animation-currenttime.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_animation-finish.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_animation-ready.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_animation-starttime.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-animations/test_setting-effect.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_animation-cancel.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_animation-computed-timing.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_animation-currenttime.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_animation-pausing.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_animation-ready.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_animation-starttime.html [ Timeout ]
-webkit.org/b/187264 imported/mozilla/css-transitions/test_setting-effect.html [ Timeout ]
-webkit.org/b/187264 webanimations/opacity-animation-yields-compositing.html [ Timeout ]
 
 webkit.org/b/187266 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-api-texttracks.html [ Pass Timeout ]
 
@@ -3417,7 +3381,6 @@ webkit.org/b/183902 fast/dom/frame-loading-via-document-write.html [ Failure ]
 
 webkit.org/b/184080 animations/animation-direction-normal.html [ Failure ]
 webkit.org/b/184080 animations/animation-direction-reverse.html [ Failure ]
-webkit.org/b/184080 animations/change-keyframes.html [ Failure ]
 webkit.org/b/184080 animations/play-state-in-shorthand.html [ Failure ]
 webkit.org/b/184080 animations/transform-non-accelerated.html [ Failure ]
 
@@ -3485,20 +3448,14 @@ webkit.org/b/186100 css3/color-filters/color-filter-color-property-list-item.htm
 webkit.org/b/186100 css3/color-filters/color-filter-opacity.html [ ImageOnlyFailure ]
 webkit.org/b/186100 fast/hidpi/filters-turbulence.html [ ImageOnlyFailure ]
 
-webkit.org/b/186138 imported/mozilla/css-transitions/test_event-dispatch.html [ Failure Timeout ]
-
 webkit.org/b/186139 imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html [ Failure ]
 
 webkit.org/b/186141 svg/dom/SVGGeometry-isPointInStroke.xhtml [ Failure ]
 
 webkit.org/b/186142 imported/w3c/web-platform-tests/css/css-text/text-transform/text-transform-upperlower-016.html [ ImageOnlyFailure ]
 
-webkit.org/b/186144 transitions/transition-end-event-rendering.html [ Timeout ]
-
 webkit.org/b/186252 legacy-animation-engine/css3/filters/composited-during-transition-layertree.html [ Failure ]
 
-webkit.org/b/186340 transitions/zero-duration-with-non-zero-delay-start.html [ Timeout Failure ]
-
 webkit.org/b/186618 imported/w3c/web-platform-tests/fetch/api/headers/header-values.html [ Failure ]
 
 webkit.org/b/186601 fullscreen/full-screen-layer-dump.html [ Failure ]
index 38a0d11..28192a9 100644 (file)
@@ -1,3 +1,25 @@
+2018-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        REGRESSION(r233325): [GTK] Broke 40 animations tests
+        https://bugs.webkit.org/show_bug.cgi?id=187264
+
+        Reviewed by Žan Doberšek.
+
+        This is because DocumentAnimationScheduler uses DisplayRefreshMonitor, that is only used by GTK port when
+        accelerated compositing is enabled. Add a GTK display refresh monitor implementation to be used as the default.
+
+        * PlatformGTK.cmake: Add new file to compilation.
+        * platform/graphics/DisplayRefreshMonitor.cpp:
+        (WebCore::DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor): Create DisplayRefreshMonitorGtk in GTK.
+        * platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp: Added.
+        (WebCore::DisplayRefreshMonitorGtk::DisplayRefreshMonitorGtk):
+        (WebCore::DisplayRefreshMonitorGtk::~DisplayRefreshMonitorGtk):
+        (WebCore::onFrameClockUpdate):
+        (WebCore::DisplayRefreshMonitorGtk::requestRefreshCallback):
+        (WebCore::DisplayRefreshMonitorGtk::displayLinkFired):
+        * platform/graphics/gtk/DisplayRefreshMonitorGtk.h: Added.
+        (WebCore::DisplayRefreshMonitorGtk::create):
+
 2018-07-04  Antti Koivisto  <antti@apple.com>
 
         Reparse user stylesheets when _useSystemAppearance changes
index c2d4cae..ee5f1bb 100644 (file)
@@ -48,6 +48,7 @@ list(APPEND WebCorePlatformGTK_SOURCES
     platform/graphics/PlatformDisplay.cpp
 
     platform/graphics/gtk/ColorGtk.cpp
+    platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp
     platform/graphics/gtk/GdkCairoUtilities.cpp
     platform/graphics/gtk/IconGtk.cpp
     platform/graphics/gtk/ImageBufferGtk.cpp
index 21a2e7d..968bb22 100644 (file)
@@ -35,6 +35,8 @@
 #include "DisplayRefreshMonitorIOS.h"
 #elif PLATFORM(MAC)
 #include "DisplayRefreshMonitorMac.h"
+#elif PLATFORM(GTK)
+#include "DisplayRefreshMonitorGtk.h"
 #endif
 
 namespace WebCore {
@@ -47,6 +49,9 @@ RefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::createDefaultDisplayRefresh
 #if PLATFORM(IOS)
     return DisplayRefreshMonitorIOS::create(displayID);
 #endif
+#if PLATFORM(GTK)
+    return DisplayRefreshMonitorGtk::create(displayID);
+#endif
     UNUSED_PARAM(displayID);
     return nullptr;
 }
diff --git a/Source/WebCore/platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp b/Source/WebCore/platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp
new file mode 100644 (file)
index 0000000..1052a62
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * 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 "DisplayRefreshMonitorGtk.h"
+
+#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+
+#include <gtk/gtk.h>
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+DisplayRefreshMonitorGtk::DisplayRefreshMonitorGtk(PlatformDisplayID displayID)
+    : DisplayRefreshMonitor(displayID)
+{
+}
+
+DisplayRefreshMonitorGtk::~DisplayRefreshMonitorGtk()
+{
+    if (m_window)
+        gtk_widget_destroy(m_window);
+}
+
+#ifndef GTK_API_VERSION_2
+static void onFrameClockUpdate(GdkFrameClock*, DisplayRefreshMonitorGtk* monitor)
+{
+    monitor->displayLinkFired();
+}
+#endif
+
+bool DisplayRefreshMonitorGtk::requestRefreshCallback()
+{
+    if (!isActive())
+        return false;
+
+#ifndef GTK_API_VERSION_2
+    if (!m_window) {
+        // GdkFrameClockIdle is private in GDK, so we need to create a toplevel to get its frame clock.
+        m_window = gtk_offscreen_window_new();
+        gtk_widget_realize(m_window);
+
+        auto* frameClock = gtk_widget_get_frame_clock(m_window);
+        if (!frameClock)
+            return false;
+
+        g_signal_connect(frameClock, "update", G_CALLBACK(onFrameClockUpdate), this);
+        gdk_frame_clock_begin_updating(frameClock);
+
+        setIsActive(true);
+    }
+
+    LockHolder lock(mutex());
+    setIsScheduled(true);
+    return true;
+#else
+    return false;
+#endif
+}
+
+void DisplayRefreshMonitorGtk::displayLinkFired()
+{
+    {
+        LockHolder lock(mutex());
+        if (!isPreviousFrameDone())
+            return;
+
+        setIsPreviousFrameDone(false);
+    }
+    ASSERT(isMainThread());
+    handleDisplayRefreshedNotificationOnMainThread(this);
+}
+
+} // namespace WebCore
+
+#endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
diff --git a/Source/WebCore/platform/graphics/gtk/DisplayRefreshMonitorGtk.h b/Source/WebCore/platform/graphics/gtk/DisplayRefreshMonitorGtk.h
new file mode 100644 (file)
index 0000000..1596375
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * 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
+
+#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+
+#include "DisplayRefreshMonitor.h"
+
+typedef struct _GtkWidget GtkWidget;
+
+namespace WebCore {
+
+class DisplayRefreshMonitorGtk : public DisplayRefreshMonitor {
+public:
+    static RefPtr<DisplayRefreshMonitorGtk> create(PlatformDisplayID displayID)
+    {
+#ifndef GTK_API_VERSION_2
+        return adoptRef(*new DisplayRefreshMonitorGtk(displayID));
+#else
+        UNUSED_PARAM(displayID);
+        return nullptr;
+#endif
+    }
+
+    virtual ~DisplayRefreshMonitorGtk();
+
+    void displayLinkFired() override;
+    bool requestRefreshCallback() override;
+
+private:
+    explicit DisplayRefreshMonitorGtk(PlatformDisplayID);
+
+    GtkWidget* m_window { nullptr };
+};
+
+} // namespace WebCore
+
+#endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
index 8987174..55c5726 100644 (file)
@@ -1,3 +1,28 @@
+2018-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        REGRESSION(r233325): [GTK] Broke 40 animations tests
+        https://bugs.webkit.org/show_bug.cgi?id=187264
+
+        Reviewed by Žan Doberšek.
+
+        Use a different PlatformDisplayID for compositing in the GTK port. This way, when entering AC a window screen
+        changed is emitted and the GTK default display refresh monitor is destroyed, ensuring the one created by the
+        threaded compositor is used.
+
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::create): Remove unused WebPage parameter and add PlatformDisplayID.
+        (WebKit::ThreadedCompositor::ThreadedCompositor): Create the display refresh monitor with the given displayID.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp:
+        (WebKit::ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor): Pass the given displayID to the parent constructor.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h:
+        (WebKit::ThreadedDisplayRefreshMonitor::create): Add PlatformDisplayID parameter.
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Use compositingDisplayID when
+        creating the threaded compositor and notify about the window screen change.
+        (WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable): Use primaryDisplayID when leaving AC and
+        compositingDisplayID when re-entering.
+
 2018-07-04  Olivia Barnett  <obarnett@apple.com>
 
         A WKWebView in a UIViewController that is presented modally and uses a file picker will be incorrectly dismissed by the system
index de676dc..6f1ff2c 100644 (file)
 namespace WebKit {
 using namespace WebCore;
 
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, WebPage& webPage, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
 {
-    return adoptRef(*new ThreadedCompositor(client, webPage, viewportSize, scaleFactor, doFrameSync, paintFlags));
+    return adoptRef(*new ThreadedCompositor(client, displayID, viewportSize, scaleFactor, doFrameSync, paintFlags));
 }
 
-ThreadedCompositor::ThreadedCompositor(Client& client, WebPage& webPage, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+ThreadedCompositor::ThreadedCompositor(Client& client, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
     : m_client(client)
     , m_doFrameSync(doFrameSync)
     , m_paintFlags(paintFlags)
     , m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
-    , m_displayRefreshMonitor(ThreadedDisplayRefreshMonitor::create(*this))
+    , m_displayRefreshMonitor(ThreadedDisplayRefreshMonitor::create(displayID, *this))
 #endif
 {
     {
index fe37b21..037fd77 100644 (file)
@@ -47,7 +47,6 @@ namespace WebKit {
 class CoordinatedGraphicsScene;
 class CoordinatedGraphicsSceneClient;
 class ThreadedDisplayRefreshMonitor;
-class WebPage;
 
 class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
     WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
@@ -66,7 +65,7 @@ public:
 
     enum class ShouldDoFrameSync { No, Yes };
 
-    static Ref<ThreadedCompositor> create(Client&, WebPage&, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
+    static Ref<ThreadedCompositor> create(Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
     virtual ~ThreadedCompositor();
 
     void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -90,7 +89,7 @@ public:
     void frameComplete();
 
 private:
-    ThreadedCompositor(Client&, WebPage&, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
+    ThreadedCompositor(Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
 
     // CoordinatedGraphicsSceneClient
     void updateViewport() override;
index dee5d01..51487b9 100644 (file)
@@ -37,8 +37,8 @@
 
 namespace WebKit {
 
-ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(ThreadedCompositor& compositor)
-    : WebCore::DisplayRefreshMonitor(0)
+ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID displayID, ThreadedCompositor& compositor)
+    : WebCore::DisplayRefreshMonitor(displayID)
     , m_displayRefreshTimer(RunLoop::main(), this, &ThreadedDisplayRefreshMonitor::displayRefreshCallback)
     , m_compositor(&compositor)
 {
index 8d46e3d..d0b07f3 100644 (file)
@@ -36,9 +36,9 @@ class ThreadedCompositor;
 
 class ThreadedDisplayRefreshMonitor : public WebCore::DisplayRefreshMonitor {
 public:
-    static Ref<ThreadedDisplayRefreshMonitor> create(ThreadedCompositor& compositor)
+    static Ref<ThreadedDisplayRefreshMonitor> create(WebCore::PlatformDisplayID displayID, ThreadedCompositor& compositor)
     {
-        return adoptRef(*new ThreadedDisplayRefreshMonitor(compositor));
+        return adoptRef(*new ThreadedDisplayRefreshMonitor(displayID, compositor));
     }
     virtual ~ThreadedDisplayRefreshMonitor() = default;
 
@@ -49,7 +49,7 @@ public:
     void invalidate();
 
 private:
-    ThreadedDisplayRefreshMonitor(ThreadedCompositor&);
+    ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID, ThreadedCompositor&);
 
     void displayRefreshCallback();
     RunLoop::Timer<ThreadedDisplayRefreshMonitor> m_displayRefreshTimer;
index fb1b5f7..5419851 100644 (file)
 namespace WebKit {
 using namespace WebCore;
 
+static const PlatformDisplayID primaryDisplayID = 0;
+#if PLATFORM(GTK)
+static const PlatformDisplayID compositingDisplayID = 1;
+#else
+static const PlatformDisplayID compositingDisplayID = primaryDisplayID;
+#endif
+
 Ref<ThreadedCoordinatedLayerTreeHost> ThreadedCoordinatedLayerTreeHost::create(WebPage& webPage)
 {
     return adoptRef(*new ThreadedCoordinatedLayerTreeHost(webPage));
@@ -70,10 +77,12 @@ ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webP
         if (m_surface->shouldPaintMirrored())
             paintFlags |= TextureMapper::PaintingMirrored;
 
-        m_compositor = ThreadedCompositor::create(m_compositorClient, webPage, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, compositingDisplayID, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
         m_layerTreeContext.contextID = m_surface->surfaceID();
     } else
-        m_compositor = ThreadedCompositor::create(m_compositorClient, webPage, scaledSize, scaleFactor);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, compositingDisplayID, scaledSize, scaleFactor);
+
+    m_webPage.windowScreenDidChange(compositingDisplayID);
 
     didChangeViewport();
 }
@@ -253,8 +262,10 @@ void ThreadedCoordinatedLayerTreeHost::setIsDiscardable(bool discardable)
     m_isDiscardable = discardable;
     if (m_isDiscardable) {
         m_discardableSyncActions = OptionSet<DiscardableSyncActions>();
+        m_webPage.windowScreenDidChange(primaryDisplayID);
         return;
     }
+    m_webPage.windowScreenDidChange(compositingDisplayID);
 
     if (m_discardableSyncActions.isEmpty())
         return;