OSDN Git Service

Use ASSERT_RET() instead of assert() for some assertions
[android-x86/hardware-intel-common-vaapi.git] / src / i965_output_dri.c
index ae3bcf6..94d6312 100644 (file)
@@ -8,11 +8,11 @@
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 
 #define LIBVA_X11_NAME "libva-x11.so.1"
 
-typedef struct dri_drawable *(*dri_get_drawable_func)(
-    VADriverContextP ctx, XID drawable);
-typedef union dri_buffer *(*dri_get_rendering_buffer_func)(
-    VADriverContextP ctx, struct dri_drawable *d);
-typedef void (*dri_swap_buffer_func)(
-    VADriverContextP ctx, struct dri_drawable *d);
+typedef struct dri_drawable *(*dri_get_drawable_func)(VADriverContextP ctx, XID drawable);
+typedef union dri_buffer *(*dri_get_rendering_buffer_func)(VADriverContextP ctx, struct dri_drawable *d);
+typedef void (*dri_swap_buffer_func)(VADriverContextP ctx, struct dri_drawable *d);
 
 struct dri_vtable {
     dri_get_drawable_func               get_drawable;
@@ -53,17 +50,23 @@ struct va_dri_output {
 bool
 i965_output_dri_init(VADriverContextP ctx)
 {
-    struct i965_driver_data * const i965 = i965_driver_data(ctx); 
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
     struct dso_handle *dso_handle;
     struct dri_vtable *dri_vtable;
 
     static const struct dso_symbol symbols[] = {
-        { "dri_get_drawable",
-          offsetof(struct dri_vtable, get_drawable) },
-        { "dri_get_rendering_buffer",
-          offsetof(struct dri_vtable, get_rendering_buffer) },
-        { "dri_swap_buffer",
-          offsetof(struct dri_vtable, swap_buffer) },
+        {
+            "dri_get_drawable",
+            offsetof(struct dri_vtable, get_drawable)
+        },
+        {
+            "dri_get_rendering_buffer",
+            offsetof(struct dri_vtable, get_rendering_buffer)
+        },
+        {
+            "dri_swap_buffer",
+            offsetof(struct dri_vtable, swap_buffer)
+        },
         { NULL, }
     };
 
@@ -89,7 +92,7 @@ error:
 void
 i965_output_dri_terminate(VADriverContextP ctx)
 {
-    struct i965_driver_data * const i965 = i965_driver_data(ctx); 
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
     struct va_dri_output * const dri_output = i965->dri_output;
 
     if (!dri_output)
@@ -116,13 +119,13 @@ i965_put_surface_dri(
     unsigned int        flags
 )
 {
-    struct i965_driver_data * const i965 = i965_driver_data(ctx); 
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
     struct dri_vtable * const dri_vtable = &i965->dri_output->vtable;
     struct i965_render_state * const render_state = &i965->render_state;
     struct dri_drawable *dri_drawable;
     union dri_buffer *buffer;
     struct intel_region *dest_region;
-    struct object_surface *obj_surface; 
+    struct object_surface *obj_surface;
     uint32_t name;
     int i, ret;
 
@@ -136,21 +139,23 @@ i965_put_surface_dri(
     obj_surface = SURFACE(surface);
     ASSERT_RET(obj_surface && obj_surface->bo, VA_STATUS_SUCCESS);
     ASSERT_RET(obj_surface->fourcc != VA_FOURCC_YUY2 &&
-               obj_surface->fourcc != VA_FOURCC_UYVY,
+               obj_surface->fourcc != VA_FOURCC_UYVY &&
+               obj_surface->fourcc != VA_FOURCC_RGBX &&
+               obj_surface->fourcc != VA_FOURCC_BGRX,
                VA_STATUS_ERROR_UNIMPLEMENTED);
 
     _i965LockMutex(&i965->render_mutex);
 
     dri_drawable = dri_vtable->get_drawable(ctx, (Drawable)draw);
-    assert(dri_drawable);
+    ASSERT_RET(dri_drawable, VA_STATUS_ERROR_ALLOCATION_FAILED);
 
     buffer = dri_vtable->get_rendering_buffer(ctx, dri_drawable);
-    assert(buffer);
-    
+    ASSERT_RET(buffer, VA_STATUS_ERROR_ALLOCATION_FAILED);
+
     dest_region = render_state->draw_region;
     if (dest_region == NULL) {
         dest_region = (struct intel_region *)calloc(1, sizeof(*dest_region));
-        assert(dest_region);
+        ASSERT_RET(dest_region, VA_STATUS_ERROR_ALLOCATION_FAILED);
         render_state->draw_region = dest_region;
     }
 
@@ -158,8 +163,8 @@ i965_put_surface_dri(
         dri_bo_flink(dest_region->bo, &name);
         if (buffer->dri2.name != name) {
             dri_bo_unreference(dest_region->bo);
-           dest_region->bo = NULL;
-       }
+            dest_region->bo = NULL;
+        }
     }
 
     if (dest_region->bo == NULL) {
@@ -167,10 +172,10 @@ i965_put_surface_dri(
         dest_region->pitch = buffer->dri2.pitch;
 
         dest_region->bo = intel_bo_gem_create_from_name(i965->intel.bufmgr, "rendering buffer", buffer->dri2.name);
-        assert(dest_region->bo);
+        ASSERT_RET(dest_region->bo, VA_STATUS_ERROR_UNKNOWN);
 
         ret = dri_bo_get_tiling(dest_region->bo, &(dest_region->tiling), &(dest_region->swizzle));
-        assert(ret == 0);
+        ASSERT_RET((ret == 0), VA_STATUS_ERROR_UNKNOWN);
     }
 
     dest_region->x = dri_drawable->x;