1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__
5 * Copyright (c) 2014 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/internal/common/shader-saver.h>
24 #include <dali/internal/render/common/post-process-resource-dispatcher.h>
25 #include <dali/internal/update/resources/resource-manager-declarations.h>
26 #include <dali/internal/render/gl-resources/gpu-buffer.h>
50 class RenderInstruction;
51 class RenderInstructionContainer;
55 class PropertyBufferDataProvider;
58 * RenderManager is responsible for rendering the result of the previous "update", which
59 * is provided in a RenderCommand during UpdateManager::Update().
61 class RenderManager : public PostProcessResourceDispatcher
66 * Construct a new RenderManager.
67 * @param[in] glAbstraction The GL abstraction used for rendering.
68 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
70 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
73 * Non-virtual destructor; not intended as a base class
78 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
79 * @return The render queue.
81 RenderQueue& GetRenderQueue();
84 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
85 * accessor methods should only be used from the render thread.
86 * @return The texture cache
88 TextureCache& GetTextureCache();
91 * @copydoc Dali::Integration::Core::ContextCreated()
93 void ContextCreated();
96 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
98 void ContextDestroyed();
101 * Dispatch requests onto the postProcessResourcesQueue
102 * @param[in] request The request to dispatch
104 virtual void DispatchPostProcessRequest( ResourcePostProcessRequest& request );
107 * Set the upstream interface for compiled shader binaries to be sent back to for eventual
108 * caching and saving.
109 * @param[in] upstream The abstract interface to send any received ShaderDatas onwards to..
110 * @note This should be called during core initialisation if shader binaries are to be used.
112 void SetShaderSaver( ShaderSaver& upstream );
115 * Retrieve the render instructions; these should be set during each "update" traversal.
116 * @return The render instruction container.
118 RenderInstructionContainer& GetRenderInstructionContainer();
120 // The following methods should be called via RenderQueue messages
123 * Set the background color i.e. the glClear color used at the beginning of each frame.
124 * @param[in] color The new background color.
126 void SetBackgroundColor( const Vector4& color );
129 * Set the frame time delta (time elapsed since the last frame.
130 * @param[in] deltaTime the delta time
132 void SetFrameDeltaTime( float deltaTime );
135 * Returns the rectangle for the default surface (probably the application window).
136 * @return Rectangle for the surface.
138 void SetDefaultSurfaceRect( const Rect<int>& rect );
141 * Add a Renderer to the render manager.
142 * @param[in] renderer The renderer to add.
143 * @post renderer is owned by RenderManager
145 void AddRenderer( Renderer* renderer );
148 * Remove a Renderer from the render manager.
149 * @param[in] renderer The renderer to remove.
150 * @post renderer is destroyed.
152 void RemoveRenderer( Renderer* renderer );
155 * Add a geometry to the render manager.
156 * @param[in] geometry The geometry to add.
157 * @post geometry is owned by RenderManager
159 void AddGeometry( RenderGeometry* geometry );
162 * Remove a geometry from the render manager.
163 * @param[in] geometry The geometry to remove.
164 * @post geometry is destroyed.
166 void RemoveGeometry( RenderGeometry* geometry );
169 * Adds a property buffer to a RenderGeometry from the render manager.
170 * @param[in] geometry The geometry
171 * @param[in] propertyBuffer The property buffer to remove.
172 * @param[in] target Specifies the type of the buffer
173 * @param[in] usage Specifies how will the buffer be used
175 void AddPropertyBuffer( RenderGeometry* renderGeometry, PropertyBufferDataProvider* propertyBuffer, const GpuBuffer::Target& target, const GpuBuffer::Usage& usage );
178 * Remove a property buffer from a RenderGeometry from the render manager.
179 * @param[in] geometry The geometry
180 * @param[in] propertyBuffer The property buffer to remove.
181 * @post property buffer is destroyed.
183 void RemovePropertyBuffer( RenderGeometry* renderGeometry, PropertyBufferDataProvider* propertyBuffer );
186 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
187 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
188 * object, usually an offscreen render task.
189 * @param[in] renderTracker The render tracker
191 void AddRenderTracker( RenderTracker* renderTracker );
194 * Removes a render tracker from the RenderManager.
195 * @param[in] renderTracker The render tracker to remove.
197 void RemoveRenderTracker( RenderTracker* renderTracker );
200 * Set the default shader that is to be used in absence of custom shader
201 * @param[in] shader that is the default one
203 void SetDefaultShader( Shader* shader );
206 * returns the Program controller for sending program messages
207 * @return the ProgramController
209 ProgramCache* GetProgramCache();
211 // This method should be called from Core::Render()
214 * Renders the results of the previous "update" traversal.
215 * @param[out] status contains the flag that indicates if render instructions exist
216 * @return true if a further update is required
218 bool Render( Integration::RenderStatus& status );
223 * Helper to process a single RenderInstruction.
224 * @param[in] instruction A description of the rendering operation.
225 * @param[in] defaultShader default shader to use.
226 * @param[in] elapsedTime from previous render.
228 void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
233 * Construct a new RenderManager.
238 RenderManager( const RenderManager& );
241 RenderManager& operator=( const RenderManager& rhs );
250 } // namespace SceneGraph
252 } // namespace Internal
256 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__