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/integration-api/render-surface.h>
23 #include <dali/integration-api/egl-interface.h>
26 #include <dali/public-api/signals/connection-tracker.h>
32 class TriggerEventInterface;
42 * Window interface of render surface.
44 class WindowRenderSurface : public Dali::RenderSurface, public ConnectionTracker
49 * Uses an window surface to render to.
50 * @param [in] positionSize the position and size of the surface
51 * @param [in] surface can be a window or pixmap.
52 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
54 WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
59 virtual ~WindowRenderSurface();
64 * @brief Get the native window handle
65 * @return The native window handle
67 Any GetNativeWindow();
70 * @brief Get the native window id
71 * @return The native window id
73 int GetNativeWindowId();
81 * @brief Sets the render notification trigger to call when render thread is completed a frame
82 * @param renderNotification to use
84 void SetRenderNotification( TriggerEventInterface* renderNotification );
87 * @brief Sets whether the surface is transparent or not.
88 * @param[in] transparent Whether the surface is transparent
90 void SetTransparency( bool transparent );
93 * Request surface rotation
94 * @param[in] angle A new angle of the surface
95 * @param[in] width A new width of the surface
96 * @param[in] height A new height of the surface
98 void RequestRotation( int angle, int width, int height );
101 * @brief Gets the window base object
102 * @return The window base object
104 WindowBase* GetWindowBase();
106 public: // from Dali::RenderSurface
109 * @copydoc Dali::RenderSurface::GetPositionSize()
111 virtual PositionSize GetPositionSize() const override;
114 * @copydoc Dali::RenderSurface::GetDpi()
116 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
119 * @copydoc Dali::RenderSurface::InitializeEgl()
121 virtual void InitializeEgl( EglInterface& egl ) override;
124 * @copydoc Dali::RenderSurface::CreateEglSurface()
126 virtual void CreateEglSurface( EglInterface& egl ) override;
129 * @copydoc Dali::RenderSurface::DestroyEglSurface()
131 virtual void DestroyEglSurface( EglInterface& egl ) override;
134 * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
136 virtual bool ReplaceEGLSurface( EglInterface& egl ) override;
139 * @copydoc Dali::RenderSurface::MoveResize()
141 virtual void MoveResize( Dali::PositionSize positionSize) override;
144 * @copydoc Dali::RenderSurface::SetViewMode()
146 virtual void SetViewMode( ViewMode viewMode ) override;
149 * @copydoc Dali::RenderSurface::StartRender()
151 virtual void StartRender() override;
154 * @copydoc Dali::RenderSurface::PreRender()
156 virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override;
159 * @copydoc Dali::RenderSurface::PostRender()
161 virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) override;
164 * @copydoc Dali::RenderSurface::StopRender()
166 virtual void StopRender() override;
169 * @copydoc Dali::RenderSurface::SetThreadSynchronization
171 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
174 * @copydoc Dali::RenderSurface::ReleaseLock()
176 virtual void ReleaseLock() override;
179 * @copydoc Dali::RenderSurface::GetSurfaceType()
181 virtual RenderSurface::Type GetSurfaceType() override;
186 * @brief Second stage construction
188 void Initialize( Any surface );
191 * Notify output is transformed.
193 void OutputTransformed();
196 * @brief Used as the callback for the rotation-trigger.
198 void ProcessRotationRequest();
203 WindowRenderSurface(const WindowRenderSurface&) = delete;
206 WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
210 PositionSize mPositionSize; ///< Position
211 std::unique_ptr< WindowBase > mWindowBase;
212 ThreadSynchronizationInterface* mThreadSynchronization;
213 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
214 TriggerEventInterface* mRotationTrigger;
215 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
217 int mScreenRotationAngle;
218 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
219 bool mRotationSupported;
220 bool mRotationFinished;
221 bool mScreenRotationFinished;
222 bool mResizeFinished;
224 }; // class WindowRenderSurface
226 } // namespace Adaptor
228 } // namespace internal
232 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H