X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Ftdm_helper.h;h=8bae8fa819d313fee19ac52dcf9ce2b1ef27b703;hb=dc1e81c0f4f0c6e6c4c0d4d553cf8ba730dfb4f5;hp=245b7b0d8c8f8fa7800708cbf143ea5cc894ffe9;hpb=de8a46fd6d5ee74507a92a4a6a95e2316e877707;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 245b7b0..8bae8fa 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -1,42 +1,43 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + * + * libtdm + * + * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Eunchul Kim , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * **************************************************************************/ #ifndef _TDM_HELPER_H_ #define _TDM_HELPER_H_ #include "tdm_types.h" +#include #ifdef __cplusplus extern "C" { @@ -44,61 +45,195 @@ extern "C" { /** * @file tdm_helper.h - * @brief The header file to help a vendor to implement a backend module - * @remark - * tdm_helper_drm_fd is external drm_fd which is opened by ecore_drm. - * This is very @b TRICKY!! But we have no choice at this time because ecore_drm - * doesn't use tdm yet. When we make ecore_drm use tdm, tdm_helper_drm_fd will - * be removed. - * @warning - * If tdm_helper_drm_fd is more than -1, a tdm backend module @b SHOULDN't call - * drmWaitVBlank by itself because a DRM vblank event will be handled in ecore_drm - * internally. In this case, a tdm backend module NEVER get a DRM vblank event. - * If a tdm backend module need to handle a vendor specific DRM event, - * drmAddUserHandler() of libdrm makes possible that a tdm backend module handle - * it. - * @par Example - * @code - static int - _tdm_drm_user_handler(struct drm_event *event) - { - if (event->type != DRM_VENDOR_XXX_EVENT) - return -1; - - //handling a vendor event - - return 0; - } - - ... - - drm_data->drm_fd = -1; - if (tdm_helper_drm_fd >= 0) - { - drm_data->drm_fd = tdm_helper_drm_fd; - drmAddUserHandler(tdm_helper_drm_fd, _tdm_drm_user_handler); - } - - if (drm_data->drm_fd < 0) - drm_data->drm_fd = _tdm_drm_open_drm(); - - ... - - drmRemoveUserHandler(tdm_helper_drm_fd, _tdm_drm_user_handler); - * @endcode - * @code - if (tdm_helper_drm_fd == -1) - { - ... - if (drmWaitVBlank(fd, &vbl)) - return TDM_ERROR_OPERATION_FAILED; - ... - } - * @endcode - * @endcode - * @todo - */ -extern int tdm_helper_drm_fd; + * @brief The header file to help tdm backend/frontend user + */ + +/** + * @brief Get the current time as a floating point value in seconds + * @return The number of seconds + */ +double +tdm_helper_get_time(void); + +/** + * @brief Dump a buffer + * @details + * This function supports only if a buffer has below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * - TBM_FORMAT_YVU420 + * - TBM_FORMAT_YUV420 + * - TBM_FORMAT_NV12 + * - TBM_FORMAT_NV21 + * - TBM_FORMAT_YUYV + * - TBM_FORMAT_UYVY + * The filename extension should be "png" for TBM_FORMAT_ARGB8888 and TBM_FORMAT_XRGB8888 + * or "yuv" for YUV formats. + * @param[in] buffer A TDM buffer + * @param[in] file The path of file. + */ +void +tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file); + +/** + * @brief fill a buffer with 0 for given pos. + * @details + * This function supports only if a buffer has below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos); + +/** + * @brief fill a buffer with 0 for given pos. + * @details + * This function supports only if a buffer has below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_clear_buffer_color(tbm_surface_h buffer, tdm_pos *pos, unsigned int color); + +/** + * @brief fill a buffer with 0. + * @details + * This function supports only if a buffer has below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * - TBM_FORMAT_YVU420 + * - TBM_FORMAT_YUV420 + * - TBM_FORMAT_NV12 + * - TBM_FORMAT_NV21 + * - TBM_FORMAT_YUYV + * - TBM_FORMAT_UYVY + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_clear_buffer(tbm_surface_h buffer); + +/** + * @brief Get the buffer full size. + * @details + * In some hardware, the buffer width or height is aligned with the fixed size. + * eg. 8, 16, etc. In this case, the real size of buffer could be bigger than + * the buffer size of tbm_surface_info_s. + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_get_buffer_full_size(tbm_surface_h buffer, int *buffer_w, int *buffer_h); + +/** + * @brief convert the source buffer to the destination buffer with given rectangles + * trannsform + * @details + * This function supports only if buffers have below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * @param[in] buffer A TDM buffer + */ +tdm_error +tdm_helper_convert_buffer(tbm_surface_h srcbuf, tbm_surface_h dstbuf, + tdm_pos *srcpos, tdm_pos *dstpos, + tdm_transform transform, int over); + +/** + * @brief Get a fd from the given enviroment variable. + * @details + * This function will dup the fd of the given enviroment variable. The Caller + * @b SHOULD close the fd. + * @param[in] env The given enviroment variable + * @return fd if success. Otherwise, -1. + * @see #tdm_helper_set_fd() + */ +int tdm_helper_get_fd(const char *env); + +/** + * @brief Set the given fd to the give enviroment variable. + * @param[in] env The given enviroment variable + * @param[in] fd The given fd + * @see #tdm_helper_get_fd() + */ +void tdm_helper_set_fd(const char *env, int fd); + +/** + * @brief Start the dump debugging. + * @details + * Start tdm dump. + * Make dump file when tdm_layer_set_buffer() function is called. + * Set the dump count to 1. + * @param[in] dumppath The given dump path + * @param[in] count The dump count number + * @see #tdm_helper_dump_stop() + */ +void +tdm_helper_dump_start(char *dumppath, int *count); + +/** + * @brief Stop the dump debugging. + * @details + * Stop tdm dump. + * Set the dump count to 0. + * @see #tdm_helper_dump_start() + */ +void +tdm_helper_dump_stop(void); + +/** + * @brief The tdm helper capture handler + * @details + * This handler will be called when composit image produced. + * @see #tdm_helper_capture_output() function + */ +typedef void (*tdm_helper_capture_handler)(tbm_surface_h buffer, void *user_data); + +/** + * @brief Make an output's image surface. + * @details Composit specific output's all layer's buffer to dst_buffer surface. + * After composing, tdm_helper_capture_handler func will be called. + * @param[in] output A output object + * @param[in] dst_buffer A surface composite image saved + * @param[in] x A horizontal position of composite image on dst_buffer + * @param[in] y A vertical position of composite image on dst_buffer + * @param[in] w A composite image width + * @param[in] h A composite image height + * @param[in] func A composing done handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, + int x, int y, int w, int h, + tdm_helper_capture_handler func, void *data); + +/** + * @brief Fill the display information to the reply buffer as string. + * @param[in] dpy A display object + * @param[out] reply the string buffer to be filled by this function. + * @param[out] len the length of the reply buffer + */ +void +tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len); + +/** + * @brief Get whether the commit-per-vblank functionality is enabled or not. + * @param[in] dpy A display object + * @return 1 if enabled. Otherwise, 0. + * + * @deprecated use @c tdm_helper_output_commit_per_vblank_enabled instead + */ +int +tdm_helper_commit_per_vblank_enabled(tdm_display *dpy); + +/** + * @brief Get whether the commit-per-vblank functionality is enabled or not for the output. + * @param[in] output An output the functionality has to be checked for + * @return -1 if error occurred, 1 if enabled, 0 if disabled. + */ +int +tdm_helper_output_commit_per_vblank_enabled(tdm_output *output); #ifdef __cplusplus }