Changeset 204013 in webkit


Ignore:
Timestamp:
Aug 1, 2016 11:42:18 PM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Move the redirected XComposite window to the web process
https://bugs.webkit.org/show_bug.cgi?id=160389

Reviewed by Žan Doberšek.

Source/WebCore:

Add helper methods to PlatformDisplayX11 to query X extensions supported by the display.

  • platform/graphics/x11/PlatformDisplayX11.cpp:

(WebCore::PlatformDisplayX11::supportsXComposite):
(WebCore::PlatformDisplayX11::supportsXDamage):

  • platform/graphics/x11/PlatformDisplayX11.h:

Source/WebKit2:

In the current code, the UI process creates the redirected window that the web process uses to render
accelerated contents. The redirected window is sent to the web process as native surface handle, and using
XDamage extension the UI process takes a pixmap of the redirected window to render into the widget when there
are updates. This requires several points of synchronization between UI and web processes. When the web view is
resized, the UI process first resizes the redirected window and then sends a new backing store ID to the web
process. The time between the redirected window is resized and the web process renders the new contents the UI
process keeps rendering the previous contents with the previous size in the new window with the new size. This
makes the resize process slow, and it produces rendering artifacts quite often. The redirected window is created
when the web view is realized, to be able to inherit the XVisual from the parent window, and the native window
handle is sent to the web process. The time until the window is realized, the web process doesn't have a context
to render into, so the UI process simply renders an empty page. When the web view is unrealized, for example if
the web view is reparented, the redirected window is destroyed, and a sync message is sent to the web process to
destroy the current gl context and stop drawing. This needs to happen synchronously, because the UI process
can't remove the redirected window until the web process has stopped rendering into it. This makes also the
reparenting process quite unstable and risky.
To all those synchronization points we now have to add the synchronization with the compositing thread when
using the threaded compositor. The threaded compositor made resizing, reparenting, etc. even worse. We can't
avoid the synchronization with the threaded compositor, but we can reduce the synchronization points and improve
the current ones by moving the redirected window to the web process. In this case is web process who creates the
redirected window, so we can be sure that it always has a valid native surface handle to render into. This means
we no longer need the IPC message to send the native surface handle from the UI process to the web process, nor
the sync message to destroy it either. This also means we no longer need to wait until the view is realized to
start rendering accelerated contents, and we don't need to stop when it's unrealized either. We don't really
need to inherit the XVisual from the parent window if the redirected window always uses always a RGBA visual
when available. That way we always render into a transparent window that is composed into the web view
widget. And when the web view is resized, we no longer need to destroy the GL context either, because we use the
same redirected window as the native handle, but create a new pixmap that is what we send to the UI process as
layer tree context ID. The layer tree context ID is already sent to the UI process by the drawing area as part
of the backing store update process, so we don't need any new IPC message for this. When the web view is
resized, the UI process sends a backing store state update message to the web process that updates its size,
relayouts and then renders the new contents, so that when the update backing store state reply gets to the UI
process, we already have a new pixmap with the new contents updated. This makes resizing smooth again, and
avoids flickering and rendering artifacts. And finally all this also prevents several race conditions that were
causing X errors and web process crashes.

  • PlatformGTK.cmake:
  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:

(WebKit::ThreadedCompositor::create): Make it possible to optionally pass a native surface handle for
compositing to the ThreadedCompositor contructor.
(WebKit::ThreadedCompositor::ThreadedCompositor): Initialize the native surface handle and make the scene active
after the thread initialization if we already have a valid handle.

  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::enterAcceleratedCompositingMode): Pass the layer tree context ID to the web view.
(WebKit::PageClientImpl::updateAcceleratedCompositingMode): Notify the web view about the update.
(WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.

  • UIProcess/API/gtk/PageClientImpl.h:
  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseSetAcceleratedCompositingPixmap): Helper function to update the pixmap used to render the
accelerated contents.
(webkitWebViewBaseRealize): Remove the code to create the redirected window.
(webkitWebViewBaseUnrealize): Remove the code to destroy the redirected window.
(webkitWebViewBaseDispose): Reset the accelerated compositing pixmap.
(webkitWebViewRenderAcceleratedCompositingResults): Use the accelerated compositing pixmap surface.
(webkitWebViewBaseSizeAllocate): Remove the code to resize the redirected window.
(webkitWebViewBaseEnterAcceleratedCompositingMode): Update the accelerated compositing pixmap.
(webkitWebViewBaseUpdateAcceleratedCompositingMode): Ditto.
(webkitWebViewBaseExitAcceleratedCompositingMode): Reset the accelerated compositing pixmap.
(webkitWebViewBaseDidRelaunchWebProcess): Remove the code to send native surface handle to the web process.
(webkitWebViewBasePageClosed): Reset the accelerated compositing pixmap.
(_WebKitWebViewBasePrivate::updateViewStateTimerFired): Deleted.

  • UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
  • UIProcess/DrawingAreaProxy.h:
  • UIProcess/DrawingAreaProxy.messages.in:
  • UIProcess/DrawingAreaProxyImpl.cpp:

(WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Handle the case when the layer tree context ID
changes without leaving the accelerated compositing mode, calling updateAcceleratedCompositingMode().
(WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): Let the web view know we are leaving accelerated
compositing mode even when it's forced, since in case of web process crash we need to leave the accelerated
compositing mode in the UI process.
(WebKit::DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode): This message was added only to prepare the
redirected window when the web process was about to enter accelerated compositing mode, so it's no longer needed.
(WebKit::DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing): This is now only used when building
without redirected XComposite window support.

  • UIProcess/DrawingAreaProxyImpl.h:
  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::willEnterAcceleratedCompositingMode): Deleted.

  • UIProcess/WebPageProxy.h:
  • UIProcess/efl/WebView.h:
  • UIProcess/gtk/RedirectedXCompositeWindow.cpp: Removed.
  • UIProcess/gtk/XDamageNotifier.cpp: Helper class to be notified about XDamage events.

(WebKit::XDamageNotifier::singleton):
(WebKit::XDamageNotifier::XDamageNotifier):
(WebKit::XDamageNotifier::add):
(WebKit::XDamageNotifier::remove):
(WebKit::XDamageNotifier::filterXDamageEvent):
(WebKit::XDamageNotifier::notify):

  • UIProcess/gtk/XDamageNotifier.h: Added.
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.

  • UIProcess/mac/PageClientImpl.h:
  • UIProcess/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.

  • WebProcess/WebPage/AcceleratedDrawingArea.cpp:

(WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Remove code to send
WillEnterAcceleratedCompositingMode message.
(WebKit::AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing): This is now only used when building
without redirected XComposite window support.

  • WebProcess/WebPage/AcceleratedDrawingArea.h:
  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:

(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Create a redirected window and
pass the window ID as native surface handle to the threaded compositor. Use the redirected window pixmap as
layer tree context.
(WebKit::ThreadedCoordinatedLayerTreeHost::invalidate): Destroy the redirected window.
(WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Resize the redirected window and
update the layer tree context.
(WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.

  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
  • WebProcess/WebPage/DrawingArea.h:
  • WebProcess/WebPage/DrawingArea.messages.in:
  • WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:

(WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Create a redirected window and texture mapper that uses the window
ID as native surface handle. Use the redirected window pixmap as layer tree context.
(WebKit::LayerTreeHostGtk::makeContextCurrent): Use the redirected window as native handle.
(WebKit::LayerTreeHostGtk::invalidate): Destroy the redirected window.
(WebKit::LayerTreeHostGtk::sizeDidChange): Resize the redirected window and update the layer tree context.
(WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged): Ditto.
(WebKit::LayerTreeHostGtk::createTextureMapper): Helper function to create the texture mapper.
(WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Use createTextureMapper().

  • WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
  • WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp: Added.

(WebKit::RedirectedXCompositeWindow::create):
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
(WebKit::RedirectedXCompositeWindow::resize):

  • WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h.

(WebKit::RedirectedXCompositeWindow::window):
(WebKit::RedirectedXCompositeWindow::pixmap):

Location:
trunk/Source
Files:
3 added
1 deleted
31 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r204006 r204013  
     12016-08-01  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Move the redirected XComposite window to the web process
     4        https://bugs.webkit.org/show_bug.cgi?id=160389
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Add helper methods to PlatformDisplayX11 to query X extensions supported by the display.
     9
     10        * platform/graphics/x11/PlatformDisplayX11.cpp:
     11        (WebCore::PlatformDisplayX11::supportsXComposite):
     12        (WebCore::PlatformDisplayX11::supportsXDamage):
     13        * platform/graphics/x11/PlatformDisplayX11.h:
     14
    1152016-08-01  Andreas Kling  <akling@apple.com>
    216
  • trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp

    r200046 r204013  
    2929#if PLATFORM(X11)
    3030#include <X11/Xlib.h>
     31#include <X11/extensions/Xcomposite.h>
     32#if PLATFORM(GTK)
     33#include <X11/extensions/Xdamage.h>
     34#endif
    3135
    3236#if USE(EGL)
     
    6266#endif
    6367
     68bool PlatformDisplayX11::supportsXComposite() const
     69{
     70    if (!m_supportsXComposite) {
     71        int eventBase, errorBase;
     72        m_supportsXComposite = XCompositeQueryExtension(m_display, &eventBase, &errorBase);
     73    }
     74    return m_supportsXComposite.value();
     75}
     76
     77bool PlatformDisplayX11::supportsXDamage(Optional<int>& damageEventBase) const
     78{
     79    if (!m_supportsXDamage) {
     80#if PLATFORM(GTK)
     81        int eventBase, errorBase;
     82        m_supportsXDamage = XDamageQueryExtension(m_display, &eventBase, &errorBase);
     83        if (m_supportsXDamage.value())
     84            m_damageEventBase = eventBase;
     85#else
     86        m_supportsXDamage = false;
     87#endif
     88    }
     89
     90    damageEventBase = m_damageEventBase;
     91    return m_supportsXDamage.value();
     92}
     93
    6494} // namespace WebCore
    6595
  • trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h

    r197563 r204013  
    3030
    3131#include "PlatformDisplay.h"
     32#include <wtf/Optional.h>
    3233
    3334typedef struct _XDisplay Display;
     
    4243
    4344    Display* native() const { return m_display; }
     45    bool supportsXComposite() const;
     46    bool supportsXDamage(Optional<int>& damageEventBase) const;
    4447
    4548private:
     
    5255    Display* m_display;
    5356    bool m_ownedDisplay;
     57    mutable Optional<bool> m_supportsXComposite;
     58    mutable Optional<bool> m_supportsXDamage;
     59    mutable Optional<int> m_damageEventBase;
    5460};
    5561
  • trunk/Source/WebKit2/ChangeLog

    r204011 r204013  
     12016-08-01  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Move the redirected XComposite window to the web process
     4        https://bugs.webkit.org/show_bug.cgi?id=160389
     5
     6        Reviewed by Žan Doberšek.
     7
     8        In the current code, the UI process creates the redirected window that the web process uses to render
     9        accelerated contents. The redirected window is sent to the web process as native surface handle, and using
     10        XDamage extension the UI process takes a pixmap of the redirected window to render into the widget when there
     11        are updates. This requires several points of synchronization between UI and web processes. When the web view is
     12        resized, the UI process first resizes the redirected window and then sends a new backing store ID to the web
     13        process. The time between the redirected window is resized and the web process renders the new contents the UI
     14        process keeps rendering the previous contents with the previous size in the new window with the new size. This
     15        makes the resize process slow, and it produces rendering artifacts quite often. The redirected window is created
     16        when the web view is realized, to be able to inherit the XVisual from the parent window, and the native window
     17        handle is sent to the web process. The time until the window is realized, the web process doesn't have a context
     18        to render into, so the UI process simply renders an empty page. When the web view is unrealized, for example if
     19        the web view is reparented, the redirected window is destroyed, and a sync message is sent to the web process to
     20        destroy the current gl context and stop drawing. This needs to happen synchronously, because the UI process
     21        can't remove the redirected window until the web process has stopped rendering into it. This makes also the
     22        reparenting process quite unstable and risky.
     23        To all those synchronization points we now have to add the synchronization with the compositing thread when
     24        using the threaded compositor. The threaded compositor made resizing, reparenting, etc. even worse. We can't
     25        avoid the synchronization with the threaded compositor, but we can reduce the synchronization points and improve
     26        the current ones by moving the redirected window to the web process. In this case is web process who creates the
     27        redirected window, so we can be sure that it always has a valid native surface handle to render into. This means
     28        we no longer need the IPC message to send the native surface handle from the UI process to the web process, nor
     29        the sync message to destroy it either. This also means we no longer need to wait until the view is realized to
     30        start rendering accelerated contents, and we don't need to stop when it's unrealized either. We don't really
     31        need to inherit the XVisual from the parent window if the redirected window always uses always a RGBA visual
     32        when available. That way we always render into a transparent window that is composed into the web view
     33        widget. And when the web view is resized, we no longer need to destroy the GL context either, because we use the
     34        same redirected window as the native handle, but create a new pixmap that is what we send to the UI process as
     35        layer tree context ID. The layer tree context ID is already sent to the UI process by the drawing area as part
     36        of the backing store update process, so we don't need any new IPC message for this. When the web view is
     37        resized, the UI process sends a backing store state update message to the web process that updates its size,
     38        relayouts and then renders the new contents, so that when the update backing store state reply gets to the UI
     39        process, we already have a new pixmap with the new contents updated. This makes resizing smooth again, and
     40        avoids flickering and rendering artifacts. And finally all this also prevents several race conditions that were
     41        causing X errors and web process crashes.
     42
     43        * PlatformGTK.cmake:
     44        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
     45        (WebKit::ThreadedCompositor::create): Make it possible to optionally pass a native surface handle for
     46        compositing to the ThreadedCompositor contructor.
     47        (WebKit::ThreadedCompositor::ThreadedCompositor): Initialize the native surface handle and make the scene active
     48        after the thread initialization if we already have a valid handle.
     49        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
     50        * UIProcess/API/gtk/PageClientImpl.cpp:
     51        (WebKit::PageClientImpl::enterAcceleratedCompositingMode): Pass the layer tree context ID to the web view.
     52        (WebKit::PageClientImpl::updateAcceleratedCompositingMode): Notify the web view about the update.
     53        (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
     54        * UIProcess/API/gtk/PageClientImpl.h:
     55        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     56        (webkitWebViewBaseSetAcceleratedCompositingPixmap): Helper function to update the pixmap used to render the
     57        accelerated contents.
     58        (webkitWebViewBaseRealize): Remove the code to create the redirected window.
     59        (webkitWebViewBaseUnrealize): Remove the code to destroy the redirected window.
     60        (webkitWebViewBaseDispose): Reset the accelerated compositing pixmap.
     61        (webkitWebViewRenderAcceleratedCompositingResults): Use the accelerated compositing pixmap surface.
     62        (webkitWebViewBaseSizeAllocate): Remove the code to resize the redirected window.
     63        (webkitWebViewBaseEnterAcceleratedCompositingMode): Update the accelerated compositing pixmap.
     64        (webkitWebViewBaseUpdateAcceleratedCompositingMode): Ditto.
     65        (webkitWebViewBaseExitAcceleratedCompositingMode): Reset the accelerated compositing pixmap.
     66        (webkitWebViewBaseDidRelaunchWebProcess): Remove the code to send native surface handle to the web process.
     67        (webkitWebViewBasePageClosed): Reset the accelerated compositing pixmap.
     68        (_WebKitWebViewBasePrivate::updateViewStateTimerFired): Deleted.
     69        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
     70        * UIProcess/DrawingAreaProxy.h:
     71        * UIProcess/DrawingAreaProxy.messages.in:
     72        * UIProcess/DrawingAreaProxyImpl.cpp:
     73        (WebKit::DrawingAreaProxyImpl::didUpdateBackingStoreState): Handle the case when the layer tree context ID
     74        changes without leaving the accelerated compositing mode, calling updateAcceleratedCompositingMode().
     75        (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): Let the web view know we are leaving accelerated
     76        compositing mode even when it's forced, since in case of web process crash we need to leave the accelerated
     77        compositing mode in the UI process.
     78        (WebKit::DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode): This message was added only to prepare the
     79        redirected window when the web process was about to enter accelerated compositing mode, so it's no longer needed.
     80        (WebKit::DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing): This is now only used when building
     81        without redirected XComposite window support.
     82        * UIProcess/DrawingAreaProxyImpl.h:
     83        * UIProcess/PageClient.h:
     84        * UIProcess/WebPageProxy.cpp:
     85        (WebKit::WebPageProxy::willEnterAcceleratedCompositingMode): Deleted.
     86        * UIProcess/WebPageProxy.h:
     87        * UIProcess/efl/WebView.h:
     88        * UIProcess/gtk/RedirectedXCompositeWindow.cpp: Removed.
     89        * UIProcess/gtk/XDamageNotifier.cpp: Helper class to be notified about XDamage events.
     90        (WebKit::XDamageNotifier::singleton):
     91        (WebKit::XDamageNotifier::XDamageNotifier):
     92        (WebKit::XDamageNotifier::add):
     93        (WebKit::XDamageNotifier::remove):
     94        (WebKit::XDamageNotifier::filterXDamageEvent):
     95        (WebKit::XDamageNotifier::notify):
     96        * UIProcess/gtk/XDamageNotifier.h: Added.
     97        * UIProcess/ios/PageClientImplIOS.h:
     98        * UIProcess/ios/PageClientImplIOS.mm:
     99        (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
     100        * UIProcess/mac/PageClientImpl.h:
     101        * UIProcess/mac/PageClientImpl.mm:
     102        (WebKit::PageClientImpl::willEnterAcceleratedCompositingMode): Deleted.
     103        * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
     104        (WebKit::AcceleratedDrawingArea::enterAcceleratedCompositingMode): Remove code to send
     105        WillEnterAcceleratedCompositingMode message.
     106        (WebKit::AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing): This is now only used when building
     107        without redirected XComposite window support.
     108        * WebProcess/WebPage/AcceleratedDrawingArea.h:
     109        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
     110        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Create a redirected window and
     111        pass the window ID as native surface handle to the threaded compositor. Use the redirected window pixmap as
     112        layer tree context.
     113        (WebKit::ThreadedCoordinatedLayerTreeHost::invalidate): Destroy the redirected window.
     114        (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Resize the redirected window and
     115        update the layer tree context.
     116        (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Ditto.
     117        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
     118        * WebProcess/WebPage/DrawingArea.h:
     119        * WebProcess/WebPage/DrawingArea.messages.in:
     120        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
     121        (WebKit::LayerTreeHostGtk::LayerTreeHostGtk): Create a redirected window and texture mapper that uses the window
     122        ID as native surface handle. Use the redirected window pixmap as layer tree context.
     123        (WebKit::LayerTreeHostGtk::makeContextCurrent): Use the redirected window as native handle.
     124        (WebKit::LayerTreeHostGtk::invalidate): Destroy the redirected window.
     125        (WebKit::LayerTreeHostGtk::sizeDidChange): Resize the redirected window and update the layer tree context.
     126        (WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged): Ditto.
     127        (WebKit::LayerTreeHostGtk::createTextureMapper): Helper function to create the texture mapper.
     128        (WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing): Use createTextureMapper().
     129        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
     130        * WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp: Added.
     131        (WebKit::RedirectedXCompositeWindow::create):
     132        (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
     133        (WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
     134        (WebKit::RedirectedXCompositeWindow::resize):
     135        * WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h: Renamed from Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h.
     136        (WebKit::RedirectedXCompositeWindow::window):
     137        (WebKit::RedirectedXCompositeWindow::pixmap):
     138
    11392016-08-01  Carlos Garcia Campos  <cgarcia@igalia.com>
    2140
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r203691 r204013  
    300300    UIProcess/gtk/InputMethodFilter.cpp
    301301    UIProcess/gtk/KeyBindingTranslator.cpp
    302     UIProcess/gtk/RedirectedXCompositeWindow.cpp
    303302    UIProcess/gtk/TextCheckerGtk.cpp
     303    UIProcess/gtk/XDamageNotifier.cpp
    304304    UIProcess/gtk/WebColorPickerGtk.cpp
    305305    UIProcess/gtk/WebContextMenuProxyGtk.cpp
     
    351351
    352352    WebProcess/WebPage/gtk/PrinterListGtk.cpp
     353    WebProcess/WebPage/gtk/RedirectedXCompositeWindow.cpp
    353354    WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp
    354355    WebProcess/WebPage/gtk/WebPageGtk.cpp
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp

    r203776 r204013  
    4242namespace WebKit {
    4343
    44 Ref<ThreadedCompositor> ThreadedCompositor::create(Client* client)
    45 {
    46     return adoptRef(*new ThreadedCompositor(client));
    47 }
    48 
    49 ThreadedCompositor::ThreadedCompositor(Client* client)
     44Ref<ThreadedCompositor> ThreadedCompositor::create(Client* client, uint64_t nativeSurfaceHandle)
     45{
     46    return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle));
     47}
     48
     49ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHandle)
    5050    : m_client(client)
     51    , m_nativeSurfaceHandle(nativeSurfaceHandle)
    5152    , m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
    5253{
     
    5455        m_scene = adoptRef(new CoordinatedGraphicsScene(this));
    5556        m_viewportController = std::make_unique<SimpleViewportController>(this);
     57        m_scene->setActive(!!m_nativeSurfaceHandle);
    5658    });
    5759}
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h

    r203776 r204013  
    5858    };
    5959
    60     static Ref<ThreadedCompositor> create(Client*);
     60    static Ref<ThreadedCompositor> create(Client*, uint64_t nativeSurfaceHandle = 0);
    6161    virtual ~ThreadedCompositor();
    6262
     
    7878
    7979private:
    80     ThreadedCompositor(Client*);
     80    ThreadedCompositor(Client*, uint64_t nativeSurfaceHandle);
    8181
    8282    // CoordinatedGraphicsSceneClient
     
    102102    float m_deviceScaleFactor { 1 };
    103103    bool m_drawsBackground { true };
    104     uint64_t m_nativeSurfaceHandle { 0 };
     104    uint64_t m_nativeSurfaceHandle;
    105105
    106106    std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp

    r203493 r204013  
    217217}
    218218
    219 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
    220 {
    221     webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
     219void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
     220{
     221    webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
    222222}
    223223
     
    227227}
    228228
    229 void PageClientImpl::willEnterAcceleratedCompositingMode()
    230 {
    231     webkitWebViewBaseWillEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
    232 }
    233 
    234 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
    235 {
    236     notImplemented();
     229void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
     230{
     231    webkitWebViewBaseUpdateAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext);
    237232}
    238233
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h

    r202183 r204013  
    9393    void exitAcceleratedCompositingMode() override;
    9494    void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
    95     void willEnterAcceleratedCompositingMode() override;
    9695
    9796    void handleDownloadRequest(DownloadProxy*) override;
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r203504 r204013  
    3838#include "NativeWebWheelEvent.h"
    3939#include "PageClientImpl.h"
    40 #include "RedirectedXCompositeWindow.h"
    4140#include "ViewState.h"
    4241#include "WebEventFactory.h"
     
    7473#endif
    7574
     75#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     76#include "XDamageNotifier.h"
     77#include <WebCore/PlatformDisplayX11.h>
     78#include <WebCore/XUniqueResource.h>
     79#include <X11/Xlib.h>
     80#include <X11/extensions/Xdamage.h>
     81#include <cairo-xlib.h>
     82#endif
     83
    7684#if PLATFORM(X11)
    7785#include <gdk/gdkx.h>
     
    152160    _WebKitWebViewBasePrivate()
    153161        : updateViewStateTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::updateViewStateTimerFired)
    154 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    155         , clearRedirectedWindowSoonTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::clearRedirectedWindowSoonTimerFired)
    156 #endif
    157162    {
    158163    }
     
    165170        viewStateFlagsToUpdate = ViewState::NoFlags;
    166171    }
    167 
    168 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    169     void clearRedirectedWindowSoonTimerFired()
    170     {
    171         if (redirectedWindow)
    172             redirectedWindow->resize(IntSize());
    173     }
    174 #endif
    175172
    176173    WebKitWebViewChildrenMap children;
     
    216213
    217214#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    218     std::unique_ptr<RedirectedXCompositeWindow> redirectedWindow;
    219     RunLoop::Timer<WebKitWebViewBasePrivate> clearRedirectedWindowSoonTimer;
     215    RefPtr<cairo_surface_t> acceleratedCompositingSurface;
     216    XUniqueDamage acceleratedCompositingSurfaceDamage;
    220217#endif
    221218
     
    356353
    357354#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    358 static void webkitWebViewBaseResizeRedirectedWindow(WebKitWebViewBase* webView)
    359 {
     355static void webkitWebViewBaseSetAcceleratedCompositingPixmap(WebKitWebViewBase* webView, Pixmap pixmap)
     356{
     357    if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
     358        return;
     359
    360360    WebKitWebViewBasePrivate* priv = webView->priv;
     361    if (priv->acceleratedCompositingSurface
     362        && cairo_xlib_surface_get_drawable(priv->acceleratedCompositingSurface.get()) == pixmap)
     363        return;
     364
     365    if (priv->acceleratedCompositingSurface) {
     366        if (priv->acceleratedCompositingSurfaceDamage) {
     367            XDamageNotifier::singleton().remove(priv->acceleratedCompositingSurfaceDamage.get());
     368            priv->acceleratedCompositingSurfaceDamage.reset();
     369        }
     370        priv->acceleratedCompositingSurface = nullptr;
     371    }
     372
     373    if (!pixmap)
     374        return;
     375
    361376    DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    362377    if (!drawingArea)
    363378        return;
    364     priv->redirectedWindow->resize(drawingArea->size());
     379
     380    IntSize size = drawingArea->size();
     381    float deviceScaleFactor = priv->pageProxy->deviceScaleFactor();
     382    size.scale(deviceScaleFactor);
     383
     384    Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     385    ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
     386    GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
     387    if (!visual)
     388        visual = gdk_screen_get_system_visual(gdk_screen_get_default());
     389    priv->acceleratedCompositingSurface = adoptRef(cairo_xlib_surface_create(display, pixmap, GDK_VISUAL_XVISUAL(visual), size.width(), size.height()));
     390    cairoSurfaceSetDeviceScale(priv->acceleratedCompositingSurface.get(), deviceScaleFactor, deviceScaleFactor);
     391    priv->acceleratedCompositingSurfaceDamage = XDamageCreate(display, pixmap, XDamageReportNonEmpty);
     392    XDamageNotifier::singleton().add(priv->acceleratedCompositingSurfaceDamage.get(), [webView] {
     393        gtk_widget_queue_draw(GTK_WIDGET(webView));
     394    });
    365395}
    366396#endif
     
    370400    WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
    371401    WebKitWebViewBasePrivate* priv = webView->priv;
    372 
    373 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    374     if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
    375         ASSERT(!priv->redirectedWindow);
    376         DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    377         priv->redirectedWindow = RedirectedXCompositeWindow::create(
    378             *priv->pageProxy,
    379             drawingArea && drawingArea->isInAcceleratedCompositingMode() ? drawingArea->size() : IntSize(),
    380             [webView] {
    381                 DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea());
    382                 if (drawingArea && drawingArea->isInAcceleratedCompositingMode())
    383                     gtk_widget_queue_draw(GTK_WIDGET(webView));
    384             });
    385         if (priv->redirectedWindow && drawingArea) {
    386             drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
    387             if (drawingArea->isInAcceleratedCompositingMode())
    388                 webkitWebViewBaseResizeRedirectedWindow(webView);
    389         }
    390     }
    391 #endif
    392402
    393403    gtk_widget_set_realized(widget, TRUE);
     
    440450{
    441451    WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
    442 #if USE(TEXTURE_MAPPER) && PLATFORM(X11)
     452#if USE(TEXTURE_MAPPER) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    443453    if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea()))
    444454        drawingArea->destroyNativeSurfaceHandleForCompositing();
    445 #endif
    446 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    447     webView->priv->redirectedWindow = nullptr;
    448455#endif
    449456    gtk_im_context_set_client_window(webView->priv->inputMethodFilter.context(), nullptr);
     
    558565    webkitWebViewBaseSetToplevelOnScreenWindow(webView, nullptr);
    559566    webView->priv->pageProxy->close();
     567#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     568    webkitWebViewBaseSetAcceleratedCompositingPixmap(webView, 0);
     569#endif
    560570    G_OBJECT_CLASS(webkit_web_view_base_parent_class)->dispose(gobject);
    561571}
     
    578588static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect)
    579589{
    580 #if USE(TEXTURE_MAPPER) && USE(REDIRECTED_XCOMPOSITE_WINDOW)
     590#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    581591    ASSERT(drawingArea);
    582592
     
    584594        return false;
    585595
    586     // To avoid flashes when initializing accelerated compositing for the first
    587     // time, we wait until we know there's a frame ready before rendering.
    588     WebKitWebViewBasePrivate* priv = webViewBase->priv;
    589     if (!priv->redirectedWindow)
    590         return false;
    591 
    592     webkitWebViewBaseResizeRedirectedWindow(webViewBase);
    593     if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
    594         cairo_save(cr);
    595 
    596         if (!priv->pageProxy->drawsBackground()) {
    597             const WebCore::Color& color = priv->pageProxy->backgroundColor();
    598             if (color.hasAlpha()) {
    599                 cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
    600                 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
    601                 cairo_fill(cr);
    602             }
    603 
    604             if (color.alpha() > 0) {
    605                 setSourceRGBAFromColor(cr, color);
    606                 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
    607                 cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
    608                 cairo_fill(cr);
    609             }
     596    WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(webViewBase)->priv;
     597    cairo_surface_t* surface = priv->acceleratedCompositingSurface.get();
     598    cairo_save(cr);
     599
     600    if (!surface || !priv->pageProxy->drawsBackground()) {
     601        const WebCore::Color& color = priv->pageProxy->backgroundColor();
     602        if (color.hasAlpha()) {
     603            cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
     604            cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
     605            cairo_fill(cr);
    610606        }
    611607
     608        if (color.alpha() > 0) {
     609            setSourceRGBAFromColor(cr, color);
     610            cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
     611            cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
     612            cairo_fill(cr);
     613        }
     614    }
     615
     616    if (surface) {
    612617        // The surface can be modified by the web process at any time, so we mark it
    613618        // as dirty to ensure we always render the updated contents as soon as possible.
     
    617622        cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    618623        cairo_fill(cr);
    619 
    620         cairo_restore(cr);
    621     }
     624    }
     625
     626    cairo_restore(cr);
    622627
    623628    return true;
     
    718723    }
    719724
    720     DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    721     if (!drawingArea)
    722         return;
    723 
    724 
    725 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    726     if (priv->redirectedWindow && drawingArea->isInAcceleratedCompositingMode()) {
    727         // We don't use webkitWebViewBaseResizeRedirectedWindow here, because we want to update the
    728         // redirected window size before the drawing area, because on resize the drawing area sends
    729         // the UpdateBackingStoreState message to the web process and waits for its reply. We want
    730         // the web process to use the new xwindow size when UpdateBackingStoreState message arrives.
    731         priv->redirectedWindow->resize(viewRect.size());
    732     }
    733 #endif
    734 
    735     drawingArea->setSize(viewRect.size(), IntSize(), IntSize());
     725    if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea()))
     726        drawingArea->setSize(viewRect.size(), IntSize(), IntSize());
    736727}
    737728
     
    12851276static void deviceScaleFactorChanged(WebKitWebViewBase* webkitWebViewBase)
    12861277{
    1287 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1288     if (webkitWebViewBase->priv->redirectedWindow)
    1289         webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
    1290 #endif
    12911278    webkitWebViewBase->priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
    12921279}
     
    15781565}
    15791566
     1567void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext& layerTreeContext)
     1568{
    15801569#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1581 static void webkitWebViewBaseClearRedirectedWindowSoon(WebKitWebViewBase* webkitWebViewBase)
    1582 {
    1583     static const double clearRedirectedWindowSoonDelay = 2;
    1584     webkitWebViewBase->priv->clearRedirectedWindowSoonTimer.startOneShot(clearRedirectedWindowSoonDelay);
    1585 }
    1586 #endif
    1587 
    1588 void webkitWebViewBaseWillEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
    1589 {
    1590 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1591     WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
    1592     if (!priv->redirectedWindow)
    1593         return;
    1594     DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    1595     if (!drawingArea)
    1596         return;
    1597 
    1598     webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
    1599 
    1600     // Clear the redirected window if we don't enter AC mode in the end.
    1601     webkitWebViewBaseClearRedirectedWindowSoon(webkitWebViewBase);
     1570    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
    16021571#else
    16031572    UNUSED_PARAM(webkitWebViewBase);
     
    16051574}
    16061575
    1607 void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
     1576void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase, const LayerTreeContext& layerTreeContext)
    16081577{
    16091578#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1610     webkitWebViewBase->priv->clearRedirectedWindowSoonTimer.stop();
     1579    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, layerTreeContext.contextID);
    16111580#else
    16121581    UNUSED_PARAM(webkitWebViewBase);
     
    16171586{
    16181587#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1619     // Resize the window later to ensure we have already rendered the
    1620     // non composited contents and avoid flickering. We can also avoid the
    1621     // window resize entirely if we switch back to AC mode quickly.
    1622     webkitWebViewBaseClearRedirectedWindowSoon(webkitWebViewBase);
     1588    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
    16231589#else
    16241590    UNUSED_PARAM(webkitWebViewBase);
     
    16311597    gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
    16321598
    1633 #if PLATFORM(X11) && USE(TEXTURE_MAPPER)
     1599#if PLATFORM(X11) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    16341600    if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
    16351601        return;
     
    16381604    DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    16391605    ASSERT(drawingArea);
    1640 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1641     if (!priv->redirectedWindow)
    1642         return;
    1643     uint64_t windowID = priv->redirectedWindow->windowID();
    1644 #else
     1606
    16451607    if (!gtk_widget_get_realized(GTK_WIDGET(webkitWebViewBase)))
    16461608        return;
     1609
    16471610    uint64_t windowID = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(webkitWebViewBase)));
    1648 #endif
    16491611    drawingArea->setNativeSurfaceHandleForCompositing(windowID);
    16501612#else
     
    16551617void webkitWebViewBasePageClosed(WebKitWebViewBase* webkitWebViewBase)
    16561618{
    1657 #if PLATFORM(X11) && USE(TEXTURE_MAPPER)
     1619#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     1620    webkitWebViewBaseSetAcceleratedCompositingPixmap(webkitWebViewBase, 0);
     1621#elif PLATFORM(X11) && USE(TEXTURE_MAPPER)
    16581622    if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
    16591623        return;
     
    16661630    ASSERT(drawingArea);
    16671631    drawingArea->destroyNativeSurfaceHandleForCompositing();
    1668 
    1669 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    1670     priv->redirectedWindow = nullptr;
    1671 #endif
    1672 #endif // PLATFORM(X11) && USE(TEXTURE_MAPPER)
    1673 }
     1632#endif
     1633}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

    r203493 r204013  
    7272void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
    7373void webkitWebViewBaseResetClickCounter(WebKitWebViewBase*);
    74 void webkitWebViewBaseWillEnterAcceleratedCompositingMode(WebKitWebViewBase*);
    75 void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*);
     74void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&);
     75void webkitWebViewBaseUpdateAcceleratedCompositingMode(WebKitWebViewBase*, const WebKit::LayerTreeContext&);
    7676void webkitWebViewBaseExitAcceleratedCompositingMode(WebKitWebViewBase*);
    7777void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase*);
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h

    r202611 r204013  
    131131    virtual void exitAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const UpdateInfo&) { }
    132132    virtual void updateAcceleratedCompositingMode(uint64_t /* backingStoreStateID */, const LayerTreeContext&) { }
    133     virtual void willEnterAcceleratedCompositingMode(uint64_t /* backingStoreStateID */) { }
    134133#if PLATFORM(COCOA)
    135134    virtual void didUpdateGeometry() { }
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in

    r191340 r204013  
    2727    ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
    2828    UpdateAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
    29     WillEnterAcceleratedCompositingMode(uint64_t backingStoreStateID)
    3029
    3130#if PLATFORM(COCOA)
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp

    r203676 r204013  
    158158
    159159    if (layerTreeContext != m_layerTreeContext) {
    160         if (!m_layerTreeContext.isEmpty()) {
     160        if (layerTreeContext.isEmpty() && !m_layerTreeContext.isEmpty()) {
    161161            exitAcceleratedCompositingMode();
    162162            ASSERT(m_layerTreeContext.isEmpty());
    163         }
    164 
    165         if (!layerTreeContext.isEmpty()) {
     163        } else if (!layerTreeContext.isEmpty() && m_layerTreeContext.isEmpty()) {
    166164            enterAcceleratedCompositingMode(layerTreeContext);
    167165            ASSERT(layerTreeContext == m_layerTreeContext);
    168         }           
     166        } else {
     167            updateAcceleratedCompositingMode(layerTreeContext);
     168            ASSERT(layerTreeContext == m_layerTreeContext);
     169        }
    169170    }
    170171
     
    174175        m_hasReceivedFirstUpdate = true;
    175176
    176 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
     177#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    177178        if (m_pendingNativeSurfaceHandleForCompositing) {
    178179            setNativeSurfaceHandleForCompositing(m_pendingNativeSurfaceHandleForCompositing);
     
    220221
    221222    updateAcceleratedCompositingMode(layerTreeContext);
    222 }
    223 
    224 void DrawingAreaProxyImpl::willEnterAcceleratedCompositingMode(uint64_t backingStoreStateID)
    225 {
    226     // WillEnterAcceleratedCompositingMode message is sent when the LayerTreeHost is created in the Web Process.
    227     // This can happen while there's still a DidUpdateBackingStoreState pending, in which case we are receiving
    228     // here the new backingStoreStateID, but m_currentBackingStoreStateID hasn't been updated yet.
    229     ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_nextBackingStoreStateID);
    230     m_webPageProxy.willEnterAcceleratedCompositingMode();
    231223}
    232224
     
    316308}
    317309
    318 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
     310#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    319311void DrawingAreaProxyImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
    320312{
     
    352344
    353345    m_layerTreeContext = LayerTreeContext();
    354     if (!alwaysUseCompositing())
    355         m_webPageProxy.exitAcceleratedCompositingMode();
     346    m_webPageProxy.exitAcceleratedCompositingMode();
    356347}
    357348
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h

    r203676 r204013  
    4949    bool hasReceivedFirstUpdate() const { return m_hasReceivedFirstUpdate; }
    5050
    51 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
     51#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    5252    void setNativeSurfaceHandleForCompositing(uint64_t);
    5353    void destroyNativeSurfaceHandleForCompositing();
     
    7070    void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) override;
    7171    void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
    72     void willEnterAcceleratedCompositingMode(uint64_t backingStoreStateID) override;
    7372
    7473    void incorporateUpdate(const UpdateInfo&);
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r203312 r204013  
    236236    virtual void exitAcceleratedCompositingMode() = 0;
    237237    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0;
    238     virtual void willEnterAcceleratedCompositingMode() = 0;
    239238
    240239#if PLATFORM(MAC)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r203635 r204013  
    54665466}
    54675467
    5468 void WebPageProxy::willEnterAcceleratedCompositingMode()
    5469 {
    5470     m_pageClient.willEnterAcceleratedCompositingMode();
    5471 }
    5472 
    54735468void WebPageProxy::backForwardClear()
    54745469{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r203312 r204013  
    825825    virtual void exitAcceleratedCompositingMode();
    826826    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
    827     void willEnterAcceleratedCompositingMode();
    828827
    829828    enum UndoOrRedo { Undo, Redo };
  • trunk/Source/WebKit2/UIProcess/efl/WebView.h

    r202183 r204013  
    222222    void exitAcceleratedCompositingMode() override;
    223223    void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
    224     void willEnterAcceleratedCompositingMode() override { }
    225224
    226225#if ENABLE(FULLSCREEN_API)
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r202183 r204013  
    104104    void exitAcceleratedCompositingMode() override;
    105105    void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
    106     void willEnterAcceleratedCompositingMode() override;
    107106    void setAcceleratedCompositingRootLayer(LayerOrView *) override;
    108107    LayerOrView *acceleratedCompositingRootLayer() const override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r202695 r204013  
    457457}
    458458
    459 void PageClientImpl::willEnterAcceleratedCompositingMode()
    460 {
    461 }
    462 
    463459void PageClientImpl::setAcceleratedCompositingRootLayer(LayerOrView *rootLayer)
    464460{
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r203312 r204013  
    139139    void exitAcceleratedCompositingMode() override;
    140140    void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
    141     void willEnterAcceleratedCompositingMode() override;
    142141
    143142    PassRefPtr<ViewSnapshot> takeViewSnapshot() override;
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r203312 r204013  
    481481}
    482482
    483 void PageClientImpl::willEnterAcceleratedCompositingMode()
    484 {
    485 }
    486 
    487483void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
    488484{
  • trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.cpp

    r202855 r204013  
    319319    m_wantsToExitAcceleratedCompositingMode = false;
    320320
    321     m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID));
    322 
    323321    ASSERT(!m_layerTreeHost);
    324322    m_layerTreeHost = LayerTreeHost::create(m_webPage);
    325 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
     323#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    326324    if (m_nativeSurfaceHandleForCompositing)
    327325        m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
     
    355353#endif
    356354
    357 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
     355#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    358356void AcceleratedDrawingArea::setNativeSurfaceHandleForCompositing(uint64_t handle)
    359357{
  • trunk/Source/WebKit2/WebProcess/WebPage/AcceleratedDrawingArea.h

    r202855 r204013  
    6464#endif
    6565
    66 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
     66#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    6767    void setNativeSurfaceHandleForCompositing(uint64_t) override;
    6868    void destroyNativeSurfaceHandleForCompositing(bool&) override;
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp

    r203504 r204013  
    3535#include <WebCore/MainFrame.h>
    3636
     37#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     38#include "RedirectedXCompositeWindow.h"
     39#endif
     40
    3741using namespace WebCore;
    3842
     
    5155    : CoordinatedLayerTreeHost(webPage)
    5256    , m_compositorClient(*this)
     57#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     58    , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
     59    , m_compositor(ThreadedCompositor::create(&m_compositorClient, m_redirectedWindow ? m_redirectedWindow->window() : 0))
     60#else
    5361    , m_compositor(ThreadedCompositor::create(&m_compositorClient))
     62#endif
    5463{
     64#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     65    if (m_redirectedWindow)
     66        m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
     67#endif
    5568}
    5669
     
    5972    m_compositor->invalidate();
    6073    CoordinatedLayerTreeHost::invalidate();
     74#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     75    m_redirectedWindow = nullptr;
     76#endif
    6177}
    6278
     
    8096void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
    8197{
     98#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     99    if (m_redirectedWindow) {
     100        m_redirectedWindow->resize(m_webPage.size());
     101        m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
     102    }
     103#endif
     104
    82105    CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
    83106    m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor());
     
    92115void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
    93116{
     117#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     118    if (m_redirectedWindow) {
     119        m_redirectedWindow->resize(size);
     120        m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
     121    }
     122#endif
    94123    CoordinatedLayerTreeHost::sizeDidChange(size);
    95124    m_compositor->didChangeViewportSize(size);
     
    106135}
    107136
    108 #if PLATFORM(GTK)
     137#if PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    109138void ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing(uint64_t handle)
    110139{
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h

    r203776 r204013  
    4242namespace WebKit {
    4343
     44class RedirectedXCompositeWindow;
    4445class WebPage;
    4546
     
    6566    bool forceRepaintAsync(uint64_t callbackID) override { return false; }
    6667
    67 #if PLATFORM(GTK)
     68#if PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    6869    void setNativeSurfaceHandleForCompositing(uint64_t) override;
    6970#endif
     
    104105    void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
    105106
    106     WebCore::IntPoint m_prevScrollPosition;
    107107    CompositorClient m_compositorClient;
     108#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     109    std::unique_ptr<RedirectedXCompositeWindow> m_redirectedWindow;
     110#endif
    108111    RefPtr<ThreadedCompositor> m_compositor;
    109112    float m_lastScaleFactor { 1 };
     113    WebCore::IntPoint m_prevScrollPosition;
    110114    WebCore::IntPoint m_lastScrollPosition;
    111115};
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h

    r202855 r204013  
    147147    WebPage& m_webPage;
    148148
    149 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER)
     149#if PLATFORM(GTK) && USE(TEXTURE_MAPPER) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    150150    uint64_t m_nativeSurfaceHandleForCompositing { 0 };
    151151#endif
     
    173173#endif
    174174
    175 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
     175#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    176176    virtual void setNativeSurfaceHandleForCompositing(uint64_t) = 0;
    177177    virtual void destroyNativeSurfaceHandleForCompositing(bool&) = 0;
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in

    r199111 r204013  
    4141#endif
    4242
    43 #if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
     43#if USE(TEXTURE_MAPPER) && PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    4444    SetNativeSurfaceHandleForCompositing(uint64_t handle)
    4545    DestroyNativeSurfaceHandleForCompositing() -> (bool handled)
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp

    r203496 r204013  
    5858#endif
    5959
     60#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     61#include "RedirectedXCompositeWindow.h"
     62#endif
     63
    6064using namespace WebCore;
    6165
     
    134138LayerTreeHostGtk::LayerTreeHostGtk(WebPage& webPage)
    135139    : LayerTreeHost(webPage)
     140#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     141    , m_redirectedWindow(RedirectedXCompositeWindow::create(webPage))
     142#endif
    136143    , m_renderFrameScheduler(std::bind(&LayerTreeHostGtk::renderFrame, this))
    137144{
     
    160167    m_rootLayer->addChild(m_nonCompositedContentLayer.get());
    161168    m_nonCompositedContentLayer->setNeedsDisplay();
     169
     170#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     171    if (m_redirectedWindow) {
     172        createTextureMapper();
     173        m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
     174    }
     175#endif
    162176}
    163177
    164178bool LayerTreeHostGtk::makeContextCurrent()
    165179{
    166     if (!m_layerTreeContext.contextID) {
     180#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     181    uint64_t nativeHandle = m_redirectedWindow ? m_redirectedWindow->window() : m_layerTreeContext.contextID;
     182#else
     183    uint64_t nativeHandle = m_layerTreeContext.contextID;
     184#endif
     185
     186    if (!nativeHandle) {
    167187        m_context = nullptr;
    168188        return false;
     
    170190
    171191    if (!m_context) {
    172         m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_layerTreeContext.contextID), GLContext::sharingContext());
     192        m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(nativeHandle), GLContext::sharingContext());
    173193        if (!m_context)
    174194            return false;
     
    209229    m_context = nullptr;
    210230    LayerTreeHost::invalidate();
     231
     232#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     233    m_redirectedWindow = nullptr;
     234#endif
    211235}
    212236
     
    248272    m_nonCompositedContentLayer->setNeedsDisplay();
    249273
     274#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     275    if (m_redirectedWindow) {
     276        m_redirectedWindow->resize(newSize);
     277        m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
     278    }
     279#endif
     280
    250281    compositeLayersToContext(ForResize);
    251282}
     
    253284void LayerTreeHostGtk::deviceOrPageScaleFactorChanged()
    254285{
     286#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     287    if (m_redirectedWindow) {
     288        m_redirectedWindow->resize(m_webPage.size());
     289        m_layerTreeContext.contextID = m_redirectedWindow->pixmap();
     290    }
     291#endif
     292
    255293    // Other layers learn of the scale factor change via WebPage::setDeviceScaleFactor.
    256294    m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
     
    378416}
    379417
    380 void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
    381 {
    382     cancelPendingLayerFlush();
    383     m_layerTreeContext.contextID = handle;
    384 
     418void LayerTreeHostGtk::createTextureMapper()
     419{
    385420    // The creation of the TextureMapper needs an active OpenGL context.
    386421    if (!makeContextCurrent())
     
    392427    static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
    393428    downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTextureMapper(m_textureMapper.get());
    394 
     429}
     430
     431#if !USE(REDIRECTED_XCOMPOSITE_WINDOW)
     432void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
     433{
     434    cancelPendingLayerFlush();
     435    m_layerTreeContext.contextID = handle;
     436
     437    createTextureMapper();
    395438    scheduleLayerFlush();
    396439}
     440#endif
    397441
    398442} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h

    r202621 r204013  
    4040namespace WebKit {
    4141
     42class RedirectedXCompositeWindow;
     43
    4244class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClient {
    4345public:
     
    6668    void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
    6769
     70#if !USE(REDIRECTED_XCOMPOSITE_WINDOW)
    6871    void setNativeSurfaceHandleForCompositing(uint64_t) override;
     72#endif
    6973
    7074    class RenderFrameScheduler {
     
    99103    bool renderFrame();
    100104    bool makeContextCurrent();
     105    void createTextureMapper();
    101106
    102107    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
     
    105110    std::unique_ptr<WebCore::GLContext> m_context;
    106111    WebCore::TransformationMatrix m_scaleMatrix;
     112#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     113    std::unique_ptr<RedirectedXCompositeWindow> m_redirectedWindow;
     114#endif
    107115    RenderFrameScheduler m_renderFrameScheduler;
    108116};
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/RedirectedXCompositeWindow.h

    r204011 r204013  
    11/*
    2  * Copyright (C) 2012 Igalia S.L.
    3  * All rights reserved.
     2 * Copyright (C) 2012-2016 Igalia S.L.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2524 */
    2625
    27 #ifndef  RedirectedXCompositeWindow_h
    28 #define  RedirectedXCompositeWindow_h
     26#pragma once
    2927
    3028#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    3129
    3230#include <WebCore/IntSize.h>
    33 #include <WebCore/RefPtrCairo.h>
    3431#include <WebCore/XUniqueResource.h>
    35 #include <functional>
     32#include <wtf/Noncopyable.h>
    3633
    37 typedef struct _GdkWindow GdkWindow;
    3834typedef struct _XDisplay Display;
     35typedef unsigned long Pixmap;
    3936typedef unsigned long Window;
    4037
    4138namespace WebKit {
    4239
    43 class WebPageProxy;
     40class WebPage;
    4441
    4542class RedirectedXCompositeWindow {
    4643    WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
    4744public:
    48     static std::unique_ptr<RedirectedXCompositeWindow> create(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
     45    static std::unique_ptr<RedirectedXCompositeWindow> create(WebPage&);
    4946    ~RedirectedXCompositeWindow();
    5047
    51     Window windowID() const { return m_window.get(); }
     48    Window window() const { return m_window.get(); }
     49    Pixmap pixmap() const { return m_pixmap.get(); }
    5250    void resize(const WebCore::IntSize&);
    53     cairo_surface_t* surface() const { return m_surface.get(); };
    5451
    5552private:
    56     RedirectedXCompositeWindow(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
    57     void createNewPixampAndPixampSurface();
    58     void cleanupPixmapAndPixmapSurface();
     53    RedirectedXCompositeWindow(WebPage&);
    5954
    60     WebPageProxy& m_webPage;
     55    WebPage& m_webPage;
    6156    Display* m_display { nullptr };
    6257    WebCore::IntSize m_size;
     
    6459    WebCore::XUniqueWindow m_parentWindow;
    6560    WebCore::XUniquePixmap m_pixmap;
    66     WebCore::XUniqueDamage m_damage;
    67     RefPtr<cairo_surface_t> m_surface;
    6861};
    6962
     
    7164
    7265#endif // USE(REDIRECTED_XCOMPOSITE_WINDOW)
    73 
    74 #endif // RedirectedXCompositeWindow_h
Note: See TracChangeset for help on using the changeset viewer.