diff options
author | Daniel Stone <daniels@collabora.com> | 2016-11-17 17:33:08 +0000 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2017-02-07 19:16:33 +0000 |
commit | 1dc6693d36621549e0ded879cfaecfb86d27fd30 (patch) | |
tree | 7f019eacb27b2a6a6bc13e63916300ac8b4740ec | |
parent | ee0837ee8007bc333b60d98b9b0b4d9e92b28f79 (diff) |
compositor-drm: Use plane FB-import helper for scanout
Use the same codepath, which has the added advantage of being able to
import dmabufs.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D1521
-rw-r--r-- | libweston/compositor-drm.c | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 3f431f82..99ca5e25 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -1596,29 +1596,27 @@ drm_output_prepare_scanout_view(struct drm_output_state *output_state, struct weston_view *ev) { struct drm_output *output = output_state->output; - struct drm_backend *b = to_drm_backend(output->base.compositor); struct drm_plane *scanout_plane = output->scanout_plane; struct drm_plane_state *state; - struct weston_buffer *buffer = ev->surface->buffer_ref.buffer; - struct gbm_bo *bo; - - /* Don't import buffers which span multiple outputs. */ - if (ev->output_mask != (1u << output->base.id)) - return NULL; + struct drm_fb *fb; - /* We use GBM to import buffers. */ - if (b->gbm == NULL) + fb = drm_fb_get_from_view(output_state, ev); + if (!fb) return NULL; - if (buffer == NULL) - return NULL; - if (wl_shm_buffer_get(buffer->resource)) + /* Can't change formats with just a pageflip */ + if (fb->format->format != output->gbm_format) { + drm_fb_unref(fb); return NULL; + } state = drm_output_state_get_plane(output_state, scanout_plane); - if (state->fb) - goto err; + if (state->fb) { + drm_fb_unref(fb); + return NULL; + } + state->fb = fb; state->output = output; drm_plane_state_coords_for_view(state, ev); @@ -1631,34 +1629,6 @@ drm_output_prepare_scanout_view(struct drm_output_state *output_state, state->dest_h != (unsigned) output->base.current_mode->height) goto err; - if (ev->alpha != 1.0f) - goto err; - - bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER, - buffer->resource, GBM_BO_USE_SCANOUT); - - /* Unable to use the buffer for scanout */ - if (!bo) - goto err; - - state = drm_output_state_get_plane(output_state, scanout_plane); - state->fb = drm_fb_get_from_bo(bo, b, drm_view_is_opaque(ev), - BUFFER_CLIENT); - if (!state->fb) { - /* We need to explicitly destroy the BO. */ - gbm_bo_destroy(bo); - goto err; - } - - /* Can't change formats with just a pageflip */ - if (state->fb->format->format != output->gbm_format) { - /* No need to destroy the GBM BO here, as it's now owned - * by the FB. */ - goto err; - } - - drm_fb_set_buffer(state->fb, buffer); - return &scanout_plane->base; err: |