1 #ifndef DALI_RENDER_SURFACE_INTERFACE_H
2 #define DALI_RENDER_SURFACE_INTERFACE_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/core-enumerations.h>
24 #include <dali/public-api/math/vector4.h>
31 class DisplayConnection;
32 class ThreadSynchronizationInterface;
38 class AdaptorInternalServices;
39 class GraphicsInterface;
44 * @brief Interface for a render surface onto which Dali draws.
46 * Dali::Adaptor requires a render surface to draw on to. This is
47 * usually a window in the native windowing system, or some other
48 * mapped pixel buffer.
50 * Dali::Application will automatically create a render surface using a window.
52 * The implementation of the factory method below should choose an appropriate
53 * implementation of RenderSurface for the given platform
56 class RenderSurfaceInterface : public Dali::Integration::RenderSurface
62 * Inlined as this is a pure abstract interface
64 RenderSurfaceInterface()
65 : mAdaptor( nullptr ),
67 mDisplayConnection( nullptr ),
68 mDepthBufferRequired( Integration::DepthBufferAvailable::FALSE ),
69 mStencilBufferRequired( Integration::StencilBufferAvailable::FALSE ),
74 * @brief Virtual Destructor.
75 * Inlined as this is a pure abstract interface
77 virtual ~RenderSurfaceInterface() {}
80 * @brief Return the size and position of the surface.
81 * @return The position and size
83 virtual Dali::PositionSize GetPositionSize() const = 0;
87 * @param[out] dpiHorizontal set to the horizontal dpi
88 * @param[out] dpiVertical set to the vertical dpi
90 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
93 * @brief InitializeGraphics the platform specific graphics surface interfaces
95 virtual void InitializeGraphics() = 0;
98 * @brief Creates the Surface
100 virtual void CreateSurface() = 0;
103 * @brief Destroys the Surface
105 virtual void DestroySurface() = 0;
108 * @brief Replace the Surface
109 * @return true if context was lost
111 virtual bool ReplaceGraphicsSurface() = 0;
114 * @brief Resizes the underlying surface.
115 * @param[in] The dimensions of the new position
117 virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
120 * @brief Called when Render thread has started
122 virtual void StartRender() = 0;
125 * @brief Invoked by render thread before Core::Render
126 * If the operation fails, then Core::Render should not be called until there is
127 * a surface to render onto.
128 * @param[in] resizingSurface True if the surface is being resized
129 * @return True if the operation is successful, False if the operation failed
131 virtual bool PreRender( bool resizingSurface ) = 0;
134 * @brief Invoked by render thread after Core::Render
135 * @param[in] renderToFbo True if render to FBO.
136 * @param[in] replacingSurface True if the surface is being replaced.
137 * @param[in] resizingSurface True if the surface is being resized.
139 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) = 0;
141 * @brief Invoked by render thread when the thread should be stop
143 virtual void StopRender() = 0;
146 * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
148 virtual void ReleaseLock() = 0;
151 * @brief Sets the ThreadSynchronizationInterface
153 * @param threadSynchronization The thread-synchronization implementation.
155 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) = 0;
158 * @brief Gets the surface type
160 virtual Dali::Integration::RenderSurface::Type GetSurfaceType() = 0;
163 * @brief Makes the graphics context current
165 virtual void MakeContextCurrent() = 0;
168 * @brief Get whether the depth buffer is required
169 * @return TRUE if the depth buffer is required
171 virtual Integration::DepthBufferAvailable GetDepthBufferRequired() = 0;
174 * @brief Get whether the stencil buffer is required
175 * @return TRUE if the stencil buffer is required
177 virtual Integration::StencilBufferAvailable GetStencilBufferRequired() = 0;
180 * @brief Sets the background color of the surface.
181 * @param[in] color The new background color
183 virtual void SetBackgroundColor( Vector4 color ) override
185 mBackgroundColor = color;
189 * @brief Gets the background color of the surface.
190 * @return The background color
192 virtual Vector4 GetBackgroundColor() override
194 return mBackgroundColor;
199 void SetAdaptor( Dali::Internal::Adaptor::AdaptorInternalServices& adaptor )
204 void SetGraphicsInterface( Dali::Internal::Adaptor::GraphicsInterface& graphics )
206 mGraphics = &graphics;
209 void SetDisplayConnection( Dali::DisplayConnection& displayConnection )
211 mDisplayConnection = &displayConnection;
217 * @brief Undefined copy constructor. RenderSurface cannot be copied
219 RenderSurfaceInterface( const RenderSurfaceInterface& rhs );
222 * @brief Undefined assignment operator. RenderSurface cannot be copied
224 RenderSurfaceInterface& operator=( const RenderSurfaceInterface& rhs );
228 Dali::Internal::Adaptor::AdaptorInternalServices* mAdaptor;
229 Dali::Internal::Adaptor::GraphicsInterface* mGraphics;
230 Dali::DisplayConnection* mDisplayConnection;
234 Integration::DepthBufferAvailable mDepthBufferRequired; ///< Whether the depth buffer is required
235 Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
237 Vector4 mBackgroundColor; ///< The background color of the surface
242 #endif // DALI_RENDER_SURFACE_INTERFACE_H