From 07e24528fb132dd2865994d453c9170b5544627c Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Mon, 19 Jun 2023 14:54:27 +0900 Subject: [PATCH] Aurum: apply auto rotation for screenshot Change-Id: Ibfaf2ba8321c1125c0cbcdd5b32eb6676d9fe57b --- libaurum/inc/Impl/MockDeviceImpl.h | 2 +- libaurum/inc/Impl/TizenDeviceImpl.h | 3 ++- libaurum/inc/Interface/IDevice.h | 5 +++-- libaurum/inc/UiDevice.h | 5 +++-- libaurum/src/Impl/MockDeviceImpl.cc | 2 +- libaurum/src/Impl/TizenDeviceImpl.cc | 14 +++++++++++--- libaurum/src/UiDevice.cc | 7 ++++--- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/libaurum/inc/Impl/MockDeviceImpl.h b/libaurum/inc/Impl/MockDeviceImpl.h index e387a8e..655ff7c 100644 --- a/libaurum/inc/Impl/MockDeviceImpl.h +++ b/libaurum/inc/Impl/MockDeviceImpl.h @@ -160,7 +160,7 @@ public: * @brief TBD * @since_tizen 7.0 */ - bool takeScreenshot(std::string path, bool asPixels, void **pixels) override; + bool takeScreenshot(std::string path, bool asPixels, void **pixels, int angle = 0) override; /** * @brief TBD diff --git a/libaurum/inc/Impl/TizenDeviceImpl.h b/libaurum/inc/Impl/TizenDeviceImpl.h index e73a564..df9970a 100644 --- a/libaurum/inc/Impl/TizenDeviceImpl.h +++ b/libaurum/inc/Impl/TizenDeviceImpl.h @@ -24,6 +24,7 @@ #include #include +#include #include using namespace Aurum; @@ -120,7 +121,7 @@ public: /** * @copydoc IDevice::takeScreenshot() */ - bool takeScreenshot(std::string path, bool asPixels, void **pixels) override; + bool takeScreenshot(std::string path, bool asPixels, void **pixels, int angle = 0) override; /** * @copydoc IDevice::getSystemTime() diff --git a/libaurum/inc/Interface/IDevice.h b/libaurum/inc/Interface/IDevice.h index 5dc6314..6338fa5 100644 --- a/libaurum/inc/Interface/IDevice.h +++ b/libaurum/inc/Interface/IDevice.h @@ -266,12 +266,13 @@ public: * @param[in] path where the image file should be written to * @param[in] asPixels asPixels wheter to receive screen pixel data * @param[in] pixels pixel pixel buffer data pointer + * @param[in] angle rotation angle of current screen * * @return true if screen shot is created successfully, false otherwise * - * @since_tizen 6.5 + * @since_tizen 8.0 */ - virtual bool takeScreenshot(std::string path, bool asPixels, void **pixels) = 0; + virtual bool takeScreenshot(std::string path, bool asPixels, void **pixels, int angle = 0) = 0; /** * @brief Gets device system time. diff --git a/libaurum/inc/UiDevice.h b/libaurum/inc/UiDevice.h index fd30c7a..27b234b 100644 --- a/libaurum/inc/UiDevice.h +++ b/libaurum/inc/UiDevice.h @@ -254,12 +254,13 @@ public: * @param[in] path where the image file should be written to * @param[in] asPixels asPixels wheter to receive screen pixel data * @param[in] pixels pixel pixel buffer data pointer + * @param[in] angle rotation angle of current screen * * @return true if screen shot is created successfully, false otherwise * - * @since_tizen 7.0 + * @since_tizen 8.0 */ - bool takeScreenshot(std::string path, bool asPixels, void **pixels) override; + bool takeScreenshot(std::string path, bool asPixels, void **pixels, int angle = 0) override; /** * @brief Gets device system time. diff --git a/libaurum/src/Impl/MockDeviceImpl.cc b/libaurum/src/Impl/MockDeviceImpl.cc index 1f4c8dd..6c72a24 100644 --- a/libaurum/src/Impl/MockDeviceImpl.cc +++ b/libaurum/src/Impl/MockDeviceImpl.cc @@ -195,7 +195,7 @@ bool MockDeviceImpl::repeatKeyCode(std::string keycode, int intervalMs, int dura return false; } -bool MockDeviceImpl::takeScreenshot(std::string path, bool asPixels, void **pixels) +bool MockDeviceImpl::takeScreenshot(std::string path, bool asPixels, void **pixels, int angle) { return true; } diff --git a/libaurum/src/Impl/TizenDeviceImpl.cc b/libaurum/src/Impl/TizenDeviceImpl.cc index 768b63b..33f3266 100644 --- a/libaurum/src/Impl/TizenDeviceImpl.cc +++ b/libaurum/src/Impl/TizenDeviceImpl.cc @@ -307,19 +307,27 @@ bool TizenDeviceImpl::releaseKeyCode(std::string keycode) return result == EFL_UTIL_ERROR_NONE; } -bool TizenDeviceImpl::takeScreenshot(std::string path, bool asPixels, void **pixels) +bool TizenDeviceImpl::takeScreenshot(std::string path, bool asPixels, void **pixels, int angle) { efl_util_screenshot_h screenshot = NULL; tbm_surface_h tbm_surface = NULL; void *ptr = NULL; - const int WIDTH = mScreenSize.width; - const int HEIGHT = mScreenSize.height; + int WIDTH = 0; + int HEIGHT = 0; + if (angle == 90 || angle == 270) { + WIDTH = mScreenSize.height; + HEIGHT = mScreenSize.width; + } else { + WIDTH = mScreenSize.width; + HEIGHT = mScreenSize.height; + } CaptureMutex.lock(); screenshot = efl_util_screenshot_initialize(WIDTH, HEIGHT); if (screenshot) { + efl_util_screenshot_set_auto_rotation(screenshot, EINA_TRUE); tbm_surface = efl_util_screenshot_take_tbm_surface(screenshot); if (tbm_surface) { if (asPixels) { diff --git a/libaurum/src/UiDevice.cc b/libaurum/src/UiDevice.cc index e4164bd..6286d56 100644 --- a/libaurum/src/UiDevice.cc +++ b/libaurum/src/UiDevice.cc @@ -278,9 +278,10 @@ bool UiDevice::repeatKeyCode(std::string keycode, int intervalMs, int durationMs return result; } -bool UiDevice::takeScreenshot(std::string path, bool asPixels, void **pixels) +bool UiDevice::takeScreenshot(std::string path, bool asPixels, void **pixels, int angle) { - return mDeviceImpl->takeScreenshot(path, asPixels, pixels); + angle = getWindowAngle(); + return mDeviceImpl->takeScreenshot(path, asPixels, pixels, angle); } long long UiDevice::getSystemTime(TimeRequestType type) @@ -349,4 +350,4 @@ int UiDevice::getTargetAngle() if (wins.size() > 0) return wins[0]->getTargetAngle(); return 0; -} \ No newline at end of file +} -- 2.7.4