From 599b1d0ceb568fbb3e55b0187793864253341ebc Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 29 Jul 2011 14:21:56 +0200 Subject: wayland: Add vaAttachSurface --- va/va_wayland.h | 7 ++++++ va/wayland/va_wayland.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/va/va_wayland.h b/va/va_wayland.h index 364cd37..610c988 100644 --- a/va/va_wayland.h +++ b/va/va_wayland.h @@ -41,6 +41,13 @@ VAStatus vaPutSurface ( unsigned int flags /* PutSurface flags */ ); +VAStatus vaAttachSurface( + VADisplay dpy, + VASurfaceID surface, + struct wl_egl_window *window, + struct wl_visual *visual +); + #ifdef __cplusplus } #endif diff --git a/va/wayland/va_wayland.c b/va/wayland/va_wayland.c index 647ee92..73f8066 100644 --- a/va/wayland/va_wayland.c +++ b/va/wayland/va_wayland.c @@ -554,3 +554,61 @@ vaPutSurface(VADisplay dpy, destx, desty, destw, desth, cliprects, number_cliprects, flags); } + +VAStatus +vaAttachSurface(VADisplay dpy, VASurfaceID surface, + struct wl_egl_window *window, struct wl_visual *visual) +{ + struct VADriverContext *ctx; + struct wldrm_ctx *wctx; + struct wl_display *display; + struct wldrm_state *drm_state; + struct wl_buffer *buf; + VAStatus status; + VAImage image; + uint32_t name, pitch; + + if (fool_postp) + return VA_STATUS_SUCCESS; + + if (window == NULL) + return VA_STATUS_ERROR_UNKNOWN; + + CHECK_DISPLAY(dpy); + ctx = CTX(dpy); + wctx = wldrm_ctx(ctx); + display = wctx->base.native_dpy; + drm_state = ctx->drm_state; + + status = ctx->vtable->vaDeriveImage(ctx, surface, &image); + if (status != VA_STATUS_SUCCESS) + return status; + + status = drm_state->base.image_export(ctx, image.image_id, + &name, &pitch); + if (status != VA_STATUS_SUCCESS) { + /* destroy image */ + return status; + } + + if (!wctx->drm) { + int id = wl_display_get_global(display, "wl_drm", 1); + assert(id != 0); + wctx->drm = wl_drm_create_without_bind(display, id); + } + buf = wl_drm_create_buffer(wctx->drm, name, + image.width, image.height, + pitch, visual); + wl_drm_destroy(wctx->drm); + wctx->drm = NULL; + + wl_buffer_damage(buf, 0, 0, image.width, image.height); + wl_surface_attach(window->surface, buf, 0, 0); + wl_surface_damage(window->surface, 0, 0, image.width, image.height); + + /* wl_buffer_destroy(buf); */ + + /* destroy image in sync callback */ + + return VA_STATUS_SUCCESS; +} -- cgit v1.2.3