1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H
5 * Copyright (c) 2018 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/internal/graphics/common/graphics-interface.h>
24 #ifdef DALI_ADAPTOR_COMPILATION
25 #include <dali/integration-api/egl-interface.h>
26 #include <dali/integration-api/render-surface-interface.h>
28 #include <dali/integration-api/adaptors/egl-interface.h>
29 #include <dali/integration-api/adaptors/render-surface-interface.h>
33 #include <dali/public-api/signals/connection-tracker.h>
34 #include <dali/public-api/signals/dali-signal.h>
39 class TriggerEventInterface;
47 class AdaptorInternalServices;
50 * Window interface of render surface.
52 class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
56 typedef Signal< void ( ) > OutputSignalType;
59 * Uses an window surface to render to.
60 * @param [in] positionSize the position and size of the surface
61 * @param [in] surface can be a window or pixmap.
62 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
64 WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
69 virtual ~WindowRenderSurface();
74 * @brief Get the native window handle
75 * @return The native window handle
77 Any GetNativeWindow();
80 * @brief Get the native window id
81 * @return The native window id
83 int GetNativeWindowId();
91 * @brief Sets the render notification trigger to call when render thread is completed a frame
92 * @param renderNotification to use
94 void SetRenderNotification( TriggerEventInterface* renderNotification );
97 * @brief Sets whether the surface is transparent or not.
98 * @param[in] transparent Whether the surface is transparent
100 void SetTransparency( bool transparent );
103 * Request surface rotation
104 * @param[in] angle A new angle of the surface
105 * @param[in] width A new width of the surface
106 * @param[in] height A new height of the surface
108 void RequestRotation( int angle, int width, int height );
111 * @brief Gets the window base object
112 * @return The window base object
114 WindowBase* GetWindowBase();
117 * @brief This signal is emitted when the output is transformed.
119 OutputSignalType& OutputTransformedSignal();
121 public: // from Dali::Integration::RenderSurface
124 * @copydoc Dali::Integration::RenderSurface::GetPositionSize()
126 virtual PositionSize GetPositionSize() const override;
130 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
133 * @brief Return the orientation of the surface.
134 * @return The orientation
136 virtual int GetOrientation() const override;
139 * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
141 virtual void InitializeGraphics() override;
144 * @copydoc Dali::Integration::RenderSurface::CreateSurface()
146 virtual void CreateSurface() override;
149 * @copydoc Dali::Integration::RenderSurface::DestroySurface()
151 virtual void DestroySurface() override;
154 * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
156 virtual bool ReplaceGraphicsSurface() override;
159 * @copydoc Dali::Integration::RenderSurface::MoveResize()
161 virtual void MoveResize( Dali::PositionSize positionSize) override;
164 * @copydoc Dali::Integration::RenderSurface::StartRender()
166 virtual void StartRender() override;
169 * @copydoc Dali::Integration::RenderSurface::PreRender()
171 virtual bool PreRender( bool resizingSurface ) override;
174 * @copydoc Dali::Integration::RenderSurface::PostRender()
176 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
179 * @copydoc Dali::Integration::RenderSurface::StopRender()
181 virtual void StopRender() override;
184 * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
186 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
189 * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
191 virtual void ReleaseLock() override;
194 * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
196 virtual Integration::RenderSurface::Type GetSurfaceType() override;
199 * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
201 virtual void MakeContextCurrent() override;
204 * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired()
206 virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
209 * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired()
211 virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
214 * @copydoc Dali::Integration::RenderSurface::SetDamagedRect()
216 virtual void SetDamagedRect( const Dali::DamagedRect& damagedRect, Dali::DamagedRect& mergedRect ) override;
219 * @copydoc Dali::Integration::RenderSurface::GetBufferAge()
221 virtual int32_t GetBufferAge() override;
226 * @brief Second stage construction
228 void Initialize( Any surface );
231 * Notify output is transformed.
233 void OutputTransformed();
236 * @brief Used as the callback for the rotation-trigger.
238 void ProcessRotationRequest();
243 std::vector<int32_t> MergeRect( const Rect<int32_t>& damagedRectArray, int bufferAge );
248 WindowRenderSurface(const WindowRenderSurface&) = delete;
251 WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
256 Dali::DisplayConnection* mDisplayConnection;
257 PositionSize mPositionSize; ///< Position
258 std::unique_ptr< WindowBase > mWindowBase;
259 ThreadSynchronizationInterface* mThreadSynchronization;
260 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
261 TriggerEventInterface* mRotationTrigger;
262 GraphicsInterface* mGraphics; ///< Graphics interface
263 EGLSurface mEGLSurface;
264 EGLContext mEGLContext;
265 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
266 OutputSignalType mOutputTransformedSignal;
268 int mScreenRotationAngle;
271 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
272 bool mRotationSupported;
273 bool mRotationFinished;
274 bool mScreenRotationFinished;
275 bool mResizeFinished;
277 uint32_t mDpiHorizontal;
278 uint32_t mDpiVertical;
280 Rect<int32_t> mPreDamagedRect[5]; ///< The GPU driver can has up to four buffers. And one is for area calculation.
281 }; // class WindowRenderSurface
283 } // namespace Adaptor
285 } // namespace internal
289 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H