void *alloc_cb_data;
struct list_head item_link; /* link of surface queue */
+
+ int modes;
};
/* LCOV_EXCL_START */
surface_queue->format = format;
surface_queue->impl = impl;
surface_queue->impl_data = data;
+ surface_queue->modes = TBM_SURFACE_QUEUE_MODE_NONE;
_queue_init(&surface_queue->free_queue);
_queue_init(&surface_queue->dirty_queue);
surface_queue->height = height;
surface_queue->format = format;
- /* Destory surface and Push to free_queue */
- LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head, link)
- _queue_delete_node(surface_queue, node);
+ if (surface_queue->modes & TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE) {
+ /* Destory surface and Push to free_queue */
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head, link)
+ _queue_delete_node(surface_queue, node);
- LIST_FOR_EACH_ENTRY(node, &surface_queue->list, link)
- node->delete_pending = 1;
+ LIST_FOR_EACH_ENTRY(node, &surface_queue->list, link)
+ node->delete_pending = 1;
+ } else {
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->list, link)
+ _queue_delete_node(surface_queue, node);
+
+ _queue_init(&surface_queue->dirty_queue);
+ LIST_INITHEAD(&surface_queue->list);
+ }
/* Reset queue */
_queue_init(&surface_queue->free_queue);
pthread_mutex_lock(&surface_queue->lock);
if (flush) {
- /* Destory surface and Push to free_queue */
- LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head, item_link)
- _queue_delete_node(surface_queue, node);
-
- LIST_FOR_EACH_ENTRY(node, &surface_queue->list, link)
- node->delete_pending = 1;
+ if (surface_queue->modes & TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE) {
+ /* Destory surface and Push to free_queue */
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head, link)
+ _queue_delete_node(surface_queue, node);
+
+ LIST_FOR_EACH_ENTRY(node, &surface_queue->list, link)
+ node->delete_pending = 1;
+ } else {
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->list, link)
+ _queue_delete_node(surface_queue, node);
+
+ _queue_init(&surface_queue->dirty_queue);
+ LIST_INITHEAD(&surface_queue->list);
+ }
/* Reset queue */
_queue_init(&surface_queue->free_queue);
_queue_init(&data->dequeue_list);
}
+static void
+__tbm_queue_sequence_reset(tbm_surface_queue_h surface_queue)
+{
+ tbm_queue_sequence *data = (tbm_queue_sequence *)surface_queue->impl_data;
+
+ if (surface_queue->modes & TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE)
+ _queue_init(&data->dequeue_list);
+}
+
static void
__tbm_queue_sequence_destroy(tbm_surface_queue_h surface_queue)
{
static const tbm_surface_queue_interface tbm_queue_sequence_impl = {
__tbm_queue_sequence_init,
- NULL,
+ __tbm_queue_sequence_reset,
__tbm_queue_sequence_destroy,
__tbm_queue_sequence_need_attach,
__tbm_queue_sequence_enqueue,
return surface_queue;
}
+
+tbm_surface_queue_error_e
+tbm_surface_queue_set_modes(tbm_surface_queue_h surface_queue,
+ int modes)
+{
+ _tbm_surf_queue_mutex_lock();
+
+ TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue),
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+
+ pthread_mutex_lock(&surface_queue->lock);
+
+ if (modes == TBM_SURFACE_QUEUE_MODE_NONE)
+ modes = TBM_SURFACE_QUEUE_MODE_NONE;
+ else
+ surface_queue->modes |= modes;
+
+ pthread_mutex_unlock(&surface_queue->lock);
+
+ _tbm_surf_queue_mutex_unlock();
+
+ return TBM_SURFACE_QUEUE_ERROR_NONE;
+}
/* LCOV_EXCL_STOP */
TBM_SURFACE_QUEUE_TRACE_CANCEL_ACQUIRE = 6,
} tbm_surface_queue_trace;
+typedef enum {
+ TBM_SURFACE_QUEUE_MODE_NONE = 0,
+ /**
+ * GUARANTEE_CYCLE mode must do enqueue/aquire/release or cancel_dequeue
+ * for the tbm_surface which is dequeued before tbm_surface_queue is reset.
+ */
+ TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE = (1 << 0),
+} tbm_surface_queue_mode;
+
typedef struct _tbm_surface_queue *tbm_surface_queue_h;
typedef void (*tbm_surface_queue_notify_cb)(tbm_surface_queue_h surface_queue,
tbm_surface_queue_error_e tbm_surface_queue_get_trace_surface_num(
tbm_surface_queue_h surface_queue, tbm_surface_queue_trace trace, int *num);
+tbm_surface_queue_error_e tbm_surface_queue_set_modes(
+ tbm_surface_queue_h surface_queue, int modes);
+
/*The functions of queue factory*/
tbm_surface_queue_h tbm_surface_queue_create(int queue_size, int width,
int height, int format, int flags);