surface: factor out release of surface buffer storage.
[platform/upstream/libva-intel-driver.git] / src / i965_output_dri.c
index 6583802..fdd69ce 100644 (file)
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
+#include "sysdeps.h"
+
 #include <va/va_dricommon.h>
+
 #include "i965_drv_video.h"
 #include "i965_output_dri.h"
 #include "dso_utils.h"
@@ -119,7 +118,6 @@ i965_put_surface_dri(
 {
     struct i965_driver_data * const i965 = i965_driver_data(ctx); 
     struct dri_vtable * const dri_vtable = &i965->dri_output->vtable;
-    struct dri_state * const dri_state = (struct dri_state *)ctx->drm_state;
     struct i965_render_state * const render_state = &i965->render_state;
     struct dri_drawable *dri_drawable;
     union dri_buffer *buffer;
@@ -129,9 +127,10 @@ i965_put_surface_dri(
     bool new_region = false;
     uint32_t name;
     int i, ret;
+    unsigned int color_flag = 0;
 
     /* Currently don't support DRI1 */
-    if (dri_state->base.auth_type != VA_DRM_AUTH_DRI2)
+    if (!VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2))
         return VA_STATUS_ERROR_UNKNOWN;
 
     /* Some broken sources such as H.264 conformance case FM2_SVA_C
@@ -181,6 +180,12 @@ i965_put_surface_dri(
         assert(ret == 0);
     }
 
+    color_flag = flags & VA_SRC_COLOR_MASK;
+    if (color_flag == 0)
+        color_flag = VA_SRC_BT601;
+
+    pp_flag = color_flag;
+
     if ((flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC)
         pp_flag |= I965_PP_FLAG_AVS;
 
@@ -189,25 +194,23 @@ i965_put_surface_dri(
     else if (flags & VA_BOTTOM_FIELD)
         pp_flag |= I965_PP_FLAG_BOTTOM_FIELD;
 
-    intel_render_put_surface(ctx, surface, src_rect, dst_rect, pp_flag);
+    intel_render_put_surface(ctx, obj_surface, src_rect, dst_rect, pp_flag);
 
-    for(i = 0; i < I965_MAX_SUBPIC_SUM; i++){
-        if(obj_surface->subpic[i] != VA_INVALID_ID) {
-           obj_surface->subpic_render_idx = i;
-           intel_render_put_subpicture(ctx, surface, src_rect, dst_rect);
+    for (i = 0; i < I965_MAX_SUBPIC_SUM; i++) {
+        if (obj_surface->obj_subpic[i] != NULL) {
+            assert(obj_surface->subpic[i] != VA_INVALID_ID);
+            obj_surface->subpic_render_idx = i;
+            intel_render_put_subpicture(ctx, obj_surface, src_rect, dst_rect);
         }
     }
 
-    dri_vtable->swap_buffer(ctx, dri_drawable);
+    if (!getenv("INTEL_DEBUG_BENCH"))
+        dri_vtable->swap_buffer(ctx, dri_drawable);
     obj_surface->flags |= SURFACE_DISPLAYED;
 
     if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
-        dri_bo_unreference(obj_surface->bo);
-        obj_surface->bo = NULL;
         obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
-
-        if (obj_surface->free_private_data)
-            obj_surface->free_private_data(&obj_surface->private_data);
+        i965_destroy_surface_storage(obj_surface);
     }
 
     _i965UnlockMutex(&i965->render_mutex);