[Mesa-dev] [PATCH 2/5] egl/android: Declare 'const' the EGLConfig attribs template array

Chad Versace chadversary at chromium.org
Tue Jun 20 17:26:38 UTC 2017


On Tue 20 Jun 2017, Emil Velikov wrote:
> On 17 June 2017 at 03:37, Chad Versace <chadversary at chromium.org> wrote:
> > No behavioral change. Just a cleanup.
> >
> > Post-patch, we no longer modify the same array on each iteration of the
> > inner loop of droid_add_configs_for_visuals(). Instead, we just declare
> > the array as const inside the inner loop.
> > ---
> >  src/egl/drivers/dri2/platform_android.c | 16 +++++++---------
> >  1 file changed, 7 insertions(+), 9 deletions(-)
> >
> > diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> > index a5f45a0bfbe..f309fcea11f 100644
> > --- a/src/egl/drivers/dri2/platform_android.c
> > +++ b/src/egl/drivers/dri2/platform_android.c
> > @@ -1034,13 +1034,6 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
> >        { HAL_PIXEL_FORMAT_RGB_565,   { 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 } },
> >        { HAL_PIXEL_FORMAT_BGRA_8888, { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 } },
> >     };
> > -   EGLint config_attrs[] = {
> > -     EGL_NATIVE_VISUAL_ID,   0,
> > -     EGL_NATIVE_VISUAL_TYPE, 0,
> > -     EGL_FRAMEBUFFER_TARGET_ANDROID, EGL_TRUE,
> > -     EGL_RECORDABLE_ANDROID, EGL_TRUE,
> > -     EGL_NONE
> > -   };
> >
> >     unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
> >     int count = 0;
> > @@ -1049,8 +1042,13 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
> >        const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
> >
> >        for (int j = 0; j < ARRAY_SIZE(visuals); j++) {
> > -         config_attrs[1] = visuals[j].format;
> > -         config_attrs[3] = visuals[j].format;
> > +         const EGLint config_attrs[] = {
> > +           EGL_NATIVE_VISUAL_ID,   visuals[j].format,
> > +           EGL_NATIVE_VISUAL_TYPE, visuals[j].format,
> > +           EGL_FRAMEBUFFER_TARGET_ANDROID, EGL_TRUE,
> > +           EGL_RECORDABLE_ANDROID, EGL_TRUE,
> > +           EGL_NONE
> > +         };
> >
> My moving it here, we'll write the hunk i*j times, as opposed to once.
> Not a huge deal, but like 3/5 it breaks the consistency with other
> platforms' code.
> 
> Can we please update all [as one patch or not], please?
> Emil

Sure, I'll resubmit with a patch that touches all drivers.


More information about the mesa-dev mailing list