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>
24 #include <dali/internal/graphics/common/graphics-interface.h>
27 #include <dali/public-api/signals/connection-tracker.h>
28 #include <dali/public-api/signals/dali-signal.h>
34 class TriggerEventInterface;
44 * Window interface of render surface.
46 class WindowRenderSurface : public Dali::RenderSurface, 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::RenderSurface
118 * @copydoc Dali::RenderSurface::GetPositionSize()
120 virtual PositionSize GetPositionSize() const override;
124 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
127 * @copydoc Dali::RenderSurface::InitializeGraphics()
129 virtual void InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) override;
132 * @copydoc Dali::RenderSurface::CreateSurface()
134 virtual void CreateSurface() override;
137 * @copydoc Dali::RenderSurface::DestroySurface()
139 virtual void DestroySurface() override;
142 * @copydoc Dali::RenderSurface::ReplaceGraphicsSurface()
144 virtual bool ReplaceGraphicsSurface() override;
147 * @copydoc Dali::RenderSurface::MoveResize()
149 virtual void MoveResize( Dali::PositionSize positionSize) override;
152 * @copydoc Dali::RenderSurface::StartRender()
154 virtual void StartRender() override;
157 * @copydoc Dali::RenderSurface::PreRender()
159 virtual bool PreRender( bool resizingSurface ) override;
162 * @copydoc Dali::RenderSurface::PostRender()
164 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
167 * @copydoc Dali::RenderSurface::StopRender()
169 virtual void StopRender() override;
172 * @copydoc Dali::RenderSurface::SetThreadSynchronization
174 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
177 * @copydoc Dali::RenderSurface::ReleaseLock()
179 virtual void ReleaseLock() override;
182 * @copydoc Dali::RenderSurface::GetSurfaceType()
184 virtual RenderSurface::Type GetSurfaceType() override;
189 * @brief Second stage construction
191 void Initialize( Any surface );
194 * Notify output is transformed.
196 void OutputTransformed();
199 * @brief Used as the callback for the rotation-trigger.
201 void ProcessRotationRequest();
206 WindowRenderSurface(const WindowRenderSurface&) = delete;
209 WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
213 PositionSize mPositionSize; ///< Position
214 std::unique_ptr< WindowBase > mWindowBase;
215 ThreadSynchronizationInterface* mThreadSynchronization;
216 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
217 TriggerEventInterface* mRotationTrigger;
218 GraphicsInterface* mGraphics; ///< Graphics interface
219 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
220 OutputSignalType mOutputTransformedSignal;
222 int mScreenRotationAngle;
223 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
224 bool mRotationSupported;
225 bool mRotationFinished;
226 bool mScreenRotationFinished;
227 bool mResizeFinished;
229 }; // class WindowRenderSurface
231 } // namespace Adaptor
233 } // namespace internal
237 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H