From 1654e1c0448a393aca9a06cfd6622e2537f891df Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 25 May 2023 18:13:43 +0900 Subject: [PATCH] Add KeepRendering method to Window Change-Id: I5b07c7894ab9738a121b1de02b3f74f577fbe942 --- .../dali-test-suite-utils/test-application.cpp | 49 +++++++++++++++++++++- .../dali-test-suite-utils/test-application.h | 9 +++- dali/internal/window-system/common/window-impl.cpp | 5 +++ dali/internal/window-system/common/window-impl.h | 15 ++++--- dali/public-api/adaptor-framework/window.cpp | 7 +++- dali/public-api/adaptor-framework/window.h | 13 +++++- 6 files changed, 87 insertions(+), 11 deletions(-) diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp index a8354e8..47487e2 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp @@ -85,6 +85,8 @@ void TestApplication::CreateScene() rtInfo.SetSurface(&mSurfaceWidth); // Can point to anything, really. mScene.SetSurfaceRenderTarget(rtInfo); + + mScenes.push_back(mScene); } void TestApplication::InitializeCore() @@ -212,8 +214,11 @@ bool TestApplication::Render(uint32_t intervalMilliseconds, const char* location mCore->PreRender(mRenderStatus, false /*do not force clear*/); if(!uploadOnly) { - mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/); - mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/); + for(auto&& scene : mScenes) + { + mCore->RenderScene(mRenderStatus, scene, true /*render the off-screen buffers*/); + mCore->RenderScene(mRenderStatus, scene, false /*render the surface*/); + } } mCore->PostRender(); @@ -243,6 +248,36 @@ bool TestApplication::RenderWithPartialUpdate(std::vector>& damagedRec return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate(); } +bool TestApplication::RenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location) +{ + DoUpdate(intervalMilliseconds, location); + + // Reset the status + mRenderStatus.SetNeedsUpdate(false); + mRenderStatus.SetNeedsPostRender(false); + + mCore->PreRender(mRenderStatus, false /*do not force clear*/); + + for(auto&& scene : mScenes) + { + std::vector> damagedRects; + Rect clippingRect{}; + + mCore->PreRender(scene, damagedRects); + mCore->RenderScene(mRenderStatus, scene, true /*render the off-screen buffers*/); + for(auto&& iter : damagedRects) + { + clippingRect.Merge(iter); + } + mCore->RenderScene(mRenderStatus, scene, false /*render the surface*/, clippingRect); + } + mCore->PostRender(); + + mFrame++; + + return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate(); +} + uint32_t TestApplication::GetUpdateStatus() { return mStatus.KeepUpdating(); @@ -297,4 +332,14 @@ uint32_t TestApplication::Wait(uint32_t durationToWait) return time; } +void TestApplication::AddScene(Integration::Scene scene) +{ + mScenes.push_back(scene); +} + +void TestApplication::RemoveScene(Integration::Scene scene) +{ + mScenes.erase(std::remove(mScenes.begin(), mScenes.end(), scene), mScenes.end()); +} + } // namespace Dali diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.h index ce0e151..5e86b3c 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.h @@ -75,6 +75,7 @@ public: bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL, bool uploadOnly = false); bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector>& damagedRects); bool RenderWithPartialUpdate(std::vector>& damagedRects, Rect& clippingRect); + bool RenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location = NULL); uint32_t GetUpdateStatus(); bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL); bool RenderOnly(); @@ -92,6 +93,9 @@ public: return mScene; } + void AddScene(Integration::Scene scene); + void RemoveScene(Integration::Scene scene); + private: void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL, bool uploadOnly = false); @@ -103,8 +107,9 @@ protected: Integration::UpdateStatus mStatus; Integration::RenderStatus mRenderStatus; - Integration::Core* mCore; - Dali::Integration::Scene mScene; + Integration::Core* mCore; + Dali::Integration::Scene mScene; + std::vector mScenes; uint32_t mSurfaceWidth; uint32_t mSurfaceHeight; diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 9d6fcee..f1c4ac9 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -331,6 +331,11 @@ Dali::RenderTaskList Window::GetRenderTaskList() const return mScene.GetRenderTaskList(); } +void Window::KeepRendering(float durationSeconds) +{ + mScene.KeepRendering(durationSeconds); +} + std::string Window::GetNativeResourceId() const { return mWindowBase->GetNativeWindowResourceId(); diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index 849e540..407e966 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -165,11 +165,16 @@ public: Dali::Layer GetLayer(uint32_t depth) const; /** - * @copydoc Dali::DevelWindow::GetRenderTaskList() + * @copydoc Dali::Window::GetRenderTaskList() */ Dali::RenderTaskList GetRenderTaskList() const; /** + * @copydoc Dali::Window::KeepRendering() + */ + void KeepRendering(float durationSeconds); + + /** * @brief Get window resource ID assigned by window manager * @return The resource ID of the window */ @@ -816,10 +821,10 @@ private: std::vector mAvailableAngles; int mPreferredAngle; - int mRotationAngle; ///< The angle of the rotation - int mWindowWidth; ///< The width of the window - int mWindowHeight; ///< The height of the window - int mNativeWindowId; ///< The Native Window Id + int mRotationAngle; ///< The angle of the rotation + int mWindowWidth; ///< The width of the window + int mWindowHeight; ///< The height of the window + int mNativeWindowId; ///< The Native Window Id EventHandlerPtr mEventHandler; ///< The window events handler OrientationMode mOrientationMode; ///< The physical screen mode is portrait or landscape diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index 4e834a6..0e23346 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -338,6 +338,11 @@ Dali::RenderTaskList Window::GetRenderTaskList() return GetImplementation(*this).GetRenderTaskList(); } +void Window::KeepRendering(float durationSeconds) +{ + GetImplementation(*this).KeepRendering(durationSeconds); +} + Window::KeyEventSignalType& Window::KeyEventSignal() { return GetImplementation(*this).KeyEventSignal(); diff --git a/dali/public-api/adaptor-framework/window.h b/dali/public-api/adaptor-framework/window.h index 1d1f8a8..c66abe4 100644 --- a/dali/public-api/adaptor-framework/window.h +++ b/dali/public-api/adaptor-framework/window.h @@ -2,7 +2,7 @@ #define DALI_WINDOW_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -580,6 +580,17 @@ public: */ RenderTaskList GetRenderTaskList(); + /** + * @brief Keep rendering for at least the given amount of time. + * + * By default, Dali will stop rendering when no Actor positions are being set, and when no animations are running etc. + * This method is useful to force screen refreshes. + * + * @SINCE_2_2.29 + * @param[in] durationSeconds Time to keep rendering, 0 means render at least one more frame + */ + void KeepRendering(float durationSeconds); + public: // Signals /** * @brief The user should connect to this signal to get a timing when window gains focus or loses focus. -- 2.7.4