- Revision
- 203495
- Author
- [email protected]
- Date
- 2016-07-21 00:04:59 -0700 (Thu, 21 Jul 2016)
Log 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:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (203494 => 203495)
--- trunk/Source/WebKit2/ChangeLog 2016-07-21 06:51:05 UTC (rev 203494)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-21 07:04:59 UTC (rev 203495)
@@ -1,5 +1,33 @@
2016-07-20 Carlos Garcia Campos <[email protected]>
+ [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:
+
+2016-07-20 Carlos Garcia Campos <[email protected]>
+
[GTK][Threaded Compositor] Web Process crash when the page is closed before the web view is realized
https://bugs.webkit.org/show_bug.cgi?id=159918
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (203494 => 203495)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2016-07-21 06:51:05 UTC (rev 203494)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2016-07-21 07:04:59 UTC (rev 203495)
@@ -359,8 +359,8 @@
{
WebKitWebViewBasePrivate* priv = webView->priv;
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
- ASSERT(drawingArea);
- priv->redirectedWindow->setDeviceScaleFactor(priv->pageProxy->deviceScaleFactor());
+ if (!drawingArea)
+ return;
priv->redirectedWindow->resize(drawingArea->size());
}
#endif
@@ -373,19 +373,19 @@
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
ASSERT(!priv->redirectedWindow);
+ DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
priv->redirectedWindow = RedirectedXCompositeWindow::create(
- gtk_widget_get_parent_window(widget),
+ *priv->pageProxy,
+ drawingArea && drawingArea->isInAcceleratedCompositingMode() ? drawingArea->size() : IntSize(),
[webView] {
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webView->priv->pageProxy->drawingArea());
if (drawingArea && drawingArea->isInAcceleratedCompositingMode())
gtk_widget_queue_draw(GTK_WIDGET(webView));
});
- if (priv->redirectedWindow) {
- if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea())) {
- drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
- if (drawingArea->isInAcceleratedCompositingMode())
- webkitWebViewBaseResizeRedirectedWindow(webView);
- }
+ if (priv->redirectedWindow && drawingArea) {
+ drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
+ if (drawingArea->isInAcceleratedCompositingMode())
+ webkitWebViewBaseResizeRedirectedWindow(webView);
}
}
#endif
@@ -1265,7 +1265,7 @@
{
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
if (webkitWebViewBase->priv->redirectedWindow)
- webkitWebViewBase->priv->redirectedWindow->setDeviceScaleFactor(webkitWebViewBase->priv->pageProxy->deviceScaleFactor());
+ webkitWebViewBaseResizeRedirectedWindow(webkitWebViewBase);
#endif
webkitWebViewBase->priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
}
Modified: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (203494 => 203495)
--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2016-07-21 06:51:05 UTC (rev 203494)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2016-07-21 07:04:59 UTC (rev 203495)
@@ -29,6 +29,7 @@
#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+#include "WebPageProxy.h"
#include <WebCore/CairoUtilities.h>
#include <WebCore/PlatformDisplayX11.h>
#include <X11/Xlib.h>
@@ -130,21 +131,26 @@
return true;
}
-std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(GdkWindow* parentWindow, std::function<void()> damageNotify)
+std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify)
{
+ GdkWindow* parentWindow = gtk_widget_get_parent_window(webPage.viewWidget());
ASSERT(GDK_IS_WINDOW(parentWindow));
- return supportsXDamageAndXComposite(parentWindow) ? std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(parentWindow, damageNotify)) : nullptr;
+ if (!supportsXDamageAndXComposite(parentWindow))
+ return nullptr;
+ return std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(webPage, initialSize, WTFMove(damageNotify)));
}
-RedirectedXCompositeWindow::RedirectedXCompositeWindow(GdkWindow* parentWindow, std::function<void()> damageNotify)
- : m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(parentWindow)))
- , m_needsNewPixmapAfterResize(false)
- , m_deviceScale(1)
+RedirectedXCompositeWindow::RedirectedXCompositeWindow(WebPageProxy& webPage, const IntSize& initialSize, std::function<void()>&& damageNotify)
+ : m_webPage(webPage)
+ , m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(gtk_widget_get_parent_window(webPage.viewWidget()))))
+ , m_size(initialSize)
{
+ m_size.scale(m_webPage.deviceScaleFactor());
+
ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display);
Screen* screen = DefaultScreenOfDisplay(m_display);
- GdkVisual* visual = gdk_window_get_visual(parentWindow);
+ GdkVisual* visual = gdk_window_get_visual(gtk_widget_get_parent_window(webPage.viewWidget()));
XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
// This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
@@ -214,8 +220,7 @@
void RedirectedXCompositeWindow::resize(const IntSize& size)
{
IntSize scaledSize(size);
- scaledSize.scale(m_deviceScale);
-
+ scaledSize.scale(m_webPage.deviceScaleFactor());
if (scaledSize == m_size)
return;
@@ -261,7 +266,7 @@
}
RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap.get(), windowAttributes.visual, m_size.width(), m_size.height()));
- cairoSurfaceSetDeviceScale(newSurface.get(), m_deviceScale, m_deviceScale);
+ cairoSurfaceSetDeviceScale(newSurface.get(), m_webPage.deviceScaleFactor(), m_webPage.deviceScaleFactor());
RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
cairo_set_source_rgb(cr.get(), 1, 1, 1);
Modified: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h (203494 => 203495)
--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h 2016-07-21 06:51:05 UTC (rev 203494)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h 2016-07-21 07:04:59 UTC (rev 203495)
@@ -40,21 +40,24 @@
namespace WebKit {
+class WebPageProxy;
+
class RedirectedXCompositeWindow {
+ WTF_MAKE_NONCOPYABLE(RedirectedXCompositeWindow); WTF_MAKE_FAST_ALLOCATED;
public:
- static std::unique_ptr<RedirectedXCompositeWindow> create(GdkWindow*, std::function<void()> damageNotify);
+ static std::unique_ptr<RedirectedXCompositeWindow> create(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
~RedirectedXCompositeWindow();
Window windowID() const { return m_window.get(); }
void resize(const WebCore::IntSize&);
- void setDeviceScaleFactor(float scale) { m_deviceScale = scale; }
cairo_surface_t* surface();
private:
- RedirectedXCompositeWindow(GdkWindow*, std::function<void()> damageNotify);
+ RedirectedXCompositeWindow(WebPageProxy&, const WebCore::IntSize&, std::function<void ()>&& damageNotify);
void cleanupPixmapAndPixmapSurface();
- Display* m_display;
+ WebPageProxy& m_webPage;
+ Display* m_display { nullptr };
WebCore::IntSize m_size;
WebCore::XUniqueWindow m_window;
WebCore::XUniqueWindow m_parentWindow;
@@ -61,8 +64,7 @@
WebCore::XUniquePixmap m_pixmap;
WebCore::XUniqueDamage m_damage;
RefPtr<cairo_surface_t> m_surface;
- bool m_needsNewPixmapAfterResize;
- float m_deviceScale;
+ bool m_needsNewPixmapAfterResize { false };
};
} // namespace WebKit