#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/signals/connection-tracker.h>
-#include <dali/public-api/signals/dali-signal.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/integration-api/scene.h>
+#include <dali/public-api/signals/connection-tracker.h>
+#include <dali/public-api/signals/dali-signal.h>
#include <unistd.h>
// INTERNAL INCLUDES
namespace Dali
{
-
class TriggerEventInterface;
namespace Internal
{
namespace Adaptor
{
-
class WindowBase;
class AdaptorInternalServices;
class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
{
public:
-
- typedef Signal< void ( ) > OutputSignalType;
+ using OutputSignalType = Signal<void()>;
+ using DamagedRectsContainer = std::list<std::vector<Rect<int>>>;
/**
* Uses an window surface to render to.
* @param [in] surface can be a window or pixmap.
* @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
*/
- WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
+ WindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false);
/**
* @brief Destructor
virtual ~WindowRenderSurface();
public: // API
-
/**
* @brief Get the native window handle
* @return The native window handle
* @brief Sets the render notification trigger to call when render thread is completed a frame
* @param renderNotification to use
*/
- void SetRenderNotification( TriggerEventInterface* renderNotification );
+ void SetRenderNotification(TriggerEventInterface* renderNotification);
/**
* @brief Sets whether the surface is transparent or not.
* @param[in] transparent Whether the surface is transparent
*/
- void SetTransparency( bool transparent );
+ void SetTransparency(bool transparent);
/**
* Request surface rotation
* @param[in] width A new width of the surface
* @param[in] height A new height of the surface
*/
- void RequestRotation( int angle, int width, int height );
+ void RequestRotation(int angle, int width, int height);
/**
* @brief Gets the window base object
WindowBase* GetWindowBase();
/**
+ * @brief Intiailize Ime Surface for Ime window rendering.
+ *
+ * It sets one flag and callback function for Ime window rendering
+ * This callback function calls one special native window function for ready to commit buffer.
+ * The special function notify to display server.
+ * It is only used for Ime window.
+ */
+ void InitializeImeSurface();
+
+ /**
+ * @brief Sets the necessary for window rotation acknowledge.
+ * After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
+ *
+ * More detail description is written in DevelWindow::SetNeedsRotationCompletedAcknowledgement().
+ *
+ * @param[in] window The window instance.
+ * @param[in] needAcknowledgement the flag is true if window rotation acknowledgement is sent.
+ */
+ void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement);
+
+ /**
+ * @brief Query whether window is rotating or not.
+ *
+ * @return true if window is rotating, false otherwise.
+ */
+ bool IsWindowRotating() const;
+
+ /**
* @brief This signal is emitted when the output is transformed.
*/
OutputSignalType& OutputTransformedSignal();
public: // from Dali::RenderSurfaceInterface
-
/**
* @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
*/
- virtual PositionSize GetPositionSize() const override;
+ PositionSize GetPositionSize() const override;
+
+ /**
+ */
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
+ * @copydoc Dali::RenderSurfaceInterface::GetOrientation()
*/
- virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ int GetOrientation() const override;
/**
* @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
*/
- virtual void InitializeGraphics() override;
+ void InitializeGraphics() override;
/**
* @copydoc Dali::RenderSurfaceInterface::CreateSurface()
*/
- virtual void CreateSurface() override;
+ void CreateSurface() override;
/**
* @copydoc Dali::RenderSurfaceInterface::DestroySurface()
*/
- virtual void DestroySurface() override;
+ void DestroySurface() override;
/**
* @copydoc Dali::RenderSurfaceInterface::ReplaceGraphicsSurface()
*/
- virtual bool ReplaceGraphicsSurface() override;
+ bool ReplaceGraphicsSurface() override;
/**
* @copydoc Dali::RenderSurfaceInterface::MoveResize()
*/
- virtual void MoveResize( Dali::PositionSize positionSize) override;
+ void MoveResize(Dali::PositionSize positionSize) override;
/**
* @copydoc Dali::RenderSurfaceInterface::StartRender()
*/
- virtual void StartRender() override;
+ void StartRender() override;
/**
* @copydoc Dali::RenderSurfaceInterface::PreRender()
*/
- virtual bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
+ bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
/**
* @copydoc Dali::RenderSurfaceInterface::PostRender()
*/
- virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
+ void PostRender() override;
/**
* @copydoc Dali::RenderSurfaceInterface::StopRender()
*/
- virtual void StopRender() override;
+ void StopRender() override;
/**
* @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
*/
- virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
+ void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
/**
* @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
*/
- virtual void ReleaseLock() override;
+ void ReleaseLock() override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
*/
- virtual Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
+ Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
/**
* @copydoc Dali::RenderSurfaceInterface::MakeContextCurrent()
*/
- virtual void MakeContextCurrent() override;
+ void MakeContextCurrent() override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetDepthBufferRequired()
*/
- virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
+ Integration::DepthBufferAvailable GetDepthBufferRequired() override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetStencilBufferRequired()
*/
- virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
+ Integration::StencilBufferAvailable GetStencilBufferRequired() override;
private:
-
/**
* @brief Second stage construction
*/
- void Initialize( Any surface );
+ void Initialize(Any surface);
/**
* Notify output is transformed.
void OutputTransformed();
/**
- * @brief Used as the callback for the rotation-trigger.
+ * @brief Used as the callback for the post render.
+ * It is used both window rotation and supporting Ime window
*/
- void ProcessRotationRequest();
+ void ProcessPostRender();
/**
* @brief Used as the callback for the frame rendered / presented.
* @param[in] eventBitMask bit mask of events that occured on the file descriptor
* @param[in] fileDescriptor The file descriptor
*/
- void OnFileDescriptorEventDispatched( FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor );
+ void OnFileDescriptorEventDispatched(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor);
-protected:
+ /**
+ * @brief Set the buffer damage rects.
+ * @param[in] damagedRects List of damaged rects
+ * @param[in] clippingRect The rect to clip rendered scene
+ */
+ void SetBufferDamagedRects(const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
+
+ /**
+ * @brief Swap buffers.
+ * @param[in] damagedRects List of damaged rects
+ */
+ void SwapBuffers(const std::vector<Rect<int>>& damagedRects);
+protected:
// Undefined
WindowRenderSurface(const WindowRenderSurface&) = delete;
WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
private:
-
struct FrameCallbackInfo
{
- FrameCallbackInfo( Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd )
+ FrameCallbackInfo(Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd)
: callbacks(),
fileDescriptorMonitor(),
- fileDescriptor( fd )
+ fileDescriptor(fd)
{
// Transfer owership of the CallbackBase
- for( auto&& iter : callbackList )
+ for(auto&& iter : callbackList)
{
- callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
+ callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
}
}
{
// Delete FileDescriptorMonitor before close fd.
fileDescriptorMonitor.release();
- close( fileDescriptor );
+ close(fileDescriptor);
}
Dali::Integration::Scene::FrameCallbackContainer callbacks;
- std::unique_ptr< FileDescriptorMonitor > fileDescriptorMonitor;
- int fileDescriptor;
+ std::unique_ptr<FileDescriptorMonitor> fileDescriptorMonitor;
+ int fileDescriptor;
};
- using FrameCallbackInfoContainer = std::vector< std::unique_ptr< FrameCallbackInfo > >;
+ using FrameCallbackInfoContainer = std::vector<std::unique_ptr<FrameCallbackInfo>>;
private: // Data
-
- EglInterface* mEGL;
- Dali::DisplayConnection* mDisplayConnection;
- PositionSize mPositionSize; ///< Position
- std::unique_ptr< WindowBase > mWindowBase;
- ThreadSynchronizationInterface* mThreadSynchronization;
- TriggerEventInterface* mRenderNotification; ///< Render notification trigger
- TriggerEventInterface* mRotationTrigger;
- std::unique_ptr< TriggerEventInterface > mFrameRenderedTrigger;
- GraphicsInterface* mGraphics; ///< Graphics interface
- EGLSurface mEGLSurface;
- EGLContext mEGLContext;
- ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
- OutputSignalType mOutputTransformedSignal;
- FrameCallbackInfoContainer mFrameCallbackInfoContainer;
- Dali::Mutex mMutex;
- int mRotationAngle;
- int mScreenRotationAngle;
- bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
- bool mRotationSupported;
- bool mRotationFinished;
- bool mScreenRotationFinished;
- bool mResizeFinished;
-
- uint32_t mDpiHorizontal;
- uint32_t mDpiVertical;
+ EglInterface* mEGL;
+ Dali::DisplayConnection* mDisplayConnection;
+ PositionSize mPositionSize; ///< Position
+ std::unique_ptr<WindowBase> mWindowBase;
+ ThreadSynchronizationInterface* mThreadSynchronization;
+ TriggerEventInterface* mRenderNotification; ///< Render notification trigger
+ std::unique_ptr<TriggerEventInterface> mPostRenderTrigger; ///< Post render callback function
+ std::unique_ptr<TriggerEventInterface> mFrameRenderedTrigger;
+ GraphicsInterface* mGraphics; ///< Graphics interface
+ EGLSurface mEGLSurface;
+ EGLContext mEGLContext;
+ ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
+ OutputSignalType mOutputTransformedSignal;
+ FrameCallbackInfoContainer mFrameCallbackInfoContainer;
+ DamagedRectsContainer mBufferDamagedRects;
+ Dali::Mutex mMutex;
+ int mWindowRotationAngle;
+ int mScreenRotationAngle;
+ uint32_t mDpiHorizontal;
+ uint32_t mDpiVertical;
+ std::vector<Rect<int>> mDamagedRects{}; ///< Keeps collected damaged render items rects for one render pass
+ bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
+ bool mWindowRotationFinished;
+ bool mScreenRotationFinished;
+ bool mResizeFinished;
+ bool mDefaultScreenRotationAvailable;
+ bool mIsImeWindowSurface;
+ bool mNeedWindowRotationAcknowledgement;
}; // class WindowRenderSurface
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali