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>
25 #include <dali/internal/render/gl-resources/gpu-buffer.h>
48 class RenderInstruction;
49 class RenderInstructionContainer;
53 class PropertyBufferDataProvider;
56 * RenderManager is responsible for rendering the result of the previous "update", which
57 * is provided in a RenderCommand during UpdateManager::Update().
59 class RenderManager : public PostProcessResourceDispatcher
64 * Construct a new RenderManager.
65 * @param[in] glAbstraction The GL abstraction used for rendering.
66 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
68 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
71 * Non-virtual destructor; not intended as a base class
76 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
77 * @return The render queue.
79 RenderQueue& GetRenderQueue();
82 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
83 * accessor methods should only be used from the render thread.
84 * @return The texture cache
86 TextureCache& GetTextureCache();
89 * @copydoc Dali::Integration::Core::ContextCreated()
91 void ContextCreated();
94 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
96 void ContextDestroyed();
99 * Dispatch requests onto the postProcessResourcesQueue
100 * @param[in] request The request to dispatch
102 virtual void DispatchPostProcessRequest(ResourcePostProcessRequest& request);
105 * Retrieve the render instructions; these should be set during each "update" traversal.
106 * @return The render instruction container.
108 RenderInstructionContainer& GetRenderInstructionContainer();
110 // The following methods should be called via RenderQueue messages
113 * Set the background color i.e. the glClear color used at the beginning of each frame.
114 * @param[in] color The new background color.
116 void SetBackgroundColor( const Vector4& color );
119 * Set the frame time delta (time elapsed since the last frame.
120 * @param[in] deltaTime the delta time
122 void SetFrameDeltaTime( float deltaTime );
125 * Returns the rectangle for the default surface (probably the application window).
126 * @return Rectangle for the surface.
128 void SetDefaultSurfaceRect( const Rect<int>& rect );
131 * Add a Renderer to the render manager.
132 * @param[in] renderer The renderer to add.
133 * @post renderer is owned by RenderManager
135 void AddRenderer( Renderer* renderer );
138 * Remove a Renderer from the render manager.
139 * @param[in] renderer The renderer to remove.
140 * @post renderer is destroyed.
142 void RemoveRenderer( Renderer* renderer );
145 * Add a geometry to the render manager.
146 * @param[in] geometry The geometry to add.
147 * @post geometry is owned by RenderManager
149 void AddGeometry( RenderGeometry* geometry );
152 * Remove a geometry from the render manager.
153 * @param[in] geometry The geometry to remove.
154 * @post geometry is destroyed.
156 void RemoveGeometry( RenderGeometry* geometry );
159 * Adds a property buffer to a RenderGeometry from the render manager.
160 * @param[in] geometry The geometry
161 * @param[in] propertyBuffer The property buffer to remove.
162 * @param[in] target Specifies the type of the buffer
163 * @param[in] usage Specifies how will the buffer be used
165 void AddPropertyBuffer( RenderGeometry* renderGeometry, PropertyBufferDataProvider* propertyBuffer, const GpuBuffer::Target& target, const GpuBuffer::Usage& usage );
168 * Remove a property buffer from a RenderGeometry from the render manager.
169 * @param[in] geometry The geometry
170 * @param[in] propertyBuffer The property buffer to remove.
171 * @post property buffer is destroyed.
173 void RemovePropertyBuffer( RenderGeometry* renderGeometry, PropertyBufferDataProvider* propertyBuffer );
176 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
177 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
178 * object, usually an offscreen render task.
179 * @param[in] renderTracker The render tracker
181 void AddRenderTracker( RenderTracker* renderTracker );
184 * Removes a render tracker from the RenderManager.
185 * @param[in] renderTracker The render tracker to remove.
187 void RemoveRenderTracker( RenderTracker* renderTracker );
190 * Set the default shader that is to be used in absence of custom shader
191 * @param[in] shader that is the default one
193 void SetDefaultShader( Shader* shader );
196 * returns the Program controller for sending program messages
197 * @return the ProgramController
199 ProgramCache* GetProgramCache();
201 // This method should be called from Core::Render()
204 * Renders the results of the previous "update" traversal.
205 * @param[out] status contains the flag that indicates if render instructions exist
206 * @return true if a further update is required
208 bool Render( Integration::RenderStatus& status );
213 * Helper to process a single RenderInstruction.
214 * @param[in] instruction A description of the rendering operation.
215 * @param[in] defaultShader default shader to use.
216 * @param[in] elapsedTime from previous render.
218 void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
223 * Construct a new RenderManager.
228 RenderManager( const RenderManager& );
231 RenderManager& operator=( const RenderManager& rhs );
240 } // namespace SceneGraph
242 } // namespace Internal
246 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__