Message ID | 20230413142927.3137190-1-aperez@igalia.com |
---|---|
State | Accepted |
Headers | show |
Series | package/webkitgtk: allow both X11 and Wayland | expand |
Hi, A couple of extra notes... On Thu, 13 Apr 2023 17:29:27 +0300 Adrian Perez de Castro <aperez@igalia.com> wrote: > Allow enabling support for both the X11 and Wayland backends. > > This in turn needs reorganizing how desktop GL or OpenGL ES is chosen, > as it no longer can depend on whether Wayland support is enabled: the > BR2_PACKAGE_HAS_LIBGL and BR2_PACKAGE_HAS_LIBGLES variables are both > checked, and ENABLE_GLES2 is set only if the package providing OpenGL > claims only GLES is supported; otherwise desktop GL is preferred. This > matches the existing logic. Note that it is possible to pass -DUSE_OPENGL_OR_ES=OFF to CMake to make WebKitGTK use only Cairo, and skip using OpenGL at all. This is never used in Buildroot because the libgtk3 package depends on OpenGL being available anyway, so I figured there is no point in building WebKitGTK with OpenGL disabled. Moreover, some modern features (like CSS 3D transforms) don't work when OpenGL support is disabled, so with my WebKit developer hat on I cannot really recommend using -DUSE_OPENGL_OR_ES=OFF ;-) > The existing comment indicating that only one of both windowing systems > can be enabled was wrong: the same WebKitGTK build can target both > X11 and Wayland at the same time, as long as GTK itself has been built > accordingly. Enabling both is the approach taken by most Linux > distributions, and has been supported for years. The comment can be traced all the way to the commit that added the WebKitGTK package (1f5bb4454474886a2e321ab59f71bdc919516312). I only recently needed to make a build with both enabled and noticed that only one backend was being allowed by webkitgtk.mk--a bit embarrasing, given that I have been maintaining the package for a few years now. > Signed-off-by: Adrian Perez de Castro <aperez@igalia.com> > --- > package/webkitgtk/webkitgtk.mk | 37 +++++++++++++++++----------------- > 1 file changed, 19 insertions(+), 18 deletions(-) > > diff --git a/package/webkitgtk/webkitgtk.mk b/package/webkitgtk/webkitgtk.mk > index 3263f7fea0..8d88d0914e 100644 > --- a/package/webkitgtk/webkitgtk.mk > +++ b/package/webkitgtk/webkitgtk.mk > @@ -77,32 +77,33 @@ else > WEBKITGTK_CONF_OPTS += -DENABLE_GAMEPAD=OFF > endif > > -# Only one target platform can be built, assume X11 > Wayland > - > -# GTK3-X11 target gives OpenGL from newer libgtk3 versions > -# Consider this better than EGL + maybe GLESv2 since both can't be built > -# 2D CANVAS acceleration requires OpenGL proper with cairo-gl > -ifeq ($(BR2_PACKAGE_LIBGTK3_X11),y) > -WEBKITGTK_CONF_OPTS += \ > - -DENABLE_GLES2=OFF \ > - -DENABLE_X11_TARGET=ON > -WEBKITGTK_DEPENDENCIES += libgl \ > - xlib_libXcomposite xlib_libXdamage xlib_libXrender xlib_libXt > -else # !X11 > -# GTK3-BROADWAY/WAYLAND needs at least EGL > -WEBKITGTK_DEPENDENCIES += libegl > -# GLESv2 support is optional though > -ifeq ($(BR2_PACKAGE_HAS_LIBGLES),y) > +# Use GLES if available and desktop GL is not. > +$(info $(BR2_PACKAGE_HAS_LIBGL):$(BR2_PACKAGE_HAS_LIBGLES)) > +ifeq ($(BR2_PACKAGE_HAS_LIBGL):$(BR2_PACKAGE_HAS_LIBGLES),:y) > WEBKITGTK_CONF_OPTS += -DENABLE_GLES2=ON > WEBKITGTK_DEPENDENCIES += libgles > else > -# Disable general OpenGL (shading) if there's no GLESv2 > WEBKITGTK_CONF_OPTS += -DENABLE_GLES2=OFF > endif > -# We must explicitly state the wayland target > + > +ifeq ($(BR2_PACKAGE_LIBGTK3_X11),y) > +WEBKITGTK_CONF_OPTS += -DENABLE_X11_TARGET=ON > +WEBKITGTK_DEPENDENCIES += libgl \ > + xlib_libXcomposite xlib_libXdamage xlib_libXrender xlib_libXt > +else > +WEBKITGTK_CONF_OPTS += -DENABLE_X11_TARGET=OFF > +endif > + > ifeq ($(BR2_PACKAGE_LIBGTK3_WAYLAND),y) > WEBKITGTK_CONF_OPTS += -DENABLE_WAYLAND_TARGET=ON > +WEBKITGTK_DEPENDENCIES += libegl > +else > +WEBKITGTK_CONF_OPTS += -DENABLE_WAYLAND_TARGET=OFF > endif > + > +# If only the GTK Broadway backend is enabled, EGL is still needed. > +ifeq ($(BR2_PACKAGE_LIBGTK3_X11):$(BR2_PACKAGE_LIBGTK3_WAYLAND):$(BR2_PACKAGE_LIBGTK3_BROADWAY),::y) > +WEBKITGTK_DEPENDENCIES += libegl > endif > > ifeq ($(BR2_PACKAGE_LIBGTK3_WAYLAND)$(BR2_PACKAGE_WPEBACKEND_FDO),yy) > -- > 2.40.0 > > Cheers, —Adrián
One more thing... On Thu, 13 Apr 2023 17:37:28 +0300 Adrian Perez de Castro <aperez@igalia.com> wrote: > A couple of extra notes... > > On Thu, 13 Apr 2023 17:29:27 +0300 Adrian Perez de Castro <aperez@igalia.com> wrote: > > > Allow enabling support for both the X11 and Wayland backends. > > > > This in turn needs reorganizing how desktop GL or OpenGL ES is chosen, > > as it no longer can depend on whether Wayland support is enabled: the > > BR2_PACKAGE_HAS_LIBGL and BR2_PACKAGE_HAS_LIBGLES variables are both > > checked, and ENABLE_GLES2 is set only if the package providing OpenGL > > claims only GLES is supported; otherwise desktop GL is preferred. This > > matches the existing logic. > > Note that it is possible to pass -DUSE_OPENGL_OR_ES=OFF to CMake to make > WebKitGTK use only Cairo, and skip using OpenGL at all. This is never used > in Buildroot because the libgtk3 package depends on OpenGL being available > anyway, so I figured there is no point in building WebKitGTK with OpenGL > disabled. Moreover, some modern features (like CSS 3D transforms) don't > work when OpenGL support is disabled, so with my WebKit developer hat on > I cannot really recommend using -DUSE_OPENGL_OR_ES=OFF ;-) > > > The existing comment indicating that only one of both windowing systems > > can be enabled was wrong: the same WebKitGTK build can target both > > X11 and Wayland at the same time, as long as GTK itself has been built > > accordingly. Enabling both is the approach taken by most Linux > > distributions, and has been supported for years. > > The comment can be traced all the way to the commit that added the WebKitGTK > package (1f5bb4454474886a2e321ab59f71bdc919516312). I only recently needed to > make a build with both enabled and noticed that only one backend was being > allowed by webkitgtk.mk--a bit embarrasing, given that I have been maintaining > the package for a few years now. You will need this patch to successfully build WebKitGTK with X11 support: https://patchwork.ozlabs.org/project/buildroot/patch/20230412222640.109345-1-stefan@ott.net/ > > Signed-off-by: Adrian Perez de Castro <aperez@igalia.com> > > --- > > package/webkitgtk/webkitgtk.mk | 37 +++++++++++++++++----------------- > > 1 file changed, 19 insertions(+), 18 deletions(-) > > > > diff --git a/package/webkitgtk/webkitgtk.mk b/package/webkitgtk/webkitgtk.mk > > index 3263f7fea0..8d88d0914e 100644 > > --- a/package/webkitgtk/webkitgtk.mk > > +++ b/package/webkitgtk/webkitgtk.mk > > @@ -77,32 +77,33 @@ else > > WEBKITGTK_CONF_OPTS += -DENABLE_GAMEPAD=OFF > > endif > > > > -# Only one target platform can be built, assume X11 > Wayland > > - > > -# GTK3-X11 target gives OpenGL from newer libgtk3 versions > > -# Consider this better than EGL + maybe GLESv2 since both can't be built > > -# 2D CANVAS acceleration requires OpenGL proper with cairo-gl > > -ifeq ($(BR2_PACKAGE_LIBGTK3_X11),y) > > -WEBKITGTK_CONF_OPTS += \ > > - -DENABLE_GLES2=OFF \ > > - -DENABLE_X11_TARGET=ON > > -WEBKITGTK_DEPENDENCIES += libgl \ > > - xlib_libXcomposite xlib_libXdamage xlib_libXrender xlib_libXt > > -else # !X11 > > -# GTK3-BROADWAY/WAYLAND needs at least EGL > > -WEBKITGTK_DEPENDENCIES += libegl > > -# GLESv2 support is optional though > > -ifeq ($(BR2_PACKAGE_HAS_LIBGLES),y) > > +# Use GLES if available and desktop GL is not. > > +$(info $(BR2_PACKAGE_HAS_LIBGL):$(BR2_PACKAGE_HAS_LIBGLES)) > > +ifeq ($(BR2_PACKAGE_HAS_LIBGL):$(BR2_PACKAGE_HAS_LIBGLES),:y) > > WEBKITGTK_CONF_OPTS += -DENABLE_GLES2=ON > > WEBKITGTK_DEPENDENCIES += libgles > > else > > -# Disable general OpenGL (shading) if there's no GLESv2 > > WEBKITGTK_CONF_OPTS += -DENABLE_GLES2=OFF > > endif > > -# We must explicitly state the wayland target > > + > > +ifeq ($(BR2_PACKAGE_LIBGTK3_X11),y) > > +WEBKITGTK_CONF_OPTS += -DENABLE_X11_TARGET=ON > > +WEBKITGTK_DEPENDENCIES += libgl \ > > + xlib_libXcomposite xlib_libXdamage xlib_libXrender xlib_libXt > > +else > > +WEBKITGTK_CONF_OPTS += -DENABLE_X11_TARGET=OFF > > +endif > > + > > ifeq ($(BR2_PACKAGE_LIBGTK3_WAYLAND),y) > > WEBKITGTK_CONF_OPTS += -DENABLE_WAYLAND_TARGET=ON > > +WEBKITGTK_DEPENDENCIES += libegl > > +else > > +WEBKITGTK_CONF_OPTS += -DENABLE_WAYLAND_TARGET=OFF > > endif > > + > > +# If only the GTK Broadway backend is enabled, EGL is still needed. > > +ifeq ($(BR2_PACKAGE_LIBGTK3_X11):$(BR2_PACKAGE_LIBGTK3_WAYLAND):$(BR2_PACKAGE_LIBGTK3_BROADWAY),::y) > > +WEBKITGTK_DEPENDENCIES += libegl > > endif > > > > ifeq ($(BR2_PACKAGE_LIBGTK3_WAYLAND)$(BR2_PACKAGE_WPEBACKEND_FDO),yy) > > -- > > 2.40.0 > > > > > > Cheers, > —Adrián Cheers, —Adrián
diff --git a/package/webkitgtk/webkitgtk.mk b/package/webkitgtk/webkitgtk.mk index 3263f7fea0..8d88d0914e 100644 --- a/package/webkitgtk/webkitgtk.mk +++ b/package/webkitgtk/webkitgtk.mk @@ -77,32 +77,33 @@ else WEBKITGTK_CONF_OPTS += -DENABLE_GAMEPAD=OFF endif -# Only one target platform can be built, assume X11 > Wayland - -# GTK3-X11 target gives OpenGL from newer libgtk3 versions -# Consider this better than EGL + maybe GLESv2 since both can't be built -# 2D CANVAS acceleration requires OpenGL proper with cairo-gl -ifeq ($(BR2_PACKAGE_LIBGTK3_X11),y) -WEBKITGTK_CONF_OPTS += \ - -DENABLE_GLES2=OFF \ - -DENABLE_X11_TARGET=ON -WEBKITGTK_DEPENDENCIES += libgl \ - xlib_libXcomposite xlib_libXdamage xlib_libXrender xlib_libXt -else # !X11 -# GTK3-BROADWAY/WAYLAND needs at least EGL -WEBKITGTK_DEPENDENCIES += libegl -# GLESv2 support is optional though -ifeq ($(BR2_PACKAGE_HAS_LIBGLES),y) +# Use GLES if available and desktop GL is not. +$(info $(BR2_PACKAGE_HAS_LIBGL):$(BR2_PACKAGE_HAS_LIBGLES)) +ifeq ($(BR2_PACKAGE_HAS_LIBGL):$(BR2_PACKAGE_HAS_LIBGLES),:y) WEBKITGTK_CONF_OPTS += -DENABLE_GLES2=ON WEBKITGTK_DEPENDENCIES += libgles else -# Disable general OpenGL (shading) if there's no GLESv2 WEBKITGTK_CONF_OPTS += -DENABLE_GLES2=OFF endif -# We must explicitly state the wayland target + +ifeq ($(BR2_PACKAGE_LIBGTK3_X11),y) +WEBKITGTK_CONF_OPTS += -DENABLE_X11_TARGET=ON +WEBKITGTK_DEPENDENCIES += libgl \ + xlib_libXcomposite xlib_libXdamage xlib_libXrender xlib_libXt +else +WEBKITGTK_CONF_OPTS += -DENABLE_X11_TARGET=OFF +endif + ifeq ($(BR2_PACKAGE_LIBGTK3_WAYLAND),y) WEBKITGTK_CONF_OPTS += -DENABLE_WAYLAND_TARGET=ON +WEBKITGTK_DEPENDENCIES += libegl +else +WEBKITGTK_CONF_OPTS += -DENABLE_WAYLAND_TARGET=OFF endif + +# If only the GTK Broadway backend is enabled, EGL is still needed. +ifeq ($(BR2_PACKAGE_LIBGTK3_X11):$(BR2_PACKAGE_LIBGTK3_WAYLAND):$(BR2_PACKAGE_LIBGTK3_BROADWAY),::y) +WEBKITGTK_DEPENDENCIES += libegl endif ifeq ($(BR2_PACKAGE_LIBGTK3_WAYLAND)$(BR2_PACKAGE_WPEBACKEND_FDO),yy)
Allow enabling support for both the X11 and Wayland backends. This in turn needs reorganizing how desktop GL or OpenGL ES is chosen, as it no longer can depend on whether Wayland support is enabled: the BR2_PACKAGE_HAS_LIBGL and BR2_PACKAGE_HAS_LIBGLES variables are both checked, and ENABLE_GLES2 is set only if the package providing OpenGL claims only GLES is supported; otherwise desktop GL is preferred. This matches the existing logic. The existing comment indicating that only one of both windowing systems can be enabled was wrong: the same WebKitGTK build can target both X11 and Wayland at the same time, as long as GTK itself has been built accordingly. Enabling both is the approach taken by most Linux distributions, and has been supported for years. Signed-off-by: Adrian Perez de Castro <aperez@igalia.com> --- package/webkitgtk/webkitgtk.mk | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-)