hwc: refectoring hwc_apply_policy for supporting video 49/204549/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 22 Apr 2019 09:19:31 +0000 (18:19 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 24 Apr 2019 09:53:42 +0000 (18:53 +0900)
1. not support hw cursor
2. if video client is shown, ui_lzpos_bottom move to ZPOS_1

Change-Id: I9b94f7cb9d1bf5c77cafc4fc84d4f0b4eb10514b

src/tdm_exynos_hwc.c

index 778deba8af82ff0f5ea09e1d960eabf3d2ed8de6..c039780fa635be824d0b2e01101610d878205056 100644 (file)
@@ -14,7 +14,7 @@
 #define ZPOS_2    2
 #define ZPOS_1    1
 #define ZPOS_0    0
-#define ZPOS_VIDEO1  -1 //TODO:
+#define ZPOS_VIDEO1  0
 #define ZPOS_NONE    -999
 
 tbm_format hwc_window_video_formats[] = {
@@ -212,11 +212,10 @@ _exynos_hwc_apply_policy(tdm_exynos_hwc_data *hwc_data , tdm_hwc_window **compos
        int client_count = 0;
        int device_count = 0;
        int video_count = 0;
-       int cursor_count = 0;
-       int next_idx = 0;
        int ui_lzpos_top = ZPOS_2;
        int ui_lzpos_bottom = ZPOS_0;
        int num_ui_layers = NUM_LAYERS;
+       int set_clients_below = 0;
        int i = 0;
 
        composited_list = (tdm_exynos_hwc_window_data **)composited_wnds;
@@ -233,80 +232,72 @@ _exynos_hwc_apply_policy(tdm_exynos_hwc_data *hwc_data , tdm_hwc_window **compos
        /* use the target_window to commit when there is no window. */
        if (num_wnds == 0) {
                hwc_data->need_target_window = 1;
+               hwc_data->target_hwc_window->lzpos = ui_lzpos_bottom;
                return;
        }
 
-       /* count the composited(visible) windows */
+       /* 1. first check validate_type without target_window */
        for (i = 0; i < num_wnds; i++) {
-               if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_CURSOR)
-                       cursor_count++;
-               if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_CLIENT)
-                       client_count++;
-               if (client_count == 0 && composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_DEVICE)
-                       device_count++;
-               if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO)
-                       video_count++;
+               switch (composited_list[i]->client_type) {
+                       case TDM_HWC_WIN_COMPOSITION_VIDEO:
+                               composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
+                               video_count++;
+                               continue;
+                       case TDM_HWC_WIN_COMPOSITION_DEVICE:
+                               if (set_clients_below) break;
+                               if (num_ui_layers <= 0) break;
+                               if (!_exynos_hwc_window_can_set_on_hw_layer(composited_list[i])) break;
+
+                               composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_DEVICE;
+                               device_count++;
+                               num_ui_layers--;
+                               continue;
+                       default:
+                               break;
+               }
+
+               composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
+               client_count++;
+               set_clients_below = 1;
        }
 
-       /* TODO: not support the cursor layer yet */
-       if (cursor_count > 0)
-               goto set_clients_below;
+       /* 2. check need target window and set ui_lzpos top and bottom */
+       num_ui_layers = NUM_LAYERS;
 
-       /* reset the lzpos_bottom when it needs target_window */
-       if ((client_count > 0) || (client_count + device_count > 2)) {
-               hwc_data->need_target_window = 1;
-               ui_lzpos_bottom = ZPOS_1;
+       if (video_count > 0) {
+               ui_lzpos_bottom++;
                num_ui_layers--;
        }
 
-       /* apply the device layers from the top to the bottom */
-       if ((num_ui_layers - device_count) > 0)
-               ui_lzpos_top = ui_lzpos_bottom + device_count - 1;
-
-       while (device_count > 0) {
-               /* apply the video layer */
-               if (composited_list[next_idx]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
-                       composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
-                       composited_list[next_idx]->lzpos = ZPOS_VIDEO1;
-                       next_idx++;
-                       continue;
-               }
-
-               /* set clients below when exynos can not set the window to the hw layer */
-               if (!_exynos_hwc_window_can_set_on_hw_layer(composited_list[next_idx]))
-                       break;
-
-               /* set device comopsition and layer zpos */
-               composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_DEVICE;
-               composited_list[next_idx]->lzpos = ui_lzpos_top;
-               ui_lzpos_top--;
-               next_idx++;
-
-               if (ui_lzpos_top < ui_lzpos_bottom)
-                       break;
-
-               device_count--;
+       if (client_count > 0) {
+               ui_lzpos_bottom++;
+               num_ui_layers--;
+               hwc_data->need_target_window = 1;
+               hwc_data->target_hwc_window->lzpos = ui_lzpos_bottom - 1;
        }
 
-set_clients_below:
-       /* apply the client layers */
-       while (next_idx < num_wnds) {
-               hwc_data->need_target_window = 1;
-               if (composited_list[next_idx]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
-                       composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
-                       composited_list[next_idx]->lzpos = ZPOS_VIDEO1;
-                       next_idx++;
-                       continue;
+       if (num_ui_layers > device_count)
+               ui_lzpos_top = ui_lzpos_bottom + device_count - 1;
+
+       /* 3. set lzpos and modify validate_type with target_window */
+       for (i = 0; i < num_wnds; i++) {
+               switch (composited_list[i]->validated_type) {
+                       case TDM_HWC_WIN_COMPOSITION_VIDEO:
+                               composited_list[i]->lzpos = ZPOS_VIDEO1;
+                               continue;
+                       case TDM_HWC_WIN_COMPOSITION_DEVICE:
+                               if (num_ui_layers <= 0) break;
+                               composited_list[i]->lzpos = ui_lzpos_top;
+                               ui_lzpos_top--;
+                               num_ui_layers--;
+                               continue;
+                       default:
+                               break;
                }
 
-               /* set client composition */
-               composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
-               composited_list[next_idx]->lzpos = ZPOS_NONE;
-               next_idx++;
+               composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
+               composited_list[i]->lzpos = ZPOS_NONE;
        }
-
-       if (hwc_data->need_target_window)
-               hwc_data->target_hwc_window->lzpos = ZPOS_0;
 }
 
 static int