On Thu, 5 Jul 2018 18:16:30 +0100 Daniel Stone <dani...@collabora.com> wrote:
> Rather than a hardcoded ARGB8888 -> XRGB8888 translation inside a > GBM-specific helper, just determine whether or not the view is opaque, > and use the generic helpers to implement the format translation. > > As a consequence of reordering the calls in > drm_output_prepare_overlay_view(), we move the GBM BO dereference into a > different failure path, before it gets captured by the plane state. > > Signed-off-by: Daniel Stone <dani...@collabora.com> > Tested-by: Emre Ucan <eu...@de.adit-jv.com> > --- > libweston/compositor-drm.c | 118 ++++++++++++++----------------------- > 1 file changed, 45 insertions(+), 73 deletions(-) > > diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c > index cfd7d268f..93a0fb59f 100644 > --- a/libweston/compositor-drm.c > +++ b/libweston/compositor-drm.c > @@ -950,7 +950,7 @@ drm_fb_ref(struct drm_fb *fb) > > static struct drm_fb * > drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, > - uint32_t format, enum drm_fb_type type) > + bool is_opaque, enum drm_fb_type type) > { > struct drm_fb *fb = gbm_bo_get_user_data(bo); > uint32_t handles[4] = { 0 }, pitches[4] = { 0 }, offsets[4] = { 0 }; > @@ -961,8 +961,6 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend > *backend, > return drm_fb_ref(fb); > } > > - assert(format != 0); > - > fb = zalloc(sizeof *fb); > if (fb == NULL) > return NULL; > @@ -975,16 +973,19 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct > drm_backend *backend, > fb->height = gbm_bo_get_height(bo); > fb->stride = gbm_bo_get_stride(bo); > fb->handle = gbm_bo_get_handle(bo).u32; > - fb->format = pixel_format_get_info(format); > + fb->format = pixel_format_get_info(gbm_bo_get_format(bo)); > fb->size = fb->stride * fb->height; > fb->fd = backend->drm.fd; > > if (!fb->format) { > weston_log("couldn't look up format 0x%lx\n", > - (unsigned long) format); > + (unsigned long) gbm_bo_get_format(bo)); > goto err_free; > } > > + if (is_opaque) > + fb->format = pixel_format_get_opaque_substitute(fb->format); > + > if (backend->min_width > fb->width || > fb->width > backend->max_width || > backend->min_height > fb->height || > @@ -1515,34 +1516,26 @@ drm_view_transform_supported(struct weston_view *ev) > (ev->transform.matrix.type < WESTON_MATRIX_TRANSFORM_ROTATE); > } > > -static uint32_t > -drm_output_check_scanout_format(struct drm_output *output, > - struct weston_surface *es, struct gbm_bo *bo) > +static bool > +drm_view_is_opaque(struct weston_view *ev) > { > - uint32_t format; > pixman_region32_t r; > + bool ret = false; > > - format = gbm_bo_get_format(bo); > - > - if (format == GBM_FORMAT_ARGB8888) { > - /* We can scanout an ARGB buffer if the surface's > - * opaque region covers the whole output, but we have > - * to use XRGB as the KMS format code. */ > - pixman_region32_init_rect(&r, 0, 0, > - output->base.width, > - output->base.height); > - pixman_region32_subtract(&r, &r, &es->opaque); > + /* We can scanout an ARGB buffer if the surface's > + * opaque region covers the whole output, but we have > + * to use XRGB as the KMS format code. */ This comment seems a bit out of place now, there are no formats in this function. Would be nice to move it into, say, drm_fb_get_from_bo()? Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> Thanks, pq > + pixman_region32_init_rect(&r, 0, 0, > + ev->surface->width, > + ev->surface->height); > + pixman_region32_subtract(&r, &r, &ev->surface->opaque); > > - if (!pixman_region32_not_empty(&r)) > - format = GBM_FORMAT_XRGB8888; > + if (!pixman_region32_not_empty(&r)) > + ret = true; > > - pixman_region32_fini(&r); > - } > + pixman_region32_fini(&r); > > - if (output->gbm_format == format) > - return format; > - > - return 0; > + return ret; > } >
pgpW7RQN_Mqpt.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel