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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/internal/common/message.h>
22 #include <dali/internal/render/common/post-process-resource-dispatcher.h>
23 #include <dali/internal/render/gl-resources/bitmap-texture.h>
24 #include <dali/internal/update/common/double-buffered.h>
25 #include <dali/internal/update/resources/resource-manager-declarations.h>
26 #include <dali/public-api/math/rect.h>
47 class DynamicsDebugRenderer;
50 class RenderInstruction;
51 class RenderInstructionContainer;
55 * RenderManager is responsible for rendering the result of the previous "update", which
56 * is provided in a RenderCommand during UpdateManager::Update().
58 class RenderManager : public PostProcessResourceDispatcher
63 * Construct a new RenderManager.
64 * @param[in] glAbstraction The GL abstraction used for rendering.
65 * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
67 static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
70 * Non-virtual destructor; not intended as a base class
75 * Retrieve the RenderQueue. Messages should only be added to this from the update-thread.
76 * @return The render queue.
78 RenderQueue& GetRenderQueue();
81 * Retrieve the texture cache. Messages should only be sent to this from the update thread,
82 * accessor methods should only be used from the render thread.
83 * @return The texture cache
85 TextureCache& GetTextureCache();
88 * Retrieves the context. Can only be called inside render thread
89 * TODO remove this when programs are initialized in render thread
90 * @return reference to the context
92 Context& GetContext();
95 * @copydoc Dali::Integration::Core::ContextCreated()
97 void ContextCreated();
100 * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
102 void ContextDestroyed();
105 * Dispatch requests onto the postProcessResourcesQueue
106 * @param[in] request The request to dispatch
108 virtual void DispatchPostProcessRequest(ResourcePostProcessRequest& request);
111 * Retrieve the render instructions; these should be set during each "update" traversal.
112 * @return The render instruction container.
114 RenderInstructionContainer& GetRenderInstructionContainer();
116 // The following methods should be called via RenderQueue messages
119 * Set the background color i.e. the glClear color used at the beginning of each frame.
120 * @param[in] color The new background color.
122 void SetBackgroundColor( const Vector4& color );
125 * Set the frame time delta (time elapsed since the last frame.
126 * @param[in] deltaTime the delta time
128 void SetFrameDeltaTime( float deltaTime );
130 #ifdef DYNAMICS_SUPPORT
132 * create a dynamics debug renderer
133 * @param[in] debugRenderer The dynamics world debug renderer
135 void InitializeDynamicsDebugRenderer(DynamicsDebugRenderer* debugRenderer);
139 * Returns the rectangle for the default surface (probably the application window).
140 * @return Rectangle for the surface.
142 void SetDefaultSurfaceRect( const Rect<int>& rect );
145 * Add a Renderer to the render manager.
146 * @param[in] renderer The renderer to add.
147 * @post renderer is owned by RenderManager
149 void AddRenderer( Renderer* renderer );
152 * Remove a Renderer from the render manager.
153 * @param[in] renderer The renderer to remove.
154 * @post renderer is destroyed.
156 void RemoveRenderer( Renderer* renderer );
159 * Adds a RenderMaterial to the render manager for MeshRenderers to use.
160 * The RenderManager takes ownership of the material
161 * @param[in] renderMaterial
162 * @post renderMaterial is owned by RenderManager
164 void AddRenderMaterial( RenderMaterial* renderMaterial );
167 * Removes a RenderMaterial from the RenderManager
168 * RenderManager will destroy the material
169 * @pre renderManager owns the materail
170 * @param[in] renderMaterial
171 * @post renderMaterial is destroyed
173 void RemoveRenderMaterial( RenderMaterial* renderMaterial );
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 );
189 // This method should be called from Core::Render()
192 * Renders the results of the previous "update" traversal.
193 * @param[out] status contains the flag that indicates if render instructions exist
194 * @return true if a further update is required
196 bool Render( Integration::RenderStatus& status );
201 * Helper to process a single RenderInstruction.
202 * @param[in] instruction A description of the rendering operation.
204 void DoRender( RenderInstruction& instruction, float elapsedTime );
209 * Construct a new RenderManager.
214 RenderManager( const RenderManager& );
217 RenderManager& operator=( const RenderManager& rhs );
226 } // namespace SceneGraph
228 } // namespace Internal
232 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__