screenshot: add auto rotation set and get API 25/105225/4
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 16 Dec 2016 04:44:57 +0000 (13:44 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 21 Dec 2016 09:51:05 +0000 (18:51 +0900)
Change-Id: Ie29be523f3c1e4342ea95cc2400c1ccbf2c98053
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
include/efl_util_screenshot_extension.h [new file with mode: 0644]
packaging/capi-ui-efl-util.spec
src/efl_util.c

diff --git a/include/efl_util_screenshot_extension.h b/include/efl_util_screenshot_extension.h
new file mode 100644 (file)
index 0000000..6a150aa
--- /dev/null
@@ -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__ */
index a294033..da9da34 100644 (file)
@@ -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
index f5ffd75..3ae9094 100644 (file)
@@ -38,6 +38,8 @@
 #include <tizen-extension-client-protocol.h>
 #include <screenshooter-client-protocol.h>
 
+#include <efl_util_screenshot_extension.h>
+
 #include <dlog.h>
 #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;
+}