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>
47 class RenderInstruction;
48 class RenderInstructionContainer;
53 * RenderManager is responsible for rendering the result of the previous "update", which
54 * is provided in a RenderCommand during UpdateManager::Update().
56 class RenderManager : public PostProcessResourceDispatcher
61 * Construct a new RenderManager.
62 * @param[in] glAbstraction The GL abstraction used for rendering.
63 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
65 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
68 * Non-virtual destructor; not intended as a base class
73 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
74 * @return The render queue.
76 RenderQueue& GetRenderQueue();
79 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
80 * accessor methods should only be used from the render thread.
81 * @return The texture cache
83 TextureCache& GetTextureCache();
86 * @copydoc Dali::Integration::Core::ContextCreated()
88 void ContextCreated();
91 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
93 void ContextDestroyed();
96 * Dispatch requests onto the postProcessResourcesQueue
97 * @param[in] request The request to dispatch
99 virtual void DispatchPostProcessRequest(ResourcePostProcessRequest& request);
102 * Retrieve the render instructions; these should be set during each "update" traversal.
103 * @return The render instruction container.
105 RenderInstructionContainer& GetRenderInstructionContainer();
107 // The following methods should be called via RenderQueue messages
110 * Set the background color i.e. the glClear color used at the beginning of each frame.
111 * @param[in] color The new background color.
113 void SetBackgroundColor( const Vector4& color );
116 * Set the frame time delta (time elapsed since the last frame.
117 * @param[in] deltaTime the delta time
119 void SetFrameDeltaTime( float deltaTime );
122 * Returns the rectangle for the default surface (probably the application window).
123 * @return Rectangle for the surface.
125 void SetDefaultSurfaceRect( const Rect<int>& rect );
128 * Add a Renderer to the render manager.
129 * @param[in] renderer The renderer to add.
130 * @post renderer is owned by RenderManager
132 void AddRenderer( Renderer* renderer );
135 * Remove a Renderer from the render manager.
136 * @param[in] renderer The renderer to remove.
137 * @post renderer is destroyed.
139 void RemoveRenderer( Renderer* renderer );
142 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
143 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
144 * object, usually an offscreen render task.
145 * @param[in] renderTracker The render tracker
147 void AddRenderTracker( RenderTracker* renderTracker );
150 * Removes a render tracker from the RenderManager.
151 * @param[in] renderTracker The render tracker to remove.
153 void RemoveRenderTracker( RenderTracker* renderTracker );
156 * Set the default shader that is to be used in absence of custom shader
157 * @param[in] shader that is the default one
159 void SetDefaultShader( Shader* shader );
162 * returns the Program controller for sending program messages
163 * @return the ProgramController
165 ProgramCache* GetProgramCache();
167 // This method should be called from Core::Render()
170 * Renders the results of the previous "update" traversal.
171 * @param[out] status contains the flag that indicates if render instructions exist
172 * @return true if a further update is required
174 bool Render( Integration::RenderStatus& status );
179 * Helper to process a single RenderInstruction.
180 * @param[in] instruction A description of the rendering operation.
181 * @param[in] defaultShader default shader to use.
182 * @param[in] elapsedTime from previous render.
184 void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
189 * Construct a new RenderManager.
194 RenderManager( const RenderManager& );
197 RenderManager& operator=( const RenderManager& rhs );
206 } // namespace SceneGraph
208 } // namespace Internal
212 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__