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/message.h>
24 #include <dali/internal/render/common/post-process-resource-dispatcher.h>
25 #include <dali/internal/render/gl-resources/bitmap-texture.h>
26 #include <dali/internal/update/common/double-buffered.h>
27 #include <dali/internal/update/resources/resource-manager-declarations.h>
51 class RenderInstruction;
52 class RenderInstructionContainer;
57 * RenderManager is responsible for rendering the result of the previous "update", which
58 * is provided in a RenderCommand during UpdateManager::Update().
60 class RenderManager : public PostProcessResourceDispatcher
65 * Construct a new RenderManager.
66 * @param[in] glAbstraction The GL abstraction used for rendering.
67 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
69 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
72 * Non-virtual destructor; not intended as a base class
77 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
78 * @return The render queue.
80 RenderQueue& GetRenderQueue();
83 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
84 * accessor methods should only be used from the render thread.
85 * @return The texture cache
87 TextureCache& GetTextureCache();
90 * @copydoc Dali::Integration::Core::ContextCreated()
92 void ContextCreated();
95 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
97 void ContextDestroyed();
100 * Dispatch requests onto the postProcessResourcesQueue
101 * @param[in] request The request to dispatch
103 virtual void DispatchPostProcessRequest(ResourcePostProcessRequest& request);
106 * Retrieve the render instructions; these should be set during each "update" traversal.
107 * @return The render instruction container.
109 RenderInstructionContainer& GetRenderInstructionContainer();
111 // The following methods should be called via RenderQueue messages
114 * Set the background color i.e. the glClear color used at the beginning of each frame.
115 * @param[in] color The new background color.
117 void SetBackgroundColor( const Vector4& color );
120 * Set the frame time delta (time elapsed since the last frame.
121 * @param[in] deltaTime the delta time
123 void SetFrameDeltaTime( float deltaTime );
126 * Returns the rectangle for the default surface (probably the application window).
127 * @return Rectangle for the surface.
129 void SetDefaultSurfaceRect( const Rect<int>& rect );
132 * Add a Renderer to the render manager.
133 * @param[in] renderer The renderer to add.
134 * @post renderer is owned by RenderManager
136 void AddRenderer( Renderer* renderer );
139 * Remove a Renderer from the render manager.
140 * @param[in] renderer The renderer to remove.
141 * @post renderer is destroyed.
143 void RemoveRenderer( Renderer* renderer );
146 * Adds a RenderMaterial to the render manager for MeshRenderers to use.
147 * The RenderManager takes ownership of the material
148 * @param[in] renderMaterial
149 * @post renderMaterial is owned by RenderManager
151 void AddRenderMaterial( RenderMaterial* renderMaterial );
154 * Removes a RenderMaterial from the RenderManager
155 * RenderManager will destroy the material
156 * @pre renderManager owns the materail
157 * @param[in] renderMaterial
158 * @post renderMaterial is destroyed
160 void RemoveRenderMaterial( RenderMaterial* renderMaterial );
163 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
164 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
165 * object, usually an offscreen render task.
166 * @param[in] renderTracker The render tracker
168 void AddRenderTracker( RenderTracker* renderTracker );
171 * Removes a render tracker from the RenderManager.
172 * @param[in] renderTracker The render tracker to remove.
174 void RemoveRenderTracker( RenderTracker* renderTracker );
177 * Set the default shader that is to be used in absence of custom shader
178 * @param[in] shader that is the default one
180 void SetDefaultShader( Shader* shader );
183 * returns the Program controller for sending program messages
184 * @return the ProgramController
186 ProgramCache* GetProgramCache();
188 // This method should be called from Core::Render()
191 * Renders the results of the previous "update" traversal.
192 * @param[out] status contains the flag that indicates if render instructions exist
193 * @return true if a further update is required
195 bool Render( Integration::RenderStatus& status );
200 * Helper to process a single RenderInstruction.
201 * @param[in] instruction A description of the rendering operation.
202 * @param[in] defaultShader default shader to use.
203 * @param[in] elapsedTime from previous render.
205 void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
210 * Construct a new RenderManager.
215 RenderManager( const RenderManager& );
218 RenderManager& operator=( const RenderManager& rhs );
227 } // namespace SceneGraph
229 } // namespace Internal
233 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__