[Libva] [PATCH] libva: new flags for vaPutSurface() to distinguish pixmap from window

Xiang, Haihao haihao.xiang at intel.com
Tue Jun 29 00:07:24 PDT 2010


Meanwhile render pixmap directly.
---
 i965_drv_video/i965_drv_video.c |    4 ++--
 va/glx/va_glx_impl.c            |    2 +-
 va/va.h                         |    4 ++++
 va/x11/dri2_util.c              |    7 ++++++-
 va/x11/va_dricommon.c           |   15 ++++++++++-----
 va/x11/va_dricommon.h           |    3 ++-
 6 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c
index ace2181..aadb22c 100644
--- a/i965_drv_video/i965_drv_video.c
+++ b/i965_drv_video/i965_drv_video.c
@@ -1409,7 +1409,7 @@ i965_GetImage(VADriverContextP ctx,
 VAStatus 
 i965_PutSurface(VADriverContextP ctx,
                 VASurfaceID surface,
-                Drawable draw, /* X Drawable */
+                void *draw, /* X Drawable */
                 short srcx,
                 short srcy,
                 unsigned short srcw,
@@ -1443,7 +1443,7 @@ i965_PutSurface(VADriverContextP ctx,
     if (obj_surface->bo == NULL)
         return VA_STATUS_SUCCESS;
 
-    dri_drawable = dri_get_drawable(ctx, draw);
+    dri_drawable = dri_get_drawable(ctx, (XID)draw, flags & VA_DRAWABLE_MASK);
     assert(dri_drawable);
 
     buffer = dri_get_rendering_buffer(ctx, dri_drawable);
diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c
index 497b64e..b519aa8 100644
--- a/va/glx/va_glx_impl.c
+++ b/va/glx/va_glx_impl.c
@@ -933,7 +933,7 @@ associate_surface(
         0, 0, pSurfaceGLX->width, pSurfaceGLX->height,
         0, 0, pSurfaceGLX->width, pSurfaceGLX->height,
         NULL, 0,
-        flags
+        flags | VA_DRAWABLE_PIXMAP
     );
     XSync((Display *)ctx->native_dpy, False);
     if (x11_untrap_errors() != 0)
diff --git a/va/va.h b/va/va.h
index e350f74..6c9e42e 100644
--- a/va/va.h
+++ b/va/va.h
@@ -146,6 +146,10 @@ typedef int VAStatus;	/* Return status type from functions */
 #define VA_SRC_BT601            0x00000010
 #define VA_SRC_BT709            0x00000020
 
+/* Drawable type for vaPutSurface() */
+#define VA_DRAWABLE_MASK        0xf0000000
+#define VA_DRAWABLE_WINDOW      0x00000000
+#define VA_DRAWABLE_PIXMAP      0x10000000
 /*
  * Returns a short english description of error_status
  */
diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c
index 63db330..5ed5662 100644
--- a/va/x11/dri2_util.c
+++ b/va/x11/dri2_util.c
@@ -98,7 +98,12 @@ dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
     VA_DRI2Buffer *buffers;
     
     i = 0;
-    attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+
+    if (dri_drawable->type == VA_DRAWABLE_PIXMAP)
+        attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+    else
+        attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+    
     buffers = VA_DRI2GetBuffers(ctx->native_dpy, dri_drawable->x_drawable,
 			     &dri2_drawable->width, &dri2_drawable->height, 
                              attachments, i, &count);
diff --git a/va/x11/va_dricommon.c b/va/x11/va_dricommon.c
index f9c3dfd..bc445d4 100644
--- a/va/x11/va_dricommon.c
+++ b/va/x11/va_dricommon.c
@@ -1,20 +1,25 @@
+#include <assert.h>
+
 #include "va_dricommon.h"
 
-static struct dri_drawable *                                                                                                                                                                                   
-do_drawable_hash(VADriverContextP ctx, XID drawable)
+static struct dri_drawable *                                         
+do_drawable_hash(VADriverContextP ctx, XID drawable, int type)
 {
     struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
     int index = drawable % DRAWABLE_HASH_SZ;
     struct dri_drawable *dri_drawable = dri_state->drawable_hash[index];
 
     while (dri_drawable) {
-        if (dri_drawable->x_drawable == drawable)
+        if (dri_drawable->x_drawable == drawable) {
+            assert(dri_drawable->type == type);
             return dri_drawable;
+        }
         dri_drawable = dri_drawable->next;
     }
 
     dri_drawable = dri_state->createDrawable(ctx, drawable);
     dri_drawable->x_drawable = drawable;
+    dri_drawable->type = type;
     dri_drawable->next = dri_state->drawable_hash[index];
     dri_state->drawable_hash[index] = dri_drawable;
 
@@ -40,9 +45,9 @@ free_drawable_hashtable(VADriverContextP ctx)
 }
 
 struct dri_drawable *
-dri_get_drawable(VADriverContextP ctx, XID drawable)
+dri_get_drawable(VADriverContextP ctx, XID drawable, int type)
 {
-    return do_drawable_hash(ctx, drawable);
+    return do_drawable_hash(ctx, drawable, type);
 }
 
 void 
diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h
index ae364e7..cc03e45 100644
--- a/va/x11/va_dricommon.h
+++ b/va/x11/va_dricommon.h
@@ -40,6 +40,7 @@ union dri_buffer
 struct dri_drawable 
 {
     XID x_drawable;
+    int type;
     int x;
     int y;
     unsigned int width;
@@ -70,7 +71,7 @@ struct dri_state
 Bool isDRI2Connected(VADriverContextP ctx, char **driver_name);
 Bool isDRI1Connected(VADriverContextP ctx, char **driver_name);
 void free_drawable_hashtable(VADriverContextP ctx);
-struct dri_drawable *dri_get_drawable(VADriverContextP ctx, XID drawable);
+struct dri_drawable *dri_get_drawable(VADriverContextP ctx, XID drawable, int type);
 void dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable);
 union dri_buffer *dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable);
 
-- 
1.6.3.3



More information about the Libva mailing list