From ec4a6a66c7f367d579ddc4ec1d4b88c1b8db9680 Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Thu, 21 Jan 2021 19:03:31 +0900 Subject: [PATCH] Move tbm acquiring part TBM acquiring part is moved to EvasPlugin and OffscreenWindow. PostRenderSignal is removed and SetPostRenderCallback is added in OffscreenWindow. Change-Id: I4adfd699930a4dcc5e1298da9a0f1e199feadf54 --- .../adaptor-framework/offscreen-window.cpp | 6 +-- .../devel-api/adaptor-framework/offscreen-window.h | 19 ++++--- .../adaptor-framework/native-render-surface.h | 11 ---- .../offscreen/common/offscreen-window-impl.cpp | 58 +++++++++++--------- .../offscreen/common/offscreen-window-impl.h | 25 +++------ .../native-render-surface-ecore-wl.cpp | 61 ++-------------------- .../tizen-wayland/native-render-surface-ecore-wl.h | 11 ---- 7 files changed, 58 insertions(+), 133 deletions(-) diff --git a/dali/devel-api/adaptor-framework/offscreen-window.cpp b/dali/devel-api/adaptor-framework/offscreen-window.cpp index 020eca4..42cc8eb 100644 --- a/dali/devel-api/adaptor-framework/offscreen-window.cpp +++ b/dali/devel-api/adaptor-framework/offscreen-window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -103,9 +103,9 @@ Uint16Pair OffscreenWindow::GetDpi() const return Internal::GetImplementation(*this).GetDpi(); } -OffscreenWindow::PostRenderSignalType& OffscreenWindow::PostRenderSignal() +void OffscreenWindow::SetPostRenderCallback(CallbackBase* callback) { - return Internal::GetImplementation(*this).PostRenderSignal(); + Internal::GetImplementation(*this).SetPostRenderCallback(callback); } OffscreenWindow::OffscreenWindow(Internal::OffscreenWindow* window) diff --git a/dali/devel-api/adaptor-framework/offscreen-window.h b/dali/devel-api/adaptor-framework/offscreen-window.h index 5e2b502..1c2e144 100644 --- a/dali/devel-api/adaptor-framework/offscreen-window.h +++ b/dali/devel-api/adaptor-framework/offscreen-window.h @@ -2,7 +2,7 @@ #define DALI_OFFSCREEN_WINDOW_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -22,7 +22,6 @@ #include #include #include -#include // INTERNAL INCLUDES #include @@ -44,8 +43,7 @@ class OffscreenWindow; class DALI_ADAPTOR_API OffscreenWindow : public Dali::BaseHandle { public: - using WindowSize = Uint16Pair; - using PostRenderSignalType = Signal; + using WindowSize = Uint16Pair; public: /** @@ -176,13 +174,18 @@ public: */ Uint16Pair GetDpi() const; -public: // Signals /** - * @brief This signal is emitted when the OffscreenWindow is rendered. + * @brief Sets the PostRenderCallback of the OffscreenWindow. + * + * @param[in] callback The PostRenderCallback function + * @code + * void MyFunction( OffscreenWindow window, Any nativeSurface ); + * @endcode + * + * @note Ownership of the callback is passed onto this class. * - * @return The signal */ - PostRenderSignalType& PostRenderSignal(); + void SetPostRenderCallback(CallbackBase* callback); public: // Not intended for application developers /** diff --git a/dali/integration-api/adaptor-framework/native-render-surface.h b/dali/integration-api/adaptor-framework/native-render-surface.h index c15f139..c55be78 100644 --- a/dali/integration-api/adaptor-framework/native-render-surface.h +++ b/dali/integration-api/adaptor-framework/native-render-surface.h @@ -44,12 +44,6 @@ public: public: // API /** - * @brief Get the render surface the adaptor is using to render to. - * @return reference to current render surface - */ - virtual Any GetDrawable() = 0; - - /** * @brief Sets the render notification trigger to call when render thread is completed a frame * @param renderNotification to use */ @@ -67,11 +61,6 @@ private: // from NativeRenderSurface */ virtual void CreateNativeRenderable() = 0; - /** - * @brief Release a drawable - */ - virtual void ReleaseDrawable() = 0; - protected: // Undefined NativeRenderSurface(const NativeRenderSurface&) = delete; diff --git a/dali/internal/offscreen/common/offscreen-window-impl.cpp b/dali/internal/offscreen/common/offscreen-window-impl.cpp index ed34e15..d85bdd3 100644 --- a/dali/internal/offscreen/common/offscreen-window-impl.cpp +++ b/dali/internal/offscreen/common/offscreen-window-impl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include namespace Dali @@ -49,31 +50,11 @@ void OffscreenWindow::Initialize(bool isDefaultWindow) { if(isDefaultWindow) { - Initialize(); return; } Dali::Integration::SceneHolder sceneHolderHandler = Dali::Integration::SceneHolder(this); Dali::Adaptor::Get().AddWindow(sceneHolderHandler); - - Initialize(); -} - -void OffscreenWindow::Initialize() -{ - // Connect callback to be notified when the surface is rendered - TriggerEventFactory triggerEventFactory; - - mRenderNotification = std::unique_ptr(triggerEventFactory.CreateTriggerEvent(MakeCallback(this, &OffscreenWindow::OnPostRender), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER)); - - NativeRenderSurface* surface = GetNativeRenderSurface(); - - if(!surface) - { - return; - } - - surface->SetRenderNotification(mRenderNotification.get()); } OffscreenWindow::~OffscreenWindow() @@ -112,6 +93,28 @@ Dali::Any OffscreenWindow::GetNativeHandle() const return surface->GetNativeRenderable(); } +void OffscreenWindow::SetPostRenderCallback(CallbackBase* callback) +{ + // Connect callback to be notified when the surface is rendered + mPostRenderCallback = std::unique_ptr(callback); + TriggerEventFactory triggerEventFactory; + + if(!mRenderNotification) + { + mRenderNotification = std::unique_ptr(triggerEventFactory.CreateTriggerEvent(MakeCallback(this, &OffscreenWindow::OnPostRender), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER)); + } + + NativeRenderSurface* surface = GetNativeRenderSurface(); + + if(!surface) + { + DALI_LOG_ERROR("NativeRenderSurface is null."); + return; + } + + surface->SetRenderNotification(mRenderNotification.get()); +} + NativeRenderSurface* OffscreenWindow::GetNativeRenderSurface() const { return dynamic_cast(mSurface.get()); @@ -119,13 +122,18 @@ NativeRenderSurface* OffscreenWindow::GetNativeRenderSurface() const void OffscreenWindow::OnPostRender() { + NativeRenderSurface* surface = GetNativeRenderSurface(); + + if(!surface) + { + DALI_LOG_ERROR("NativeRenderSurface is null."); + return; + } + Dali::OffscreenWindow handle(this); - mPostRenderSignal.Emit(handle, GetNativeHandle()); -} + CallbackBase::Execute(*mPostRenderCallback, handle, surface->GetNativeRenderable()); -OffscreenWindow::PostRenderSignalType& OffscreenWindow::PostRenderSignal() -{ - return mPostRenderSignal; + surface->ReleaseLock(); } } // namespace Internal diff --git a/dali/internal/offscreen/common/offscreen-window-impl.h b/dali/internal/offscreen/common/offscreen-window-impl.h index ee564e9..e45cf49 100644 --- a/dali/internal/offscreen/common/offscreen-window-impl.h +++ b/dali/internal/offscreen/common/offscreen-window-impl.h @@ -20,7 +20,6 @@ // EXTERNAL INCLUDES #include -#include #include // INTERNAL INCLUDES @@ -39,12 +38,10 @@ namespace Internal /** * Implementation of the OffscreenWindow class. */ -class OffscreenWindow : public Dali::Internal::Adaptor::SceneHolder, - public ConnectionTracker +class OffscreenWindow : public Dali::Internal::Adaptor::SceneHolder { public: - using WindowSize = Dali::OffscreenWindow::WindowSize; - using PostRenderSignalType = Dali::OffscreenWindow::PostRenderSignalType; + using WindowSize = Dali::OffscreenWindow::WindowSize; /** * @brief Create a new OffscreenWindow @@ -84,18 +81,17 @@ public: */ Any GetNativeHandle() const override; + /** + * @copydoc Dali::OffscreenWindow::SetPostRenderCallback + */ + void SetPostRenderCallback(CallbackBase* callback); + /* * @brief Initialize the OffscreenWindow * @param[in] isDefaultWindow Whether the OffscreenWindow is a default one or not */ void Initialize(bool isDefaultWindow); -public: // Signals - /** - * @copydoc Dali::OffscreenWindow::PostRenderSignal - */ - PostRenderSignalType& PostRenderSignal(); - private: /** * This function is called after drawing by dali. @@ -123,14 +119,9 @@ private: OffscreenWindow(const OffscreenWindow&); OffscreenWindow& operator=(OffscreenWindow&); - /* - * @brief Initialize the OffscreenWindow (for internal use) - */ - void Initialize(); - private: std::unique_ptr mRenderNotification; - PostRenderSignalType mPostRenderSignal; + std::unique_ptr mPostRenderCallback; }; inline OffscreenWindow& GetImplementation(Dali::OffscreenWindow& offscreenWindow) diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp index ce439ba..ecdc4e2 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp @@ -59,7 +59,6 @@ NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, mEGLContext(nullptr), mOwnSurface(false), mTbmQueue(NULL), - mConsumeSurface(NULL), mThreadSynchronization(NULL) { Dali::Internal::Adaptor::WindowSystem::Initialize(); @@ -95,8 +94,6 @@ NativeRenderSurfaceEcoreWl::~NativeRenderSurfaceEcoreWl() // release the surface if we own one if(mOwnSurface) { - ReleaseDrawable(); - if(mTbmQueue) { tbm_surface_queue_destroy(mTbmQueue); @@ -108,11 +105,6 @@ NativeRenderSurfaceEcoreWl::~NativeRenderSurfaceEcoreWl() Dali::Internal::Adaptor::WindowSystem::Shutdown(); } -Any NativeRenderSurfaceEcoreWl::GetDrawable() -{ - return mConsumeSurface; -} - void NativeRenderSurfaceEcoreWl::SetRenderNotification(TriggerEventInterface* renderNotification) { mRenderNotification = renderNotification; @@ -242,54 +234,21 @@ void NativeRenderSurfaceEcoreWl::PostRender(bool renderToFbo, bool replacingSurf eglImpl.SwapBuffers(mEGLSurface, damagedRects); } - //TODO: Move calling tbm_surface_queue_acruie to OffscreenWindow and Scene in EvasPlugin - if(mOwnSurface) + if(mRenderNotification) { if(mThreadSynchronization) { mThreadSynchronization->PostRenderStarted(); } - if(tbm_surface_queue_can_acquire(mTbmQueue, 1)) - { - if(tbm_surface_queue_acquire(mTbmQueue, &mConsumeSurface) != TBM_SURFACE_QUEUE_ERROR_NONE) - { - DALI_LOG_ERROR("Failed to acquire a tbm_surface\n"); - return; - } - } - - if(mConsumeSurface) - { - tbm_surface_internal_ref(mConsumeSurface); - } - - // create damage for client applications which wish to know the update timing - if(mRenderNotification) - { - // use notification trigger - // Tell the event-thread to render the tbm_surface - mRenderNotification->Trigger(); - } + // Tell the event-thread to render the tbm_surface + mRenderNotification->Trigger(); if(mThreadSynchronization) { // wait until the event-thread completed to use the tbm_surface mThreadSynchronization->PostRenderWaitForCompletion(); } - - // release the consumed surface after post render was completed - ReleaseDrawable(); - } - else - { - // create damage for client applications which wish to know the update timing - if(mRenderNotification) - { - // use notification trigger - // Tell the event-thread to render the tbm_surface - mRenderNotification->Trigger(); - } } } @@ -354,18 +313,4 @@ void NativeRenderSurfaceEcoreWl::CreateNativeRenderable() } } -void NativeRenderSurfaceEcoreWl::ReleaseDrawable() -{ - if(mConsumeSurface) - { - tbm_surface_internal_unref(mConsumeSurface); - - if(tbm_surface_internal_is_valid(mConsumeSurface)) - { - tbm_surface_queue_release(mTbmQueue, mConsumeSurface); - } - mConsumeSurface = NULL; - } -} - } // namespace Dali diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h index 9561801..da93899 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h @@ -55,11 +55,6 @@ public: public: // from WindowRenderSurface /** - * @copydoc Dali::NativeRenderSurface::GetSurface() - */ - Any GetDrawable() override; - - /** * @copydoc Dali::NativeRenderSurface::SetRenderNotification() */ void SetRenderNotification(TriggerEventInterface* renderNotification) override; @@ -166,11 +161,6 @@ private: */ void CreateNativeRenderable() override; - /** - * @copydoc Dali::NativeRenderSurface::ReleaseDrawable() - */ - void ReleaseDrawable() override; - private: // Data SurfaceSize mSurfaceSize; TriggerEventInterface* mRenderNotification; @@ -183,7 +173,6 @@ private: // Data bool mOwnSurface; tbm_surface_queue_h mTbmQueue; - tbm_surface_h mConsumeSurface; ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization }; -- 2.7.4