1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/signals/connection-tracker.h>
23 #include <dali/public-api/signals/dali-signal.h>
26 #include <dali/integration-api/adaptor-framework/egl-interface.h>
27 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
28 #include <dali/internal/graphics/common/graphics-interface.h>
33 class TriggerEventInterface;
41 class AdaptorInternalServices;
44 * Window interface of render surface.
46 class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
50 typedef Signal< void ( ) > OutputSignalType;
53 * Uses an window surface to render to.
54 * @param [in] positionSize the position and size of the surface
55 * @param [in] surface can be a window or pixmap.
56 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
58 WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
63 virtual ~WindowRenderSurface();
68 * @brief Get the native window handle
69 * @return The native window handle
71 Any GetNativeWindow();
74 * @brief Get the native window id
75 * @return The native window id
77 int GetNativeWindowId();
85 * @brief Sets the render notification trigger to call when render thread is completed a frame
86 * @param renderNotification to use
88 void SetRenderNotification( TriggerEventInterface* renderNotification );
91 * @brief Sets whether the surface is transparent or not.
92 * @param[in] transparent Whether the surface is transparent
94 void SetTransparency( bool transparent );
97 * Request surface rotation
98 * @param[in] angle A new angle of the surface
99 * @param[in] width A new width of the surface
100 * @param[in] height A new height of the surface
102 void RequestRotation( int angle, int width, int height );
105 * @brief Gets the window base object
106 * @return The window base object
108 WindowBase* GetWindowBase();
111 * @brief This signal is emitted when the output is transformed.
113 OutputSignalType& OutputTransformedSignal();
115 public: // from Dali::Integration::RenderSurface
118 * @copydoc Dali::Integration::RenderSurface::GetPositionSize()
120 virtual PositionSize GetPositionSize() const override;
124 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
127 * @brief Return the orientation of the surface.
128 * @return The orientation
130 virtual int GetOrientation() const override;
133 * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
135 virtual void InitializeGraphics() override;
138 * @copydoc Dali::Integration::RenderSurface::CreateSurface()
140 virtual void CreateSurface() override;
143 * @copydoc Dali::Integration::RenderSurface::DestroySurface()
145 virtual void DestroySurface() override;
148 * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
150 virtual bool ReplaceGraphicsSurface() override;
153 * @copydoc Dali::Integration::RenderSurface::MoveResize()
155 virtual void MoveResize( Dali::PositionSize positionSize) override;
158 * @copydoc Dali::Integration::RenderSurface::StartRender()
160 virtual void StartRender() override;
163 * @copydoc Dali::Integration::RenderSurface::PreRender()
165 virtual bool PreRender( bool resizingSurface ) override;
168 * @copydoc Dali::Integration::RenderSurface::PostRender()
170 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
173 * @copydoc Dali::Integration::RenderSurface::StopRender()
175 virtual void StopRender() override;
178 * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
180 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
183 * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
185 virtual void ReleaseLock() override;
188 * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
190 virtual Integration::RenderSurface::Type GetSurfaceType() override;
193 * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
195 virtual void MakeContextCurrent() override;
198 * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired()
200 virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
203 * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired()
205 virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
208 * @copydoc Dali::Integration::RenderSurface::SetDamagedRect()
210 virtual void SetDamagedRect( const Dali::DamagedRect& damagedRect, Dali::DamagedRect& mergedRect ) override;
213 * @copydoc Dali::Integration::RenderSurface::GetBufferAge()
215 virtual int32_t GetBufferAge() override;
220 * @brief Second stage construction
222 void Initialize( Any surface );
225 * Notify output is transformed.
227 void OutputTransformed();
230 * @brief Used as the callback for the rotation-trigger.
232 void ProcessRotationRequest();
237 std::vector<int32_t> MergeRect( const Rect<int32_t>& damagedRectArray, int bufferAge );
242 WindowRenderSurface(const WindowRenderSurface&) = delete;
245 WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
250 Dali::DisplayConnection* mDisplayConnection;
251 PositionSize mPositionSize; ///< Position
252 std::unique_ptr< WindowBase > mWindowBase;
253 ThreadSynchronizationInterface* mThreadSynchronization;
254 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
255 TriggerEventInterface* mRotationTrigger;
256 GraphicsInterface* mGraphics; ///< Graphics interface
257 EGLSurface mEGLSurface;
258 EGLContext mEGLContext;
259 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
260 OutputSignalType mOutputTransformedSignal;
262 int mScreenRotationAngle;
265 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
266 bool mRotationSupported;
267 bool mRotationFinished;
268 bool mScreenRotationFinished;
269 bool mResizeFinished;
271 uint32_t mDpiHorizontal;
272 uint32_t mDpiVertical;
274 Rect<int32_t> mPreDamagedRect[5]; ///< The GPU driver can has up to four buffers. And one is for area calculation.
275 }; // class WindowRenderSurface
277 } // namespace Adaptor
279 } // namespace internal
283 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H