[Mesa-dev] [PATCH 2/2] egl: implement EGL_MESA_transparent_alpha for x11 and wayland

Jason Ekstrand jason at jlekstrand.net
Tue Mar 3 10:56:57 PST 2015


On Tue, Mar 3, 2015 at 10:07 AM, Chad Versace <chad.versace at intel.com>
wrote:

> On 02/23/2015 06:32 AM, Jonny Lamb wrote:
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67676
> > ---
> >  include/EGL/eglmesaext.h                |  5 +++++
> >  src/egl/drivers/dri2/platform_wayland.c |  9 +++++++--
> >  src/egl/drivers/dri2/platform_x11.c     | 22 +++++++++++++---------
> >  src/egl/main/eglapi.c                   | 13 +++++++++++++
> >  src/egl/main/eglconfig.c                |  3 ++-
> >  5 files changed, 40 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
> > index 5fcc527..3fa7c9c 100644
> > --- a/include/EGL/eglmesaext.h
> > +++ b/include/EGL/eglmesaext.h
> > @@ -170,6 +170,11 @@ typedef EGLBoolean (EGLAPIENTRYP
> PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
> >  #define EGL_NO_CONFIG_MESA                   ((EGLConfig)0)
> >  #endif
> >
> > +#ifndef EGL_MESA_transparent_alpha
> > +#define EGL_MESA_transparent_alpha 1
> > +#define EGL_TRANSPARENT_ALPHA_MESA           0x31E9
> > +#endif
>
> According to the EGL registry today, 0x31E9 is owned by Hitachi. The first
> unused enum
> in Mesa's reserved range is 0x31D9, so you should use that.
>
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/src/egl/drivers/dri2/platform_wayland.c
> b/src/egl/drivers/dri2/platform_wayland.c
> > index 3c34e07..ba071a5 100644
> > --- a/src/egl/drivers/dri2/platform_wayland.c
> > +++ b/src/egl/drivers/dri2/platform_wayland.c
> > @@ -965,6 +965,10 @@ dri2_initialize_wayland(_EGLDriver *drv,
> _EGLDisplay *disp)
> >        { 0xff0000, 0xff00, 0xff, 0xff000000 };
> >     static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0
> };
> >     static const unsigned int rgb565_masks[4] = { 0xf800, 0x07e0,
> 0x001f, 0 };
> > +   static const EGLint argb_attrs[] = {
> > +       EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_ALPHA_MESA,
> > +       EGL_NONE
> > +   };
> >
> >     loader_set_logger(_eglLog);
> >
> > @@ -1044,8 +1048,9 @@ dri2_initialize_wayland(_EGLDriver *drv,
> _EGLDisplay *disp)
> >        config = dri2_dpy->driver_configs[i];
> >        if (dri2_dpy->formats & HAS_XRGB8888)
> >        dri2_add_config(disp, config, i + 1, types, NULL, rgb_masks);
> > -      if (dri2_dpy->formats & HAS_ARGB8888)
> > -      dri2_add_config(disp, config, i + 1, types, NULL, argb_masks);
> > +      if (dri2_dpy->formats & HAS_ARGB8888) {
> > +      dri2_add_config(disp, config, i + 1, types, argb_attrs,
> argb_masks);
> > +      }
> >        if (dri2_dpy->formats & HAS_RGB565)
> >          dri2_add_config(disp, config, i + 1, types, NULL, rgb565_masks);
> >     }
>
> I tested this patch with X11 and Mesa, and it works as advertised. BUT...
>
> Pre-patch, Wayland applications who requested an EGLConfig with alpha
> received one. The EGLSurface had compositor-transparent alpha, which
> the application may not have expected. But the alpha configs *were*
> available.
>
> Post-patch, existing Wayland applications that request an EGLConfig with
> alpha will no longer receive one, because the existing applications
> do not yet know about EGL_TRANSPARENT_ALPHA_MESA.
>
> I believe a correct solution is to continue create EGLConfigs
> with EGL_ALPHA and without EGL_TRANSPARENT_TYPE, as Mesa does today,
> but tell the compositor to ignore the alpha channel. The alpha channel
> will be used for client-side alpha-blending but not for compositing.
> Jason says that should be possible by telling the compositor that
> the buffer format is WL_DRM_FORMAT_XRGB8888. And in addition to the
> existing
> EGLConfigs, also create new EGLConfigs with EGL_TRANSPARENT_ALPHA_MESA, as
> this patch already does.
>

Yes, XRGB8888 would be the correct *technical* way to handle that, but it
still makes me wonder... What about Wayland apps that expect to get
transparency by simply asking for alpha now?  Won't this break them?  I
guess we have to break one class of apps or the other.
--Jason

By the way, the X11 portion of the patch looks good to me.
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150303/4cc5585f/attachment.html>


More information about the mesa-dev mailing list