class NotificationManager;
class AnimationPlaylist;
class PropertyNotificationManager;
-class Context;
class EventProcessor;
class GestureEventProcessor;
class ResourceClient;
namespace
{
+// @todo MESH_REWORK Remove file after image removal
+
// Adjust these shift sizes if the FilterMode enum grows
const int MINIFY_BIT_SHIFT = 0; // Room for 16
const int MAGNIFY_BIT_SHIFT = 4;
* Returns a const pointer to the object owned.
* @return a const pointer to the object.
*/
- const T* Get()
+ const T* Get() const
{
return mObject;
}
void TypeInfo::GetProperties( Dali::TypeInfo::NameContainer& ret ) const
{
Property::IndexContainer indices;
-
GetPropertyIndices(indices);
ret.reserve(indices.size());
$(internal_src_dir)/render/gl-resources/texture-factory.cpp \
$(internal_src_dir)/render/gl-resources/texture-cache.cpp \
$(internal_src_dir)/render/queue/render-queue.cpp \
+ $(internal_src_dir)/render/renderers/render-geometry.cpp \
+ $(internal_src_dir)/render/renderers/render-renderer.cpp \
$(internal_src_dir)/render/renderers/scene-graph-image-renderer.cpp \
$(internal_src_dir)/render/renderers/scene-graph-renderer.cpp \
$(internal_src_dir)/render/renderers/scene-graph-renderer-debug.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-camera-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-image-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-renderable-attachment.cpp \
- $(internal_src_dir)/update/node-attachments/scene-graph-text-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-renderer-attachment.cpp \
+ $(internal_src_dir)/update/node-attachments/scene-graph-text-attachment.cpp \
$(internal_src_dir)/update/nodes/node.cpp \
$(internal_src_dir)/update/nodes/node-messages.cpp \
$(internal_src_dir)/update/nodes/scene-graph-layer.cpp \
namespace Dali
{
-
namespace Internal
{
-
class Context;
namespace SceneGraph
} // namespace Dali
#endif // __DALI_INTERNAL_RENDER_ALGORITHMS_H__
-
--- /dev/null
+#ifndef __DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_DATA_PROVIDER_H__
+#define __DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_DATA_PROVIDER_H__
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/geometry/geometry.h>
+#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/common/owner-container.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class PropertyBuffer;
+
+/**
+ * An interface to provide geometry data, such as the vertex buffers
+ * and index buffers (if present). It provides a means of getting the
+ * vertex attribute meta data and vertex data from each buffer. It
+ * provides the geometry type;
+ */
+class GeometryDataProvider
+{
+public:
+ typedef Dali::Geometry::GeometryType GeometryType;
+ typedef OwnerContainer< PropertyBuffer* > VertexBuffers;
+
+ /**
+ * Constructor. Nothing to do as a pure interface.
+ */
+ GeometryDataProvider() { }
+
+public: // GeometryDataProvider
+ /**
+ * Get the vertex buffers of the geometry
+ * @return A const reference to the vertex buffers
+ */
+ virtual const VertexBuffers& GetVertexBuffers() const = 0;
+
+ /**
+ * Get the index buffer of the geometry
+ * @return A const reference to the index buffer
+ */
+ virtual const PropertyBuffer* GetIndexBuffer() const = 0;
+
+ /**
+ * Get the type of geometry to draw
+ */
+ virtual GeometryType GetGeometryType( BufferIndex bufferIndex ) const = 0;
+
+ /**
+ * @todo MESH_REWORK - Should only use this in Update Sorting algorithm
+ * Returns true if this geometry requires depth testing, e.g. if it is
+ * a set of vertices with z != 0
+ */
+ virtual bool GetRequiresDepthTest( BufferIndex bufferIndex ) const = 0;
+
+protected:
+
+ /**
+ * Virtual destructor, this is an interface, no deletion through this interface
+ */
+ virtual ~GeometryDataProvider() { }
+};
+
+} // SceneGraph
+} // Internal
+} // Dali
+
+#endif // __DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_DATA_PROVIDER_H__
* limitations under the License.
*/
+#include <dali/public-api/common/dali-vector.h>
+
namespace Dali
{
namespace Internal
class MaterialDataProvider
{
public:
- typedef Dali::Vector< SamplerDataProvider* > Samplers;
+ typedef Dali::Vector< const SamplerDataProvider* > Samplers;
/**
* Construtor
* Returns the list of samplers that this material provides
* @return The list of samplers
*/
- const Samplers& GetSamplers();
+ virtual const Samplers& GetSamplers() const = 0;
protected:
/**
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H__
+#ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H__
+#define __DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H__
+
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* An interface to provide data for a Renderer
*/
-class RenderDataProvider
+class NodeDataProvider
{
public:
/**
* Constructor. Nothing to do as a pure interface.
*/
- RenderDataProvider() { }
+ NodeDataProvider() { }
/**
* @param bufferId to use
/**
* Virtual destructor, this is an interface, no deletion through this interface
*/
- virtual ~RenderDataProvider() { }
+ virtual ~NodeDataProvider() { }
};
} // SceneGraph
} // Internal
} // Dali
-#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H__
+#endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H__
}
/**
+ * Get the sampler's texture unit uniform name
+ * @return The texture unit uniform name
+ */
+ virtual const std::string& GetUnitName() const = 0;
+
+ /**
* Get the texture identity associated with the sampler
* @return The texture identity
*/
- virtual ResourceId GetTextureId() = 0;
+ virtual ResourceId GetTextureId( BufferIndex bufferIndex ) const = 0;
/**
* Get the filter mode
* @param[in] bufferIndex The buffer index to use
* @return The minify filter mode
*/
- virtual FilterMode GetMinifyFilterMode( BufferIndex bufferIndex ) = 0;
+ virtual FilterMode GetMinifyFilterMode( BufferIndex bufferIndex ) const = 0;
/**
* Get the filter mode
* @param[in] bufferIndex The buffer index to use
* @return The magnify filter mode
*/
- virtual FilterMode GetMagifyFilterMode( BufferIndex bufferIndex ) = 0;
+ virtual FilterMode GetMagnifyFilterMode( BufferIndex bufferIndex ) const = 0;
/**
* Get the horizontal wrap mode
* @param[in] bufferIndex The buffer index to use
* @return The horizontal wrap mode
*/
- virtual WrapMode GetUWrapMode( BufferIndex bufferIndex ) = 0;
+ virtual WrapMode GetUWrapMode( BufferIndex bufferIndex ) const = 0;
/**
* Get the vertical wrap mode
* @param[in] bufferIndex The buffer index to use
* @return The vertical wrap mode
*/
- virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) = 0;
+ virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) const = 0;
protected:
/**
--- /dev/null
+#ifndef DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_PROVIDER_H
+#define DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_PROVIDER_H
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/integration-api/resource-declarations.h>
+#include <dali/internal/common/buffer-index.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+
+/**
+ * This class maps uniform names to property value pointers.
+ * After the first string lookup, it caches the uniform location to avoid
+ * further lookups.
+ */
+class UniformMapProvider
+{
+public:
+ /**
+ * Constructor
+ */
+ UniformMapProvider()
+ {
+ }
+
+ // @todo Force material color?
+
+protected:
+
+ /**
+ * No deletion through this interface
+ */
+ virtual ~UniformMapProvider()
+ {
+ }
+};
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_PROVIDER_H
* @param size Specifies the size in bytes of the buffer object's new data store.
* @param data pointer to the data to load
*/
- void UpdateDataBuffer(GLsizeiptr size,const GLvoid *data);
+ void UpdateDataBuffer(GLsizeiptr size, const GLvoid *data);
/**
* Bind the buffer object to the target
return mSize;
}
+ void SetStride( GLuint stride )
+ {
+ mStride = stride;
+ }
+
+ GLuint GetStride()
+ {
+ return mStride;
+ }
+
/**
* Needs to be called when GL context is destroyed
*/
GLsizeiptr mCapacity; ///< buffer capacity
GLsizeiptr mSize; ///< buffer size
GLuint mBufferId; ///< buffer object name(id)
+ GLuint mStride; ///< stride of data in buffer object
Target mTarget:2; ///< type of buffer (array/element), 2 bits are enough
Usage mUsage:2; ///< how the buffer is used (read, read/write etc), 2 bits are enough
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "render-geometry.h"
+
+#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/common/scene-graph-property-buffer.h>
+#include <dali/internal/render/gl-resources/context.h>
+#include <dali/internal/render/gl-resources/gpu-buffer.h>
+#include <dali/internal/render/shaders/program.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+
+RenderGeometry::RenderGeometry()
+: mDataNeedsUploading( true )
+{
+}
+
+RenderGeometry::~RenderGeometry()
+{
+}
+
+void RenderGeometry::GlContextCreated( Context& context )
+{
+ mDataNeedsUploading = true;
+}
+
+void RenderGeometry::GlContextDestroyed()
+{
+ for( GpuBuffers::Iterator iter=mVertexBuffers.Begin(); iter != mVertexBuffers.End(); ++iter )
+ {
+ GpuBuffer* gpuBuffer = *iter;
+ if( gpuBuffer )
+ {
+ gpuBuffer->GlContextDestroyed();
+ }
+ }
+
+ if( mIndexBuffer )
+ {
+ mIndexBuffer->GlContextDestroyed();
+ }
+}
+
+void RenderGeometry::UploadAndDraw(
+ Context* context,
+ Program& program,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometryDataProvider )
+{
+ UploadVertexData( context, bufferIndex, geometryDataProvider );
+ BindBuffers();
+ EnableVertexAttributes( context, program );
+ Draw( context, bufferIndex, geometryDataProvider );
+ DisableVertexAttributes( context, program );
+}
+
+void RenderGeometry::GeometryUpdated()
+{
+ mDataNeedsUploading = true;
+}
+
+void RenderGeometry::UploadVertexData(
+ Context* context,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometry )
+{
+ if( mDataNeedsUploading ) // @todo Or if any of the property buffers are dirty
+ {
+ DoUpload( context, bufferIndex, geometry );
+
+ mDataNeedsUploading = false;
+ }
+}
+
+void RenderGeometry::DoUpload(
+ Context* context,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometry)
+{
+ // @todo MESH_REWORK Add support for multiple vertex buffers and attrs
+
+ // Vertex buffer
+ const Geometry::VertexBuffers& vertexBuffers = geometry.GetVertexBuffers();
+ DALI_ASSERT_DEBUG( vertexBuffers.Count() > 0 && "Need vertex buffers to upload" );
+
+ PropertyBuffer* firstVertexBuffer = vertexBuffers[0];
+
+ // @todo MESH_REWORK STATIC_DRAW or DYNAMIC_DRAW depends on property buffer type (static / animated)
+ GpuBuffer* vertexGpuBuffer = new GpuBuffer( *context, GpuBuffer::ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
+
+ std::size_t dataSize = firstVertexBuffer->GetDataSize( bufferIndex );
+ vertexGpuBuffer->UpdateDataBuffer( dataSize, firstVertexBuffer->GetData( bufferIndex ) );
+ vertexGpuBuffer->SetStride( firstVertexBuffer->GetElementSize( bufferIndex ) );
+
+ mVertexBuffers.PushBack( vertexGpuBuffer );
+
+ // Index buffer
+ const PropertyBuffer* indexBuffer = geometry.GetIndexBuffer();
+ if( indexBuffer )
+ {
+ GpuBuffer* indexGpuBuffer = new GpuBuffer( *context, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
+
+ dataSize = indexBuffer->GetDataSize( bufferIndex );
+ indexGpuBuffer->UpdateDataBuffer( dataSize, indexBuffer->GetData( bufferIndex ) );
+
+ mIndexBuffer.Reset();
+ mIndexBuffer = indexGpuBuffer;
+ }
+}
+
+void RenderGeometry::BindBuffers()
+{
+ for( GpuBuffers::Iterator iter=mVertexBuffers.Begin(); iter != mVertexBuffers.End(); ++iter )
+ {
+ (*iter)->Bind();
+ }
+
+ if( mIndexBuffer )
+ {
+ mIndexBuffer->Bind();
+ }
+}
+
+void RenderGeometry::EnableVertexAttributes( Context* context, Program& program )
+{
+ // @todo Loop thru the array of vertex buffers
+ // @todo Use AttributeDataProvider to get the attrs and enable them
+ // Need mapping from gpu buffers index to a particular attributes
+ Vector4 *vertex=0;
+
+ unsigned int gpuBufferIndex = 0;
+
+ GLint positionLoc = program.GetAttribLocation( Program::ATTRIB_POSITION );
+ context->VertexAttribPointer( positionLoc,
+ 2, // 2D position
+ GL_FLOAT,
+ GL_FALSE, // Not normalized
+ mVertexBuffers[gpuBufferIndex]->GetStride(),
+ &vertex->x );
+
+ context->EnableVertexAttributeArray( positionLoc );
+
+ GLint textureCoordsLoc = program.GetAttribLocation( Program::ATTRIB_TEXCOORD );
+ context->VertexAttribPointer( textureCoordsLoc,
+ 2, // Texture Coords = U, V
+ GL_FLOAT,
+ GL_FALSE,
+ mVertexBuffers[gpuBufferIndex]->GetStride(),
+ &vertex->z );
+ context->EnableVertexAttributeArray( textureCoordsLoc );
+}
+
+void RenderGeometry::DisableVertexAttributes( Context* context, Program& program )
+{
+ // @todo Loop thru the array of vertex buffers
+ // @todo Use AttributeDataProvider to get the attrs and disable them
+ GLint positionLoc = program.GetAttribLocation( Program::ATTRIB_POSITION );
+ GLint textureCoordsLoc = program.GetAttribLocation( Program::ATTRIB_TEXCOORD );
+ context->DisableVertexAttributeArray( positionLoc );
+ context->DisableVertexAttributeArray( textureCoordsLoc );
+}
+
+void RenderGeometry::Draw( Context* context, BufferIndex bufferIndex, const GeometryDataProvider& geometry )
+{
+ GeometryDataProvider::GeometryType type = geometry.GetGeometryType( bufferIndex );
+
+ unsigned int numIndices = 0;
+ const PropertyBuffer* indexBuffer = geometry.GetIndexBuffer();
+
+ if( indexBuffer )
+ {
+ numIndices = indexBuffer->GetDataSize(bufferIndex) / indexBuffer->GetElementSize(bufferIndex);
+ }
+
+ switch(type)
+ {
+ case Dali::Geometry::TRIANGLES:
+ {
+ context->DrawElements(GL_TRIANGLES, numIndices/3, GL_UNSIGNED_SHORT, 0);
+ break;
+ }
+ case Dali::Geometry::LINES:
+ {
+ context->DrawElements(GL_LINES, numIndices/2, GL_UNSIGNED_SHORT, 0);
+ break;
+ }
+ case Dali::Geometry::POINTS:
+ {
+ GpuBuffer* firstVertexBuffer = mVertexBuffers[0];
+
+ unsigned int numVertices = 0;
+ GLuint stride = firstVertexBuffer->GetStride();
+ if( stride != 0 )
+ {
+ numVertices = firstVertexBuffer->GetBufferSize() / stride;
+ }
+
+ context->DrawArrays(GL_POINTS, 0, numVertices );
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Geometry type not supported (yet)" );
+ break;
+ }
+ }
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
*/
#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/common/owner-container.h>
+#include <dali/internal/common/owner-pointer.h>
namespace Dali
{
namespace Internal
{
+class Context;
+class Program;
+class GpuBuffer;
+
namespace SceneGraph
{
+class GeometryDataProvider;
/**
* This class encapsulates the GPU buffers. It is used to upload vertex data
class RenderGeometry
{
public:
- typedef OwnerContainer< GPUBuffer* > GPUBuffers;
+ typedef OwnerContainer< GpuBuffer* > GpuBuffers;
/**
- * Constructor
+ * Constructor. Creates a render geometry object with no GPU buffers.
*/
- RenderGeometry();
+ RenderGeometry( );
/**
* Destructor
*/
+ ~RenderGeometry();
+
+ /**
+ * Called on Gl Context created
+ */
+ void GlContextCreated( Context& context );
+
+ /**
+ * Called on Gl Context destroyed.
+ */
+ void GlContextDestroyed();
+
+ /**
+ * Upload the geometry if it has changed, set up the attributes and perform
+ * the Draw call corresponding to the geometry type
+ * @param[in] context The GL context
+ * @param[in] program The shader program to query for attribute locations
+ * @param[in] bufferIndex The current buffer index
+ * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
+ */
+ void UploadAndDraw(Context* context,
+ Program& program,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometryDataProvider );
+
+ /**
+ * Tell the object that the geometry has been updated.
+ * It will be uploaded on the next UploadAndDraw call.
+ */
+ void GeometryUpdated();
+
+ /**
+ * Upload the vertex data if it needs uploading.
+ * @param[in] context The GL context
+ * @param[in] bufferIndex The current buffer index
+ * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
+ */
+ void UploadVertexData( Context* context,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometryDataProvider );
+
- void UploadVertexData();
+private:
+ /**
+ * Perform the upload of the geometry
+ * @param[in] context The GL context
+ * @param[in] bufferIndex The current buffer index
+ * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
+ */
+ void DoUpload( Context* context,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometryDataProvider );
+ /**
+ * Bind the geometry buffers
+ */
void BindBuffers();
- void EnableVertexAttributes( Program& progam );
+ /**
+ * Enable the vertex attributes for each vertex buffer from the corresponding
+ * shader program.
+ * @param[in] context The GL context
+ * @param[in] program The shader program to query for attribute locations
+ */
+ void EnableVertexAttributes( Context* context, Program& progam );
- void DisableVertexAttributes( Program& program );
+ /**
+ * Disable the vertex attributes for each vertex buffer from the corresponding
+ * shader program.
+ * @param[in] context The GL context
+ * @param[in] program The shader program to query for attribute locations
+ */
+ void DisableVertexAttributes( Context* context, Program& program );
+
+ /**
+ * Perform the correct draw call corresponding to the geometry type
+ * @param[in] context The GL context
+ * @param[in] bufferIndex The current buffer index
+ * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
+ */
+ void Draw( Context* context,
+ BufferIndex bufferIndex,
+ const GeometryDataProvider& geometry );
private:
- GPUBuffers mGpuBuffers;
- AttributeDataProvider& mAttributeDataProvider;
+ GpuBuffers mVertexBuffers;
+ OwnerPointer< GpuBuffer > mIndexBuffer;
+
+ bool mDataNeedsUploading;
};
} // namespace SceneGraph
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "render-renderer.h"
+
+#include <dali/internal/common/image-sampler.h>
+#include <dali/internal/render/data-providers/geometry-data-provider.h>
+#include <dali/internal/render/data-providers/material-data-provider.h>
+#include <dali/internal/render/data-providers/sampler-data-provider.h>
+#include <dali/internal/render/gl-resources/texture.h>
+#include <dali/internal/render/gl-resources/texture-cache.h>
+#include <dali/internal/render/shaders/program.h>
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+
+NewRenderer* NewRenderer::New( NodeDataProvider& nodeDataProvider,
+ const GeometryDataProvider* geometryDataProvider,
+ const MaterialDataProvider* materialDataProvider)
+{
+ return new NewRenderer(nodeDataProvider, geometryDataProvider, materialDataProvider);
+}
+
+
+NewRenderer::NewRenderer( NodeDataProvider& nodeDataProvider,
+ const GeometryDataProvider* geometryDataProvider,
+ const MaterialDataProvider* materialDataProvider)
+: Renderer( nodeDataProvider ),
+ //mShaderDataProvider( shaderDataProvider ), //@todo Add in after merge with parent class
+ mMaterialDataProvider( materialDataProvider ),
+ mGeometryDataProvider( geometryDataProvider )
+{
+}
+
+NewRenderer::~NewRenderer()
+{
+}
+
+// @todo MESH_REWORK Should we consider changing the providers, or should we instead
+// create a new renderer when these change?
+void NewRenderer::SetGeometryDataProvider( const GeometryDataProvider* geometryDataProvider )
+{
+ mGeometryDataProvider = geometryDataProvider;
+}
+
+void NewRenderer::SetMaterialDataProvider( const MaterialDataProvider* materialDataProvider )
+{
+ mMaterialDataProvider = materialDataProvider;
+}
+
+
+// Note - this is currently called from UpdateThread, PrepareRenderInstructions,
+// as an optimisation.
+// @todo MESH_REWORK Should use Update thread objects only in PrepareRenderInstructions.
+bool NewRenderer::RequiresDepthTest() const
+{
+ return true;
+}
+
+bool NewRenderer::CheckResources()
+{
+ // Query material to check it has texture pointers & image has size
+ // Query geometry to check it has vertex buffers
+
+ // General point though - why would we have a render item in RenderThread with no ready
+ // resources in UpdateThread?
+ return true;
+}
+
+void NewRenderer::ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType& outType, ShaderSubTypes& outSubType )
+{
+ // @todo MESH_REWORK Remove after merge
+
+ // Do nothing
+}
+
+bool NewRenderer::IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
+{
+ // @todo MESH_REWORK Add clipping
+ return false;
+}
+
+void NewRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
+{
+ BindTextures( bufferIndex, program, mMaterialDataProvider->GetSamplers() );
+
+ SetUniforms( program );
+
+ mRenderGeometry.UploadAndDraw( mContext, program, bufferIndex, *mGeometryDataProvider );
+}
+
+void NewRenderer::GlContextDestroyed()
+{
+ mRenderGeometry.GlContextDestroyed();
+}
+
+void NewRenderer::GlCleanup()
+{
+}
+
+void NewRenderer::SetUniforms( Program& program )
+{
+ // @todo MESH_REWORK Implement uniform map
+}
+
+void NewRenderer::BindTextures(
+ BufferIndex bufferIndex,
+ Program& program,
+ const MaterialDataProvider::Samplers& samplers )
+{
+ // @todo MESH_REWORK Write a cache of texture units to commonly used sampler textures
+ unsigned int textureUnit = 0;
+
+ for( MaterialDataProvider::Samplers::Iterator iter = samplers.Begin();
+ iter != samplers.End();
+ ++iter )
+ {
+ const SamplerDataProvider* sampler = *iter;
+ ResourceId textureId = sampler->GetTextureId(bufferIndex);
+ Texture* texture = mTextureCache->GetTexture( textureId );
+ if( texture != NULL )
+ {
+ unsigned int textureUnitUniformIndex = GetTextureUnitUniformIndex( program, *sampler );
+ TextureUnit theTextureUnit = static_cast<TextureUnit>(textureUnit);
+ BindTexture( program, textureId, texture, theTextureUnit, textureUnitUniformIndex );
+ ApplySampler( bufferIndex, texture, theTextureUnit, *sampler );
+ }
+
+ ++textureUnit;
+ }
+}
+
+void NewRenderer::BindTexture(
+ Program& program,
+ ResourceId id,
+ Texture* texture,
+ TextureUnit textureUnit,
+ unsigned int textureUnitUniformIndex )
+{
+ DALI_ASSERT_DEBUG( NULL != mTextureCache );
+
+ if( texture != NULL )
+ {
+ mTextureCache->BindTexture( texture, id, GL_TEXTURE_2D, textureUnit );
+
+ // Set sampler uniform location for the texture
+ GLint textureUnitLoc = program.GetUniformLocation( textureUnitUniformIndex );
+ if( Program::UNIFORM_UNKNOWN != textureUnitLoc )
+ {
+ program.SetUniform1i( textureUnitLoc, textureUnit );
+ }
+ }
+}
+
+void NewRenderer::ApplySampler(
+ BufferIndex bufferIndex,
+ Texture* texture,
+ TextureUnit textureUnit,
+ const SamplerDataProvider& sampler )
+{
+ unsigned int samplerBitfield = ImageSampler::PackBitfield(
+ static_cast< FilterMode::Type >(sampler.GetMinifyFilterMode(bufferIndex)),
+ static_cast< FilterMode::Type >(sampler.GetMagnifyFilterMode(bufferIndex)) );
+
+ texture->ApplySampler( textureUnit, samplerBitfield );
+
+ // @todo MESH_REWORK add support for wrap modes
+}
+
+unsigned int NewRenderer::GetTextureUnitUniformIndex(
+ Program& program,
+ const SamplerDataProvider& sampler )
+{
+ // Find sampler in mSamplerNameCache
+ // If it doesn't exist,
+ // get the index by calling program.RegisterUniform and store it
+ // If it exists, it's index should be set.
+ // @todo Cache should be reset on scene change
+
+ unsigned int uniformIndex = 0;
+ bool found = false;
+
+ for( unsigned int i=0; i< mTextureUnitUniforms.Count(); ++i )
+ {
+ if( mTextureUnitUniforms[i].sampler == &sampler )
+ {
+ uniformIndex = mTextureUnitUniforms[i].index;
+ found = true;
+ }
+ }
+
+ if( ! found )
+ {
+ TextureUnitUniformIndex textureUnitUniformIndex;
+ textureUnitUniformIndex.sampler = &sampler;
+ textureUnitUniformIndex.index = program.RegisterUniform( sampler.GetUnitName() );
+ mTextureUnitUniforms.PushBack( textureUnitUniformIndex );
+ uniformIndex = textureUnitUniformIndex.index;
+ }
+
+ return uniformIndex;
+}
+
+
+} // SceneGraph
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_SCENE_GRAPH_NEW_RENDERER_H__
+#define __DALI_INTERNAL_SCENE_GRAPH_NEW_RENDERER_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/integration-api/resource-declarations.h> // For resource id
+#include <dali/internal/render/data-providers/material-data-provider.h>
+#include <dali/internal/render/gl-resources/texture-units.h>
+#include <dali/internal/render/renderers/scene-graph-renderer.h>
+#include <dali/internal/render/renderers/render-geometry.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class NodeDataProvider;
+class ShaderDataProvider;
+class SamplerDataProvider;
+class MaterialDataProvider;
+class GeometryDataProvider;
+class RenderGeometry;
+
+/**
+ * The new geometry renderer.
+ *
+ * @todo MESH_REWORK It will be merged into the base class eventually
+ */
+class NewRenderer : public Renderer
+{
+public:
+ typedef Integration::ResourceId ResourceId;
+
+ /**
+ * Create a new renderer instance
+ * @param[in] nodeDataProvider The node data provider
+ * @param[in] geoemtryDataProvider The geometry data provider
+ * @param[in] materialDataProvider The material data provider
+ */
+ static NewRenderer* New( NodeDataProvider& nodeDataProvider,
+ const GeometryDataProvider* geometryDataProvider,
+ const MaterialDataProvider* materialDataProvider );
+ /**
+ * Constructor.
+ * @param[in] nodeDataProvider The node data provider
+ * @param[in] geoemtryDataProvider The geometry data provider
+ * @param[in] materialDataProvider The material data provider
+ */
+ NewRenderer( NodeDataProvider& nodeDataProvider,
+ const GeometryDataProvider* geometryDataProvider,
+ const MaterialDataProvider* materialDataProvider );
+
+ virtual ~NewRenderer();
+
+ /**
+ * Change the geometry data provider of the renderer
+ * @param[in] geoemtryDataProvider The geometry data provider
+ */
+ void SetGeometryDataProvider( const GeometryDataProvider* geometryDataProvider );
+
+ /**
+ * Change the material data provider of the renderer
+ * @param[in] materialDataProvider The material data provider
+ */
+ void SetMaterialDataProvider( const MaterialDataProvider* materialDataProvider );
+
+public: // Implementation of Renderer
+ /**
+ * @copydoc SceneGraph::Renderer::RequiresDepthTest()
+ */
+ virtual bool RequiresDepthTest() const;
+
+ /**
+ * @copydoc SceneGraph::Renderer::CheckResources()
+ */
+ virtual bool CheckResources();
+
+ /**
+ * @copydoc SceneGraph::Renderer::ResolveGeometryTypes()
+ */
+ virtual void ResolveGeometryTypes( BufferIndex bufferIndex,
+ GeometryType& outType,
+ ShaderSubTypes& outSubType );
+
+ /**
+ * @copydoc SceneGraph::Renderer::IsOutsideClipSpace()
+ */
+ virtual bool IsOutsideClipSpace( const Matrix& modelMatrix,
+ const Matrix& modelViewProjectionMatrix );
+
+ /**
+ * @copydoc SceneGraph::Renderer::DoRender()
+ */
+ virtual void DoRender( BufferIndex bufferIndex,
+ Program& program,
+ const Matrix& modelViewMatrix,
+ const Matrix& viewMatrix );
+
+public: // Implementation of GlResourceOwner
+
+ /**
+ * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
+ */
+ virtual void GlContextDestroyed();
+
+ /**
+ * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
+ */
+ virtual void GlCleanup();
+
+private:
+ /**
+ * Set the uniforms from properties according to the uniform map
+ * @param[in] program The shader program on which to set the uniforms.
+ */
+ void SetUniforms( Program& program );
+
+ /**
+ * Bind the material textures in the samplers and setup the samplers
+ * @param[in] bufferIndex The buffer index
+ * @param[in] program The shader program
+ * @param[in] samplers The samplers to bind
+ */
+ void BindTextures( BufferIndex bufferIndex,
+ Program& program,
+ const MaterialDataProvider::Samplers& samplers );
+
+ /**
+ * Bind a material texture to a texture unit, and set the sampler's texture uniform
+ * to that texture unit.
+ * @param[in] program The shader program
+ * @param[in] id The resource id of the texture to bind
+ * @param[in] texture The texture to bind
+ * @param[in] textureUnit The texture unit index to use
+ * @param[in] nameIndex The index of the texture uniform in the program
+ */
+ void BindTexture( Program& program,
+ ResourceId id,
+ Texture* texture,
+ TextureUnit textureUnit,
+ unsigned int nameIndex );
+
+ /**
+ * Apply the sampler modes to the texture.
+ * @param[in] bufferIndex The current buffer index
+ * @param[in] texture The texture to which to apply the sampler modes
+ * @param[in] textureUnit The texture unit of the texture
+ * @param[in] sampler The sampler from which to get the modes.
+ */
+ void ApplySampler( BufferIndex bufferIndex,
+ Texture* texture,
+ TextureUnit textureUnit,
+ const SamplerDataProvider& sampler );
+
+ /**
+ * Get the texture uniform index of the name sampler in the program.
+ * If not already registered in the program, then this performs the registration
+ * @param[in] program The shader program
+ * @param[in] sampler The sampler holding a texture unit uniform name to search for
+ * @return The texture uniform index in the program
+ */
+ unsigned int GetTextureUnitUniformIndex( Program& program,
+ const SamplerDataProvider& sampler );
+
+
+private:
+ //const NodeDataProvider& mNodeDataProvider;
+ //const ShaderDataProvider& mShaderDataProvider;
+ const MaterialDataProvider* mMaterialDataProvider;
+ const GeometryDataProvider* mGeometryDataProvider;
+
+ RenderGeometry mRenderGeometry;
+
+ struct TextureUnitUniformIndex
+ {
+ const SamplerDataProvider* sampler;
+ unsigned int index;
+ };
+
+ typedef Dali::Vector< TextureUnitUniformIndex > TextureUnitUniforms;
+ TextureUnitUniforms mTextureUnitUniforms;
+};
+
+
+} // SceneGraph
+} // Internal
+} // Dali
+
+#endif // __DALI_INTERNAL_SCENE_GRAPH_NEW_RENDERER_H__
namespace SceneGraph
{
-ImageRenderer* ImageRenderer::New( RenderDataProvider& dataprovider )
+ImageRenderer* ImageRenderer::New( NodeDataProvider& dataProvider )
{
- return new ImageRenderer( dataprovider );
+ return new ImageRenderer( dataProvider );
}
ImageRenderer::~ImageRenderer()
}
}
-ImageRenderer::ImageRenderer( RenderDataProvider& dataprovider )
-: Renderer( dataprovider ),
+ImageRenderer::ImageRenderer( NodeDataProvider& dataProvider )
+: Renderer( dataProvider ),
mTexture( NULL ),
mBorder( 0.45, 0.45, 0.1, 0.1 ),
mPixelArea(),
namespace SceneGraph
{
-class RenderDataProvider;
+class NodeDataProvider;
/**
* Used to render an image.
* @param dataprovider to render
* @return The newly allocated ImageRenderer.
*/
- static ImageRenderer* New( RenderDataProvider& dataprovider );
+ static ImageRenderer* New( NodeDataProvider& dataprovider );
/**
* Virtual destructor
/**
* Private constructor. @see New()
*/
- ImageRenderer(RenderDataProvider& dataprovider);
+ ImageRenderer( NodeDataProvider& dataprovider );
// Undefined
- ImageRenderer(const ImageRenderer&);
+ ImageRenderer( const ImageRenderer& );
// Undefined
- ImageRenderer& operator=(const ImageRenderer& rhs);
+ ImageRenderer& operator=( const ImageRenderer& rhs );
private:
#include <dali/integration-api/resource-declarations.h>
#include <dali/internal/render/shaders/program.h>
#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/renderers/render-data-provider.h>
+#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
namespace Dali
namespace SceneGraph
{
-class RenderDataProvider;
+class NodeDataProvider;
void DebugBoundingBox(Context& context, Rect<float> boundingBox, const Matrix& mvp);
#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/render/shaders/program.h>
#include <dali/internal/render/renderers/scene-graph-renderer-debug.h>
-#include <dali/internal/render/renderers/render-data-provider.h>
+#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/public-api/actors/blending.h>
#include <dali/internal/common/image-sampler.h>
DoRender( bufferIndex, *program, modelViewMatrix, viewMatrix );
}
-Renderer::Renderer( RenderDataProvider& dataprovider )
+Renderer::Renderer( NodeDataProvider& dataprovider )
: mDataProvider( dataprovider ),
mContext( NULL ),
class SceneController;
class Shader;
class TextureCache;
-class RenderDataProvider;
+class NodeDataProvider;
/**
* Renderers are used to render images, text, & meshes etc.
bool cull );
protected:
-
/**
* Protected constructor; only derived classes can be instantiated.
* @param dataprovider for rendering
*/
- Renderer( RenderDataProvider& dataprovider );
+ Renderer( NodeDataProvider& dataprovider );
private:
virtual bool CheckResources() = 0;
/**
+ * @deprecated - Not needed in final MESH_REWORK
+ * @todo MESH_REWORK Remove this API
+ *
* Resolve the derived renderers geometry type and subtype
* @param[in] bufferIndex The index of the previous update buffer.
* @param[out] outType The geometry type
protected:
- RenderDataProvider& mDataProvider;
+ NodeDataProvider& mDataProvider;
Context* mContext;
TextureCache* mTextureCache;
Shader* mShader;
namespace SceneGraph
{
-TextRenderer* TextRenderer::New( RenderDataProvider& dataprovider )
+TextRenderer* TextRenderer::New( NodeDataProvider& dataprovider )
{
return new TextRenderer( dataprovider );
}
}
-TextRenderer::TextRenderer( RenderDataProvider& dataprovider )
+TextRenderer::TextRenderer( NodeDataProvider& dataprovider )
: Renderer( dataprovider ),
mTexture( NULL ),
mTextColor( NULL ),
namespace SceneGraph
{
-class RenderDataProvider;
class TextureCache;
/**
* @param dataprovider to render
* @return The newly allocated TextRenderer
*/
- static TextRenderer* New( RenderDataProvider& dataprovider );
+ static TextRenderer* New( NodeDataProvider& dataprovider );
/**
* Virtual destructor
/**
* Private constructor. @see New()
*/
- TextRenderer( RenderDataProvider& dataprovider );
+ TextRenderer( NodeDataProvider& dataprovider );
// Undefined
TextRenderer( const TextRenderer& copy );
{
DALI_ASSERT_DEBUG(type != ATTRIB_UNKNOWN);
- if( mAttribLocations[ type ] == ATTRIB_UNKNOWN )
+ return GetCustomAttributeLocation( type );
+}
+
+unsigned int Program::RegisterCustomAttribute( const std::string& name )
+{
+ unsigned int index = 0;
+ // find the value from cache
+ for( ;index < mAttributeLocations.size(); ++index )
{
- GLint loc = CHECK_GL( mGlAbstraction, mGlAbstraction.GetAttribLocation( mProgramId, gStdAttribs[type] ) );
- mAttribLocations[ type ] = loc;
- LOG_GL( "GetAttribLocation(program=%d,%s) = %d\n", mProgramId, gStdAttribs[type], mAttribLocations[type] );
+ if( mAttributeLocations[ index ].first == name )
+ {
+ // name found so return index
+ return index;
+ }
}
+ // if we get here, index is one past end so push back the new name
+ mAttributeLocations.push_back( std::make_pair( name, ATTRIB_UNKNOWN ) );
+ return index;
+}
- return mAttribLocations[type];
+GLint Program::GetCustomAttributeLocation( unsigned int attributeIndex )
+{
+ // debug check that index is within name cache
+ DALI_ASSERT_DEBUG( mAttributeLocations.size() > attributeIndex );
+
+ // check if we have already queried the location of the attribute
+ GLint location = mAttributeLocations[ attributeIndex ].second;
+
+ if( location == ATTRIB_UNKNOWN )
+ {
+ location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetAttribLocation( mProgramId, mAttributeLocations[ attributeIndex ].first.c_str() ) );
+
+ mAttributeLocations[ attributeIndex ].second = location;
+ LOG_GL( "GetAttributeLocation(program=%d,%s) = %d\n", mProgramId, mAttributeLocations[ attributeIndex ].first.c_str(), mAttributeLocations[ attributeIndex ].second );
+ }
+
+ return location;
}
+
unsigned int Program::RegisterUniform( const std::string& name )
{
unsigned int index = 0;
mProgramData(shaderData),
mModifiesGeometry( modifiesGeometry )
{
+ // reserve space for standard attributes
+ mAttributeLocations.reserve( ATTRIB_TYPE_LAST );
+ for( int i=0; i<ATTRIB_TYPE_LAST; ++i )
+ {
+ RegisterCustomAttribute( gStdAttribs[i] );
+ }
+
// reserve space for standard uniforms
mUniformLocations.reserve( UNIFORM_TYPE_LAST );
// reset built in uniform names in cache
void Program::ResetAttribsUniformCache()
{
// reset attribute locations
- for( unsigned i = 0; i < ATTRIB_TYPE_LAST; ++i )
+ for( unsigned i = 0; i < mAttributeLocations.size() ; ++i )
{
- mAttribLocations[ i ] = ATTRIB_UNKNOWN;
+ mAttributeLocations[ i ].second = ATTRIB_UNKNOWN;
}
// reset all gl uniform locations
GLint GetAttribLocation( AttribType type );
/**
+ * Register an attribute name in our local cache
+ * @param [in] name attribute name
+ * @return the index of the attribute name in local cache
+ */
+ unsigned int RegisterCustomAttribute( const std::string& name );
+
+ /**
+ * Gets the location of a pre-registered attribute.
+ * @param [in] attributeIndex of the attribute in local cache
+ * @return the index of the attribute in the GL program
+ */
+ GLint GetCustomAttributeLocation( unsigned int attributeIndex );
+
+ /**
* Register a uniform name in our local cache
* @param [in] name uniform name
* @return the index of the uniform name in local cache
Integration::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
// location caches
- GLint mAttribLocations[ ATTRIB_TYPE_LAST ]; ///< attribute location cache
+ std::vector< std::pair< std::string, GLint > > mAttributeLocations; ///< attribute location cache
std::vector< std::pair< std::string, GLint > > mUniformLocations; ///< uniform location cache
// uniform value caching
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/boolean.h>
#include <dali/public-api/object/property.h>
#include <dali/public-api/object/property-input.h>
#include <dali/public-api/object/property-types.h>
PropertyBoolean& operator=(const PropertyBoolean& rhs);
public:
- boolean mValue; ///< The property value
+ bool mValue; ///< The property value
private:
- boolean mDirtyFlag;
+ bool mDirtyFlag;
};
} // namespace SceneGraph
PropertyBuffer* PropertyBuffer::NewQuadVertices()
{
PropertyBuffer* propertyBuffer = new PropertyBuffer();
- propertyBuffer->mVertexSize = sizeof(Vector4);
- propertyBuffer->mData.Resize( propertyBuffer->mVertexSize * 4 );
+ propertyBuffer->mElementSize = sizeof(Vector4);
+ propertyBuffer->mData.Resize( propertyBuffer->mElementSize * 4 );
Vector4* vertices = reinterpret_cast<Vector4*>(propertyBuffer->mData[0]);
vertices[ 0 ] = Vector4( -0.5f, -0.5f, 1.0f, 0.0f );
{
PropertyBuffer* propertyBuffer = new PropertyBuffer();
- propertyBuffer->mVertexSize = sizeof( unsigned short );
- propertyBuffer->mData.Resize( propertyBuffer->mVertexSize * 6 );
+ propertyBuffer->mElementSize = sizeof( unsigned short );
+ propertyBuffer->mData.Resize( propertyBuffer->mElementSize * 6 );
unsigned short* indices = reinterpret_cast<unsigned short*>(propertyBuffer->mData[0]);
indices[0] = 0; indices[1] = 3; indices[2] = 1;
return propertyBuffer;
}
+std::size_t PropertyBuffer::GetDataSize( BufferIndex bufferIndex ) const
+{
+ // @todo MESH_REWORK mData should be double buffered
+ return mData.Count();
+}
+
+std::size_t PropertyBuffer::GetElementSize( BufferIndex bufferIndex ) const
+{
+ // @todo MESH_REWORK mElementSize should be double buffered
+ return mElementSize;
+}
+
+const void* PropertyBuffer::GetData( BufferIndex bufferIndex ) const
+{
+ // @todo MESH_REWORK mData should be double buffered
+ return reinterpret_cast< const void* >(mData[0]);
+}
+
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
*/
#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/math/vector4.h>
+#include <dali/internal/common/buffer-index.h>
namespace Dali
{
*/
~PropertyBuffer();
+ /**
+ * Get the size of the property buffer in bytes
+ * @return the size in bytes
+ */
+ std::size_t GetDataSize( BufferIndex bufferIndex ) const;
+
+ /**
+ * Get the size of an element of the buffer in bytes
+ * @return the element size in bytes
+ */
+ std::size_t GetElementSize( BufferIndex bufferIndex ) const;
+
+ /**
+ * Get the property buffer data
+ * @return the property buffer's data array
+ */
+ const void* GetData( BufferIndex bufferIndex ) const;
+
private:
// @todo MESH_REWORK - TEMPORARY TYPES - REMOVE WHEN WE HAVE WORKING BUFFERS
typedef Dali::Vector< char > CharBuffer;
CharBuffer mData;
- std::size_t mVertexSize;
+ std::size_t mElementSize;
};
} // namespace SceneGraph
#include "scene-graph-material.h"
// INTERNAL HEADERS
-#include <dali/internal/render/renderers/sampler-data-provider.h>
+#include <dali/internal/render/data-providers/sampler-data-provider.h>
+#include <dali/internal/update/effects/scene-graph-sampler.h>
namespace Dali
{
{
Material::Material()
-: mShader(NULL)
+: mShader(NULL),
+ mColor( Color::WHITE )
{
}
void Material::SetShader( Shader* shader )
{
+ mShader = shader;
}
Shader* Material::GetShader()
void Material::AddSampler( const Sampler* sampler )
{
- // @todo MESH_REWORK
+ const SamplerDataProvider* sdp = static_cast< const SamplerDataProvider*>( sampler );
+ mSamplers.PushBack( sdp );
}
void Material::RemoveSampler( const Sampler* sampler )
{
- // @todo MESH_REWORK
+ const SamplerDataProvider* samplerDataProvider = sampler;
+
+ for( Samplers::Iterator iter = mSamplers.Begin(); iter != mSamplers.End(); ++iter )
+ {
+ if( *iter == samplerDataProvider )
+ {
+ mSamplers.Erase(iter);
+ return;
+ }
+ }
+ DALI_ASSERT_DEBUG( 0 && "Sampler not found" );
}
const Material::Samplers& Material::GetSamplers() const
{
- // @todo MESH_REWORK
return mSamplers;
}
-
-
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/blending-options.h>
#include <dali/internal/common/event-to-update.h>
+#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/render/renderers/material-data-provider.h>
+#include <dali/internal/render/data-providers/material-data-provider.h>
namespace Dali
{
class Material : public PropertyOwner, public MaterialDataProvider
{
public:
- typedef Dali::Vector< Sampler* > Samplers;
/**
* Constructor
* Get the samplers this material uses.
* @return the samplers
*/
- const Samplers& GetSamplers() const;
+ virtual const Samplers& GetSamplers() const;
private:
Shader* mShader;
- Samplers mSamplers; // Not owned (though who does?)
+ Samplers mSamplers; // Not owned ( @todo MESH_REWORK though who does?)
+
+ AnimatableProperty<Vector4> mColor;
// @todo MESH_REWORK add property values for cull face mode, blending options, blend color
// Add getters/setters?
namespace SceneGraph
{
-Sampler::Sampler( const std::string& samplerName )
-: mUniformName( samplerName ),
- mTextureId( 0 ),
+Sampler::Sampler( const std::string& unitName )
+: mUnitName( unitName ),
mMinFilter( Dali::Sampler::DEFAULT ),
mMagFilter( Dali::Sampler::DEFAULT ),
mUWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
mVWrapMode( Dali::Sampler::CLAMP_TO_EDGE )
{
+ mTextureId[0] = 0;
+ mTextureId[1] = 0;
}
Sampler::~Sampler()
{
}
-void Sampler::SetUniformName( const std::string& samplerName )
+void Sampler::SetUnitName( const std::string& unitName )
{
+ mUnitName = unitName;
}
-void Sampler::SetTextureId( ResourceId textureId )
+void Sampler::SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId, const BitmapMetadata& metadata )
{
- mTextureId = textureId;
+ mTextureId[bufferIndex] = textureId;
+ mBitmapMetadata[bufferIndex] = metadata;
}
void Sampler::SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter )
{
}
-const std::string& Sampler::GetUniformName()
+const std::string& Sampler::GetUnitName()
{
- // @todo MESH_REWORK
- return mUniformName;
+ return mUnitName;
}
-Integration::ResourceId Sampler::GetTextureId()
+Integration::ResourceId Sampler::GetTextureId( BufferIndex bufferIndex ) const
{
- // @todo MESH_REWORK
- return mTextureId;
+ return mTextureId[bufferIndex];
}
-Sampler::FilterMode Sampler::GetMinifyFilterMode( BufferIndex bufferIndex )
+Sampler::FilterMode Sampler::GetMinifyFilterMode( BufferIndex bufferIndex ) const
{
- // @todo MESH_REWORK
return mMinFilter[bufferIndex];
}
-Sampler::FilterMode Sampler::GetMagnifyFilterMode( BufferIndex bufferIndex )
+Sampler::FilterMode Sampler::GetMagnifyFilterMode( BufferIndex bufferIndex ) const
{
- // @todo MESH_REWORK
return mMagFilter[bufferIndex];
}
-Sampler::WrapMode Sampler::GetUWrapMode( BufferIndex bufferIndex )
+Sampler::WrapMode Sampler::GetUWrapMode( BufferIndex bufferIndex ) const
{
- // @todo MESH_REWORK
return mUWrapMode[bufferIndex];
}
-Sampler::WrapMode Sampler::GetVWrapMode( BufferIndex bufferIndex )
+Sampler::WrapMode Sampler::GetVWrapMode( BufferIndex bufferIndex ) const
{
- // @todo MESH_REWORK
return mVWrapMode[bufferIndex];
}
-bool Sampler::IsFullyOpaque()
+bool Sampler::AffectsTransparency( BufferIndex bufferIndex ) const
{
- return true; // @todo MESH_REWORK - check the actual image. For the moment, pretend it's opaque
+ return mAffectsTransparency[bufferIndex] ;
+}
+
+bool Sampler::IsFullyOpaque( BufferIndex bufferIndex ) const
+{
+ return mBitmapMetadata[bufferIndex].IsFullyOpaque();
}
} // namespace SceneGraph
*/
#include <dali/public-api/shader-effects/sampler.h>
+#include <dali/integration-api/resource-declarations.h>
#include <dali/internal/common/event-to-update.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/render/renderers/sampler-data-provider.h>
+#include <dali/internal/update/resources/bitmap-metadata.h>
+#include <dali/internal/render/data-providers/sampler-data-provider.h>
#include <string>
* Set the uniform name of this sampler. This allows the shader to find the
* GL index of this sampler.
*/
- void SetUniformName( const std::string& samplerName );
+ void SetUnitName( const std::string& unitName );
/**
- * Set the texture identity of this sampler
+ * Set the texture identity of this sampler (needs to double buffer this value because
+ * it can be read through the data provider interface in the render thread )
+ * @param[in] bufferIndex The buffer index to use
* @param[in] textureId The identity of the texture
+ * @param[in] bitmapMetadata The metadata for the texture
*/
- void SetTextureId( ResourceId textureId );
+ void SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId, const BitmapMetadata& bitmapMetadata );
/**
* Set the filter modes for minify and magnify filters
*/
void SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap );
-public: // SamplerDataProvider interface
/**
- *
+ * @param[in] bufferIndex The buffer index to use
+ * @return true if this sampler affects transparency of the material
+ * @note this should only be called from Update thread
+ */
+ bool AffectsTransparency( BufferIndex bufferIndex ) const;
+
+ /**
+ * @param[in] bufferIndex The buffer index to use
+ * @return true if the texture is fully opaque
+ * @note this should only be called from Update thread
+ */
+ bool IsFullyOpaque( BufferIndex bufferIndex ) const;
+
+
+public: // SamplerDataProvider interface - called from RenderThread
+ /**
+ * Get the texture unit uniform name
+ * @return the name of the texture unit uniform
*/
- const std::string& GetUniformName();
+ virtual const std::string& GetUnitName();
/**
* Get the texture ID
+ * @param[in] bufferIndex The buffer index to use
* @return the identity of the associated texture
*/
- virtual ResourceId GetTextureId();
+ virtual Integration::ResourceId GetTextureId(BufferIndex buffer) const;
/**
* Get the filter mode
* @param[in] bufferIndex The buffer index to use
* @return The minify filter mode
*/
- virtual FilterMode GetMinifyFilterMode( BufferIndex bufferIndex );
+ virtual FilterMode GetMinifyFilterMode( BufferIndex bufferIndex ) const;
/**
* Get the filter mode
* @param[in] bufferIndex The buffer index to use
* @return The magnify filter mode
*/
- virtual FilterMode GetMagnifyFilterMode( BufferIndex bufferIndex );
+ virtual FilterMode GetMagnifyFilterMode( BufferIndex bufferIndex ) const;
/**
* Get the horizontal wrap mode
* @param[in] bufferIndex The buffer index to use
* @return The horizontal wrap mode
*/
- virtual WrapMode GetUWrapMode( BufferIndex bufferIndex );
+ virtual WrapMode GetUWrapMode( BufferIndex bufferIndex ) const;
/**
* Get the vertical wrap mode
* @param[in] bufferIndex The buffer index to use
* @return The vertical wrap mode
*/
- virtual WrapMode GetVWrapMode( BufferIndex bufferIndex );
-
- /**
- * @return true if the texture is fully opaque.
- * @todo MESH_REWORK Requires access to ResourceManager::GetBitmapMetadata()
- */
- bool IsFullyOpaque();
+ virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) const;
private:
- std::string mUniformName; ///< The name of the uniform referencing this sampler
- ResourceId mTextureId; ///< The identity of the associated texture
+ std::string mUnitName; ///< The name of the uniform of the texture unit
+ // @todo MESH_REWORK Need these to automatically copy
+ // new value into old value on frame change
+
+ ResourceId mTextureId[2]; ///< The identity of the associated texture for this frame (Can be read from RenderThread)
+
+ BitmapMetadata mBitmapMetadata[2]; /// The meta data of the associated texture for this frame (Not needed in RenderThread)
+
+ // @todo MESH_REWORK These need to be non-animatable properties (that also copy
+ // new values into old on frame change ) that can be read in RenderThread
DoubleBuffered<FilterMode> mMinFilter; ///< The minify filter
DoubleBuffered<FilterMode> mMagFilter; ///< The magnify filter
DoubleBuffered<WrapMode> mUWrapMode; ///< The horizontal wrap mode
DoubleBuffered<WrapMode> mVWrapMode; ///< The vertical wrap mode
+
+ // Note, this is only called from UpdateThread
+ DoubleBuffered<bool> mAffectsTransparency; ///< If this sampler affects renderer transparency
};
inline void SetUniformNameMessage( EventToUpdate& eventToUpdate, const Sampler& sampler, const std::string& name )
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &sampler, &Sampler::SetUniformName, name );
+ new (slot) LocalType( &sampler, &Sampler::SetUnitName, name );
}
} // namespace SceneGraph
mIndexBuffer.Reset();
}
-void Geometry::SetGeometryType( Geometry::GeometryType geometryType )
+void Geometry::SetGeometryType( BufferIndex bufferIndex, Geometry::GeometryType geometryType )
{
- mGeometryType = geometryType;
+ mGeometryType[bufferIndex] = geometryType;
}
-const Geometry::VertexBuffers& Geometry::GetVertexBuffers()
+const GeometryDataProvider::VertexBuffers& Geometry::GetVertexBuffers() const
{
return mVertexBuffers;
}
-const PropertyBuffer& Geometry::GetIndexBuffer()
+const PropertyBuffer* Geometry::GetIndexBuffer() const
{
- return *mIndexBuffer.Get();
+ return mIndexBuffer.Get();
}
-Geometry::GeometryType Geometry::GetGeometryType( )
+Geometry::GeometryType Geometry::GetGeometryType( BufferIndex bufferIndex) const
{
- return mGeometryType;
+ int geometryType = mGeometryType[ bufferIndex ];
+ return static_cast< GeometryDataProvider::GeometryType > ( geometryType );
+}
+
+bool Geometry::GetRequiresDepthTest( BufferIndex bufferIndex ) const
+{
+ return mRequiresDepthTest.GetBoolean( bufferIndex );
}
} // namespace SceneGraph
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/property-boolean.h>
#include <dali/internal/update/common/scene-graph-property-buffer.h>
+#include <dali/internal/render/data-providers/geometry-data-provider.h>
namespace Dali
{
* This scene graph object is a property owner. It describes a geometry using a
* number of PropertyBuffers acting as Vertex buffers.
*/
-class Geometry : public PropertyOwner
+class Geometry : public PropertyOwner, public GeometryDataProvider
{
public:
- typedef Dali::Geometry::GeometryType GeometryType;
-
- typedef OwnerContainer< PropertyBuffer* > VertexBuffers;
/**
* Constructor
* Set the type of geometry to draw (Points, Lines, Triangles, etc)
* @param[in] geometryType The geometry type
*/
- void SetGeometryType( GeometryType geometryType );
+ void SetGeometryType( BufferIndex bufferIndex, GeometryType geometryType );
public: // GeometryDataProvider
/**
* Get the vertex buffers of the geometry
* @return A const reference to the vertex buffers
*/
- virtual const VertexBuffers& GetVertexBuffers();
+ virtual const GeometryDataProvider::VertexBuffers& GetVertexBuffers() const;
/**
* Get the index buffer of the geometry
- * @return A const reference to the index buffer
+ * @return A const pointer to the index buffer if it exists, or NULL if it doesn't.
*/
- virtual const PropertyBuffer& GetIndexBuffer();
+ virtual const PropertyBuffer* GetIndexBuffer() const;
/**
* Get the type of geometry to draw
*/
- virtual GeometryType GetGeometryType( );
+ virtual GeometryType GetGeometryType( BufferIndex bufferIndex ) const;
+
+ /**
+ * Returns true if this geometry requires depth testing, e.g. if it is
+ * a set of vertices with z != 0
+ */
+ virtual bool GetRequiresDepthTest( BufferIndex bufferIndex ) const;
private:
VertexBuffers mVertexBuffers; ///< The vertex buffers
OwnerPointer<PropertyBuffer> mIndexBuffer; ///< The index buffer if required
private: // Properties
- AnimatableProperty<Vector3> mCenter;
- AnimatableProperty<Vector3> mHalfExtents;
- GeometryType mGeometryType; ///< The type of geometry (tris/lines etc)
- AnimatableProperty<bool> mRequiresDepthTest;
+ //DoubleBufferedProperty<Vector3> mCenter;
+ //DoubleBufferedProperty<Vector3> mHalfExtents;
+ //DoubleBufferedProperty<GeometryType> mGeometryType; ///< The type of geometry (tris/lines etc)
+ //DoubleBufferedProperty<bool> mRequiresDepthTest;
+
+ AnimatableProperty<Vector3> mCenter;
+ AnimatableProperty<Vector3> mHalfExtents;
+ AnimatableProperty<int> mGeometryType; ///< The type of geometry (tris/lines etc)
+ PropertyBoolean mRequiresDepthTest;
};
inline void AddVertexBufferMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, PropertyBuffer& vertexBuffer )
inline void SetGeometryTypeMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, SceneGraph::Geometry::GeometryType geometryType )
{
- typedef MessageValue1< Geometry, SceneGraph::Geometry::GeometryType > LocalType;
+ typedef MessageDoubleBuffered1< Geometry, SceneGraph::Geometry::GeometryType > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
*/
inline void SetOpaqueRenderFlags( RenderList& renderList, bool transparentRenderersExist, bool stencilRenderablesExist, bool depthTestDisabled )
{
+ //@todo MESH_REWORK Move RequiresDepthTest from render thread object to update thread object
+
// Special optimization if depth test is disabled or if only one opaque rendered in the layer (for example background image)
// and this renderer does not need depth test against itself (e.g. mesh)
// and if this layer has got exactly one opaque renderer
// This keeps the material alive, until the render-thread has finished with it
mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), materials.Release( iter ) );
+ materials.Erase(iter);
return;
}
}
#include <dali/internal/update/animation/scene-graph-animation.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
-#include <dali/internal/update/geometry/scene-graph-geometry.h>
-#include <dali/internal/update/effects/scene-graph-material.h>
#include <dali/internal/update/node-attachments/node-attachment.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
+//@todo MESH_REWORK Move messages to a separate file to avoid having dependent headers
+// pollute core & slow the build down.
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/effects/scene-graph-material.h>
+
+
namespace Dali
{
*/
#include "scene-graph-renderer-attachment.h"
+#include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/effects/scene-graph-sampler.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/resources/complete-status-manager.h>
+#include <dali/internal/update/resources/resource-manager.h>
+#include <dali/internal/render/queue/render-queue.h>
+#include <dali/internal/render/renderers/render-renderer.h>
namespace Dali
{
namespace SceneGraph
{
+RendererAttachment* RendererAttachment::New()
+{
+ return new RendererAttachment();
+}
+
+
RendererAttachment::RendererAttachment()
: RenderableAttachment( false ),
+ mRenderer(NULL),
mMaterial(NULL),
mGeometry(NULL),
mDepthIndex(0)
mGeometry=NULL;
}
-void RendererAttachment::SetMaterial(const Material* material)
+void RendererAttachment::SetMaterial( BufferIndex updateBufferIndex, const Material* material)
{
- // @todo MESH_REWORK
mMaterial = material;
+
+ // Tell renderer about a new provider
+ {
+ typedef MessageValue1< NewRenderer, const MaterialDataProvider*> DerivedType;
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+ new (slot) DerivedType( mRenderer, &NewRenderer::SetMaterialDataProvider, material );
+ }
}
const Material& RendererAttachment::GetMaterial() const
return *mMaterial;
}
-void RendererAttachment::SetGeometry(const Geometry* geometry)
+void RendererAttachment::SetGeometry( BufferIndex updateBufferIndex, const Geometry* geometry)
{
- // @todo MESH_REWORK
mGeometry = geometry;
+
+ // Tell renderer about a new provider
+ {
+ typedef MessageValue1< NewRenderer, const GeometryDataProvider*> DerivedType;
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+ new (slot) DerivedType( mRenderer, &NewRenderer::SetGeometryDataProvider, geometry );
+ }
}
const Geometry& RendererAttachment::GetGeometry() const
return mDepthIndex;
}
+
+Renderer& RendererAttachment::GetRenderer()
+{
+ return *mRenderer;
+}
+
+const Renderer& RendererAttachment::GetRenderer() const
+{
+ return *mRenderer;
+}
+
+void RendererAttachment::DoPrepareRender( BufferIndex updateBufferIndex )
+{
+ // Do nothing
+}
+
+bool RendererAttachment::IsFullyOpaque( BufferIndex updateBufferIndex )
+{
+ bool opaque = false;
+
+ if( mParent )
+ {
+ opaque = mParent->GetWorldColor( updateBufferIndex ).a >= FULLY_OPAQUE;
+ }
+
+ // Require that all affecting samplers are opaque
+ unsigned int opaqueCount=0;
+ unsigned int affectingCount=0;
+ const Material::Samplers& samplers = mMaterial->GetSamplers();
+ for( Material::Samplers::ConstIterator iter = samplers.Begin();
+ iter != samplers.End(); ++iter )
+ {
+ const Sampler* sampler = static_cast<const Sampler*>(*iter);
+ if( sampler->AffectsTransparency( updateBufferIndex ) )
+ {
+ affectingCount++;
+ if( sampler->IsFullyOpaque( updateBufferIndex ) )
+ {
+ opaqueCount++;
+ }
+ }
+ }
+ opaque = (opaqueCount == affectingCount);
+
+ return opaque;
+}
+
+void RendererAttachment::SizeChanged( BufferIndex updateBufferIndex )
+{
+ // Do nothing.
+}
+
+void RendererAttachment::ConnectToSceneGraph2( BufferIndex updateBufferIndex )
+{
+ DALI_ASSERT_DEBUG( mSceneController );
+ mRenderer = NewRenderer::New( *mParent, mGeometry, mMaterial );
+ mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
+}
+
+void RendererAttachment::OnDestroy2()
+{
+ DALI_ASSERT_DEBUG( mSceneController );
+ mSceneController->GetRenderMessageDispatcher().RemoveRenderer( *mRenderer );
+ mRenderer = NULL;
+}
+
+bool RendererAttachment::DoPrepareResources(
+ BufferIndex updateBufferIndex,
+ ResourceManager& resourceManager )
+{
+ DALI_ASSERT_DEBUG( mSceneController );
+
+ CompleteStatusManager& completeStatusManager = mSceneController->GetCompleteStatusManager();
+
+ bool ready = false;
+ mFinishedResourceAcquisition = false;
+
+ if( mGeometry && mMaterial )
+ {
+ unsigned int completeCount = 0;
+ unsigned int neverCount = 0;
+ unsigned int frameBufferCount = 0;
+
+ const Material::Samplers& samplers = mMaterial->GetSamplers();
+ for( Material::Samplers::ConstIterator iter = samplers.Begin();
+ iter != samplers.End(); ++iter )
+ {
+ const Sampler* sampler = static_cast<const Sampler*>(*iter);
+
+ ResourceId textureId = sampler->GetTextureId( updateBufferIndex );
+ switch( completeStatusManager.GetStatus( textureId ) )
+ {
+ case CompleteStatusManager::NOT_READY:
+ {
+ ready = false;
+ BitmapMetadata metaData = resourceManager.GetBitmapMetadata( textureId );
+ if( metaData.GetIsFramebuffer() )
+ {
+ frameBufferCount++;
+ }
+ FollowTracker( textureId ); // @todo MESH_REWORK Trackers per sampler rather than per actor?
+ }
+ break;
+
+ case CompleteStatusManager::COMPLETE:
+ {
+ completeCount++;
+ }
+ break;
+
+ case CompleteStatusManager::NEVER:
+ {
+ neverCount++;
+ }
+ break;
+ }
+ }
+
+ // We are ready if all samplers are complete, or those that aren't are framebuffers
+ // We are complete if all samplers are either complete or will never complete
+
+ ready = ( completeCount + frameBufferCount >= samplers.Count() ) ;
+ mFinishedResourceAcquisition = ( completeCount + neverCount >= samplers.Count() );
+ }
+ return ready;
+}
+
+
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/controllers/render-message-dispatcher.h>
+#include <dali/internal/update/controllers/scene-controller.h>
#include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
+#include <dali/internal/render/data-providers/uniform-map-provider.h>
namespace Dali
{
{
class Material;
class Geometry;
+class NewRenderer;
-class RendererAttachment : public RenderableAttachment, public PropertyOwner
+class RendererAttachment : public RenderableAttachment, public PropertyOwner, public UniformMapProvider
{
public:
/**
+ * Create a new renderer attachment.
+ * @return The newly allocated RendererAttachment
+ */
+ static RendererAttachment* New();
+
+ /**
* Constructor
*/
RendererAttachment();
/**
* Set the material for the renderer
+ * @param[in] bufferIndex The current frame's buffer index
* @param[in] material The material this renderer will use
*/
- void SetMaterial(const Material* material);
+ void SetMaterial( BufferIndex bufferIndex, const Material* material);
/**
* Get the material of this renderer
/**
* Set the geometry for the renderer
+ * @param[in] bufferIndex The current frame's buffer index
* @param[in] geometry The geometry this renderer will use
*/
- void SetGeometry(const Geometry* geometry);
+ void SetGeometry( BufferIndex bufferIndex, const Geometry* geometry);
/**
* Get the geometry of this renderer
*/
int GetDepthIndex() const ;
+protected: // From RenderableAttachment
+ /**
+ * @copydoc RenderableAttachment::GetRenderer().
+ */
+ virtual Renderer& GetRenderer();
+
+ /**
+ * @copydoc RenderableAttachment::GetRenderer().
+ */
+ virtual const Renderer& GetRenderer() const;
+
+ /**
+ * @copydoc RenderableAttachment::DoPrepareRender()
+ */
+ virtual void DoPrepareRender( BufferIndex updateBufferIndex );
+
+ /**
+ * @copydoc RenderableAttachment::IsFullyOpaque()
+ */
+ virtual bool IsFullyOpaque( BufferIndex updateBufferIndex );
+
+ /**
+ * @copydoc RenderableAttachment::SizeChanged()
+ */
+ virtual void SizeChanged( BufferIndex updateBufferIndex );
+
+ /**
+ * @copydoc RenderableAttachment::ConnectToSceneGraph2().
+ */
+ virtual void ConnectToSceneGraph2( BufferIndex updateBufferIndex );
+
+ /**
+ * @copydoc RenderableAttachment::OnDestroy2().
+ */
+ virtual void OnDestroy2();
+
+ /**
+ * @copydoc RenderableAttachment::DoPrepareResources()
+ */
+ virtual bool DoPrepareResources( BufferIndex updateBufferIndex,
+ ResourceManager& resourceManager );
+
private:
+ NewRenderer* mRenderer; ///< Raw pointer to the new renderer (that's owned by RenderManager)
+
const Material* mMaterial; ///< The material this renderer uses. (Not owned)
const Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned)
+
int mDepthIndex; ///< Used only in PrepareRenderInstructions
};
inline void SetMaterialMessage( EventToUpdate& eventToUpdate, const RendererAttachment& attachment, const Material& material )
{
- typedef MessageValue1< RendererAttachment, const Material* > LocalType;
+ typedef MessageDoubleBuffered1< RendererAttachment, const Material* > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
inline void SetGeometryMessage( EventToUpdate& eventToUpdate, const RendererAttachment& attachment, const Geometry& geometry )
{
- typedef MessageValue1< RendererAttachment, const Geometry* > LocalType;
+ typedef MessageDoubleBuffered1< RendererAttachment, const Geometry* > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
#include <dali/integration-api/debug.h>
#include <dali/internal/update/nodes/node-declarations.h>
#include <dali/internal/update/node-attachments/node-attachment-declarations.h>
-#include <dali/internal/render/renderers/render-data-provider.h>
+#include <dali/internal/render/data-providers/node-data-provider.h>
namespace Dali
{
/**
* Node is the base class for all nodes in the Scene Graph.
- * Each node provides a transformation which applies to the node and its children.
- * Node data is double-buffered. This allows an update thread to modify node data, without interferring
- * with another thread reading the values from the previous update traversal.
+ *
+ * Each node provides a transformation which applies to the node and
+ * its children. Node data is double-buffered. This allows an update
+ * thread to modify node data, without interferring with another
+ * thread reading the values from the previous update traversal.
*/
-class Node : public PropertyOwner, public RenderDataProvider
+class Node : public PropertyOwner, public NodeDataProvider
{
public:
*/
Node();
-private: // from RenderDataProvider
+private: // from NodeDataProvider
/**
- * @copydoc RenderDataProvider::GetModelMatrix
+ * @copydoc NodeDataProvider::GetModelMatrix
*/
virtual const Matrix& GetModelMatrix( unsigned int bufferId )
{
}
/**
- * @copydoc RenderDataProvider::GetRenderColor
+ * @copydoc NodeDataProvider::GetRenderColor
*/
virtual const Vector4& GetRenderColor( unsigned int bufferId )
{