1 #ifndef DALI_RENDER_SURFACE_H
2 #define DALI_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/math/rect.h>
23 #include <dali/public-api/math/vector4.h>
24 #include <dali/public-api/object/any.h>
25 #include <dali/public-api/common/view-mode.h>
26 #include <dali/integration-api/core-enumerations.h>
31 class DisplayConnection;
32 class ThreadSynchronizationInterface;
40 class GraphicsInterface;
42 } // namespace Adaptor
44 } // namespace Internal
47 * @brief The position and size of the render surface.
49 typedef Dali::Rect<int> PositionSize;
57 * @brief Interface for a render surface onto which Dali draws.
59 * Dali::Adaptor requires a render surface to draw on to. This is
60 * usually a window in the native windowing system, or some other
61 * mapped pixel buffer.
63 * Dali::Application will automatically create a render surface using a window.
65 * The implementation of the factory method below should choose an appropriate
66 * implementation of RenderSurface for the given platform
69 class DALI_CORE_API RenderSurface
75 WINDOW_RENDER_SURFACE,
76 PIXMAP_RENDER_SURFACE,
82 * Inlined as this is a pure abstract interface
87 * @brief Virtual Destructor.
88 * Inlined as this is a pure abstract interface
90 virtual ~RenderSurface() {}
93 * @brief Return the size and position of the surface.
94 * @return The position and size
96 virtual PositionSize GetPositionSize() const = 0;
100 * @param[out] dpiHorizontal set to the horizontal dpi
101 * @param[out] dpiVertical set to the vertical dpi
103 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
106 * @brief InitializeGraphics the platform specific graphics surface interfaces
108 virtual void InitializeGraphics() = 0;
111 * @brief Creates the Surface
113 virtual void CreateSurface() = 0;
116 * @brief Destroys the Surface
118 virtual void DestroySurface() = 0;
121 * @brief Replace the Surface
122 * @return true if context was lost
124 virtual bool ReplaceGraphicsSurface() = 0;
127 * @brief Resizes the underlying surface.
128 * @param[in] The dimensions of the new position
130 virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
133 * @brief Called when Render thread has started
135 virtual void StartRender() = 0;
138 * @brief Invoked by render thread before Core::Render
139 * If the operation fails, then Core::Render should not be called until there is
140 * a surface to render onto.
141 * @param[in] resizingSurface True if the surface is being resized
142 * @return True if the operation is successful, False if the operation failed
144 virtual bool PreRender( bool resizingSurface ) = 0;
147 * @brief Invoked by render thread after Core::Render
148 * @param[in] renderToFbo True if render to FBO.
149 * @param[in] replacingSurface True if the surface is being replaced.
150 * @param[in] resizingSurface True if the surface is being resized.
152 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) = 0;
155 * @brief Invoked by render thread when the thread should be stop
157 virtual void StopRender() = 0;
160 * @brief Invoked by Event Thread when the compositor lock should be released and rendering should resume.
162 virtual void ReleaseLock() = 0;
165 * @brief Gets the surface type
167 virtual RenderSurface::Type GetSurfaceType() = 0;
170 * @brief Makes the graphics context current
172 virtual void MakeContextCurrent() = 0;
175 * @brief Gets whether the depth buffer is required
176 * @return TRUE if the depth buffer is required
178 virtual Integration::DepthBufferAvailable GetDepthBufferRequired() = 0;
181 * @brief Gets whether the stencil buffer is required
182 * @return TRUE if the stencil buffer is required
184 virtual Integration::StencilBufferAvailable GetStencilBufferRequired() = 0;
189 * @brief Undefined copy constructor. RenderSurface cannot be copied
191 RenderSurface( const RenderSurface& rhs ) = delete;
194 * @brief Undefined assignment operator. RenderSurface cannot be copied
196 RenderSurface& operator=( const RenderSurface& rhs ) = delete;
199 } // namespace Integration
203 #endif // DALI_RENDER_SURFACE_H