layer: correct set_buffer_queue behavior 87/170987/1
authorBoram Park <boram1288.park@samsung.com>
Thu, 22 Feb 2018 22:51:29 +0000 (07:51 +0900)
committerBoram Park <boram1288.park@samsung.com>
Sun, 25 Feb 2018 23:00:39 +0000 (08:00 +0900)
Change-Id: I7d72456f54ed91b392799918727886d8520e6b9f

src/tdm_layer.c

index 1f757ee3d19020a9239abeb006cee9ef9400e774..79c7c2fca9e52c3764fdd09d3b4cbdb0b0344e12 100644 (file)
@@ -1131,7 +1131,7 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data)
        tdm_layer *layer = data;
        tdm_private_backend *private_backend;
        tdm_func_layer *func_layer;
-       tbm_surface_h surface = NULL;
+       tbm_surface_h buffer = NULL;
        tdm_private_layer_buffer *layer_buffer;
        LAYER_FUNC_ENTRY_VOID_RETURN();
 
@@ -1157,49 +1157,30 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data)
        }
        LIST_INITHEAD(&layer_buffer->link);
 
-       if (TBM_SURFACE_QUEUE_ERROR_NONE != tbm_surface_queue_acquire(private_layer->buffer_queue, &surface) ||
-               surface == NULL) {
+       if (TBM_SURFACE_QUEUE_ERROR_NONE != tbm_surface_queue_acquire(private_layer->buffer_queue, &buffer) ||
+               buffer == NULL) {
                /* LCOV_EXCL_START */
                TDM_ERR("layer(%p) tbm_surface_queue_acquire() failed surface:%p",
-                               private_layer, surface);
+                               private_layer, buffer);
                _pthread_mutex_unlock(&private_display->lock);
                free(layer_buffer);
                return;
                /* LCOV_EXCL_STOP */
        }
 
-       /* we don't need to handle pending data here because the changes in this function
-        * should be applied immediately. we can't expect calling tdm_layer_commit.
-        */
-       ret = func_layer->layer_set_buffer(private_layer->layer_backend, surface);
-       TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
-
-       if (ret == TDM_ERROR_NONE) {
-               if (private_layer->waiting_buffer) {
-                       TDM_DBG("layer(%p) drop waiting_buffer(%p)", private_layer, private_layer->waiting_buffer->buffer);
-                       _tdm_layer_free_buffer(private_layer, private_layer->waiting_buffer);
-               }
-
-               private_layer->waiting_buffer = layer_buffer;
-               private_layer->waiting_buffer->buffer = tdm_buffer_ref_backend(surface);
-
-               if (tdm_debug_module & TDM_DEBUG_BUFFER)
-                       TDM_INFO("layer(%p) waiting_buffer(%p)",
-                                        private_layer, private_layer->waiting_buffer->buffer);
+       ret = tdm_layer_set_buffer_internal(private_layer, buffer);
+       if (ret != TDM_ERROR_NONE) {
+               TDM_ERR("tdm_layer_set_buffer_internal failed");
+               _pthread_mutex_unlock(&private_display->lock);
+               return;
+       }
 
-               if (private_output->commit_type == TDM_COMMIT_TYPE_OUTPUT) {
-                       ret = tdm_output_commit_internal(private_layer->private_output, 0, NULL, NULL);
-                       if (ret != TDM_ERROR_NONE)
-                               TDM_ERR("tdm_output_commit_internal() is fail");
-               } else if (private_output->commit_type == TDM_COMMIT_TYPE_LAYER) {
-                       ret = _tdm_layer_commit(private_layer, NULL, NULL);
-                       if (ret != TDM_ERROR_NONE)
-                               TDM_ERR("layer(%p) _tdm_layer_commit() is fail", private_layer);
-               } else {
-                       TDM_NEVER_GET_HERE();
-               }
-       } else
-               _tdm_layer_free_buffer(private_layer, layer_buffer);
+       ret = tdm_layer_commit_internal(private_layer, NULL, NULL);
+       if (ret != TDM_ERROR_NONE) {
+               TDM_ERR("tdm_layer_commit_internal failed");
+               _pthread_mutex_unlock(&private_display->lock);
+               return;
+       }
 
        _pthread_mutex_unlock(&private_display->lock);
 }