⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 203495 in webkit


Ignore:
Timestamp:
Jul 21, 2016, 12:04:59 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Avoid the redirected window resize when the view is realized in AC mode
​https://bugs.webkit.org/show_bug.cgi?id=159463

Reviewed by Michael Catanzaro.

We are always creating the redirected window at 1x1 and then resizing it if we are in AC mode. When the view is
realized and AC mode is already enabled, which happens for example when AC mode is forced, or when the threaded
compositor is enabled, we could just pass the initial size to the redirected window constructor to create the
XWindow at the right size.

  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseResizeRedirectedWindow): We no longer need to pass the device scale factor, since the
RedirectedXCompositeWindow already knows it.
(webkitWebViewBaseRealize): Pass the WebPageProxy and an initial size to the RedirectedXCompositeWindow
constructor instead of the parent GdkWindow. If AC mode is disabled, the initial size will be empty. With the
WebPageProxy the redirected window has access to the device scale factor and view widget to get the parent
GdkWindow.
(deviceScaleFactorChanged): Resize the redirected window when device scale factor changes.

  • UIProcess/gtk/RedirectedXCompositeWindow.cpp:

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

  • UIProcess/gtk/RedirectedXCompositeWindow.h:
Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r203493 r203495  
     12016-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Avoid the redirected window resize when the view is realized in AC mode
     4        https://bugs.webkit.org/show_bug.cgi?id=159463
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        We are always creating the redirected window at 1x1 and then resizing it if we are in AC mode. When the view is
     9        realized and AC mode is already enabled, which happens for example when AC mode is forced, or when the threaded
     10        compositor is enabled, we could just pass the initial size to the redirected window constructor to create the
     11        XWindow at the right size.
     12
     13        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     14        (webkitWebViewBaseResizeRedirectedWindow): We no longer need to pass the device scale factor, since the
     15        RedirectedXCompositeWindow already knows it.
     16        (webkitWebViewBaseRealize): Pass the WebPageProxy and an initial size to the RedirectedXCompositeWindow
     17        constructor instead of the parent GdkWindow. If AC mode is disabled, the initial size will be empty. With the
     18        WebPageProxy the redirected window has access to the device scale factor and view widget to get the parent
     19        GdkWindow.
     20        (deviceScaleFactorChanged): Resize the redirected window when device scale factor changes.
     21        * UIProcess/gtk/RedirectedXCompositeWindow.cpp:
     22        (WebKit::RedirectedXCompositeWindow::create):
     23        (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
     24        (WebKit::RedirectedXCompositeWindow::resize):
     25        (WebKit::RedirectedXCompositeWindow::surface):
     26        (WebKit::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
     27        * UIProcess/gtk/RedirectedXCompositeWindow.h:
     28
    1292016-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    230
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r203493 r203495  
    360360    WebKitWebViewBasePrivate* priv = webView->priv;
    361361    DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    362     ASSERT(drawingArea);
    363     priv->redirectedWindow->setDeviceScaleFactor(priv->pageProxy->deviceScaleFactor());
     362    if (!drawingArea)
     363        return;
    364364    priv->redirectedWindow->resize(drawingArea->size());
    365365}
    … …  
    374374    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
    375375        ASSERT(!priv->redirectedWindow);
     376        DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
    376377        priv->redirectedWindow = RedirectedXCompositeWindow::create(
    377             gtk_widget_get_parent_window(widget),
     378            *priv->pageProxy,
     379            drawingArea && drawingArea->isInAcceleratedCompositingMode() ? drawingArea->size() : IntSize(),
    378380            [webView] {
    379381                DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea());
    … …  
    381383                    gtk_widget_queue_draw(GTK_WIDGET(webView));
    382384            });
    383         if (priv->redirectedWindow) {
    384             if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea())) {
    385                 drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
    386                 if (drawingArea->isInAcceleratedCompositingMode())
    387                     webkitWebViewBaseResizeRedirectedWindow(webView);
    388             }
     385        if (priv->redirectedWindow && drawingArea) {
     386            drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
     387            if (drawingArea->isInAcceleratedCompositingMode())
     388                webkitWebViewBaseResizeRedirectedWindow(webView);
    389389        }
    390390    }
    … …  
    12661266#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    12671267    if (webkitWebViewBase->priv->redirectedWindow)
    1268         webkitWebViewBase->priv->redirectedWindow->setDeviceScaleFactor(webkitWebViewBase->priv->pageProxy->deviceScaleFactor());
     1268        webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
    12691269#endif
    12701270    webkitWebViewBase->priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
  • trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp

    r202273 r203495  
    3030#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
    3131
     32#include "WebPageProxy.h"
    3233#include <WebCore/CairoUtilities.h>
    3334#include <WebCore/PlatformDisplayX11.h>
    … …  
    131132}
    132133
    133 std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(GdkWindow* parentWindow, std::function<void()> damageNotify)
    134 {
     134std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify)
     135{
     136    GdkWindow* parentWindow = gtk_widget_get_parent_window(webPage.viewWidget());
    135137    ASSERT(GDK_IS_WINDOW(parentWindow));
    136     return supportsXDamageAndXComposite(parentWindow) ? std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(parentWindow, damageNotify)) : nullptr;
    137 }
    138 
    139 RedirectedXCompositeWindow::RedirectedXCompositeWindow(GdkWindow* parentWindow, std::function<void()> damageNotify)
    140     : m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(parentWindow)))
    141     , m_needsNewPixmapAfterResize(false)
    142     , m_deviceScale(1)
    143 {
     138    if (!supportsXDamageAndXComposite(parentWindow))
     139        return nullptr;
     140    return std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(webPage, initialSize, WTFMove(damageNotify)));
     141}
     142
     143RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify)
     144    : m_webPage(webPage)
     145    , m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(gtk_widget_get_parent_window(webPage.viewWidget()))))
     146    , m_size(initialSize)
     147{
     148    m_size.scale(m_webPage.deviceScaleFactor());
     149
    144150    ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display);
    145151    Screen* screen = DefaultScreenOfDisplay(m_display);
    146152
    147     GdkVisual* visual = gdk_window_get_visual(parentWindow);
     153    GdkVisual* visual = gdk_window_get_visual(gtk_widget_get_parent_window(webPage.viewWidget()));
    148154    XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
    149155
    … …  
    215221{
    216222    IntSize scaledSize(size);
    217     scaledSize.scale(m_deviceScale);
    218 
     223    scaledSize.scale(m_webPage.deviceScaleFactor());
    219224    if (scaledSize == m_size)
    220225        return;
    … …  
    262267
    263268    RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap.get(), windowAttributes.visual, m_size.width(), m_size.height()));
    264     cairoSurfaceSetDeviceScale(newSurface.get(), m_deviceScale, m_deviceScale);
     269    cairoSurfaceSetDeviceScale(newSurface.get(), m_webPage.deviceScaleFactor(), m_webPage.deviceScaleFactor());
    265270
    266271    RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
  • trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h

    r190344 r203495  
    4141namespace WebKit {
    4242
     43class WebPageProxy;
     44
    4345class RedirectedXCompositeWindow {
     46    WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
    4447public:
    45     static std::unique_ptr<RedirectedXCompositeWindow> create(GdkWindow*, std::function<void()> damageNotify);
     48    static std::unique_ptr<RedirectedXCompositeWindow> create(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
    4649    ~RedirectedXCompositeWindow();
    4750
    4851    Window windowID() const { return m_window.get(); }
    4952    void resize(const WebCore::IntSize&);
    50     void setDeviceScaleFactor(float scale) { m_deviceScale = scale; }
    5153    cairo_surface_t* surface();
    5254
    5355private:
    54     RedirectedXCompositeWindow(GdkWindow*, std::function<void()> damageNotify);
     56    RedirectedXCompositeWindow(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
    5557    void cleanupPixmapAndPixmapSurface();
    5658
    57     Display* m_display;
     59    WebPageProxy& m_webPage;
     60    Display* m_display { nullptr };
    5861    WebCore::IntSize m_size;
    5962    WebCore::XUniqueWindow m_window;
    … …  
    6265    WebCore::XUniqueDamage m_damage;
    6366    RefPtr<cairo_surface_t> m_surface;
    64     bool m_needsNewPixmapAfterResize;
    65     float m_deviceScale;
     67    bool m_needsNewPixmapAfterResize { false };
    6668};
    6769
Note: See TracChangeset for help on using the changeset viewer.