[Libva] [PATCH 14/16] update test case

Zhao Halley halley.zhao at intel.com
Tue Jun 5 02:07:02 PDT 2012


From: Zhao halley <halley.zhao at intel.com>

---
 test/common/va_display_wayland.c     |   29 ++++++++++++++-------------
 test/putsurface/putsurface_wayland.c |   35 +++++++++++++++------------------
 2 files changed, 31 insertions(+), 33 deletions(-)
 mode change 100644 => 100755 test/common/va_display_wayland.c
 mode change 100644 => 100755 test/putsurface/putsurface_wayland.c

diff --git a/test/common/va_display_wayland.c b/test/common/va_display_wayland.c
old mode 100644
new mode 100755
index a022740..1a32068
--- a/test/common/va_display_wayland.c
+++ b/test/common/va_display_wayland.c
@@ -36,7 +36,6 @@ struct display {
     unsigned int                ref_count;
     int                         event_fd;
     unsigned int                event_mask;
-    VASurfaceWL                 va_surface_wl;
 };
 
 static struct display *g_display;
@@ -106,11 +105,6 @@ va_close_display_wayland(VADisplay va_dpy)
     if (!d || --d->ref_count > 0)
         return;
 
-    if (d->va_surface_wl) {
-        vaDestroySurfaceWL(va_dpy, d->va_surface_wl);
-        d->va_surface_wl = NULL;
-    }
-
     if (d->surface) {
         wl_surface_destroy(d->surface);
         d->surface = NULL;
@@ -161,11 +155,6 @@ ensure_window(VADisplay va_dpy, unsigned int width, unsigned int height)
         wl_shell_surface_set_toplevel(d->shell_surface);
     }
 
-    if (!d->va_surface_wl) {
-        va_status = vaCreateSurfaceWL(va_dpy, d->surface, &d->va_surface_wl);
-        if (va_status != VA_STATUS_SUCCESS)
-            return 0;
-    }
     return 1;
 }
 
@@ -179,19 +168,31 @@ va_put_surface_wayland(
 {
     struct display * const d = g_display;
     VAStatus va_status;
+    struct wl_buffer *buffer;
 
     if (!ensure_window(va_dpy, dst_rect->width, dst_rect->height))
         return VA_STATUS_ERROR_ALLOCATION_FAILED;
 
-    va_status = vaAttachSurfaceWL(
+    va_status = vaGetSurfaceBufferWl(
         va_dpy,
-        d->va_surface_wl,
         surface,
-        VA_FRAME_PICTURE
+        &buffer
     );
     if (va_status != VA_STATUS_SUCCESS)
         return va_status;
 
+    
+    wl_surface_attach(
+        d->surface,
+        buffer,
+        0, 0
+    );
+
+     wl_surface_damage(
+         d->surface,
+         dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height
+     );
+
     wl_display_flush(d->display);
     return VA_STATUS_SUCCESS;
 }
diff --git a/test/putsurface/putsurface_wayland.c b/test/putsurface/putsurface_wayland.c
old mode 100644
new mode 100755
index afadf8b..2386e0c
--- a/test/putsurface/putsurface_wayland.c
+++ b/test/putsurface/putsurface_wayland.c
@@ -105,7 +105,6 @@ struct display {
 struct drawable {
     struct wl_display  *display;
     struct wl_surface  *surface;
-    VASurfaceWL         va_wl_surface;
     unsigned int        redraw_pending  : 1;
 };
 
@@ -116,6 +115,7 @@ frame_redraw_callback(void *data, struct wl_callback *callback, uint32_t time)
 
     drawable->redraw_pending = 0;
     wl_callback_destroy(callback);
+    // todo, release wl_buffer and vaSurface
 }
 
 static const struct wl_callback_listener frame_callback_listener = {
@@ -137,22 +137,11 @@ va_put_surface(
     struct display *d;
     struct wl_callback *callback;
     VAStatus va_status;
+    struct wl_buffer *buffer;
 
     if (!wl_drawable)
         return VA_STATUS_ERROR_INVALID_SURFACE;
 
-    if (!wl_drawable->va_wl_surface) {
-        va_status = vaCreateSurfaceWL(
-            dpy,
-            wl_drawable->surface,
-            &wl_drawable->va_wl_surface
-        );
-        if (va_status != VA_STATUS_SUCCESS) {
-            fprintf(stderr, "error: failed to create VA/WL surface\n");
-            return va_status;
-        }
-    }
-
     d = wl_display_get_user_data(wl_drawable->display);
     if (!d)
         return VA_STATUS_ERROR_INVALID_DISPLAY;
@@ -164,14 +153,24 @@ va_put_surface(
             wl_display_iterate(wl_drawable->display, WL_DISPLAY_READABLE);
     }
 
-    va_status = vaAttachSurfaceWL(
-        dpy,
-        wl_drawable->va_wl_surface,
+    va_status = vaGetSurfaceBufferWl(
+        va_dpy,
         va_surface,
-        flags
+        &buffer
     );
     if (va_status != VA_STATUS_SUCCESS)
         return va_status;
+    
+    wl_surface_attach(
+        wl_drawable->surface,
+        buffer,
+        0, 0
+    );
+
+    wl_surface_damage(
+        wl_drawable->surface,
+        dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height
+    );
 
     wl_display_flush(d->display);
     wl_drawable->redraw_pending = 1;
@@ -252,7 +251,6 @@ create_window(void *win_display, int x, int y, int width, int height)
     drawable1 = malloc(sizeof(*drawable1));
     drawable1->display          = display;
     drawable1->surface          = surface1;
-    drawable1->va_wl_surface    = NULL;
     drawable1->redraw_pending   = 0;
 
     /* global out */
@@ -268,7 +266,6 @@ create_window(void *win_display, int x, int y, int width, int height)
     drawable2 = malloc(sizeof(*drawable2));
     drawable2->display          = display;
     drawable1->surface          = surface2;
-    drawable2->va_wl_surface    = NULL;
     drawable2->redraw_pending   = 0;
 
     /* global out */
-- 
1.7.5.4



More information about the Libva mailing list