Diff
Modified: trunk/Source/WebKit/ChangeLog (260815 => 260816)
--- trunk/Source/WebKit/ChangeLog 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/ChangeLog 2020-04-28 11:28:36 UTC (rev 260816)
@@ -1,3 +1,33 @@
+2020-04-28 Carlos Garcia Campos <[email protected]>
+
+ [GTK4][Wayland] Add support for rendering web view contents
+ https://bugs.webkit.org/show_bug.cgi?id=211021
+
+ Reviewed by Adrian Perez de Castro.
+
+ Implement GtkWidgetClass::snapshot and GtkWidgetClass::measure instead of GtkWidgetClass::draw and
+ GtkWidgetClass::get_preferred_width|height. Add AcceleratedBackingStore::snapshot() pure virtual to be used with
+ GTK4 instead of AcceleratedBackingStore::paint(), and implement it for Wayland.
+
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseSnapshot): Call AcceleratedBackingStore::snapshot().
+ (webkitWebViewBaseMeasure): Return the natural width/height for the WebView.
+ (webkit_web_view_base_class_init): Add implementations for snapshot and measure vfuncs.
+ * UIProcess/gtk/AcceleratedBackingStore.h:
+ * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
+ (WebKit::AcceleratedBackingStoreWayland::tryEnsureGLContext): Always try to realize the context here, since that
+ can fail too.
+ (WebKit::AcceleratedBackingStoreWayland::tryEnsureTexture): Helper to share the code to prepare the texture.
+ (WebKit::AcceleratedBackingStoreWayland::downloadTexture): Helper to share the code to download the texture.
+ (WebKit::AcceleratedBackingStoreWayland::snapshot): Use gtk_snapshot_append_texture().
+ (WebKit::AcceleratedBackingStoreWayland::paint): Use new helpers.
+ * UIProcess/gtk/AcceleratedBackingStoreWayland.h:
+ * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
+ (WebKit::AcceleratedBackingStoreX11::snapshot):
+ * UIProcess/gtk/AcceleratedBackingStoreX11.h:
+ * UIProcess/gtk/HardwareAccelerationManager.cpp:
+ (WebKit::HardwareAccelerationManager::HardwareAccelerationManager): Force accelerated compositing mode for GTK4.
+
2020-04-27 Devin Rousso <[email protected]>
Web Inspector: Storage: can see third-party cookies
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-04-28 11:28:36 UTC (rev 260816)
@@ -614,7 +614,24 @@
priv->dialog = nullptr;
}
-#if !USE(GTK4)
+#if USE(GTK4)
+void webkitWebViewBaseSnapshot(GtkWidget* widget, GtkSnapshot* snapshot)
+{
+ int scaleFactor = gtk_widget_get_scale_factor(widget);
+ int width = gtk_widget_get_width(widget) * scaleFactor;
+ int height = gtk_widget_get_height(widget) * scaleFactor;
+ if (!width || !height)
+ return;
+
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(webViewBase->priv->pageProxy->drawingArea());
+ if (!drawingArea)
+ return;
+
+ ASSERT(drawingArea->isInAcceleratedCompositingMode());
+ webViewBase->priv->acceleratedBackingStore->snapshot(snapshot);
+}
+#else
static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
{
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
@@ -720,7 +737,22 @@
drawingArea->setSize(viewRect.size());
}
-#if !USE(GTK4)
+#if USE(GTK4)
+static void webkitWebViewBaseMeasure(GtkWidget* widget, GtkOrientation orientation, int, int* minimumSize, int* naturalSize, int*, int*)
+{
+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
+ switch (orientation) {
+ case GTK_ORIENTATION_HORIZONTAL:
+ *naturalSize = priv->contentsSize.width();
+ break;
+ case GTK_ORIENTATION_VERTICAL:
+ *naturalSize = priv->contentsSize.height();
+ break;
+ }
+
+ *minimumSize = 0;
+}
+#else
static void webkitWebViewBaseGetPreferredWidth(GtkWidget* widget, gint* minimumSize, gint* naturalSize)
{
WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
@@ -1476,11 +1508,15 @@
GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webkitWebViewBaseClass);
widgetClass->realize = webkitWebViewBaseRealize;
widgetClass->unrealize = webkitWebViewBaseUnrealize;
-#if !USE(GTK4)
+#if USE(GTK4)
+ widgetClass->snapshot = webkitWebViewBaseSnapshot;
+#else
widgetClass->draw = webkitWebViewBaseDraw;
#endif
widgetClass->size_allocate = webkitWebViewBaseSizeAllocate;
-#if !USE(GTK4)
+#if USE(GTK4)
+ widgetClass->measure = webkitWebViewBaseMeasure;
+#else
widgetClass->get_preferred_width = webkitWebViewBaseGetPreferredWidth;
widgetClass->get_preferred_height = webkitWebViewBaseGetPreferredHeight;
#endif
Modified: trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.h (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.h 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.h 2020-04-28 11:28:36 UTC (rev 260816)
@@ -29,6 +29,11 @@
typedef struct _cairo cairo_t;
+#if USE(GTK4)
+typedef struct _GdkSnapshot GdkSnapshot;
+typedef GdkSnapshot GtkSnapshot;
+#endif
+
namespace WebCore {
class IntRect;
}
@@ -46,7 +51,11 @@
virtual ~AcceleratedBackingStore() = default;
virtual void update(const LayerTreeContext&) { }
+#if USE(GTK4)
+ virtual void snapshot(GtkSnapshot*) = 0;
+#else
virtual bool paint(cairo_t*, const WebCore::IntRect&) = 0;
+#endif
virtual void realize() { };
virtual void unrealize() { };
virtual bool makeContextCurrent() { return false; }
Modified: trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp 2020-04-28 11:28:36 UTC (rev 260816)
@@ -214,19 +214,22 @@
return;
m_glContextInitialized = true;
-
-#if !USE(GTK4)
GUniqueOutPtr<GError> error;
+#if USE(GTK4)
+ m_gdkGLContext = adoptGRef(gdk_surface_create_gl_context(gtk_native_get_surface(gtk_widget_get_native(m_webPage.viewWidget())), &error.outPtr()));
+#else
m_gdkGLContext = adoptGRef(gdk_window_create_gl_context(gtk_widget_get_window(m_webPage.viewWidget()), &error.outPtr()));
+#endif
if (m_gdkGLContext) {
#if USE(OPENGL_ES)
gdk_gl_context_set_use_es(m_gdkGLContext.get(), TRUE);
#endif
- return;
+ gdk_gl_context_realize(m_gdkGLContext.get(), &error.outPtr());
+ if (!error)
+ return;
}
g_warning("GDK is not able to create a GL context, falling back to glReadPixels (slow!): %s", error->message);
-#endif
m_glContext = GLContext::createOffscreenContext();
}
@@ -278,14 +281,11 @@
}
#endif
-bool AcceleratedBackingStoreWayland::paint(cairo_t* cr, const IntRect& clipRect)
+bool AcceleratedBackingStoreWayland::tryEnsureTexture(unsigned& texture, IntSize& textureSize)
{
- GLuint texture;
- IntSize textureSize;
-
#if USE(WPE_RENDERER)
if (!makeContextCurrent())
- return true;
+ return false;
if (m_pendingImage) {
wpe_view_backend_exportable_fdo_dispatch_frame_complete(m_exportable);
@@ -297,7 +297,7 @@
}
if (!m_committedImage)
- return true;
+ return false;
if (!m_viewTexture) {
glGenTextures(1, &m_viewTexture);
@@ -317,16 +317,11 @@
return false;
#endif
- cairo_save(cr);
+ return true;
+}
-#if !USE(GTK4)
- if (m_gdkGLContext) {
- 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());
- cairo_restore(cr);
- return true;
- }
-#endif
-
+void AcceleratedBackingStoreWayland::downloadTexture(unsigned texture, const IntSize& textureSize)
+{
ASSERT(m_glContext);
if (!m_surface || cairo_image_surface_get_width(m_surface.get()) != textureSize.width() || cairo_image_surface_get_height(m_surface.get()) != textureSize.height())
@@ -366,10 +361,57 @@
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fb);
- // 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());
+}
+#if USE(GTK4)
+void AcceleratedBackingStoreWayland::snapshot(GtkSnapshot* gtkSnapshot)
+{
+ GLuint texture;
+ IntSize textureSize;
+ if (!tryEnsureTexture(texture, textureSize))
+ return;
+
+ FloatSize viewSize(gtk_widget_get_width(m_webPage.viewWidget()), gtk_widget_get_height(m_webPage.viewWidget()));
+ if (m_gdkGLContext) {
+ GRefPtr<GdkTexture> gdkTexture = adoptGRef(gdk_gl_texture_new(m_gdkGLContext.get(), texture, textureSize.width(), textureSize.height(), nullptr, nullptr));
+ graphene_rect_t rect = GRAPHENE_RECT_INIT(0, 0, viewSize.width(), viewSize.height());
+ gtk_snapshot_append_texture(gtkSnapshot, gdkTexture.get(), &rect);
+ return;
+ }
+
+ downloadTexture(texture, textureSize);
+
+ graphene_rect_t rect = GRAPHENE_RECT_INIT(0, 0, viewSize.width(), viewSize.height());
+ RefPtr<cairo_t> cr = adoptRef(gtk_snapshot_append_cairo(gtkSnapshot, &rect));
+
+ // The compositor renders the texture flipped for gdk, fix that here.
+ cairo_matrix_t transform;
+ cairo_matrix_init(&transform, 1, 0, 0, -1, 0, textureSize.height() / m_webPage.deviceScaleFactor());
+ cairo_transform(cr.get(), &transform);
+
+ cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
+ cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER);
+ cairo_paint(cr.get());
+}
+#else
+bool AcceleratedBackingStoreWayland::paint(cairo_t* cr, const IntRect& clipRect)
+{
+ GLuint texture;
+ IntSize textureSize;
+ if (!tryEnsureTexture(texture, textureSize))
+ return true;
+
+ cairo_save(cr);
+
+ if (m_gdkGLContext) {
+ 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());
+ cairo_restore(cr);
+ return true;
+ }
+
+ downloadTexture(texture, textureSize);
+
// 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() / m_webPage.deviceScaleFactor());
@@ -384,6 +426,7 @@
return true;
}
+#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.h (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.h 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.h 2020-04-28 11:28:36 UTC (rev 260816)
@@ -43,6 +43,7 @@
namespace WebCore {
class GLContext;
+class IntSize;
}
namespace WebKit {
@@ -63,8 +64,14 @@
#if USE(WPE_RENDERER)
void displayBuffer(struct wpe_fdo_egl_exported_image*);
#endif
+ bool tryEnsureTexture(unsigned&, WebCore::IntSize&);
+ void downloadTexture(unsigned, const WebCore::IntSize&);
+#if USE(GTK4)
+ void snapshot(GtkSnapshot*) override;
+#else
bool paint(cairo_t*, const WebCore::IntRect&) override;
+#endif
void realize() override;
void unrealize() override;
bool makeContextCurrent() override;
Modified: trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.cpp (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.cpp 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.cpp 2020-04-28 11:28:36 UTC (rev 260816)
@@ -195,6 +195,12 @@
#endif
}
+#if USE(GTK4)
+void AcceleratedBackingStoreX11::snapshot(GtkSnapshot*)
+{
+ // FIXME: Implement this.
+}
+#else
bool AcceleratedBackingStoreX11::paint(cairo_t* cr, const IntRect& clipRect)
{
if (!m_surface)
@@ -216,6 +222,7 @@
return true;
}
+#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.h (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.h 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.h 2020-04-28 11:28:36 UTC (rev 260816)
@@ -47,7 +47,11 @@
explicit AcceleratedBackingStoreX11(WebPageProxy&);
void update(const LayerTreeContext&) override;
+#if USE(GTK4)
+ void snapshot(GtkSnapshot*) override;
+#else
bool paint(cairo_t*, const WebCore::IntRect&) override;
+#endif
RefPtr<cairo_surface_t> m_surface;
WebCore::XUniqueDamage m_damage;
Modified: trunk/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp (260815 => 260816)
--- trunk/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp 2020-04-28 11:28:36 UTC (rev 260816)
@@ -46,6 +46,11 @@
return;
#endif
+#if USE(GTK4)
+ RELEASE_ASSERT(AcceleratedBackingStore::checkRequirements());
+ m_forceHardwareAcceleration = true;
+#endif
+
const char* disableCompositing = getenv("WEBKIT_DISABLE_COMPOSITING_MODE");
if (disableCompositing && strcmp(disableCompositing, "0")) {
m_canUseHardwareAcceleration = false;
Modified: trunk/Tools/ChangeLog (260815 => 260816)
--- trunk/Tools/ChangeLog 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Tools/ChangeLog 2020-04-28 11:28:36 UTC (rev 260816)
@@ -1,3 +1,15 @@
+2020-04-28 Carlos Garcia Campos <[email protected]>
+
+ [GTK4][Wayland] Add support for rendering web view contents
+ https://bugs.webkit.org/show_bug.cgi?id=211021
+
+ Reviewed by Adrian Perez de Castro.
+
+ Set vertical expand of web view to TRUE.
+
+ * MiniBrowser/gtk/BrowserTab.c:
+ (browserTabConstructed):
+
2020-04-27 Philippe Normand <[email protected]>
[GTK][WebInspector] platformSave broken when running within the Flatpak runtime
Modified: trunk/Tools/MiniBrowser/gtk/BrowserTab.c (260815 => 260816)
--- trunk/Tools/MiniBrowser/gtk/BrowserTab.c 2020-04-28 10:58:24 UTC (rev 260815)
+++ trunk/Tools/MiniBrowser/gtk/BrowserTab.c 2020-04-28 11:28:36 UTC (rev 260816)
@@ -427,6 +427,7 @@
gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(tab->webView));
gtk_widget_show(GTK_WIDGET(tab->webView));
#else
+ gtk_widget_set_vexpand(GTK_WIDGET(tab->webView), TRUE);
gtk_container_add(GTK_CONTAINER(tab), GTK_WIDGET(tab->webView));
#endif