GNOME Bugzilla – Bug 769739
Add a more efficient way to draw EGLImages, gdk_cairo_draw_from_egl_image()
Last modified: 2016-09-28 11:01:15 UTC
While working on the experimental branch of WebKit2GTK+ that enables Accelerated Compositing under Wayland by way of a nested Wayland compositor, we needed an efficient way to draw a single EGLImage on screen. We first tried setting up a GL context, importing the EGLImage as a texture, and rendering it which worked but had some overhead. We then developed a more efficient approach that skips some of the above steps by introducing the gdk_cairo_draw_from_egl_image() function. Note that this is used by our experimental wayland-ac[1] branch, but for WebKit2GTK+ upstream we'll likely adopt a different approach by importing the EGLImages as textures, since the long-term aim in to move composition to the UIProcess which would need a real GL context and real textures. In the short term we'd be likely trading off performance for compatibility and future-proofing, but we thought the current approach may interest other people for different purposes. [1] The WebKit2GTK+ wayland-ac branch, don't be fooled by the repository name, no Clutter involved: https://git.apertis.org/cgit/webkit-gtk-clutter.git/log/?h=wayland-ac
Created attachment 333111 [details] [review] gdk: Add gdk_cairo_draw_from_egl_image() This complements gdk_cairo_draw_from_gl() when you somehow ends up with a EGLImage that you want to efficiently paint to screen, instead of a full GL context.
ebassi, this looks like its in your area ?
Review of attachment 333111 [details] [review]: I honestly don't like this approach, and I really don't want to have an explosion of gdk_cairo_draw_from_<random_gl_object_id> functions. Looking at the implementation, I see a ton of duplication with the existing gdk_cairo_draw_from_gl(). Additional, gdk_cairo_draw_from_gl() already takes two types of GL object ids — textures and render buffers. Would it be possible to just add support for EGLImage object ids to gdk_cairo_draw_from_gl(), on supported platforms?
The codepath is slightly different in several places, but I guess it can be beaten into shape, as the proliferation of similar interface is a very good point. I'll have a look at that, thanks!
Gustavo landed in WebKit a patch to use gdk_cairo_draw_from_gl() by flipping the rendering in the WebProcess with marginal overhead (if any), which makes this the approach of this patch obsolete (the only difference left is indeed the flipping, as we turn the EGLImage to a texture in WebKit). Closing as INVALID.