summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2011-11-09 16:32:51 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2011-12-14 08:27:03 +0800
commit731d575b238238e90d576692af82f74d47c1ae77 (patch)
treeca3cfe1a2e62c4a2c16f5155aa4cc71d18771410
parent52c87f898b210cddde70231021097c5a0bb6fdc3 (diff)
New hooks to create/free native pixmap
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rw-r--r--va/va_backend.h10
-rw-r--r--va/x11/va_x11.c43
2 files changed, 53 insertions, 0 deletions
diff --git a/va/va_backend.h b/va/va_backend.h
index 9b47cae..22f1765 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -459,6 +459,16 @@ struct VADisplayContext
);
void *opaque; /* opaque for display extensions (e.g. GLX) */
+
+ VAStatus (*vaCreateNativePixmap) (
+ VADisplayContextP pDisplayContext,
+ unsigned int width,
+ unsigned int height,
+ void **native_pixmap);
+
+ VAStatus (*vaFreeNativePixmap) (
+ VADisplayContextP pDisplayContext,
+ void *native_pixmap);
};
typedef VAStatus (*VADriverInit) (
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index b51f5f0..036499c 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -161,6 +161,47 @@ static VAStatus va_DisplayContextGetDriverName (
return vaStatus;
}
+static VAStatus va_CreateNativePixmap(
+ VADisplayContextP pDisplayContext,
+ unsigned int width,
+ unsigned int height,
+ void **native_pixmap)
+{
+ VADriverContextP ctx = pDisplayContext->pDriverContext;
+ Window root_window;
+ XWindowAttributes wattr;
+ Pixmap pixmap = None;
+
+ root_window = RootWindow(ctx->native_dpy, ctx->x11_screen);
+ XGetWindowAttributes(ctx->native_dpy, root_window, &wattr);
+
+ if (wattr.depth != 24 && wattr.depth != 32)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ pixmap = XCreatePixmap(
+ ctx->native_dpy,
+ root_window,
+ width,
+ height,
+ wattr.depth
+ );
+
+ *native_pixmap = (void *)pixmap;
+
+ return !pixmap ? VA_STATUS_ERROR_UNKNOWN : VA_STATUS_SUCCESS;
+}
+
+static VAStatus va_FreeNativePixmap(
+ VADisplayContextP pDisplayContext,
+ void *native_pixmap)
+{
+ VADriverContextP ctx = pDisplayContext->pDriverContext;
+ Pixmap pixmap = (Pixmap)native_pixmap;
+
+ XFreePixmap(ctx->native_dpy, pixmap);
+
+ return VA_STATUS_SUCCESS;
+}
VADisplay vaGetDisplay (
VANativeDisplay native_dpy /* implementation specific */
@@ -190,6 +231,8 @@ VADisplay vaGetDisplay (
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContext->opaque = NULL;
+ pDisplayContext->vaCreateNativePixmap = va_CreateNativePixmap;
+ pDisplayContext->vaFreeNativePixmap = va_FreeNativePixmap;
pDriverContext->dri_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}