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/internal/common/message.h>
23 #include <dali/internal/render/common/post-process-resource-dispatcher.h>
24 #include <dali/internal/render/gl-resources/bitmap-texture.h>
25 #include <dali/internal/update/common/double-buffered.h>
26 #include <dali/internal/update/resources/resource-manager-declarations.h>
27 #include <dali/public-api/math/rect.h>
48 class DynamicsDebugRenderer;
51 class RenderInstruction;
52 class RenderInstructionContainer;
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 * Retrieves the context. Can only be called inside render thread
90 * TODO remove this when programs are initialized in render thread
91 * @return reference to the context
93 Context& GetContext();
96 * @copydoc Dali::Integration::Core::ContextCreated()
98 void ContextCreated();
101 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
103 void ContextDestroyed();
106 * Dispatch requests onto the postProcessResourcesQueue
107 * @param[in] request The request to dispatch
109 virtual void DispatchPostProcessRequest(ResourcePostProcessRequest& request);
112 * Retrieve the render instructions; these should be set during each "update" traversal.
113 * @return The render instruction container.
115 RenderInstructionContainer& GetRenderInstructionContainer();
117 // The following methods should be called via RenderQueue messages
120 * Set the background color i.e. the glClear color used at the beginning of each frame.
121 * @param[in] color The new background color.
123 void SetBackgroundColor( const Vector4& color );
126 * Set the frame time delta (time elapsed since the last frame.
127 * @param[in] deltaTime the delta time
129 void SetFrameDeltaTime( float deltaTime );
131 #ifdef DYNAMICS_SUPPORT
133 * create a dynamics debug renderer
134 * @param[in] debugRenderer The dynamics world debug renderer
136 void InitializeDynamicsDebugRenderer(DynamicsDebugRenderer* debugRenderer);
140 * Returns the rectangle for the default surface (probably the application window).
141 * @return Rectangle for the surface.
143 void SetDefaultSurfaceRect( const Rect<int>& rect );
146 * Add a Renderer to the render manager.
147 * @param[in] renderer The renderer to add.
148 * @post renderer is owned by RenderManager
150 void AddRenderer( Renderer* renderer );
153 * Remove a Renderer from the render manager.
154 * @param[in] renderer The renderer to remove.
155 * @post renderer is destroyed.
157 void RemoveRenderer( Renderer* renderer );
160 * Adds a RenderMaterial to the render manager for MeshRenderers to use.
161 * The RenderManager takes ownership of the material
162 * @param[in] renderMaterial
163 * @post renderMaterial is owned by RenderManager
165 void AddRenderMaterial( RenderMaterial* renderMaterial );
168 * Removes a RenderMaterial from the RenderManager
169 * RenderManager will destroy the material
170 * @pre renderManager owns the materail
171 * @param[in] renderMaterial
172 * @post renderMaterial is destroyed
174 void RemoveRenderMaterial( RenderMaterial* renderMaterial );
177 * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
178 * tracker. The lifetime of the tracker is related to the lifetime of the tracked
179 * object, usually an offscreen render task.
180 * @param[in] renderTracker The render tracker
182 void AddRenderTracker( RenderTracker* renderTracker );
185 * Removes a render tracker from the RenderManager.
186 * @param[in] renderTracker The render tracker to remove.
188 void RemoveRenderTracker( RenderTracker* renderTracker );
190 // This method should be called from Core::Render()
193 * Renders the results of the previous "update" traversal.
194 * @param[out] status contains the flag that indicates if render instructions exist
195 * @return true if a further update is required
197 bool Render( Integration::RenderStatus& status );
202 * Helper to process a single RenderInstruction.
203 * @param[in] instruction A description of the rendering operation.
205 void DoRender( RenderInstruction& instruction, 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__