Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GTK] Enable depth 32 for the RedirectedXCompositeWindow
https://bugs.webkit.org/show_bug.cgi?id=139028

On gtk/X11, the layout compositing is done in the web process.
If one needs to handle alpha with the rest of the application
then it is not enough to make to browser's window as RGBA.
The shared redirected window needs to be RGBA as well.
(The shared X composite window between UIProcess and WebProcess).

This allows an end-to-end RGBA solution when the application
wants to interact with the alpha channel at compositing time.
For example for transparent Web UI.

Patch by Julien Isorce <j.isorce@samsung.com> on 2014-12-10
Reviewed by Martin Robinson.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseRealize):
(webkitWebViewBaseConstructed):
(webkitWebViewRenderAcceleratedCompositingResults):
(webkitWebViewBaseUpdatePreferences):
(webkitWebViewBaseCreateWebPage):
* UIProcess/gtk/RedirectedXCompositeWindow.cpp:
(WebKit::RedirectedXCompositeWindow::create):
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
* UIProcess/gtk/RedirectedXCompositeWindow.h:

Canonical link: https://commits.webkit.org/157335@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177075 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JulienIsorce authored and mrobinson committed Dec 10, 2014
1 parent 4b5ad35 commit cf5b87c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 23 deletions.
28 changes: 28 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,31 @@
2014-12-10 Julien Isorce <j.isorce@samsung.com>

[GTK] Enable depth 32 for the RedirectedXCompositeWindow
https://bugs.webkit.org/show_bug.cgi?id=139028

On gtk/X11, the layout compositing is done in the web process.
If one needs to handle alpha with the rest of the application
then it is not enough to make to browser's window as RGBA.
The shared redirected window needs to be RGBA as well.
(The shared X composite window between UIProcess and WebProcess).

This allows an end-to-end RGBA solution when the application
wants to interact with the alpha channel at compositing time.
For example for transparent Web UI.

Reviewed by Martin Robinson.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseRealize):
(webkitWebViewBaseConstructed):
(webkitWebViewRenderAcceleratedCompositingResults):
(webkitWebViewBaseUpdatePreferences):
(webkitWebViewBaseCreateWebPage):
* UIProcess/gtk/RedirectedXCompositeWindow.cpp:
(WebKit::RedirectedXCompositeWindow::create):
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
* UIProcess/gtk/RedirectedXCompositeWindow.h:

2014-12-09 Claudio Saavedra <csaavedra@igalia.com> and Gustavo Noronha Silva <gustavo.noronha@collabora.com>

[GTK][WK2] Add HTML5 Notifications support
Expand Down
42 changes: 25 additions & 17 deletions Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
Expand Up @@ -255,6 +255,26 @@ static void webkitWebViewBaseSetToplevelOnScreenWindow(WebKitWebViewBase* webVie

static void webkitWebViewBaseRealize(GtkWidget* widget)
{
#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
if (GDK_IS_X11_DISPLAY(display)) {
WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
GdkWindow* parentWindow = gtk_widget_get_parent_window(widget);
priv->redirectedWindow = RedirectedXCompositeWindow::create(
GDK_DISPLAY_XDISPLAY(display),
parentWindow ? GDK_WINDOW_XID(parentWindow) : 0,
IntSize(1, 1),
[widget] {
gtk_widget_queue_draw(widget);
});
if (priv->redirectedWindow) {
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
}
webkitWebViewBaseUpdatePreferences(WEBKIT_WEB_VIEW_BASE(widget));
}
#endif

gtk_widget_set_realized(widget, TRUE);

GtkAllocation allocation;
Expand Down Expand Up @@ -427,13 +447,6 @@ static void webkitWebViewBaseConstructed(GObject* object)

WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(object)->priv;
priv->pageClient = PageClientImpl::create(viewWidget);

#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
if (GDK_IS_X11_DISPLAY(display))
priv->redirectedWindow = RedirectedXCompositeWindow::create(GDK_DISPLAY_XDISPLAY(display), IntSize(1, 1), [viewWidget] { gtk_widget_queue_draw(viewWidget); });
#endif

priv->authenticationDialog = 0;
}

Expand All @@ -453,6 +466,7 @@ static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase*
if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
cairo_set_source_surface(cr, surface, 0, 0);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_fill(cr);
}

Expand Down Expand Up @@ -1027,11 +1041,12 @@ void webkitWebViewBaseUpdatePreferences(WebKitWebViewBase* webkitWebViewBase)
WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;

#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
if (priv->redirectedWindow)
return;
bool acceleratedCompositingEnabled = priv->redirectedWindow ? true : false;
#else
bool acceleratedCompositingEnabled = false;
#endif

priv->pageProxy->preferences().setAcceleratedCompositingEnabled(false);
priv->pageProxy->preferences().setAcceleratedCompositingEnabled(acceleratedCompositingEnabled);
}

#if HAVE(GTK_SCALE_FACTOR)
Expand All @@ -1055,13 +1070,6 @@ void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebCon

priv->inputMethodFilter.setPage(priv->pageProxy.get());

#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
if (priv->redirectedWindow) {
DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(priv->pageProxy->drawingArea());
drawingArea->setNativeSurfaceHandleForCompositing(priv->redirectedWindow->windowID());
}
#endif

#if HAVE(GTK_SCALE_FACTOR)
// We attach this here, because changes in scale factor are passed directly to the page proxy.
priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
Expand Down
12 changes: 8 additions & 4 deletions Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp
Expand Up @@ -126,12 +126,12 @@ static bool supportsXDamageAndXComposite(Display* display)
return true;
}

std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(Display* display, const IntSize& size, std::function<void()> damageNotify)
std::unique_ptr<RedirectedXCompositeWindow> RedirectedXCompositeWindow::create(Display* display, Window parent, const IntSize& size, std::function<void()> damageNotify)
{
return supportsXDamageAndXComposite(display) ? std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(display, size, damageNotify)) : nullptr;
return supportsXDamageAndXComposite(display) ? std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow(display, parent, size, damageNotify)) : nullptr;
}

RedirectedXCompositeWindow::RedirectedXCompositeWindow(Display* display, const IntSize& size, std::function<void()> damageNotify)
RedirectedXCompositeWindow::RedirectedXCompositeWindow(Display* display, Window parent, const IntSize& size, std::function<void()> damageNotify)
: m_display(display)
, m_size(size)
, m_window(0)
Expand All @@ -146,7 +146,7 @@ RedirectedXCompositeWindow::RedirectedXCompositeWindow(Display* display, const I
XSetWindowAttributes windowAttributes;
windowAttributes.override_redirect = True;
m_parentWindow = XCreateWindow(display,
RootWindowOfScreen(screen),
parent ? parent : RootWindowOfScreen(screen),
WidthOfScreen(screen) + 1, 0, 1, 1,
0,
CopyFromParent,
Expand All @@ -156,6 +156,10 @@ RedirectedXCompositeWindow::RedirectedXCompositeWindow(Display* display, const I
&windowAttributes);
XMapWindow(display, m_parentWindow);

// The top parent is only necessary to copy from parent the visual and depth at creation time.
if (parent)
XReparentWindow(display, m_parentWindow, RootWindowOfScreen(screen), WidthOfScreen(screen) + 1, 0);

windowAttributes.event_mask = StructureNotifyMask;
windowAttributes.override_redirect = False;
m_window = XCreateWindow(display,
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h
Expand Up @@ -42,15 +42,15 @@ namespace WebKit {

class RedirectedXCompositeWindow {
public:
static std::unique_ptr<RedirectedXCompositeWindow> create(Display*, const WebCore::IntSize&, std::function<void()> damageNotify);
static std::unique_ptr<RedirectedXCompositeWindow> create(Display*, Window parent, const WebCore::IntSize&, std::function<void()> damageNotify);
~RedirectedXCompositeWindow();

Window windowID() const { return m_window; }
void resize(const WebCore::IntSize&);
cairo_surface_t* surface();

private:
RedirectedXCompositeWindow(Display*, const WebCore::IntSize&, std::function<void()> damageNotify);
RedirectedXCompositeWindow(Display*, Window parent, const WebCore::IntSize&, std::function<void()> damageNotify);
void cleanupPixmapAndPixmapSurface();

Display* m_display;
Expand Down

0 comments on commit cf5b87c

Please sign in to comment.