Diff
Modified: trunk/Source/WebKit2/ChangeLog (206079 => 206080)
--- trunk/Source/WebKit2/ChangeLog 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-18 15:10:39 UTC (rev 206080)
@@ -1,3 +1,31 @@
+2016-09-18 Gustavo Noronha Silva <gustavo.noro...@collabora.co.uk>
+
+ [GTK] Stop using glReadPixels() to blit AC surfaces in the UIProcess under Wayland
+ https://bugs.webkit.org/show_bug.cgi?id=161530
+
+ Reviewed by Carlos Garcia Campos.
+
+ Use gdk_cairo_draw_from_gl when all necessary conditions exist.
+
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+ (WebKit::ThreadedCompositor::create): take TextureMapper::PaintFlags as optional argument.
+ (WebKit::ThreadedCompositor::ThreadedCompositor): ditto.
+ (WebKit::ThreadedCompositor::renderLayerTree): relay paint flags to TextureMapper::beginPaint.
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+ * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
+ (WebKit::AcceleratedBackingStoreWayland::paint): use the faster gdk_cairo_draw_from_gl when a new
+ enough GTK+ is in use.
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+ (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): create compositor
+ with PaintingMirrored flag if we have recent GTK+ and are running under Wayland.
+ * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h: implement shouldPaintMirrored by always
+ returning false.
+ * WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h: implement shouldPaintMirrored by always
+ returning true.
+ * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+ (WebKit::LayerTreeHostGtk::compositeLayersToContext): pass PaintingMirror flag to TextureMapper
+ when under a recent enough GTK+ and Wayland.
+
2016-09-17 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Move the rendering of auth dialog shadow to the auth dialog widget
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (206079 => 206080)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-09-18 15:10:39 UTC (rev 206080)
@@ -42,15 +42,16 @@
namespace WebKit {
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
{
- return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle, doFrameSync));
+ return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle, doFrameSync, paintFlags));
}
-ThreadedCompositor::ThreadedCompositor(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
+ThreadedCompositor::ThreadedCompositor(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
: m_client(client)
, m_nativeSurfaceHandle(nativeSurfaceHandle)
, m_doFrameSync(doFrameSync)
+ , m_paintFlags(paintFlags)
, m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
{
m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
@@ -196,8 +197,9 @@
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}
- m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, m_scrollPosition);
+ m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, m_scrollPosition, m_paintFlags);
+
m_context->swapBuffers();
}
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (206079 => 206080)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-09-18 15:10:39 UTC (rev 206080)
@@ -32,6 +32,7 @@
#include "CoordinatedGraphicsScene.h"
#include <WebCore/GLContext.h>
#include <WebCore/IntSize.h>
+#include <WebCore/TextureMapper.h>
#include <wtf/FastMalloc.h>
#include <wtf/Noncopyable.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -57,7 +58,7 @@
enum class ShouldDoFrameSync { No, Yes };
- static Ref<ThreadedCompositor> create(Client&, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes);
+ static Ref<ThreadedCompositor> create(Client&, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
virtual ~ThreadedCompositor();
void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -73,7 +74,7 @@
void forceRepaint();
private:
- ThreadedCompositor(Client&, uint64_t nativeSurfaceHandle, ShouldDoFrameSync);
+ ThreadedCompositor(Client&, uint64_t nativeSurfaceHandle, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
// CoordinatedGraphicsSceneClient
void renderNextFrame() override;
@@ -95,6 +96,7 @@
bool m_drawsBackground { true };
uint64_t m_nativeSurfaceHandle;
ShouldDoFrameSync m_doFrameSync;
+ WebCore::TextureMapper::PaintFlags m_paintFlags { 0 };
bool m_needsResize { false };
std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
Modified: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp (206079 => 206080)
--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp 2016-09-18 15:10:39 UTC (rev 206080)
@@ -71,9 +71,8 @@
cairo_save(cr);
AcceleratedBackingStore::paint(cr, clipRect);
-#if 0
- // FIXME: Use this when GTK+ >= 3.16. GTK+ expects the Y axis to be inverted to what we get, so we need to flip it somehow.
- gdk_cairo_draw_from_gl(cr, gtk_widget_get_window(m_webPage.viewWidget()), texture, GL_TEXTURE, 1, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
+#if GTK_CHECK_VERSION(3, 16, 0)
+ gdk_cairo_draw_from_gl(cr, gtk_widget_get_window(m_webPage.viewWidget()), texture, GL_TEXTURE, m_webPage.deviceScaleFactor(), 0, 0, textureSize.width(), textureSize.height());
#else
if (!m_surface || cairo_image_surface_get_width(m_surface.get()) != textureSize.width() || cairo_image_surface_get_height(m_surface.get()) != textureSize.height())
m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, textureSize.width(), textureSize.height()));
@@ -115,6 +114,12 @@
// The surface can be modified by the web process at any time, so we mark it
// as dirty to ensure we always render the updated contents as soon as possible.
cairo_surface_mark_dirty(m_surface.get());
+
+ // The compositor renders the texture flipped for gdk_cairo_draw_from_gl, fix that here.
+ cairo_matrix_t transform;
+ cairo_matrix_init(&transform, 1, 0, 0, -1, 0, textureSize.height() / deviceScaleFactor);
+ cairo_transform(cr, &transform);
+
cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
cairo_set_source_surface(cr, m_surface.get(), 0, 0);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (206079 => 206080)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-09-18 15:10:39 UTC (rev 206080)
@@ -55,10 +55,15 @@
, m_surface(AcceleratedSurface::create(webPage))
{
if (m_surface) {
+ TextureMapper::PaintFlags paintFlags = 0;
+
+ if (m_surface->shouldPaintMirrored())
+ paintFlags |= TextureMapper::PaintingMirrored;
+
// Do not do frame sync when rendering offscreen in the web process to ensure that SwapBuffers never blocks.
// Rendering to the actual screen will happen later anyway since the UI process schedules a redraw for every update,
// the compositor will take care of syncing to vblank.
- m_compositor = ThreadedCompositor::create(m_compositorClient, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No);
+ m_compositor = ThreadedCompositor::create(m_compositorClient, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No, paintFlags);
m_layerTreeContext.contextID = m_surface->surfaceID();
} else
m_compositor = ThreadedCompositor::create(m_compositorClient);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h (206079 => 206080)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurface.h 2016-09-18 15:10:39 UTC (rev 206080)
@@ -41,6 +41,7 @@
virtual uint64_t window() const { ASSERT_NOT_REACHED(); return 0; }
virtual uint64_t surfaceID() const { ASSERT_NOT_REACHED(); return 0; };
virtual bool resize(const WebCore::IntSize&);
+ virtual bool shouldPaintMirrored() const { return false; }
protected:
AcceleratedSurface(WebPage&);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h (206079 => 206080)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceWayland.h 2016-09-18 15:10:39 UTC (rev 206080)
@@ -43,6 +43,7 @@
uint64_t window() const override { return reinterpret_cast<uint64_t>(m_window); }
uint64_t surfaceID() const override { return m_webPage.pageID(); }
bool resize(const WebCore::IntSize&) override;
+ bool shouldPaintMirrored() const override { return true; }
private:
AcceleratedSurfaceWayland(WebPage&);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h (206079 => 206080)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h 2016-09-18 15:10:39 UTC (rev 206080)
@@ -47,6 +47,7 @@
uint64_t window() const override { return m_window.get(); }
uint64_t surfaceID() const override { return m_pixmap.get(); }
bool resize(const WebCore::IntSize&) override;
+ bool shouldPaintMirrored() const override { return false; }
private:
AcceleratedSurfaceX11(WebPage&);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (206079 => 206080)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2016-09-18 14:03:13 UTC (rev 206079)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2016-09-18 15:10:39 UTC (rev 206080)
@@ -337,7 +337,13 @@
}
ASSERT(m_textureMapper);
- m_textureMapper->beginPainting();
+
+ TextureMapper::PaintFlags paintFlags = 0;
+
+ if (m_surface && m_surface->shouldPaintMirrored())
+ paintFlags |= TextureMapper::PaintingMirrored;
+
+ m_textureMapper->beginPainting(paintFlags);
downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().paint();
m_textureMapper->endPainting();