/*
- * 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.
Internal::GetImplementation(*this).SetPostRenderCallback(callback);
}
+void OffscreenWindow::SetFrameRenderedCallback(CallbackBase* callback)
+{
+ Internal::GetImplementation(*this).SetFrameRenderedCallback(callback);
+}
+
OffscreenWindow::OffscreenWindow(Internal::OffscreenWindow* window)
: BaseHandle(window)
{
#define DALI_OFFSCREEN_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.
*/
void SetPostRenderCallback(CallbackBase* callback);
+ /**
+ * @brief Sets a callback that is called when the frame rendering is done by the graphics driver.
+ *
+ * @param[in] callback The function to call
+ *
+ * @note A callback of the following type may be used:
+ * @code
+ * void MyFunction();
+ * @endcode
+ *
+ * @note Ownership of the callback is passed onto this class.
+ */
+ void SetFrameRenderedCallback(CallbackBase* callback);
+
public: // Not intended for application developers
/**
* @brief Internal constructor
#define DALI_NATIVE_RENDER_SURFACE_H
/*
- * Copyright (c) 2021 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.
*/
virtual Any GetNativeRenderable() = 0;
+ /**
+ * @brief Sets a callback that is called when the frame rendering is done by the graphics driver.
+ * @param callback The function to call
+ */
+ virtual void SetFrameRenderedCallback(CallbackBase* callback) = 0;
+
private: // from NativeRenderSurface
/**
* @brief Create a renderable
/*
- * Copyright (c) 2021 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.
surface->SetRenderNotification(mRenderNotification.get());
}
+void OffscreenWindow::SetFrameRenderedCallback(CallbackBase* callback)
+{
+ NativeRenderSurface* surface = GetNativeRenderSurface();
+
+ if(!surface)
+ {
+ DALI_LOG_ERROR("NativeRenderSurface is null.");
+ return;
+ }
+
+ surface->SetFrameRenderedCallback(callback);
+}
+
NativeRenderSurface* OffscreenWindow::GetNativeRenderSurface() const
{
return dynamic_cast<NativeRenderSurface*>(mSurface.get());
#define DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_H
/*
- * Copyright (c) 2021 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.
*/
void SetPostRenderCallback(CallbackBase* callback);
+ /**
+ * @copydoc Dali::OffscreenWindow::SetFrameRenderedCallback
+ */
+ void SetFrameRenderedCallback(CallbackBase* callback);
+
/*
* @brief Initialize the OffscreenWindow
* @param[in] isDefaultWindow Whether the OffscreenWindow is a default one or not
Debug::Filter* gNativeSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_NATIVE_RENDER_SURFACE");
#endif
+// The callback of tbm_surface_queue_add_acquirable_cb()
+static void TbmAcquirableCallback(tbm_surface_queue_h queue, void* data)
+{
+ NativeRenderSurfaceEcoreWl* surface = static_cast<NativeRenderSurfaceEcoreWl*>(data);
+ if(surface)
+ {
+ surface->TriggerFrameRenderedCallback();
+ }
+}
+
} // unnamed namespace
NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, Any surface, bool isTransparent)
return mTbmQueue;
}
+void NativeRenderSurfaceEcoreWl::TriggerFrameRenderedCallback()
+{
+ if(mFrameRenderedCallback)
+ {
+ mFrameRenderedCallback->Trigger();
+ }
+}
+
+void NativeRenderSurfaceEcoreWl::SetFrameRenderedCallback(CallbackBase* callback)
+{
+ mFrameRenderedCallback = std::unique_ptr<EventThreadCallback>(new EventThreadCallback(callback));
+
+ tbm_surface_queue_error_e result = tbm_surface_queue_add_acquirable_cb(mTbmQueue, TbmAcquirableCallback, this);
+ if(result != TBM_ERROR_NONE)
+ {
+ DALI_LOG_ERROR("Failed calling tbm_surface_queue_add_acquirable_cb(), error : %x", result);
+ }
+}
+
PositionSize NativeRenderSurfaceEcoreWl::GetPositionSize() const
{
return PositionSize(0, 0, static_cast<int>(mSurfaceSize.GetWidth()), static_cast<int>(mSurfaceSize.GetHeight()));
mDamagedRects.clear();
}
- //TODO: Need to support partial update
- // This is now done when the render pass for the render surface begins
- // MakeContextCurrent();
+ // TODO: Need to support partial update
+ // This is now done when the render pass for the render surface begins
+ // MakeContextCurrent();
return true;
}
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H
/*
- * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
#include <dali/devel-api/threading/conditional-wait.h>
#include <tbm_surface.h>
#include <tbm_surface_queue.h>
{
public:
/**
- * Uses an Wayland surface to render to.
- * @param [in] surfaceSize the size of the surface
- * @param [in] surface the native surface handle
- * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
- */
+ * Uses an Wayland surface to render to.
+ * @param [in] surfaceSize the size of the surface
+ * @param [in] surface the native surface handle
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, Any surface, bool isTransparent = false);
/**
*/
virtual ~NativeRenderSurfaceEcoreWl();
-public: // from WindowRenderSurface
+public:
+ /**
+ * @brief Triggers the FrameRenderedCallback
+ */
+ void TriggerFrameRenderedCallback();
+
+public: // from NativeRenderSurface
/**
* @copydoc Dali::NativeRenderSurface::SetRenderNotification()
*/
*/
virtual Any GetNativeRenderable() override;
+ /**
+ * @copydoc Dali::NativeRenderSurface::SetFrameRenderedCallback()
+ */
+ void SetFrameRenderedCallback(CallbackBase* callback) override;
+
public: // from Dali::RenderSurfaceInterface
/**
* @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
bool mOwnSurface;
std::vector<Rect<int>> mDamagedRects{}; ///< Keeps collected damaged render items rects for one render pass
- tbm_surface_queue_h mTbmQueue;
- ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
+ tbm_surface_queue_h mTbmQueue;
+ ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
+ std::unique_ptr<EventThreadCallback> mFrameRenderedCallback; ///< The FrameRendredCallback called from graphics driver
};
} // namespace Dali