[PATCH weston] gl-renderer: If an XRGB format is requested but unavailable, try ARGB

Daniel Stone daniel at fooishbar.org
Tue May 5 08:15:50 PDT 2015


Hi,

On 5 May 2015 at 14:52, Derek Foreman <derekf at osg.samsung.com> wrote:
> +static bool
> +fallback_format(EGLint *format)
> +{
> +       char *fourcc = (char *)format;
> +
> +       if (fourcc[0] != 'X')
> +               return false;
> +
> +       fourcc[0] = 'A';
> +       return true;
> +}

Took me a moment to work out what was going on here. Cute, but nasty.
We should probably fix this up once we get the format database we need
for linux_dmabuf. Could probably squeeze it into a single pass with
two variables and some restructuring, along these lines:

EGLConfig matching_config = EGL_NO_CONFIG;
EGLConfig fallback_config = EGL_NO_CONFIG;

fallback_id = *visual_id;
if (!fallback_format(&fallback_id))
        fallback_id = 0;

for (i = 0; i < matched; i++) {
        eglGetConfigAttrib(...);

        if (id == visual_id) {
                matching_config = configs[i];
                break;
        }
        else if (fallback_id != 0 && id == fallback_id &&
fallback_config == EGL_NO_CONFIG) {
                fallback_config = configs[i];
        }
}

free(configs);

if (matching_config != EGL_NO_CONFIG) {
        *config_out = matching_config;
        return 0;
}
else if (fallback_config != EGL_NO_CONFIG) {
        *config_out = fallback_config;
        return 0;
}
else {
        return -1;
}

But that's just nitpicking; the current version does work fine. And my
reworked version does have a less elegant return ladder. So, either
way:
Reviewed-by: Daniel Stone <daniels at collabora.com>

Cheers,
Daniel


More information about the wayland-devel mailing list