1 #ifndef __DALI_INTERNAL_RENDER_NEW_RENDERER_H__
2 #define __DALI_INTERNAL_RENDER_NEW_RENDERER_H__
5 * Copyright (c) 2015 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.
21 #include <dali/integration-api/resource-declarations.h> // For resource id
22 #include <dali/internal/common/owner-pointer.h>
23 #include <dali/internal/render/data-providers/render-data-provider.h>
24 #include <dali/internal/render/gl-resources/texture-units.h>
25 #include <dali/internal/render/renderers/render-renderer.h>
26 #include <dali/internal/render/renderers/render-geometry.h>
27 #include <dali/internal/update/manager/prepare-render-instructions.h>
35 class PropertyInputImpl;
41 * The new geometry renderer.
44 class NewRenderer : public Renderer
47 typedef Integration::ResourceId ResourceId;
51 * Create a new renderer instance
52 * @param[in] dataProviders The data providers for the renderer
53 * @param[in] renderGeometry The geometry for the renderer
55 static NewRenderer* New( SceneGraph::RenderDataProvider* dataProviders, SceneGraph::RenderGeometry* renderGeometry );
59 * @param[in] dataProviders The data providers for the renderer
60 * @param[in] renderGeometry The geometry for the renderer
62 NewRenderer( SceneGraph::RenderDataProvider* dataProviders, SceneGraph::RenderGeometry* renderGeometry );
67 virtual ~NewRenderer();
70 * Change the data providers of the renderer
71 * @param[in] dataProviders The data providers
73 void SetRenderDataProvider( SceneGraph::RenderDataProvider* dataProviders );
76 * Change the geometry used by the renderer
77 * @param[in] renderGeometry The new geometry
79 void SetGeometry( SceneGraph::RenderGeometry* renderGeometry );
82 * Write the renderer's sort attributes to the passed in reference.
83 * @param[in] bufferIndex The buffer index
84 * @param[out] sortAttributes
86 void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const
88 sortAttributes.shader = &( mRenderDataProvider->GetShader() );
89 const std::vector<Render::Texture>& textures( mRenderDataProvider->GetTextures() );
90 if( !textures.empty() )
92 sortAttributes.textureResourceId = textures[0].GetTextureId();
96 sortAttributes.textureResourceId = Integration::InvalidResourceId;
99 sortAttributes.geometry = mRenderGeometry;
102 public: // Implementation of Renderer
105 * @copydoc SceneGraph::Renderer::GetNewRenderer()
107 virtual NewRenderer* GetNewRenderer()
113 * @copydoc SceneGraph::Renderer::RequiresDepthTest()
115 virtual bool RequiresDepthTest() const;
118 * @copydoc SceneGraph::Renderer::CheckResources()
120 virtual bool CheckResources();
123 * @copydoc SceneGraph::Renderer::DoSetUniforms()
125 virtual void DoSetUniforms( Context& context, BufferIndex bufferIndex, SceneGraph::Shader* shader, Program* program, unsigned int programIndex );
128 * @copydoc SceneGraph::Renderer::DoSetCullFaceMode
130 virtual void DoSetCullFaceMode( Context& context );
133 * @copydoc SceneGraph::Renderer::DoSetBlending
135 virtual void DoSetBlending( Context& context );
138 * @copydoc SceneGraph::Renderer::DoRender()
140 virtual void DoRender( Context& context,
141 SceneGraph::TextureCache& textureCache,
142 const SceneGraph::NodeDataProvider& node,
143 BufferIndex bufferIndex,
145 const Matrix& modelViewMatrix,
146 const Matrix& viewMatrix );
148 public: // Implementation of GlResourceOwner
151 * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
153 virtual void GlContextDestroyed();
156 * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
158 virtual void GlCleanup();
161 struct UniformIndexMap;
164 * Set the uniforms from properties according to the uniform map
165 * @param[in] node The node using the renderer
166 * @param[in] program The shader program on which to set the uniforms.
168 void SetUniforms( BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, Program& program );
171 * Set the program uniform in the map from the mapped property
173 void SetUniformFromProperty( BufferIndex bufferIndex, Program& program, UniformIndexMap& map );
176 * Bind the material textures in the samplers and setup the samplers
177 * @param[in] textureCache The texture cache
178 * @param[in] program The shader program
180 void BindTextures( SceneGraph::TextureCache& textureCache, Program& program );
184 OwnerPointer< SceneGraph::RenderDataProvider > mRenderDataProvider;
188 SceneGraph::RenderGeometry* mRenderGeometry;
190 struct UniformIndexMap
192 unsigned int uniformIndex; // The index of the cached location in the Program
193 const PropertyInputImpl* propertyValue;
196 typedef Dali::Vector< UniformIndexMap > UniformIndexMappings;
197 UniformIndexMappings mUniformIndexMap;
199 Vector<GLint> mAttributesLocation;
200 bool mUpdateAttributesLocation;
209 #endif // __DALI_INTERNAL_RENDER_NEW_RENDERER_H__