[PATCH 3/3] compositor-drm: Allow scanning out of opaque ARGB surfaces
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Fri Sep 7 07:32:17 PDT 2012
---
src/compositor-drm.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index c6634a0..c6d4658 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -276,6 +276,34 @@ fb_handle_buffer_destroy(struct wl_listener *listener, void *data)
weston_output_schedule_repaint(&fb->output->base);
}
+static int
+drm_output_check_scanout_format(struct drm_output *output,
+ struct weston_surface *es, struct gbm_bo *bo)
+{
+ int ret = 0;
+ uint32_t format;
+ pixman_region32_t r;
+
+ format = gbm_bo_get_format(bo);
+
+ if (format == GBM_FORMAT_XRGB8888)
+ ret = 1;
+ else if (format == GBM_FORMAT_ARGB8888) {
+ /* We can only scanout an ARGB buffer if the surface's
+ * opaque region covers the whole output */
+ pixman_region32_init(&r);
+ pixman_region32_subtract(&r, &output->base.region,
+ &es->opaque);
+
+ if (!pixman_region32_not_empty(&r))
+ ret = 1;
+
+ pixman_region32_fini(&r);
+ }
+
+ return ret;
+}
+
static struct weston_plane *
drm_output_prepare_scanout_surface(struct weston_output *_output,
struct weston_surface *es)
@@ -296,10 +324,7 @@ drm_output_prepare_scanout_surface(struct weston_output *_output,
bo = gbm_bo_import(c->gbm, GBM_BO_IMPORT_WL_BUFFER,
es->buffer, GBM_BO_USE_SCANOUT);
- /* Need to verify output->region contained in surface opaque
- * region. Or maybe just that format doesn't have alpha.
- * For now, scanout only if format is XRGB8888. */
- if (gbm_bo_get_format(bo) != GBM_FORMAT_XRGB8888) {
+ if (!drm_output_check_scanout_format(output, es, bo)) {
gbm_bo_destroy(bo);
return NULL;
}
--
1.7.9.5
More information about the wayland-devel
mailing list