TBM acquiring part is moved to EvasPlugin and OffscreenWindow.
PostRenderSignal is removed and SetPostRenderCallback is added in
OffscreenWindow.
Change-Id: I4adfd699930a4dcc5e1298da9a0f1e199feadf54
/*
- * 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.
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)
#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.
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/math/uint-16-pair.h>
#include <dali/public-api/object/any.h>
-#include <dali/public-api/signals/dali-signal.h>
// INTERNAL INCLUDES
#include <dali/public-api/dali-adaptor-common.h>
class DALI_ADAPTOR_API OffscreenWindow : public Dali::BaseHandle
{
public:
- using WindowSize = Uint16Pair;
- using PostRenderSignalType = Signal<void(OffscreenWindow, Any)>;
+ using WindowSize = Uint16Pair;
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
/**
virtual ~NativeRenderSurface() = default;
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
*/
virtual void CreateNativeRenderable() = 0;
- /**
- * @brief Release a drawable
- */
- virtual void ReleaseDrawable() = 0;
-
protected:
// Undefined
NativeRenderSurface(const NativeRenderSurface&) = delete;
#include <dali/integration-api/adaptor-framework/native-render-surface-factory.h>
#include <dali/integration-api/adaptor-framework/native-render-surface.h>
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
+#include <dali/integration-api/debug.h>
#include <dali/internal/offscreen/common/offscreen-application-impl.h>
namespace Dali
{
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<TriggerEventInterface>(triggerEventFactory.CreateTriggerEvent(MakeCallback(this, &OffscreenWindow::OnPostRender), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
-
- NativeRenderSurface* surface = GetNativeRenderSurface();
-
- if(!surface)
- {
- return;
- }
-
- surface->SetRenderNotification(mRenderNotification.get());
}
OffscreenWindow::~OffscreenWindow()
return surface->GetNativeRenderable();
}
+void OffscreenWindow::SetPostRenderCallback(CallbackBase* callback)
+{
+ // Connect callback to be notified when the surface is rendered
+ mPostRenderCallback = std::unique_ptr<CallbackBase>(callback);
+ TriggerEventFactory triggerEventFactory;
+
+ if(!mRenderNotification)
+ {
+ mRenderNotification = std::unique_ptr<TriggerEventInterface>(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<NativeRenderSurface*>(mSurface.get());
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
// EXTERNAL INCLUDES
#include <dali/public-api/common/intrusive-ptr.h>
-#include <dali/public-api/signals/connection-tracker.h>
#include <memory>
// INTERNAL INCLUDES
/**
* 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
*/
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.
OffscreenWindow(const OffscreenWindow&);
OffscreenWindow& operator=(OffscreenWindow&);
- /*
- * @brief Initialize the OffscreenWindow (for internal use)
- */
- void Initialize();
-
private:
std::unique_ptr<TriggerEventInterface> mRenderNotification;
- PostRenderSignalType mPostRenderSignal;
+ std::unique_ptr<CallbackBase> mPostRenderCallback;
};
inline OffscreenWindow& GetImplementation(Dali::OffscreenWindow& offscreenWindow)
mEGLContext(nullptr),
mOwnSurface(false),
mTbmQueue(NULL),
- mConsumeSurface(NULL),
mThreadSynchronization(NULL)
{
Dali::Internal::Adaptor::WindowSystem::Initialize();
// release the surface if we own one
if(mOwnSurface)
{
- ReleaseDrawable();
-
if(mTbmQueue)
{
tbm_surface_queue_destroy(mTbmQueue);
Dali::Internal::Adaptor::WindowSystem::Shutdown();
}
-Any NativeRenderSurfaceEcoreWl::GetDrawable()
-{
- return mConsumeSurface;
-}
-
void NativeRenderSurfaceEcoreWl::SetRenderNotification(TriggerEventInterface* renderNotification)
{
mRenderNotification = renderNotification;
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();
- }
}
}
}
}
-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
virtual ~NativeRenderSurfaceEcoreWl();
public: // from WindowRenderSurface
- /**
- * @copydoc Dali::NativeRenderSurface::GetSurface()
- */
- Any GetDrawable() override;
-
/**
* @copydoc Dali::NativeRenderSurface::SetRenderNotification()
*/
*/
void CreateNativeRenderable() override;
- /**
- * @copydoc Dali::NativeRenderSurface::ReleaseDrawable()
- */
- void ReleaseDrawable() override;
-
private: // Data
SurfaceSize mSurfaceSize;
TriggerEventInterface* mRenderNotification;
bool mOwnSurface;
tbm_surface_queue_h mTbmQueue;
- tbm_surface_h mConsumeSurface;
ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
};