[Libva] [PATCH v3 intel-driver 3/8] surface: factor out release of surface buffer storage.
Gwenole Beauchesne
gb.devel at gmail.com
Thu May 15 03:07:53 PDT 2014
Introduce a new i965_destroy_surface_storage() helper function to
unreference the underlying GEM buffer object, and any associated
private data, if any.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
src/i965_decoder_utils.c | 6 +-----
src/i965_drv_video.c | 14 +++++++++++---
src/i965_drv_video.h | 3 +++
src/i965_output_dri.c | 6 +-----
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/i965_decoder_utils.c b/src/i965_decoder_utils.c
index 617bc15..fac9628 100644
--- a/src/i965_decoder_utils.c
+++ b/src/i965_decoder_utils.c
@@ -387,14 +387,10 @@ intel_update_avc_frame_store_index(VADriverContextP ctx,
obj_surface->flags &= ~SURFACE_REFERENCED;
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;
+ i965_destroy_surface_storage(obj_surface);
}
- if (obj_surface->free_private_data)
- obj_surface->free_private_data(&obj_surface->private_data);
-
frame_store[i].surface_id = VA_INVALID_ID;
frame_store[i].frame_store_id = -1;
frame_store[i].obj_surface = NULL;
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 064cb26..4f473ee 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -749,10 +749,11 @@ VAStatus i965_QueryConfigAttributes(VADriverContextP ctx,
return vaStatus;
}
-static void
-i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
+void
+i965_destroy_surface_storage(struct object_surface *obj_surface)
{
- struct object_surface *obj_surface = (struct object_surface *)obj;
+ if (!obj_surface)
+ return;
dri_bo_unreference(obj_surface->bo);
obj_surface->bo = NULL;
@@ -761,7 +762,14 @@ i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
obj_surface->free_private_data(&obj_surface->private_data);
obj_surface->private_data = NULL;
}
+}
+
+static void
+i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
+{
+ struct object_surface *obj_surface = (struct object_surface *)obj;
+ i965_destroy_surface_storage(obj_surface);
object_heap_free(heap, obj);
}
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 535402f..8f2d288 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -423,4 +423,7 @@ extern VAStatus i965_DestroySurfaces(VADriverContextP ctx,
#define I965_SURFACE_MEM_GEM_FLINK 1
#define I965_SURFACE_MEM_DRM_PRIME 2
+void
+i965_destroy_surface_storage(struct object_surface *obj_surface);
+
#endif /* _I965_DRV_VIDEO_H_ */
diff --git a/src/i965_output_dri.c b/src/i965_output_dri.c
index 717ee9a..fdd69ce 100644
--- a/src/i965_output_dri.c
+++ b/src/i965_output_dri.c
@@ -209,12 +209,8 @@ i965_put_surface_dri(
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);
--
1.9.1
More information about the Libva
mailing list