From a5de97f3218e077afd0bb180a301014eecc0bf09 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 16 Dec 2016 13:44:57 +0900 Subject: [PATCH] screenshot: add auto rotation set and get API Change-Id: Ie29be523f3c1e4342ea95cc2400c1ccbf2c98053 Signed-off-by: Junkyeong Kim --- include/efl_util_screenshot_extension.h | 78 +++++++++++++++++++++++++++++++++ packaging/capi-ui-efl-util.spec | 1 + src/efl_util.c | 37 ++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 include/efl_util_screenshot_extension.h diff --git a/include/efl_util_screenshot_extension.h b/include/efl_util_screenshot_extension.h new file mode 100644 index 0000000..6a150aa --- /dev/null +++ b/include/efl_util_screenshot_extension.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UI_EFL_UTIL_SCREENSHOT_EXTENSION_H__ +#define __TIZEN_UI_EFL_UTIL_SCREENSHOT_EXTENSION_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __GNUC__ +# if __GNUC__ >= 4 +# ifndef API +# define API __attribute__ ((visibility("default"))) +# endif +# endif +#endif + +/** + * @file efl_util_screenshot_extension.h + */ + +/** + * @addtogroup CAPI_EFL_UTIL_MODULE + * @{ + */ + +/** + * @platform + * @brief Set auto rotation value for screenshot. + * @since_tizen $TZ_CFG_VER_40$ + * @privlevel platform + * @privilege %http://tizen.org/privilege/screenshot + * @param[in] screenshot efl_util_screenshot_h handle + * @param[in] set auto rotation value (1:use auto rotation, 0:don't use auto rotation) + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @see efl_util_screenshot_get_auto_rotation() + */ +API int efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set); + +/** + * @platform + * @brief Get current auto rotation value of screenshot. + * @since_tizen $TZ_CFG_VER_40$ + * @privlevel platform + * @privilege %http://tizen.org/privilege/screenshot + * @param[in] screenshot efl_util_screenshot_h handle + * @param[out] set The current auto rotation value of screenshot + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @see efl_util_screenshot_set_auto_rotation() + */ +API int efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif /* __TIZEN_UI_EFL_UTIL_SCREENSHOT_EXTENSION_H__ */ diff --git a/packaging/capi-ui-efl-util.spec b/packaging/capi-ui-efl-util.spec index a294033..da9da34 100644 --- a/packaging/capi-ui-efl-util.spec +++ b/packaging/capi-ui-efl-util.spec @@ -78,6 +78,7 @@ cp -a LICENSE.APLv2 %{buildroot}/%{TZ_SYS_RO_SHARE}/license/%{name} %files devel %manifest %{name}.manifest %{_includedir}/ui/efl_util.h +%{_includedir}/ui/efl_util_screenshot_extension.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-ui-efl-util.so %exclude %{_includedir}/ui/config.h diff --git a/src/efl_util.c b/src/efl_util.c index f5ffd75..3ae9094 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -38,6 +38,8 @@ #include #include +#include + #include #ifdef LOG_TAG #undef LOG_TAG @@ -1448,6 +1450,8 @@ struct _efl_util_screenshot_h /* tbm bufmgr */ tbm_bufmgr bufmgr; + + Eina_Bool auto_rotation; }; /* scrrenshot handle */ @@ -1574,6 +1578,7 @@ efl_util_screenshot_initialize(int width, int height) screenshot->width = width; screenshot->height = height; + screenshot->auto_rotation = EINA_TRUE; screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client); EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init); @@ -1701,6 +1706,8 @@ efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot) /* reset shot_done for next screenshot */ screenshot->shot_done = EINA_FALSE; + set_last_result(EFL_UTIL_ERROR_NONE); + _screenshot_mutex_unlock(); return t_surface; @@ -1717,3 +1724,33 @@ fail: return NULL; } + +API int +efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set) +{ + if (!screenshot || (screenshot != g_screenshot)) + return EFL_UTIL_ERROR_INVALID_PARAMETER; + + if (!(set == 0 || set == 1)) + return EFL_UTIL_ERROR_INVALID_PARAMETER; + + if (set) + g_screenshot->auto_rotation = EINA_TRUE; + else + g_screenshot->auto_rotation = EINA_FALSE; + + tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation); + + return EFL_UTIL_ERROR_NONE; +} + +API int +efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set) +{ + if (!screenshot || (screenshot != g_screenshot) || !set) + return EFL_UTIL_ERROR_INVALID_PARAMETER; + + *set = g_screenshot->auto_rotation; + + return EFL_UTIL_ERROR_NONE; +} -- 2.7.4