1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDERER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDERER_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/matrix.h>
23 #include <dali/public-api/math/vector4.h>
24 #include <dali/internal/common/blending-options.h>
25 #include <dali/internal/common/message.h>
26 #include <dali/internal/event/effects/shader-declarations.h>
27 #include <dali/internal/render/gl-resources/gl-resource-owner.h>
28 #include <dali/internal/render/renderers/scene-graph-renderer-declarations.h>
29 #include <dali/integration-api/debug.h>
30 #include <dali/internal/common/type-abstraction-enums.h>
43 class SceneController;
46 class NodeDataProvider;
49 * Renderers are used to render images, text, & meshes etc.
50 * These objects are used during RenderManager::Render(), so properties modified during
51 * the Update must either be double-buffered, or set via a message added to the RenderQueue.
53 class Renderer : public GlResourceOwner
58 * Second-phase construction.
59 * This is called when the renderer is inside render thread
60 * @param[in] textureCache to use
62 void Initialize( Context& context, TextureCache& textureCache );
70 * Set the NodeDataProvider.
71 * @param[in] dataProvider The node data provider.
73 void SetDataProvider( NodeDataProvider* dataProvider );
76 * Set the Shader used to render.
77 * @param[in] shader The shader used to render.
79 void SetShader( Shader* shader );
82 * Set the face-culling mode.
83 * @param[in] mode The face-culling mode.
85 void SetCullFace( CullFaceMode mode );
88 * Set the sampler used to render the set texture.
89 * @param[in] samplerBitfield The packed sampler options used to render.
91 void SetSampler( unsigned int samplerBitfield );
94 * Query whether the derived type of Renderer requires depth testing.
95 * @return True if the renderer requires depth testing.
97 virtual bool RequiresDepthTest() const = 0;
100 * Called to render during RenderManager::Render().
101 * @param[in] context The context used for rendering
102 * @param[in] textureCache The texture cache used to get textures
103 * @param[in] bufferIndex The index of the previous update buffer.
104 * @param[in] defaultShader in case there is no custom shader
105 * @param[in] modelViewMatrix The model-view matrix.
106 * @param[in] viewMatrix The view matrix.
107 * @param[in] projectionMatrix The projection matrix.
108 * @param[in] frametime The elapsed time between the last two updates.
109 * @param[in] cull Whether to frustum cull this renderer
111 void Render( Context& context,
112 TextureCache& textureCache,
113 BufferIndex bufferIndex,
114 Shader& defaultShader,
115 const Matrix& modelViewMatrix,
116 const Matrix& viewMatrix,
117 const Matrix& projectionMatrix,
123 * Protected constructor; only derived classes can be instantiated.
124 * @param dataprovider for rendering
126 Renderer( NodeDataProvider& dataprovider );
131 Renderer( const Renderer& );
134 Renderer& operator=( const Renderer& rhs );
137 * Checks if renderer's resources are ready to be used.
139 * @return \e true if they are. Otherwise \e false.
141 virtual bool CheckResources() = 0;
144 * Checks if renderer is culled.
145 * @param[in] modelMatrix The model matrix.
146 * @param[in] modelViewProjectionMatrix The MVP matrix.
147 * @return \e true if it is. Otherwise \e false.
149 virtual bool IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix ) = 0;
152 * Called from Render prior to DoRender().
153 * @todo MESH_REWORK Remove after merge
155 virtual void DoSetUniforms( Context& context, BufferIndex bufferIndex, Shader* shader, Program* program );
158 * Called from Render prior to DoRender(). Default method to set CullFaceMode
159 * @todo MESH_REWORK Remove after merge
161 virtual void DoSetCullFaceMode( Context& context, BufferIndex bufferIndex );
164 * Called from Render prior to DoRender(). Default method to set blending options
165 * @todo MESH_REWORK Remove after merge
167 virtual void DoSetBlending( Context& context, BufferIndex bufferIndex ) = 0;
170 * Called from Render; implemented in derived classes.
171 * @param[in] context The context used for rendering
172 * @param[in] textureCache The texture cache used to get textures
173 * @param[in] bufferIndex The index of the previous update buffer.
174 * @param[in] program to use.
175 * @param[in] modelViewMatrix The model-view matrix.
176 * @param[in] viewMatrix The view matrix.
178 virtual void DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix ) = 0;
182 NodeDataProvider* mDataProvider; // @todo MESH_REWORK rename to mNodeDataProvider. Shouldn't it be const?
184 Context* mContextDELETEME; // TODO: MESH_REWORK DELETE THIS
185 TextureCache* mTextureCacheDELETEME; // TODO: MESH_REWORK DELETE THIS
187 unsigned int mSamplerBitfield; ///< Sampler options used for texture filtering
191 CullFaceMode mCullFaceMode:3; ///< cullface enum, 3 bits is enough
194 } // namespace SceneGraph
196 } // namespace Internal
200 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDERER_H__