return tbm_surface;
}
+static int
+_wayland_tbm_client_is_valid_attach_bufs(struct wayland_tbm_surface_queue *queue_info,
+ struct wayland_tbm_buffer *buffer)
+{
+ int width, height, format;
+
+ width = tbm_surface_get_width(buffer->tbm_surface);
+ height = tbm_surface_get_height(buffer->tbm_surface);
+ format = tbm_surface_get_format(buffer->tbm_surface);
+
+ if (queue_info->width != width ||
+ queue_info->height != height ||
+ queue_info->format != format)
+ return 0;
+
+ return 1;
+}
+
static tbm_surface_h
__wayland_tbm_client_surface_alloc_cb(tbm_surface_queue_h surface_queue, void *data)
{
if (queue_info->is_active && queue_info->active_flush) {
wl_list_for_each_reverse(buffer, &queue_info->attach_bufs, link) {
if (!buffer->allocated) {
- surface = buffer->tbm_surface;
- /* ref.. pair of __wayland_tbm_client_surface_free_cb */
- tbm_surface_internal_ref(surface);
- buffer->allocated = 1;
-
+ if (_wayland_tbm_client_is_valid_attach_bufs(queue_info, buffer)) {
+ surface = buffer->tbm_surface;
+ /* ref.. pair of __wayland_tbm_client_surface_free_cb */
+ tbm_surface_internal_ref(surface);
+ buffer->allocated = 1;
#ifdef DEBUG_TRACE
- WL_TBM_TRACE(" pid:%d wl_buffer:%p tbm_surface:%p ACTIVE", getpid(), buffer->wl_buffer, buffer->tbm_surface);
+ WL_TBM_TRACE(" pid:%d wl_buffer:%p tbm_surface:%p ACTIVE", getpid(), buffer->wl_buffer, buffer->tbm_surface);
#endif
+ } else {
+ surface = tbm_surface_internal_create_with_flags(queue_info->width,
+ queue_info->height,
+ queue_info->format,
+ queue_info->flag);
+#ifdef DEBUG_TRACE
+ WL_TBM_TRACE(" pid:%d tbm_surface:%p invalid attach_bufs fallback", getpid(), surface);
+#endif
+ }
+
break;
}
}
-
} else {
- int width = tbm_surface_queue_get_width(queue_info->tbm_queue);
- int height = tbm_surface_queue_get_height(queue_info->tbm_queue);
- int format = tbm_surface_queue_get_format(queue_info->tbm_queue);
-
/* ref.. pair of __wayland_tbm_client_surface_free_cb */
- surface = tbm_surface_internal_create_with_flags(width,
- height,
- format,
+ surface = tbm_surface_internal_create_with_flags(queue_info->width,
+ queue_info->height,
+ queue_info->format,
queue_info->flag);
#ifdef DEBUG_TRACE
struct wayland_tbm_surface_queue *queue_info =
(struct wayland_tbm_surface_queue *)data;
struct wayland_tbm_buffer *buffer;
- int width, height;
WL_TBM_RETURN_IF_FAIL(wl_buffer != NULL);
wl_list_insert(&queue_info->attach_bufs, &buffer->link);
- width = tbm_surface_get_width(buffer->tbm_surface);
- height = tbm_surface_get_height(buffer->tbm_surface);
-
- if (queue_info->width != width || queue_info->height != height) {
- if (queue_info->is_active && queue_info->active_flush) {
- queue_info->is_active = 0;
- queue_info->active_flush = 0;
-
- _wayland_tbm_client_surface_queue_flush(queue_info);
- }
- }
-
#ifdef DEBUG_TRACE
WL_TBM_TRACE("pid:%d wl_buffer:%p tbm_surface:%p",
getpid(), buffer->wl_buffer, buffer->tbm_surface);
height = tbm_surface_queue_get_height(surface_queue);
format = tbm_surface_queue_get_format(surface_queue);
- if (queue_info->width != width || queue_info->height != height ||
- queue_info->format != format) {
- /* remove the attach_bufs int the queue_info */
- if (queue_info->is_active && queue_info->active_flush) {
- queue_info->is_active = 0;
- queue_info->active_flush = 0;
- _wayland_tbm_client_queue_destroy_attach_bufs(queue_info);
- }
- }
-
queue_info->width = width;
queue_info->height = height;
queue_info->format = format;