From bd22218b99baabc11f4c688993bf7d879aa17f8f Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Thu, 11 Jul 2019 20:08:08 +0900 Subject: [PATCH] fota_gui : apply HWC(HardWare Composer) - Wearable targets use HWC windows since Tizen 5.5 - Commit via HWC if backend has HWC capability Change-Id: I444050c369d58d2b7ddc4c96df693803720095fb Signed-off-by: Kichan Kwon --- fota_gui/fota_gui_main.c | 16 ++++---- fota_gui/tdm-if.c | 102 +++++++++++++++++++++++++++++++---------------- fota_gui/tdm-if.h | 3 ++ 3 files changed, 78 insertions(+), 43 deletions(-) diff --git a/fota_gui/fota_gui_main.c b/fota_gui/fota_gui_main.c index 45cfce4..a98ea15 100755 --- a/fota_gui/fota_gui_main.c +++ b/fota_gui/fota_gui_main.c @@ -138,11 +138,19 @@ static void *__thread_draw_progress_img(void *arg) if (setpriority(PRIO_PROCESS, getpid(), -11) < 0) LOG("failed to setpriority\n"); + if (fota_gr_init() < 0) { + LOG("fota_gr_init() failed.\n"); + _exit_stdio(); + return -1; + } + while (do_exit != 1) { usleep(delay); fota_gr_direct_circular_progress(); } + fota_gr_deinit(); + return NULL; } @@ -157,12 +165,6 @@ int main(int argc, char **argv) // _init_stdio(); - if (fota_gr_init() < 0) { - LOG("fota_gr_init() failed.\n"); - _exit_stdio(); - return -1; - } - fota_gr_update_progress(s_prog_percent); s_last_prog_percent = s_prog_percent; int error = 0; @@ -265,8 +267,6 @@ int main(int argc, char **argv) return -1; } - fota_gr_deinit(); - _exit_stdio(); return 0; diff --git a/fota_gui/tdm-if.c b/fota_gui/tdm-if.c index 1333de5..7567476 100755 --- a/fota_gui/tdm-if.c +++ b/fota_gui/tdm-if.c @@ -32,7 +32,6 @@ #include #include #include -#include #include "fota_gui_common.h" #include "tdm-if.h" @@ -118,6 +117,12 @@ int tdm_if_display_init(tdm_if_disp *st_disp) goto exit; } + err = tdm_output_set_mode(output, &output_mode[0]); + if (err != TDM_ERROR_NONE) { + LOGE("failed to set mode. error num = %d\n", err); + goto exit; + } + /* GET MODE INFO */ st_disp->output = output; st_disp->width = output_mode->hdisplay; @@ -175,40 +180,56 @@ int tdm_if_display_init(tdm_if_disp *st_disp) } } + /* CHECK HWC USAGE */ + tdm_output_capability output_caps; + tdm_output_get_capabilities(st_disp->output, &output_caps); + if (output_caps & TDM_OUTPUT_CAPABILITY_HWC) + st_disp->use_tdm_hwc = true; + else + st_disp->use_tdm_hwc = false; + /* SET LAYER */ - tdm_layer_capability layer_caps; - tdm_layer *tmp_layer = NULL; - for (i = 0; i < output_count; i++) { - tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err); - tdm_layer_get_capabilities(tmp_layer, &layer_caps); - if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY) - break; - } + if (st_disp->use_tdm_hwc) { + st_disp->hwc = tdm_output_get_hwc(st_disp->output, &err); + if (!st_disp->hwc) { + LOGE("failed to get hwc. error num = %d\n", err); + goto exit; + } + } else { + tdm_layer_capability layer_caps; + tdm_layer *tmp_layer = NULL; + for (i = 0; i < output_count; i++) { + tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err); + tdm_layer_get_capabilities(tmp_layer, &layer_caps); + if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY) + break; + } - if (!tmp_layer) { - LOGE("failed to get output layer. error num = %d\n", err); - goto exit; - } + if (!tmp_layer) { + LOGE("failed to get output layer. error num = %d\n", err); + goto exit; + } - st_disp->layer = tmp_layer; - - layer_info.src_config.size.h = st_disp->width; - layer_info.src_config.size.v = st_disp->height; - layer_info.src_config.pos.x = 0; - layer_info.src_config.pos.y = 0; - layer_info.src_config.pos.w = st_disp->width; - layer_info.src_config.pos.h = st_disp->height; - layer_info.src_config.format = TBM_FORMAT_ARGB8888; - layer_info.dst_pos.x = 0; - layer_info.dst_pos.y = 0; - layer_info.dst_pos.w = st_disp->width; - layer_info.dst_pos.h = st_disp->height; - layer_info.transform = TDM_TRANSFORM_NORMAL; - - err = tdm_layer_set_info(st_disp->layer, &layer_info); - if (err != TDM_ERROR_NONE) { - LOGE("failed to get output layer. error num = %d\n", err); - goto exit; + st_disp->layer = tmp_layer; + + layer_info.src_config.size.h = st_disp->width; + layer_info.src_config.size.v = st_disp->height; + layer_info.src_config.pos.x = 0; + layer_info.src_config.pos.y = 0; + layer_info.src_config.pos.w = st_disp->width; + layer_info.src_config.pos.h = st_disp->height; + layer_info.src_config.format = TBM_FORMAT_ARGB8888; + layer_info.dst_pos.x = 0; + layer_info.dst_pos.y = 0; + layer_info.dst_pos.w = st_disp->width; + layer_info.dst_pos.h = st_disp->height; + layer_info.transform = TDM_TRANSFORM_NORMAL; + + err = tdm_layer_set_info(st_disp->layer, &layer_info); + if (err != TDM_ERROR_NONE) { + LOGE("failed to get output layer. error num = %d\n", err); + goto exit; + } } st_disp->current_buf_id = 0; @@ -250,10 +271,21 @@ void tdm_if_display_update(tdm_if_disp *st_disp) buf_cnt = st_disp->current_buf_id; //st_disp->current_buf_id = (++st_disp->current_buf_id)%MAX_BUF; - tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]); + if (st_disp->use_tdm_hwc) { + uint32_t num_types; + tdm_region damage; + memset(&damage, 0, sizeof(damage)); - // TODO: sync or async?? - tdm_output_commit(st_disp->output, 1, tdm_if_display_commit_handler_cb, st_disp); + tdm_hwc_set_client_target_buffer(st_disp->hwc, st_disp->surf[buf_cnt], damage); + tdm_hwc_validate(st_disp->hwc, NULL, 0, &num_types); + tdm_hwc_accept_validation(st_disp->hwc); + tdm_hwc_commit(st_disp->hwc, 1, tdm_if_display_commit_handler_cb, st_disp); + } else { + tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]); + + // TODO: sync or async?? + tdm_output_commit(st_disp->output, 1, tdm_if_display_commit_handler_cb, st_disp); + } return ; } diff --git a/fota_gui/tdm-if.h b/fota_gui/tdm-if.h index fdc5dc6..9bd8d3b 100755 --- a/fota_gui/tdm-if.h +++ b/fota_gui/tdm-if.h @@ -53,6 +53,9 @@ typedef struct _tdm_if_disp { int height; int stride; int current_buf_id; + + bool use_tdm_hwc; + tdm_hwc *hwc; } tdm_if_disp; typedef enum { -- 2.7.4