From: SooChan Lim Date: Mon, 12 Feb 2018 02:04:06 +0000 (+0900) Subject: hwc: add tdm_hwc_window_commit X-Git-Tag: accepted/tizen/unified/20180213.055931~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F169894%2F3;p=platform%2Fcore%2Fuifw%2Flibtdm.git hwc: add tdm_hwc_window_commit Change-Id: Ic6282508e8ce1a075c340b167ae821512de7bf90 --- diff --git a/include/tdm.h b/include/tdm.h index e317832..7437d86 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1083,6 +1083,18 @@ tdm_error tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); /** + * @brief Commit changes for a window object + * @details After all change of a window object are applied, a user commit handler + * will be called. + * @param[in] hwc_window A window object + * @param[in] func A user commit handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_hwc_window_commit(tdm_hwc_window *hwc_window, tdm_hwc_window_commit_handler func, void *user_data); + +/** * @brief Get the available property array of a video hwc window object. * @param[in] hwc window A video hwc window object * @param[out] props The available property array diff --git a/include/tdm_types.h b/include/tdm_types.h index a20049f..f08d347 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -267,6 +267,13 @@ typedef void (*tdm_layer_commit_handler)(tdm_layer *layer, unsigned int sequence void *user_data); /** + * @brief The hwc_window commit handler + */ +typedef void (*tdm_hwc_window_commit_handler)(tdm_hwc_window *hwc_window, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** * @brief The done handler of a pp object */ typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 96d2698..08fc80c 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -409,6 +409,123 @@ tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags return ret; } +static void +_tdm_hwc_window_layer_commit_handler(tdm_layer *layer, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data) +{ + tdm_private_hwc_window_commit_handler *hwc_window_commit_handler = (tdm_private_hwc_window_commit_handler *)user_data; + tdm_hwc_window_commit_handler func = hwc_window_commit_handler->func; + tdm_hwc_window *hwc_window = (tdm_hwc_window *)hwc_window_commit_handler->private_hwc_window; + void *data = hwc_window_commit_handler->user_data; + + func(hwc_window, sequence, tv_sec, tv_usec, data); + + free(hwc_window_commit_handler); +} + +tdm_error +tdm_hwc_window_commit(tdm_hwc_window *hwc_window, tdm_hwc_window_commit_handler func, void *user_data) +{ + tdm_func_hwc_window *func_hwc_window = NULL; + tdm_private_hwc_window_commit_handler *hwc_window_commit_handler; + tdm_layer *layer = NULL; + tdm_private_layer *private_layer; + tdm_info_layer *info_layer; + tdm_hwc_window_info window_info; + tbm_surface_h buffer; + + HWC_WINDOW_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + func_hwc_window = &private_display->func_hwc_window; + + if (!func_hwc_window->hwc_window_get_layer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + /* LCOV_EXCL_STOP */ + } + + layer = func_hwc_window->hwc_window_get_layer(private_hwc_window->hwc_window_backend, + &ret); + if (!layer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("no assigned layer!!"); + return TDM_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + private_layer = (tdm_private_layer*)layer; + + buffer = func_hwc_window->hwc_window_get_buffer(private_hwc_window->hwc_window_backend, + &ret); + if (!buffer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("no assigned buffer!!"); + return TDM_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (buffer) + ret = tdm_layer_set_buffer_internal(private_layer, buffer); + else + ret = tdm_layer_unset_buffer_internal(private_layer); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set buffer(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + ret = func_hwc_window->hwc_window_get_info(private_hwc_window->hwc_window_backend, + &window_info); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: commit layer(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + info_layer = (tdm_info_layer *)&window_info; + ret = tdm_layer_set_info_internal(private_layer, info_layer); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set info(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + hwc_window_commit_handler = calloc(1, sizeof(tdm_private_hwc_window_commit_handler)); + if (!hwc_window_commit_handler) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: alloc memory"); + return TDM_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } + + hwc_window_commit_handler->private_hwc_window = private_hwc_window; + hwc_window_commit_handler->func = func; + hwc_window_commit_handler->user_data = user_data; + + ret = tdm_layer_commit_internal(private_layer, _tdm_hwc_window_layer_commit_handler, user_data); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: commit layer(window)"); + free(hwc_window_commit_handler); + /* LCOV_EXCL_STOP */ + return ret; + } + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + EXTERN tdm_error tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window, tdm_hwc_window_video_capability *video_capability) diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h index 8f7fb7d..642e962 100644 --- a/src/tdm_private_types.h +++ b/src/tdm_private_types.h @@ -107,6 +107,7 @@ typedef struct _tdm_private_thread tdm_private_thread; typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler; typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler; typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler; +typedef struct _tdm_private_hwc_window_commit_handler tdm_private_hwc_window_commit_handler; typedef struct _tdm_private_change_handler tdm_private_change_handler; typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer; @@ -368,6 +369,12 @@ struct _tdm_private_layer_commit_handler { tdm_private_layer_buffer *committed_buffer; /* for layer_commit */ }; +struct _tdm_private_hwc_window_commit_handler { + tdm_private_hwc_window *private_hwc_window; + tdm_hwc_window_commit_handler func; + void *user_data; +}; + struct _tdm_private_change_handler { struct list_head link;