gtk4: implement custom Widget for WebView rendering
As a future improvement idea, I suppose that instead of using GtkGLArea maybe it could be possible to implement a GtkWidget which would use gtk_snapshot_append_texture() to directly pass the GL texture, and let GTK do the compositing—we would not need to provide shaders to scan out the texture when painting a quad using GL calls, and if I understand correctly it should be faster because GtkGLArea paints to a FBO backed by a texture, and then that texture is snapshotted by the `GtkGLArea widget implementation.
Originally posted by @aperezdc in https://github.com/Igalia/cog/pull/262#discussion_r589310427
With the current approach we can't select text. I think we should consider this new approach sooner than later :)
With the current approach we can't select text. I think we should consider this new approach sooner than later :)
Ah well, maybe a different rendering approach wouldn't help much with this specific issue.
This comment in the GTK GitLab shows how to import a DMA-BUF as a texture that then can be passed to GTK as an snapshot. It should work both for Wayland and X11 after this change in GTK to prefer EGL.
(Of course it should be possible to use EGLImage, there is no need to go all-in and use DMA-BUF to implement a widget, but it seemed interesting to share.)