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/render/common/post-process-resource-dispatcher.h>
24 #include <dali/internal/update/resources/resource-manager-declarations.h>
48 class RenderInstruction;
49 class RenderInstructionContainer;
54 * RenderManager is responsible for rendering the result of the previous "update", which
55 * is provided in a RenderCommand during UpdateManager::Update().
57 class RenderManager : public PostProcessResourceDispatcher
62 * Construct a new RenderManager.
63 * @param[in] glAbstraction The GL abstraction used for rendering.
64 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
66 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
69 * Non-virtual destructor; not intended as a base class
74 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
75 * @return The render queue.
77 RenderQueue& GetRenderQueue();
80 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
81 * accessor methods should only be used from the render thread.
82 * @return The texture cache
84 TextureCache& GetTextureCache();
87 * @copydoc Dali::Integration::Core::ContextCreated()
89 void ContextCreated();
92 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
94 void ContextDestroyed();
97 * Dispatch requests onto the postProcessResourcesQueue
98 * @param[in] request The request to dispatch
100 virtual void DispatchPostProcessRequest(ResourcePostProcessRequest& request);
103 * Retrieve the render instructions; these should be set during each "update" traversal.
104 * @return The render instruction container.
106 RenderInstructionContainer& GetRenderInstructionContainer();
108 // The following methods should be called via RenderQueue messages
111 * Set the background color i.e. the glClear color used at the beginning of each frame.
112 * @param[in] color The new background color.
114 void SetBackgroundColor( const Vector4& color );
117 * Set the frame time delta (time elapsed since the last frame.
118 * @param[in] deltaTime the delta time
120 void SetFrameDeltaTime( float deltaTime );
123 * Returns the rectangle for the default surface (probably the application window).
124 * @return Rectangle for the surface.
126 void SetDefaultSurfaceRect( const Rect<int>& rect );
129 * Add a Renderer to the render manager.
130 * @param[in] renderer The renderer to add.
131 * @post renderer is owned by RenderManager
133 void AddRenderer( Renderer* renderer );
136 * Remove a Renderer from the render manager.
137 * @param[in] renderer The renderer to remove.
138 * @post renderer is destroyed.
140 void RemoveRenderer( Renderer* renderer );
143 * Adds a RenderMaterial to the render manager for MeshRenderers to use.
144 * The RenderManager takes ownership of the material
145 * @param[in] renderMaterial
146 * @post renderMaterial is owned by RenderManager
148 void AddRenderMaterial( RenderMaterial* renderMaterial );
151 * Removes a RenderMaterial from the RenderManager
152 * RenderManager will destroy the material
153 * @pre renderManager owns the materail
154 * @param[in] renderMaterial
155 * @post renderMaterial is destroyed
157 void RemoveRenderMaterial( RenderMaterial* renderMaterial );
160 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
161 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
162 * object, usually an offscreen render task.
163 * @param[in] renderTracker The render tracker
165 void AddRenderTracker( RenderTracker* renderTracker );
168 * Removes a render tracker from the RenderManager.
169 * @param[in] renderTracker The render tracker to remove.
171 void RemoveRenderTracker( RenderTracker* renderTracker );
174 * Set the default shader that is to be used in absence of custom shader
175 * @param[in] shader that is the default one
177 void SetDefaultShader( Shader* shader );
180 * returns the Program controller for sending program messages
181 * @return the ProgramController
183 ProgramCache* GetProgramCache();
185 // This method should be called from Core::Render()
188 * Renders the results of the previous "update" traversal.
189 * @param[out] status contains the flag that indicates if render instructions exist
190 * @return true if a further update is required
192 bool Render( Integration::RenderStatus& status );
197 * Helper to process a single RenderInstruction.
198 * @param[in] instruction A description of the rendering operation.
199 * @param[in] defaultShader default shader to use.
200 * @param[in] elapsedTime from previous render.
202 void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
207 * Construct a new RenderManager.
212 RenderManager( const RenderManager& );
215 RenderManager& operator=( const RenderManager& rhs );
224 } // namespace SceneGraph
226 } // namespace Internal
230 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__