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>
54 class RenderInstruction;
55 class RenderInstructionContainer;
59 class PropertyBufferDataProvider;
62 * RenderManager is responsible for rendering the result of the previous "update", which
63 * is provided in a RenderCommand during UpdateManager::Update().
65 class RenderManager : public PostProcessResourceDispatcher
70 * Construct a new RenderManager.
71 * @param[in] glAbstraction The GL abstraction used for rendering.
72 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
74 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
77 * Non-virtual destructor; not intended as a base class
82 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
83 * @return The render queue.
85 RenderQueue& GetRenderQueue();
88 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
89 * accessor methods should only be used from the render thread.
90 * @return The texture cache
92 TextureCache& GetTextureCache();
95 * @copydoc Dali::Integration::Core::ContextCreated()
97 void ContextCreated();
100 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
102 void ContextDestroyed();
105 * Dispatch requests onto the postProcessResourcesQueue
106 * @param[in] request The request to dispatch
108 virtual void DispatchPostProcessRequest( ResourcePostProcessRequest& request );
111 * Set the upstream interface for compiled shader binaries to be sent back to for eventual
112 * caching and saving.
113 * @param[in] upstream The abstract interface to send any received ShaderDatas onwards to..
114 * @note This should be called during core initialisation if shader binaries are to be used.
116 void SetShaderSaver( ShaderSaver& upstream );
119 * Retrieve the render instructions; these should be set during each "update" traversal.
120 * @return The render instruction container.
122 RenderInstructionContainer& GetRenderInstructionContainer();
124 // The following methods should be called via RenderQueue messages
127 * Set the background color i.e. the glClear color used at the beginning of each frame.
128 * @param[in] color The new background color.
130 void SetBackgroundColor( const Vector4& color );
133 * Set the frame time delta (time elapsed since the last frame.
134 * @param[in] deltaTime the delta time
136 void SetFrameDeltaTime( float deltaTime );
139 * Returns the rectangle for the default surface (probably the application window).
140 * @return Rectangle for the surface.
142 void SetDefaultSurfaceRect( const Rect<int>& rect );
145 * Add a Renderer to the render manager.
146 * @param[in] renderer The renderer to add.
147 * @post renderer is owned by RenderManager
149 void AddRenderer( Render::Renderer* renderer );
152 * Remove a Renderer from the render manager.
153 * @param[in] renderer The renderer to remove.
154 * @post renderer is destroyed.
156 void RemoveRenderer( Render::Renderer* renderer );
159 * Add a geometry to the render manager.
160 * @param[in] geometry The geometry to add.
161 * @post geometry is owned by RenderManager
163 void AddGeometry( RenderGeometry* geometry );
166 * Remove a geometry from the render manager.
167 * @param[in] geometry The geometry to remove.
168 * @post geometry is destroyed.
170 void RemoveGeometry( RenderGeometry* geometry );
173 * Adds a property buffer to a RenderGeometry from the render manager.
174 * @param[in] geometry The geometry
175 * @param[in] propertyBuffer The property buffer to remove.
176 * @param[in] target Specifies the type of the buffer
177 * @param[in] usage Specifies how will the buffer be used
179 void AddPropertyBuffer( RenderGeometry* renderGeometry, PropertyBufferDataProvider* propertyBuffer, const GpuBuffer::Target& target, const GpuBuffer::Usage& usage );
182 * Remove a property buffer from a RenderGeometry from the render manager.
183 * @param[in] geometry The geometry
184 * @param[in] propertyBuffer The property buffer to remove.
185 * @post property buffer is destroyed.
187 void RemovePropertyBuffer( RenderGeometry* renderGeometry, PropertyBufferDataProvider* propertyBuffer );
190 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
191 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
192 * object, usually an offscreen render task.
193 * @param[in] renderTracker The render tracker
195 void AddRenderTracker( RenderTracker* renderTracker );
198 * Removes a render tracker from the RenderManager.
199 * @param[in] renderTracker The render tracker to remove.
201 void RemoveRenderTracker( RenderTracker* renderTracker );
204 * Set the default shader that is to be used in absence of custom shader
205 * @param[in] shader that is the default one
207 void SetDefaultShader( Shader* shader );
210 * returns the Program controller for sending program messages
211 * @return the ProgramController
213 ProgramCache* GetProgramCache();
215 // This method should be called from Core::Render()
218 * Renders the results of the previous "update" traversal.
219 * @param[out] status contains the flag that indicates if render instructions exist
220 * @return true if a further update is required
222 bool Render( Integration::RenderStatus& status );
227 * Helper to process a single RenderInstruction.
228 * @param[in] instruction A description of the rendering operation.
229 * @param[in] defaultShader default shader to use.
230 * @param[in] elapsedTime from previous render.
232 void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
237 * Construct a new RenderManager.
242 RenderManager( const RenderManager& );
245 RenderManager& operator=( const RenderManager& rhs );
254 } // namespace SceneGraph
256 } // namespace Internal
260 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__