correct the wrong condition
[platform/core/uifw/libtdm.git] / src / tdm_layer.c
index 9897c5c..e751f54 100644 (file)
@@ -700,25 +700,39 @@ _tdm_lauer_get_output_used_layer_count(tdm_private_output *private_output)
        return count;
 }
 
+/* commit_per_vblank == 1: we can commit if
+ *                           - there is no previous commit request
+ *                           - only 1 layer is used
+ * commit_per_vblank == 2: we can commit if
+ *                           - there is no previous commit request
+ */
 static int
 _tdm_layer_commit_possible(tdm_private_layer *private_layer)
 {
        tdm_private_output *private_output = private_layer->private_output;
        tdm_private_display *private_display = private_output->private_display;
 
-       if (private_display->commit_per_vblank == 1 && _tdm_lauer_get_output_used_layer_count(private_output) == 1) {
+       TDM_RETURN_VAL_IF_FAIL(private_display->commit_per_vblank > 0, 1);
+
+       /* There is a previous commit request which is not done and displayed on screen yet.
+        * We can't commit at this time.
+        */
+       if (!LIST_IS_EMPTY(&private_output->layer_commit_handler_list)) {
                if (tdm_debug_module & TDM_DEBUG_COMMIT)
-                       TDM_INFO("layer(%p) commit: 1 layer", private_layer);
-               return 1;
+                       TDM_INFO("layer(%p) commit: not possible(previous commit)", private_layer);
+               return 0;
        }
 
-       if (private_display->commit_per_vblank == 2 && LIST_IS_EMPTY(&private_output->layer_commit_handler_list)) {
+       if (private_display->commit_per_vblank == 1 && _tdm_lauer_get_output_used_layer_count(private_output) > 1) {
                if (tdm_debug_module & TDM_DEBUG_COMMIT)
-                       TDM_INFO("layer(%p) commit: non previous commit", private_layer);
-               return 1;
+                       TDM_INFO("layer(%p) commit: not possible(more than 2 layers)", private_layer);
+               return 0;
        }
 
-       return 0;
+       if (tdm_debug_module & TDM_DEBUG_COMMIT)
+               TDM_INFO("layer(%p) commit: possible", private_layer);
+
+       return 1;
 }
 
 /* CAUTION: Once _tdm_layer_commit returns success, the layer commit handler MUST be called always.
@@ -870,6 +884,7 @@ tdm_layer_remove_commit_handler_internal(tdm_layer *layer, tdm_layer_commit_hand
        tdm_private_layer_commit_handler *lm = NULL, *lmm = NULL;
 
        TDM_RETURN_IF_FAIL(private_layer != NULL);
+       TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
 
        LIST_FOR_EACH_ENTRY_SAFE(lm, lmm, &private_output->layer_commit_handler_list, link) {
                if (lm->func == func && lm->user_data == user_data) {