#include <stdlib.h>
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
-#include <dali/devel-api/object/property-buffer.h>
-#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/material.h>
-#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/sampler.h>
-#include <dali/devel-api/rendering/shader.h>
using namespace Dali;
// This should not be culled
DALI_TEST_CHECK( drawTrace.FindMethod( "DrawElements" ) );
END_TEST;
-}
+}
\ No newline at end of file
*/
#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/object/property-buffer.h>
-#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/material.h>
-#include <dali/devel-api/rendering/sampler.h>
-#include <dali/devel-api/rendering/renderer.h>
namespace Dali
{
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
-#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/renderer.h>
using namespace Dali;
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
-#include <dali/devel-api/rendering/renderer.h>
using namespace Dali;
develapiimagesdir = $(develapidir)/images
develapimodelingdir = $(develapidir)/modeling
develapiobjectdir = $(develapidir)/object
-develapirenderingdir = $(develapidir)/rendering
develapiscriptingdir = $(develapidir)/scripting
develapi_HEADERS = $(devel_api_header_files)
develapiimages_HEADERS = $(devel_api_core_images_header_files)
develapimodeling_HEADERS = $(devel_api_core_modeling_header_files)
develapiobject_HEADERS = $(devel_api_core_object_header_files)
-develapirendering_HEADERS = $(devel_api_core_rendering_header_files)
develapiscripting_HEADERS = $(devel_api_core_scripting_header_files)
publicapianimationdir = $(publicapidir)/animation
publicapicommondir = $(publicapidir)/common
publicapieventsdir = $(publicapidir)/events
+publicapigeometrydir = $(publicapidir)/geometry
publicapiimagesdir = $(publicapidir)/images
publicapimathdir = $(publicapidir)/math
publicapiobjectdir = $(publicapidir)/object
publicapianimation_HEADERS = $(public_api_core_animation_header_files)
publicapicommon_HEADERS = $(public_api_core_common_header_files)
publicapievents_HEADERS = $(public_api_core_events_header_files)
+publicapigeometry_HEADERS = $(public_api_core_geometry_header_files)
publicapiimages_HEADERS = $(public_api_core_images_header_files)
publicapimath_HEADERS = $(public_api_core_math_header_files)
publicapirendertasks_HEADERS = $(public_api_core_render_tasks_header_files)
$(devel_api_src_dir)/geometry/cloth.cpp \
$(devel_api_src_dir)/images/atlas.cpp \
$(devel_api_src_dir)/images/distance-field.cpp \
- $(devel_api_src_dir)/object/property-buffer.cpp \
- $(devel_api_src_dir)/rendering/geometry.cpp \
- $(devel_api_src_dir)/rendering/material.cpp \
- $(devel_api_src_dir)/rendering/renderer.cpp \
- $(devel_api_src_dir)/rendering/sampler.cpp \
- $(devel_api_src_dir)/rendering/shader.cpp \
$(devel_api_src_dir)/scripting/scripting.cpp
# Add devel header files here DALi internal developer files used by Adaptor & Toolkit
$(devel_api_src_dir)/dynamics/dynamics-world.h \
$(devel_api_src_dir)/dynamics/dynamics-world-config.h
+
devel_api_core_events_header_files = \
$(devel_api_src_dir)/events/hit-test-algorithm.h
+
devel_api_core_geometry_header_files = \
$(devel_api_src_dir)/geometry/cloth.h
+
devel_api_core_images_header_files = \
$(devel_api_src_dir)/images/atlas.h \
$(devel_api_src_dir)/images/distance-field.h
devel_api_core_object_header_files = \
- $(devel_api_src_dir)/object/property-buffer.h \
$(devel_api_src_dir)/object/type-registry-helper.h
-devel_api_core_rendering_header_files = \
- $(devel_api_src_dir)/rendering/geometry.h \
- $(devel_api_src_dir)/rendering/material.h \
- $(devel_api_src_dir)/rendering/renderer.h \
- $(devel_api_src_dir)/rendering/sampler.h \
- $(devel_api_src_dir)/rendering/shader.h
-
devel_api_core_scripting_header_files = \
$(devel_api_src_dir)/scripting/scripting.h
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/vector4.h>
#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/object/property-buffer.h>
namespace Dali
{
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/object/property-buffer.h> // Dali::PropertyBuffer
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/property-map.h> // Dali::Property::Map
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
-
-namespace Dali
-{
-
-PropertyBuffer PropertyBuffer::New( Dali::Property::Map& bufferFormat, std::size_t size )
-{
- Internal::PropertyBufferPtr propertyBuffer = Internal::PropertyBuffer::New();
-
- propertyBuffer->SetFormat( bufferFormat );
- propertyBuffer->SetSize( size );
-
- return PropertyBuffer( propertyBuffer.Get() );
-}
-
-PropertyBuffer::PropertyBuffer()
-{
-}
-
-PropertyBuffer::~PropertyBuffer()
-{
-}
-
-PropertyBuffer::PropertyBuffer( const PropertyBuffer& handle )
-: Handle( handle )
-{
-}
-
-PropertyBuffer PropertyBuffer::DownCast( BaseHandle handle )
-{
- return PropertyBuffer( dynamic_cast<Dali::Internal::PropertyBuffer*>(handle.GetObjectPtr()));
-}
-
-PropertyBuffer& PropertyBuffer::operator=( const PropertyBuffer& handle )
-{
- BaseHandle::operator=( handle );
- return *this;
-}
-
-void PropertyBuffer::SetSize( std::size_t size )
-{
- GetImplementation(*this).SetSize( size );
-}
-
-std::size_t PropertyBuffer::GetSize() const
-{
- return GetImplementation(*this).GetSize();
-}
-
-void PropertyBuffer::SetData( void* data )
-{
- GetImplementation(*this).SetData( data );
-}
-
-PropertyBuffer::PropertyBuffer( Internal::PropertyBuffer* pointer )
-: Handle( pointer )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_PROPERTY_BUFFER_H
-#define DALI_PROPERTY_BUFFER_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cstddef> // std::size_t
-#include <string> // std::string
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/object/property.h> // Dali::Property::Index
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-#include <dali/public-api/object/property-map.h> // Dali::Property::Map
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class PropertyBuffer;
-}
-
-/**
- * @brief PropertyBuffer is a handle to an object that contains a buffer of structured properties
- *
- * PropertyBuffers can be used to provide data to Geometry objects.
- *
- * Example:
- *
- * const float halfQuadSize = .5f;
- * struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
- * TexturedQuadVertex texturedQuadVertexData[4] = {
- * { Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
- * { Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
- * { Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
- * { Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
- *
- * Property::Map texturedQuadVertexFormat;
- * texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
- * texturedQuadVertexFormat["aTexCoord"] = Property::VECTOR2;
- * PropertyBuffer texturedQuadVertices = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
- * texturedQuadVertices.SetData(texturedQuadVertexData);
- *
- * // Create indices
- * unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
- * Property::Map indexFormat;
- * indexFormat["indices"] = Property::UNSIGNED_INTEGER;
- * PropertyBuffer indices = PropertyBuffer::New( indexFormat, 6 );
- * indices.SetData(indexData);
- *
- * // Create the geometry object
- * Geometry texturedQuadGeometry = Geometry::New();
- * texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
- * texturedQuadGeometry.SetIndexBuffer( indices );
- *
- */
-class DALI_IMPORT_API PropertyBuffer : public Handle
-{
-public:
-
- /**
- * @brief An enumeration of properties belonging to the PropertyBuffer class.
- */
- struct Property
- {
- enum
- {
- SIZE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "size", type UNSIGNED_INT
- BUFFER_FORMAT, ///< name "buffer-format", type MAP
- };
- };
-
- /**
- * @brief Create a PropertyBuffer
- *
- * Static property buffers use less memory.
- *
- * @param[in] bufferFormat Map of names and types that describes the components of the buffer
- * @param[in] size The number of elements in the property buffer
- * @return Handle to a newly allocated PropertyBuffer
- */
- static PropertyBuffer New( Dali::Property::Map& bufferFormat, std::size_t size );
-
- /**
- * @brief Default constructor, creates an empty handle
- */
- PropertyBuffer();
-
- /**
- * @brief Destructor
- */
- ~PropertyBuffer();
-
- /**
- * @brief Copy constructor, creates a new handle to the same object
- *
- * @param[in] handle Handle to an object
- */
- PropertyBuffer( const PropertyBuffer& handle );
-
- /**
- * @brief Downcast to a property buffer handle.
- *
- * If not a property buffer the returned property buffer handle is left uninitialized.
- * @param[in] handle to an object
- * @return property buffer handle or an uninitialized handle
- */
- static PropertyBuffer DownCast( BaseHandle handle );
-
- /**
- * @brief Assignment operator, changes this handle to point at the same object
- *
- * @param[in] handle Handle to an object
- * @return Reference to the assigned object
- */
- PropertyBuffer& operator=( const PropertyBuffer& handle );
-
- /**
- * @brief Set the number of elements in the buffer
- *
- * Calling this function is equivalent to setting the property SIZE
- *
- * @param[in] size Number of elements to expand or contract the buffer
- */
- void SetSize( std::size_t size );
-
- /**
- * @brief Get the number of elements in the buffer
- *
- * @return Number of elements to expand or contract the buffer
- */
- std::size_t GetSize() const;
-
- /**
- * @brief Update the whole buffer information
- *
- * This function expects a pointer to an array of structures with the same
- * format that was given in the construction, and the number of elements to
- * be the sane as the size of the buffer.
- *
- * If the initial structure was: { { "position", VECTOR3}, { "uv", VECTOR2 } }
- * and a size of 10 elements, this function should be called with a pointer equivalent to:
- * <pre>
- * struct Vertex {
- * Dali::Vector3 position;
- * Dali::Vector2 uv;
- * };
- * Vertex vertices[ 10 ] = { ... };
- * propertyBuffer.SetData( vertices );
- * </pre>
- *
- * @param[in] data A pointer to the data that will be copied to the buffer.
- */
- void SetData( void* data );
-
-public:
- /**
- * @brief The constructor
- *
- * @param [in] pointer A pointer to a newly allocated PropertyBuffer
- */
- explicit DALI_INTERNAL PropertyBuffer( Internal::PropertyBuffer* pointer );
-};
-
-} // namespace Dali
-
-#endif // DALI_PROPERTY_BUFFER_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
-
-namespace Dali
-{
-
-Geometry Geometry::New()
-{
- Internal::GeometryPtr geometry = Internal::Geometry::New();
- return Geometry( geometry.Get() );
-}
-
-Geometry::Geometry()
-{
-}
-
-Geometry::~Geometry()
-{
-}
-
-Geometry::Geometry( const Geometry& handle )
-: Handle( handle )
-{
-}
-
-Geometry Geometry::DownCast( BaseHandle handle )
-{
- return Geometry( dynamic_cast<Dali::Internal::Geometry*>(handle.GetObjectPtr()));
-}
-
-Geometry& Geometry::operator=( const Geometry& handle )
-{
- BaseHandle::operator=( handle );
- return *this;
-}
-
-std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer )
-{
- DALI_ASSERT_ALWAYS( vertexBuffer && "VertexBuffer is not initialized ");
- return GetImplementation(*this).AddVertexBuffer( GetImplementation( vertexBuffer ) );
-}
-
-std::size_t Geometry::GetNumberOfVertexBuffers() const
-{
- return GetImplementation(*this).GetNumberOfVertexBuffers();
-}
-
-void Geometry::RemoveVertexBuffer( std::size_t index )
-{
- GetImplementation(*this).RemoveVertexBuffer( index );
-}
-
-void Geometry::SetIndexBuffer( PropertyBuffer& indexBuffer )
-{
- DALI_ASSERT_ALWAYS( indexBuffer && "indexBuffer is not initialized ");
- GetImplementation(*this).SetIndexBuffer( GetImplementation( indexBuffer ) );
-}
-
-void Geometry::SetGeometryType( GeometryType geometryType )
-{
- GetImplementation(*this).SetGeometryType( geometryType );
-}
-
-Geometry::GeometryType Geometry::GetGeometryType() const
-{
- return GetImplementation(*this).GetGeometryType();
-}
-
-void Geometry::SetRequiresDepthTesting( bool requiresDepthTest )
-{
- GetImplementation(*this).SetRequiresDepthTesting( requiresDepthTest );
-}
-
-bool Geometry::GetRequiresDepthTesting() const
-{
- return GetImplementation(*this).GetRequiresDepthTesting();
-}
-
-Geometry::Geometry( Internal::Geometry* pointer )
-: Handle( pointer )
-{
-}
-
-} //namespace Dali
+++ /dev/null
-#ifndef DALI_GEOMETRY_H
-#define DALI_GEOMETRY_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cstddef> // std::size_t
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-#include <dali/devel-api/object/property-buffer.h> // Dali::PropertyBuffer
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Geometry;
-}
-
-/**
- * @brief Geometry is handle to an object that can be used to define a geometric elements.
- */
-class DALI_IMPORT_API Geometry : public Handle
-{
-public:
-
- enum GeometryType
- {
- POINTS,
- LINES,
- LINE_LOOP,
- LINE_STRIP,
- TRIANGLES,
- TRIANGLE_FAN,
- TRIANGLE_STRIP
- };
-
- /**
- * @brief An enumeration of properties belonging to the Geometry class.
- */
- struct Property
- {
- enum
- {
- GEOMETRY_TYPE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depth-index", type STRING
- GEOMETRY_CENTER, ///< name "geometry-center", type VECTOR3
- GEOMETRY_HALF_EXTENTS, ///< name "geometry-half-extents", type VECTOR3
- REQUIRES_DEPTH_TEST, ///< name "requires-depth-testing", type BOOLEAN
- };
- };
-
- /**
- * @brief Creates a new Geometry object
- *
- * @return An handle to a newly allocated Geometry
- */
- static Geometry New();
-
- /**
- * @brief Default constructor, creates an empty handle
- */
- Geometry();
-
- /**
- * @brief Destructor
- */
- ~Geometry();
-
- /**
- * @brief Copy constructor, creates a new handle to the same object
- *
- * @param[in] handle Handle to an object
- */
- Geometry( const Geometry& handle );
-
- /**
- * @brief Downcast to a geometry.
- *
- * If not the returned handle is left uninitialized.
- * @param[in] handle to an object
- * @return geometry handle or an uninitialized handle
- */
- static Geometry DownCast( BaseHandle handle );
-
- /**
- * @brief Assignment operator, changes this handle to point at the same object
- *
- * @param[in] handle Handle to an object
- * @return Reference to the assigned object
- */
- Geometry& operator=( const Geometry& handle );
-
- /**
- * @brief Add a PropertyBuffer to be used as source of geometry vertices
- *
- * @param[in] vertexBuffer PropertyBuffer to be used as source of geometry vertices
- * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
- * this buffer if no longer required
- */
- std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
-
- /**
- * @brief Retrieve the number of vertex buffers that have been added to this geometry
- *
- * @return Number of vertex buffers that have been added to this geometry
- */
- std::size_t GetNumberOfVertexBuffers() const;
-
- /**
- * @brief Remove a vertex buffer
- *
- * The index must be between 0 and GetNumberOfVertexBuffers()
- *
- * @param[in] index Index to the vertex buffer to remove
- */
- void RemoveVertexBuffer( std::size_t index );
-
- /**
- * @brief Set a PropertyBuffer to be used as a source of indices for the geometry
- *
- * This buffer is required to have exactly one component and it must be of the type Property::INTEGER
- *
- * By setting this buffer the will case the geometry to be rendered using indices.
- * To unset call SetIndexBuffer with an empty handle.
- *
- * @param[in] indexBuffer PropertyBuffer to be used as a source of indices for the geometry
- */
- void SetIndexBuffer( PropertyBuffer& indexBuffer );
-
- /**
- * @brief Set the type of primitives this geometry contains
- *
- * @param[in] geometryType Type of primitives this geometry contains
- */
- void SetGeometryType( GeometryType geometryType );
-
- /**
- * @brief Get the type of primitives this geometry contains
- *
- * Calling this function sets the property GEOMETRY_TYPE
- *
- * @return Type of primitives this geometry contains
- */
- GeometryType GetGeometryType() const;
-
- /**
- * @brief Set if the geometry requires depth testing
- *
- * Should be set to true if this geometry has overlapping triangles in arbitrary order
- *
- * Calling this function is equivalent to setting the REQUIRES_DEPTH_TESTING property
- *
- * @param[in] requiresDepthTest Specifies if the geometry requires depth testing
- */
- void SetRequiresDepthTesting( bool requiresDepthTest );
-
- /**
- * @brief Return if the geometry requires depth testing
- *
- * @return True if the geometry requires depth testing
- */
- bool GetRequiresDepthTesting() const;
-
-public:
- /**
- * @brief The constructor
- *
- * @param [in] pointer A pointer to a newly allocated Geometry
- */
- explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
-};
-
-} //namespace Dali
-
-#endif // DALI_GEOMETRY_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/rendering/material.h> // Dali::Material
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/rendering/material-impl.h> // Dali::Internal::Material
-#include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
-#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
-
-namespace Dali
-{
-
-Material Material::New( Shader shader )
-{
- // TODO: MESH_REWORK
- Internal::MaterialPtr material = Internal::Material::New();
- material->SetShader( GetImplementation(shader) );
-
- return Material( material.Get() );
-}
-
-Material::Material()
-{
-}
-
-Material::~Material()
-{
-}
-
-Material::Material( const Material& handle )
-: Handle( handle )
-{
-}
-
-Material Material::DownCast( BaseHandle handle )
-{
- return Material( dynamic_cast<Dali::Internal::Material*>(handle.GetObjectPtr()));
-}
-
-Material& Material::operator=( const Material& handle )
-{
- BaseHandle::operator=( handle );
- return *this;
-}
-
-void Material::SetShader( Shader& shader )
-{
- DALI_ASSERT_ALWAYS( shader && "Shader handle is uninitialized" );
- GetImplementation(*this).SetShader( GetImplementation( shader ) );
-}
-
-Shader Material::GetShader() const
-{
- Internal::Shader* shaderPtr( GetImplementation(*this).GetShader() );
- return Dali::Shader( shaderPtr );
-}
-
-void Material::AddSampler( Sampler& sampler )
-{
- DALI_ASSERT_ALWAYS( sampler && "Sampler handle is uninitialized" );
- GetImplementation(*this).AddSampler( GetImplementation( sampler ) );
-}
-
-std::size_t Material::GetNumberOfSamplers() const
-{
- return GetImplementation(*this).GetNumberOfSamplers();
-}
-
-void Material::RemoveSampler( std::size_t index )
-{
- GetImplementation(*this).RemoveSampler( index );
-}
-
-Sampler Material::GetSamplerAt( unsigned int index ) const
-{
- Internal::Sampler* samplerPtr( GetImplementation(*this).GetSamplerAt(index) );
- return Dali::Sampler( samplerPtr );
-}
-
-void Material::SetFaceCullingMode( FaceCullingMode cullingMode )
-{
- GetImplementation(*this).SetFaceCullingMode( cullingMode );
-}
-
-void Material::SetBlendMode( BlendingMode::Type mode )
-{
- GetImplementation(*this).SetBlendMode( mode );
-}
-
-BlendingMode::Type Material::GetBlendMode() const
-{
- return GetImplementation(*this).GetBlendMode();
-}
-
-void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba,
- BlendingFactor::Type destFactorRgba )
-{
- GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba );
-}
-
-void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
- BlendingFactor::Type destFactorRgb,
- BlendingFactor::Type srcFactorAlpha,
- BlendingFactor::Type destFactorAlpha )
-{
- GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
-}
-
-void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
- BlendingFactor::Type& destFactorRgb,
- BlendingFactor::Type& srcFactorAlpha,
- BlendingFactor::Type& destFactorAlpha ) const
-{
- GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
-}
-
-void Material::SetBlendEquation( BlendingEquation::Type equationRgba )
-{
- GetImplementation(*this).SetBlendEquation( equationRgba );
-}
-
-void Material::SetBlendEquation( BlendingEquation::Type equationRgb,
- BlendingEquation::Type equationAlpha )
-{
- GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha );
-}
-
-void Material::GetBlendEquation( BlendingEquation::Type& equationRgb,
- BlendingEquation::Type& equationAlpha ) const
-{
- GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha );
-}
-
-void Material::SetBlendColor( const Vector4& color )
-{
- GetImplementation(*this).SetBlendColor( color );
-}
-
-const Vector4& Material::GetBlendColor() const
-{
- return GetImplementation(*this).GetBlendColor();
-}
-
-Material::Material( Internal::Material* pointer )
-: Handle( pointer )
-{
-}
-
-} //namespace Dali
+++ /dev/null
-#ifndef DALI_MATERIAL_H
-#define DALI_MATERIAL_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cstddef> // std::size_t
-#include <string> // std::string
-
-// INTERNAL INCLUDES
-#include <dali/public-api/actors/blending.h> // Dali::BlendingMode, Dali::BlendingEquation, Dali::BlendingFactor
-#include <dali/public-api/images/image.h> // Dali::Image
-#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-#include <dali/devel-api/rendering/sampler.h> // Dali::Sampler
-#include <dali/devel-api/rendering/shader.h> // Dali::Shader
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Material;
-}
-
-/**
- * @brief Material is a handle to an object that specifies the visual properties of the renderer.
- */
-class DALI_IMPORT_API Material : public Handle
-{
-public:
-
- /**
- * @brief Set face culling mode.
- */
- enum FaceCullingMode
- {
- NONE, ///< None of the faces should be culled
- CULL_BACK, ///< Cull back face, back face should never be shown
- CULL_BACK_HINT, ///< Cull back face hinting, will still display correctly if no culling is done
- CULL_FRONT, ///< Cull front face, back face should never be shown
- CULL_FRONT_HINT, ///< Cull front face hinting, will still display correctly if no culling is done
- CULL_BACK_AND_FRONT, ///< Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
- CULL_BACK_AND_FRONT_HINT, ///< Cull back and front hint, will still display correctly if no culling is done
- };
-
- /**
- * @brief An enumeration of properties belonging to the Material class.
- */
- struct Property
- {
- enum
- {
- COLOR = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "color", type VECTOR4
- FACE_CULLING_MODE, ///< name "face-culling-mode", type STRING
- BLENDING_MODE, ///< name "blending-mode", type STRING
- BLEND_EQUATION_RGB, ///< name "blend-equation-rgb", type STRING
- BLEND_EQUATION_ALPHA, ///< name "blend-equation-alpha", type STRING
- BLENDING_SRC_FACTOR_RGB, ///< name "source-blend-factor-rgb", type STRING
- BLENDING_DEST_FACTOR_RGB, ///< name "destination-blend-factor-rgb", type STRING
- BLENDING_SRC_FACTOR_ALPHA, ///< name "source-blend-factor-alpha", type STRING
- BLENDING_DEST_FACTOR_ALPHA, ///< name "destination-blend-factor-alpha", type STRING
- BLEND_COLOR, ///< name "blend-color", type VECTOR4
- };
- };
-
- /// @name Uniform Mapping
- /** @{ */
- ///< property "COLOR", uniform "uMaterialColor"
- /** @} */
-
- /**
- * @brief Creates a new Material object
- *
- * @return A handle to a newly allocated Material
- */
- static Material New( Shader shader );
-
- /**
- * @brief Default constructor, creates an empty handle
- */
- Material();
-
- /**
- * @brief Destructor
- */
- ~Material();
-
- /**
- * @brief Copy constructor, creates a new handle to the same object
- *
- * @param[in] handle Handle to an object
- */
- Material( const Material& handle );
-
- /**
- * @brief Downcast to a material handle.
- *
- * If handle is not a material, the returned handle is left uninitialized.
- * @param[in] handle to an object
- * @return material handle or an uninitialized handle
- */
- static Material DownCast( BaseHandle handle );
-
- /**
- * @brief Assignment operator, changes this handle to point at the same object
- *
- * @param[in] handle Handle to an object
- */
- Material& operator=( const Material& handle );
-
- /**
- * @brief Sets the Shader used by this material
- *
- * @param[in] shader Handle to a shader
- */
- void SetShader( Shader& shader );
-
- /**
- * @brief Gets the shader used by this material
- *
- * @return The shader used by the material
- */
- Shader GetShader() const;
-
- /**
- * @brief Add a sampler to this material
- *
- * param[in] sampler The sampler to add to this material
- */
- void AddSampler( Sampler& sampler );
-
- /**
- * @brief Get the number of samplers
- *
- * @return The number of samplers
- */
- std::size_t GetNumberOfSamplers() const;
-
- /**
- * @brief Remove a sampler
- *
- * The index must be between 0 and GetNumberOfSamplers()-1
- *
- * @param[in] index The index of the sampler to remove
- */
- void RemoveSampler( std::size_t index );
-
- /**
- * @brief Get the sampler at the given index for this material
- *
- * The index must be between 0 and GetNumberOfSamplers()-1
- *
- * @param[in] index The index of the sampler
- * @return The sampler at that index
- */
- Sampler GetSamplerAt( unsigned int index ) const;
-
- /**
- * @brief Set the culling mode for this material
- *
- * Calling this function sets the properties CULLING_MODE
- *
- * @param[in] cullingMode The culling mode for this material
- */
- void SetFaceCullingMode( FaceCullingMode cullingMode );
-
- /**
- * @brief Sets the blending mode.
- *
- * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
- *
- * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work.
- *
- * <ul>
- * <li> \e OFF Blending is disabled.
- * <li> \e AUTO Blending is enabled only if the renderable actor has alpha channel.
- * <li> \e ON Blending is enabled.
- * </ul>
- *
- * @param[in] mode The blending mode.
- */
- void SetBlendMode( BlendingMode::Type mode );
-
- /**
- * @brief Retrieves the blending mode.
- *
- * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON.
- */
- BlendingMode::Type GetBlendMode() const;
-
- /**
- * @brief Specify the pixel arithmetic used when the actor is blended.
- *
- * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
- * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
- * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
- * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
- *
- * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
- * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
- * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
- * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
- */
- void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
-
- /**
- * @brief Specify the pixel arithmetic used when the actor is blended.
- *
- * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
- * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
- * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
- * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
- *
- * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
- * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
- * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
- * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
- *
- * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
- * The options are the same as for srcFactorRgb.
- *
- * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
- * The options are the same as for destFactorRgb.
- */
- void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
- BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
-
- /**
- * @brief Query the pixel arithmetic used when the actor is blended.
- *
- * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
- * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
- * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
- * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
- */
- void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
- BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
-
- /**
- * @brief Specify the equation used when the actor is blended.
- *
- * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
- * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
- */
- void SetBlendEquation( BlendingEquation::Type equationRgba );
-
- /**
- * @brief Specify the equation used when the actor is blended.
- *
- * @param[in] equationRgb The equation used for combining red, green, and blue components.
- * @param[in] equationAlpha The equation used for combining the alpha component.
- * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
- */
- void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
-
- /**
- * @brief Query the equation used when the actor is blended.
- *
- * @param[out] equationRgb The equation used for combining red, green, and blue components.
- * @param[out] equationAlpha The equation used for combining the alpha component.
- */
- void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
-
- /**
- * @brief Specify the color used when the actor is blended; the default is Vector4::ZERO.
- *
- * @param[in] color The blend color.
- */
- void SetBlendColor( const Vector4& color );
-
- /**
- * @brief Query the color used when the actor is blended.
- *
- * @return The blend color.
- */
- const Vector4& GetBlendColor() const;
-
-public:
- /**
- * @brief The constructor
- *
- * @param [in] pointer A pointer to a newly allocated Material
- */
- explicit DALI_INTERNAL Material( Internal::Material* pointer );
-};
-
-} //namespace Dali
-
-
-
-#endif // DALI_MATERIAL_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/rendering/renderer-impl.h> // Dali::Internal::Renderer
-
-namespace Dali
-{
-
-Renderer Renderer::New( Geometry& geometry, Material& material )
-{
- Internal::RendererPtr renderer = Internal::Renderer::New( );
- renderer->SetGeometry( GetImplementation(geometry) );
- renderer->SetMaterial( GetImplementation(material) );
- return Renderer( renderer.Get() );
-}
-
-Renderer::Renderer()
-{
-}
-
-Renderer::~Renderer()
-{
-}
-
-Renderer::Renderer( const Renderer& handle )
-: Handle( handle )
-{
-}
-
-Renderer Renderer::DownCast( BaseHandle handle )
-{
- return Renderer( dynamic_cast<Dali::Internal::Renderer*>(handle.GetObjectPtr()));
-}
-
-Renderer& Renderer::operator=( const Renderer& handle )
-{
- BaseHandle::operator=( handle );
- return *this;
-}
-
-void Renderer::SetGeometry( Geometry& geometry )
-{
- DALI_ASSERT_ALWAYS( geometry && "Geometry handle not initialized" );
- GetImplementation(*this).SetGeometry( GetImplementation(geometry) );
-}
-
-Geometry Renderer::GetGeometry() const
-{
- Internal::Geometry* geometryPtr( GetImplementation(*this).GetGeometry() );
- return Dali::Geometry( geometryPtr );
-}
-
-void Renderer::SetMaterial( Material& material )
-{
- DALI_ASSERT_ALWAYS( material && "Material handle not initialized" );
- GetImplementation(*this).SetMaterial( GetImplementation(material) );
-}
-
-Material Renderer::GetMaterial() const
-{
- Internal::Material* materialPtr( GetImplementation(*this).GetMaterial() );
- return Dali::Material( materialPtr );
-}
-
-void Renderer::SetDepthIndex( int depthIndex )
-{
- GetImplementation(*this).SetDepthIndex( depthIndex );
-}
-
-int Renderer::GetDepthIndex()
-{
- return GetImplementation(*this).GetDepthIndex();
-}
-
-Renderer::Renderer( Internal::Renderer* pointer )
-: Handle( pointer )
-{
-}
-
-} //namespace Dali
+++ /dev/null
-#ifndef DALI_RENDERER_H
-#define DALI_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string> // std::string
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-#include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
-#include <dali/devel-api/rendering/material.h> // Dali::Material
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Renderer;
-}
-
-/**
- * @brief Renderer is a handle to an object that can be used to provide an image to a material.
- */
-class DALI_IMPORT_API Renderer : public Handle
-{
-public:
-
- /**
- * @brief An enumeration of properties belonging to the Renderer class.
- */
- struct Property
- {
- enum
- {
- DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depth-index", type INTEGER
- };
- };
-
- /**
- * @brief Creates a new Renderer object
- *
- * @param[in] geometry Geometry to be used by this renderer
- * @param[in] material Material to be used by this renderer
- */
- static Renderer New( Geometry& geometry, Material& material );
-
- /**
- * @brief Default constructor, creates an empty handle
- */
- Renderer();
-
- /**
- * @brief Destructor
- */
- ~Renderer();
-
- /**
- * @brief Copy constructor, creates a new handle to the same object
- *
- * @param[in] handle Handle to an object
- */
- Renderer( const Renderer& handle );
-
- /**
- * @brief Downcast to a renderer handle.
- *
- * If not a renderer the returned renderer handle is left uninitialized.
- * @param[in] handle to an object
- * @return renderer handle or an uninitialized handle
- */
- static Renderer DownCast( BaseHandle handle );
-
- /**
- * @brief Assignment operator, changes this handle to point at the same object
- *
- * @param[in] handle Handle to an object
- * @return Reference to the assigned object
- */
- Renderer& operator=( const Renderer& handle );
-
- /**
- * @brief Sets the geometry to be used by this renderer
- *
- * @param[in] geometry The geometry to be used by this renderer
- */
- void SetGeometry( Geometry& geometry );
-
- /**
- * @brief Gets the geometry used by this renderer
- *
- * @return The geometry used by the renderer
- */
- Geometry GetGeometry() const;
-
- /**
- * @brief Sets the material to be used by this renderer
- *
- * @param[in] material The material to be used by this renderer
- */
- void SetMaterial( Material& material );
-
- /**
- * @brief Gets the material used by this renderer
- *
- * @return The material used by the renderer
- */
- Material GetMaterial() const;
-
- /**
- * @brief Set the depth index of this renderer
- *
- * Renderer with higher depth indices are rendered in front of other renderers with smaller values
- *
- * @param[in] depthIndex The depth index of this renderer
- */
- void SetDepthIndex( int depthIndex );
-
- //@todo No interface to remove geometry / material? I guess you have to throw away
- // this renderer if you don't want it to work any more...
-
- /**
- * @brief Get the depth index of this renderer
- *
- * @sa SetDepthIndex()
- * @return the depth index
- */
- int GetDepthIndex();
-
-public:
- /**
- * @brief The constructor
- *
- * @param [in] pointer A pointer to a newly allocated Renderer
- */
- explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer );
-};
-
-} //namespace Dali
-
-#endif // DALI_RENDERER_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/rendering/sampler.h> // Dali::Sampler
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
-
-namespace Dali
-{
-
-Sampler Sampler::New( Image& image, const std::string& textureUnitUniformName )
-{
- Internal::SamplerPtr sampler = Internal::Sampler::New(textureUnitUniformName);
- Internal::ImagePtr imagePtr = &GetImplementation( image );
- sampler->SetImage( imagePtr );
- return Sampler( sampler.Get() );
-}
-
-Sampler::Sampler()
-{
-}
-
-Sampler::~Sampler()
-{
-}
-
-Sampler::Sampler( const Sampler& handle )
-: Handle( handle )
-{
-}
-
-Sampler Sampler::DownCast( BaseHandle handle )
-{
- return Sampler( dynamic_cast<Dali::Internal::Sampler*>(handle.GetObjectPtr()));
-}
-
-Sampler& Sampler::operator=( const Sampler& handle )
-{
- BaseHandle::operator=( handle );
- return *this;
-}
-
-void Sampler::SetUniformName( const std::string& name )
-{
- GetImplementation(*this).SetTextureUnitUniformName( name );
-}
-
-void Sampler::SetImage( Image& image )
-{
- Internal::ImagePtr imagePtr = &GetImplementation( image );
- GetImplementation(*this).SetImage( imagePtr );
-}
-
-Image Sampler::GetImage() const
-{
- Internal::ImagePtr imagePtr( GetImplementation(*this).GetImage() );
- return Dali::Image( imagePtr.Get() );
-}
-
-void Sampler::SetFilterMode( FilterMode minFilter, FilterMode magFilter )
-{
- GetImplementation(*this).SetFilterMode( minFilter, magFilter );
-}
-
-void Sampler::SetWrapMode( WrapMode uWrap, WrapMode vWrap )
-{
- GetImplementation(*this).SetWrapMode( uWrap, vWrap );
-}
-
-void Sampler::SetAffectsTransparency( bool affectsTransparency )
-{
- GetImplementation(*this).SetAffectsTransparency( affectsTransparency );
-}
-
-Sampler::Sampler(Internal::Sampler* pointer)
-: Handle( pointer )
-{
-}
-
-} //namespace Dali
+++ /dev/null
-#ifndef DALI_SAMPLER_H
-#define DALI_SAMPLER_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cstddef> // std::size_t
-#include <string> // std::string
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/images/image.h> // Dali::Image
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Sampler;
-}
-
-/**
- * @brief Sampler is a handle to an object that can be used to provide an image to a material.
- */
-class DALI_IMPORT_API Sampler : public Handle
-{
-public:
-
- /**
- * @brief Texture filter mode.
- */
- enum FilterMode
- {
- NONE, ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
- DEFAULT, ///< Use dali defaults (minification LINEAR, magnification LINEAR)
- NEAREST, ///< Filter nearest
- LINEAR ///< Filter linear
- };
-
- /**
- * @brief Texture wrap mode.
- */
- enum WrapMode
- {
- CLAMP_TO_EDGE, ///< The texture coordinates get clamped to the range [0, 1]
- REPEAT, ///< Only the fractional part of the texture coordinates is used
- MIRRORED_REPEAT, ///< If the integer part of the texture coordinate is odd then it uses
- ///< the fractional part, if it's even it uses 1 - the fractional part
- };
-
- /**
- * @brief An enumeration of properties belonging to the Sampler class.
- */
- struct Property
- {
- enum
- {
- MINIFICATION_FILTER = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "minification-filter", type STRING
- MAGNIGICATION_FILTER, ///< name "magnification-filter", type STRING
- U_WRAP, ///< name "u-wrap", type STRING
- V_WRAP, ///< name "v-wrap", type STRING
- AFFECTS_TRANSPARENCY, ///< name "affects-transparency", type BOOLEAN
- };
- };
-
- /**
- * @brief Creates a new Sampler object
- *
- * @param[in] image Image used by this sampler
- * @param[in] uniformName String with the name of the uniform
- */
- static Sampler New( Image& image, const std::string& uniformName );
-
- /**
- * @brief Default constructor, creates an empty handle
- */
- Sampler();
-
- /**
- * @brief Destructor
- */
- ~Sampler();
-
- /**
- * @brief Copy constructor, creates a new handle to the same object
- *
- * @param[in] handle Handle to an object
- */
- Sampler( const Sampler& handle );
-
- /**
- * @brief Downcast to a sampler handle.
- *
- * If not the returned handle is left uninitialized.
- * @param[in] handle to An object
- * @return handle or an uninitialized handle
- */
- static Sampler DownCast( BaseHandle handle );
-
- /**
- * @brief Assignment operator, changes this handle to point at the same object
- *
- * @param[in] handle Handle to an object
- * @return Reference to the assigned object
- */
- Sampler& operator=( const Sampler& handle );
-
- /**
- * @brief Sets the name of the shader uniform that will use this sampler
- *
- * @param[in] name String with the name of the uniform
- */
- void SetUniformName( const std::string& name );
-
- /**
- * @brief Set the image used by this sampler
- *
- * @param[in] image Image used by this sampler
- */
- void SetImage( Image& image );
-
- /**
- * @brief Retrieve the image used by this sampler
- *
- * If no image is assigned, an empty handle is returned
- * @return The image.
- */
- Image GetImage() const;
-
- /**
- * @brief Set the filter modes for this sampler
- *
- * Calling this function sets the properties MINIFICATION_FILTER
- * and MAGNIFICATION_FILTER
- *
- * @param[in] minFilter The minification filter that will be used
- * @param[in] magFilter The magnification filter that will be used
- */
- void SetFilterMode( FilterMode minFilter, FilterMode magFilter );
-
- /**
- * @brief Set the wrap modes for this sampler
- *
- * Calling this function sets the properties U_WRAP and V_WRAP
- *
- * param[in] uWrap Wrap mode for u coordinates
- * param[in] vWrap Wrap mode for v coordinates
- */
- void SetWrapMode( WrapMode uWrap, WrapMode vWrap );
-
- /**
- * @brief Set if this sampler should be considered for opacity hinting
- *
- * Calling this function sets the property AFFECTS_TRANSPARENCY
- *
- * param[in] affectsTransparency Specifies if this sampler should be considered for opacity hinting
- */
- void SetAffectsTransparency( bool affectsTransparency );
-
-public:
- /**
- * @brief The constructor
- *
- * @param [in] pointer A pointer to a newly allocated Sampler
- */
- explicit DALI_INTERNAL Sampler( Internal::Sampler* pointer );
-};
-
-} //namespace Dali
-
-#endif // DALI_SAMPLER_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/rendering/shader.h> // Dali::Shader
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
-
-namespace Dali
-{
-
-Shader Shader::New( const std::string& vertexShader,
- const std::string& fragmentShader,
- ShaderHints hints )
-{
- Internal::ShaderPtr renderer = Internal::Shader::New( vertexShader, fragmentShader, hints );
- return Shader( renderer.Get() );
-}
-
-Shader::Shader()
-{
-}
-
-Shader::~Shader()
-{
-}
-
-Shader::Shader( const Shader& handle )
-: Handle( handle )
-{
-}
-
-Shader Shader::DownCast( BaseHandle handle )
-{
- return Shader( dynamic_cast<Dali::Internal::Shader*>(handle.GetObjectPtr()));
-}
-
-Shader& Shader::operator=( const Shader& handle )
-{
- BaseHandle::operator=( handle );
- return *this;
-}
-
-Shader::Shader( Internal::Shader* pointer )
-: Handle( pointer )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_SHADER_H
-#define DALI_SHADER_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string> // std::string
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-
-/**
- * @brief DALI_COMPOSE_SHADER macro provides a convenient way to write shader source code.
- *
- * We normally use double quotation marks to write a string such as "Hello World".
- * However many symbols are needed to add multiple lines of string.
- * We don't need to write quotation marks using this macro at every line.
- *
- * [An example of double quotation marks usage]
- * <pre>
- * const string FRAGMENT_SHADER_SOURCE = \
- * " void main()\n"
- * " {\n"
- * " gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
- * " }\n";
- * </pre><br/>
- * [An example of DALI_COMPOSE_SHADER usage]
- * <pre>
- * const string VERTEX_SHADER_SOURCE = DALI_COMPOSE_SHADER (
- * void main()
- * {
- * gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);
- * vTexCoord = aTexCoord;
- * }
- * );
- * </pre>
- */
-#define DALI_COMPOSE_SHADER(STR) #STR
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Shader;
-}
-
-/**
- * @brief Shaders allows custom vertex and color transformations in the GPU
- */
-class DALI_IMPORT_API Shader : public Handle
-{
-public:
- /**
- * @brief Hints for rendering/subdividing geometry.
- */
- enum ShaderHints
- {
- HINT_NONE = 0x00, ///< no hints
- HINT_REQUIRES_SELF_DEPTH_TEST = 0x01, ///< Expects depth testing enabled
- HINT_OUTPUT_IS_TRANSPARENT = 0x02, ///< Might generate transparent alpha from opaque inputs
- HINT_OUTPUT_IS_OPAQUE = 0x04, ///< Outputs opaque colors even if the inputs are transparent
- HINT_MODIFIES_GEOMETRY = 0x08, ///< Might change position of vertices,
- ///< this option disables any culling optimizations
- };
-
- /**
- * @brief An enumeration of properties belonging to the Shader class.
- */
- struct Property
- {
- enum
- {
- PROGRAM = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "program", type MAP; {"vertex-prefix":"","fragment-prefix":"","vertex":"","fragment":""}
- SHADER_HINTS, ///< name "shader-hints", type UNSIGNED_INTEGER; (bitfield) values from enum Shader::Hints
- };
- };
-
- /**
- * @brief Create Shader.
- *
- * @param vertexShader code for the effect. If you pass in an empty string, the default version will be used
- * @param fragmentShader code for the effect. If you pass in an empty string, the default version will be used
- * @param hints GeometryHints to define the geometry of the rendered object
- * @return A handle to a shader effect
- */
- static Shader New( const std::string& vertexShader,
- const std::string& fragmentShader,
- ShaderHints hints = ShaderHints(HINT_NONE) );
-
- /**
- * @brief Default constructor, creates an empty handle
- */
- Shader();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Shader();
-
- /**
- * @brief Copy constructor
- *
- * @param handle A handle to a Shader object
- */
- Shader( const Shader& handle );
-
- /**
- * @brief Downcast to a shader handle.
- *
- * If not a shader the returned shader handle is left uninitialized.
- * @param[in] handle to an object
- * @return shader handle or an uninitialized handle
- */
- static Shader DownCast( BaseHandle handle );
-
- /**
- * @brief Assignment operator, changes this handle to point at the same object
- *
- * @param[in] handle Handle to an object
- * @return Reference to the assigned object
- */
- Shader& operator=( const Shader& handle );
-
-public: // Not intended for application developers
- /**
- * @brief This constructor is used by Dali New() methods.
- * @param [in] effect A pointer to a newly allocated Dali resource.
- */
- explicit DALI_INTERNAL Shader( Internal::Shader* effect );
-};
-
-} // namespace Dali
-
-#endif // DALI_SHADER_H
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
-#include <dali/devel-api/rendering/geometry.h>
+#include <dali/public-api/geometry/geometry.h>
namespace Dali
{
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
-#include <dali/devel-api/object/property-buffer.h>
+#include <dali/public-api/object/property-buffer.h>
namespace Dali
{
// INTERNAL INCLUDES
#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
+#include <dali/internal/update/manager/update-manager.h>
namespace Dali
{
*/
// INTERNAL INCLUDES
-#include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
#include <dali/internal/event/common/object-connector.h>
-#include <dali/internal/event/rendering/renderer-impl.h>
+#include <dali/internal/event/actors/renderer-impl.h>
+#include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
namespace Dali
{
#include <string>
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/actors/actor.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/events/gesture.h>
#include <dali/public-api/math/viewport.h>
-#include <dali/public-api/object/ref-object.h>
+#include <dali/internal/event/common/object-impl.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/internal/event/common/stage-def.h>
#include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/actors/renderer-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
-#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/common/stage-def.h>
-#include <dali/internal/event/rendering/renderer-impl.h>
#include <dali/internal/update/nodes/node-declarations.h>
#ifdef DYNAMICS_SUPPORT
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/event/actors/renderer-impl.h> // Dali::Internal::Renderer
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/renderer.h> // Dali::Renderer
+#include <dali/public-api/object/type-registry.h>
+#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/event/common/property-input-impl.h>
+#include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
+#include <dali/internal/update/manager/update-manager.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace
+{
+
+/**
+ * |name |type |writable|animatable|constraint-input|enum for index-checking|
+ */
+DALI_PROPERTY_TABLE_BEGIN
+DALI_PROPERTY( "depth-index", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
+DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
+
+const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
+
+BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create );
+
+} // unnamed namespace
+
+RendererPtr Renderer::New()
+{
+ RendererPtr rendererPtr( new Renderer() );
+ rendererPtr->Initialize();
+ return rendererPtr;
+}
+
+void Renderer::SetGeometry( Geometry& geometry )
+{
+ mGeometryConnector.Set( geometry, OnStage() );
+ const SceneGraph::Geometry* geometrySceneObject = geometry.GetGeometrySceneObject();
+
+ SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject );
+}
+
+Geometry* Renderer::GetGeometry() const
+{
+ return mGeometryConnector.Get().Get();
+}
+
+void Renderer::SetMaterial( Material& material )
+{
+ mMaterialConnector.Set( material, OnStage() );
+ const SceneGraph::Material* materialSceneObject = material.GetMaterialSceneObject();
+ SetMaterialMessage( GetEventThreadServices(), *mSceneObject, *materialSceneObject );
+}
+
+Material* Renderer::GetMaterial() const
+{
+ return mMaterialConnector.Get().Get();
+}
+
+void Renderer::SetDepthIndex( int depthIndex )
+{
+ if ( mDepthIndex != depthIndex )
+ {
+ mDepthIndex = depthIndex;
+ SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex );
+ }
+}
+
+int Renderer::GetDepthIndex() const
+{
+ return mDepthIndex;
+}
+
+SceneGraph::RendererAttachment* Renderer::GetRendererSceneObject()
+{
+ return mSceneObject;
+}
+
+unsigned int Renderer::GetDefaultPropertyCount() const
+{
+ return RENDERER_IMPL.GetDefaultPropertyCount();
+}
+
+void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
+{
+ RENDERER_IMPL.GetDefaultPropertyIndices( indices );
+}
+
+const char* Renderer::GetDefaultPropertyName(Property::Index index) const
+{
+ return RENDERER_IMPL.GetDefaultPropertyName( index );
+}
+
+Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const
+{
+ return RENDERER_IMPL.GetDefaultPropertyIndex( name );
+}
+
+bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const
+{
+ return RENDERER_IMPL.IsDefaultPropertyWritable( index );
+}
+
+bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const
+{
+ return RENDERER_IMPL.IsDefaultPropertyAnimatable( index );
+}
+
+bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index );
+}
+
+Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const
+{
+ return RENDERER_IMPL.GetDefaultPropertyType( index );
+}
+
+void Renderer::SetDefaultProperty( Property::Index index,
+ const Property::Value& propertyValue )
+{
+ switch( index )
+ {
+ case Dali::Renderer::Property::DEPTH_INDEX:
+ {
+ SetDepthIndex( propertyValue.Get<int>() );
+ }
+ break;
+ }
+}
+
+void Renderer::SetSceneGraphProperty( Property::Index index,
+ const PropertyMetadata& entry,
+ const Property::Value& value )
+{
+ RENDERER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
+ OnPropertySet(index, value);
+}
+
+Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
+{
+ Property::Value value;
+ switch( index )
+ {
+ case Dali::Renderer::Property::DEPTH_INDEX:
+ {
+ value = GetDepthIndex();
+ }
+ break;
+ }
+ return value;
+}
+
+const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
+{
+ DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
+ const SceneGraph::PropertyBase* property = NULL;
+
+ if( OnStage() )
+ {
+ property = RENDERER_IMPL.GetRegisteredSceneGraphProperty(
+ this,
+ &Renderer::FindAnimatableProperty,
+ &Renderer::FindCustomProperty,
+ index );
+ }
+
+ return property;
+}
+
+const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
+{
+ const PropertyInputImpl* property = NULL;
+
+ if( OnStage() )
+ {
+ const SceneGraph::PropertyBase* baseProperty =
+ RENDERER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Renderer::FindAnimatableProperty,
+ &Renderer::FindCustomProperty,
+ index );
+ property = static_cast<const PropertyInputImpl*>( baseProperty );
+ }
+
+ return property;
+}
+
+int Renderer::GetPropertyComponentIndex( Property::Index index ) const
+{
+ return Property::INVALID_COMPONENT_INDEX;
+}
+
+bool Renderer::OnStage() const
+{
+ return mOnStage;
+}
+
+void Renderer::Connect()
+{
+ // @todo: MESH_REWORK : check this
+ mGeometryConnector.OnStageConnect();
+ mMaterialConnector.OnStageConnect();
+ mOnStage = true;
+}
+
+void Renderer::Disconnect()
+{
+ // @todo: MESH_REWORK : check this
+ mGeometryConnector.OnStageDisconnect();
+ mMaterialConnector.OnStageDisconnect();
+ mOnStage = false;
+}
+
+Renderer::Renderer()
+: mSceneObject(NULL),
+ mDepthIndex(0),
+ mOnStage(false)
+{
+}
+
+void Renderer::Initialize()
+{
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+
+ // Transfer object ownership of scene-object to message
+ mSceneObject = SceneGraph::RendererAttachment::New();
+
+ // Send message to update to connect to scene graph:
+ AttachToSceneGraphMessage( updateManager, mSceneObject );
+
+ eventThreadServices.RegisterObject( this );
+}
+
+Renderer::~Renderer()
+{
+ if( EventThreadServices::IsCoreRunning() )
+ {
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveObjectMessage( updateManager, mSceneObject );
+
+ eventThreadServices.UnregisterObject( this );
+ }
+}
+
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_RENDERER_H
+#define DALI_INTERNAL_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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/renderer.h> // Dali::Renderer
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/effects/material-impl.h> // Dali::Internal::Material
+#include <dali/internal/event/geometry/geometry-impl.h> // Dali::Internal::Geometry
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class RendererAttachment;
+}
+
+class Renderer;
+typedef IntrusivePtr<Renderer> RendererPtr;
+
+/**
+ * Renderer is an object that can be used to show content by combining a Geometry with a material.
+ */
+class Renderer : public Object, public Connectable
+{
+public:
+
+ /**
+ * Create a new Renderer.
+ * @return A smart-pointer to the newly allocated Renderer.
+ */
+ static RendererPtr New();
+
+ /**
+ * @copydoc Dali::Renderer::SetGeometry()
+ */
+ void SetGeometry( Geometry& geometry );
+
+ /**
+ * @copydoc Dali::Renderer::GetGeometry()
+ */
+ Geometry* GetGeometry() const;
+
+ /**
+ * @copydoc Dali::Renderer::SetMaterial()
+ */
+ void SetMaterial( Material& material );
+
+ /**
+ * @copydoc Dali::Renderer::GetMaterial()
+ */
+ Material* GetMaterial() const;
+
+ /**
+ * @copydoc Dali::Renderer::SetDepthIndex()
+ */
+ void SetDepthIndex( int depthIndex );
+
+ /**
+ * @copydoc Dali::Renderer::GetDepthIndex()
+ */
+ int GetDepthIndex() const;
+
+ /**
+ * @brief Get the scene graph object ( the node attachment )
+ *
+ * @return the scene object
+ */
+ SceneGraph::RendererAttachment* GetRendererSceneObject();
+
+public: // Default property extensions from Object
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
+ */
+ virtual unsigned int GetDefaultPropertyCount() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
+ */
+ virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
+ */
+ virtual const char* GetDefaultPropertyName(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
+ */
+ virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
+ */
+ virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
+ */
+ virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
+ */
+ virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::SetDefaultProperty()
+ */
+ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+
+ /**
+ * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
+ */
+ virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultProperty()
+ */
+ virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyOwner()
+ */
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObject()
+ */
+ virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
+ */
+ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
+ */
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ */
+ virtual int GetPropertyComponentIndex( Property::Index index ) const;
+
+public: // Functions from Connectable
+ /**
+ * @copydoc Dali::Internal::Connectable::OnStage()
+ */
+ virtual bool OnStage() const;
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Connect()
+ */
+ virtual void Connect();
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Disconnect()
+ */
+ virtual void Disconnect();
+
+private: // implementation
+ Renderer();
+
+ void Initialize();
+
+protected:
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Renderer();
+
+private: // unimplemented methods
+ Renderer( const Renderer& );
+ Renderer& operator=( const Renderer& );
+
+private: // data
+ SceneGraph::RendererAttachment* mSceneObject;
+ ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
+ ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
+ int mDepthIndex;
+ bool mOnStage;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
+
+ BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<Internal::Renderer&>(object);
+}
+
+inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
+
+ const BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<const Internal::Renderer&>(object);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_RENDERER_H
#include <algorithm> // std::sort
// INTERNAL INCLUDES
+#include <dali/public-api/object/property-buffer.h> // Dali::Internal::PropertyBuffer
#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/object/property-buffer.h> // Dali::Internal::PropertyBuffer
#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/object/property-buffer.h> // Dali::PropertyBuffer
#include <dali/public-api/object/property-map.h> // Dali::Property::Map
-#include <dali/devel-api/object/property-buffer.h> // Dali::PropertyBuffer
#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/event/effects/material-impl.h> // Dali::Internal::Material
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/shader-effects/material.h> // Dali::Internal::Material
+#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/effects/scene-graph-sampler.h>
+#include <dali/internal/update/manager/update-manager.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace
+{
+
+/**
+ * |name |type |writable|animatable|constraint-input|enum for index-checking|
+ */
+DALI_PROPERTY_TABLE_BEGIN
+DALI_PROPERTY( "color", VECTOR4, true, true, true, Dali::Material::Property::COLOR )
+DALI_PROPERTY( "face-culling-mode", STRING, true, false, false, Dali::Material::Property::FACE_CULLING_MODE )
+DALI_PROPERTY( "blending-mode", STRING, true, false, false, Dali::Material::Property::BLENDING_MODE )
+DALI_PROPERTY( "blend-equation-rgb", STRING, true, false, false, Dali::Material::Property::BLEND_EQUATION_RGB )
+DALI_PROPERTY( "blend-equation-alpha", STRING, true, false, false, Dali::Material::Property::BLEND_EQUATION_ALPHA )
+DALI_PROPERTY( "source-blend-factor-rgb", STRING, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_RGB )
+DALI_PROPERTY( "destination-blend-factor-rgb", STRING, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_RGB )
+DALI_PROPERTY( "source-blend-factor-alpha", STRING, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA )
+DALI_PROPERTY( "destination-blend-factor-alpha", STRING, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA )
+DALI_PROPERTY( "blend-color", VECTOR4, true, true, true, Dali::Material::Property::BLEND_COLOR )
+DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
+
+const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> MATERIAL_IMPL = { DEFAULT_PROPERTY_DETAILS };
+
+BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+TypeRegistration mType( typeid( Dali::Material ), typeid( Dali::Handle ), Create );
+
+} // unnamed namespace
+
+MaterialPtr Material::New()
+{
+ MaterialPtr material( new Material() );
+ material->Initialize();
+ return material;
+}
+
+void Material::SetShader( Shader& shader )
+{
+ DALI_ASSERT_DEBUG( mSceneObject )
+ mShaderConnector.Set( shader, OnStage() );
+
+ const SceneGraph::Shader& sceneGraphShader = dynamic_cast<const SceneGraph::Shader&>( *shader.GetSceneObject() );
+ SceneGraph::SetShaderMessage( GetEventThreadServices(), *mSceneObject, sceneGraphShader );
+}
+
+Shader* Material::GetShader() const
+{
+ return mShaderConnector.Get().Get();
+}
+
+void Material::AddSampler( Sampler& sampler )
+{
+ SamplerConnector connector;
+ connector.Set( sampler, OnStage() );
+ mSamplerConnectors.push_back( connector );
+
+ const SceneGraph::Sampler& sceneGraphSampler = dynamic_cast<const SceneGraph::Sampler&>( *sampler.GetSceneObject() );
+ SceneGraph::AddSamplerMessage( GetEventThreadServices(), *mSceneObject, sceneGraphSampler );
+}
+
+std::size_t Material::GetNumberOfSamplers() const
+{
+ return mSamplerConnectors.size();
+}
+
+void Material::RemoveSampler( std::size_t index )
+{
+ mSamplerConnectors.erase( mSamplerConnectors.begin() + index );
+}
+
+Sampler* Material::GetSamplerAt( unsigned int index ) const
+{
+ return mSamplerConnectors[index].Get().Get();
+}
+
+void Material::SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode )
+{
+ if( NULL != mSceneObject )
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mFaceCullingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, static_cast<int>(cullingMode) );
+ }
+}
+
+void Material::SetBlendMode( BlendingMode::Type mode )
+{
+ mBlendingMode = mode;
+
+ if( NULL != mSceneObject )
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, static_cast<int>(mode) );
+ }
+}
+
+BlendingMode::Type Material::GetBlendMode() const
+{
+ return mBlendingMode;
+}
+
+void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
+{
+ mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+}
+
+void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
+ BlendingFactor::Type destFactorRgb,
+ BlendingFactor::Type srcFactorAlpha,
+ BlendingFactor::Type destFactorAlpha )
+{
+ mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+}
+
+void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
+ BlendingFactor::Type& destFactorRgb,
+ BlendingFactor::Type& srcFactorAlpha,
+ BlendingFactor::Type& destFactorAlpha ) const
+{
+ srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
+ destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
+ srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha();
+ destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
+}
+
+void Material::SetBlendEquation( BlendingEquation::Type equationRgba )
+{
+ mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+}
+
+void Material::SetBlendEquation( BlendingEquation::Type equationRgb,
+ BlendingEquation::Type equationAlpha )
+{
+ mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+}
+
+void Material::GetBlendEquation( BlendingEquation::Type& equationRgb,
+ BlendingEquation::Type& equationAlpha ) const
+{
+ // These are not animatable, the cached values are up-to-date.
+ equationRgb = mBlendingOptions.GetBlendEquationRgb();
+ equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
+}
+
+void Material::SetBlendColor( const Vector4& color )
+{
+ if( mSceneObject )
+ {
+ SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, color );
+ }
+}
+
+const Vector4& Material::GetBlendColor() const
+{
+ return mSceneObject->mBlendColor[ GetEventThreadServices().GetEventBufferIndex() ];
+}
+
+const SceneGraph::Material* Material::GetMaterialSceneObject() const
+{
+ return mSceneObject;
+}
+
+unsigned int Material::GetDefaultPropertyCount() const
+{
+ return MATERIAL_IMPL.GetDefaultPropertyCount();
+}
+
+void Material::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
+{
+ MATERIAL_IMPL.GetDefaultPropertyIndices( indices );
+}
+
+const char* Material::GetDefaultPropertyName(Property::Index index) const
+{
+ return MATERIAL_IMPL.GetDefaultPropertyName( index );
+}
+
+Property::Index Material::GetDefaultPropertyIndex( const std::string& name ) const
+{
+ return MATERIAL_IMPL.GetDefaultPropertyIndex( name );
+}
+
+bool Material::IsDefaultPropertyWritable( Property::Index index ) const
+{
+ return MATERIAL_IMPL.IsDefaultPropertyWritable( index );
+}
+
+bool Material::IsDefaultPropertyAnimatable( Property::Index index ) const
+{
+ return MATERIAL_IMPL.IsDefaultPropertyAnimatable( index );
+}
+
+bool Material::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return MATERIAL_IMPL.IsDefaultPropertyAConstraintInput( index );
+}
+
+Property::Type Material::GetDefaultPropertyType( Property::Index index ) const
+{
+ return MATERIAL_IMPL.GetDefaultPropertyType( index );
+}
+
+void Material::SetDefaultProperty( Property::Index index,
+ const Property::Value& propertyValue )
+{
+ switch( index )
+ {
+ case Dali::Material::Property::COLOR:
+ {
+ SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, propertyValue.Get<Vector4>() );
+ break;
+ }
+ case Dali::Material::Property::FACE_CULLING_MODE:
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mFaceCullingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_MODE:
+ {
+ if( mSceneObject )
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ }
+ break;
+ }
+ case Dali::Material::Property::BLEND_EQUATION_RGB:
+ {
+ BlendingEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
+ mBlendingOptions.SetBlendEquation( static_cast<BlendingEquation::Type>(propertyValue.Get<int>()), alphaEquation );
+ break;
+ }
+ case Dali::Material::Property::BLEND_EQUATION_ALPHA:
+ {
+ BlendingEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
+ mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendingEquation::Type>(propertyValue.Get<int>()) );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
+ destFactorRgb,
+ srcFactorAlpha,
+ destFactorAlpha );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
+ srcFactorAlpha,
+ destFactorAlpha );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ destFactorRgb,
+ static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
+ destFactorAlpha );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ destFactorRgb,
+ srcFactorAlpha,
+ static_cast<BlendingFactor::Type>(propertyValue.Get<int>()) );
+ break;
+ }
+ case Dali::Material::Property::BLEND_COLOR:
+ {
+ SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, propertyValue.Get<Vector4>() );
+ break;
+ }
+ }
+}
+
+void Material::SetSceneGraphProperty( Property::Index index,
+ const PropertyMetadata& entry,
+ const Property::Value& value )
+{
+ MATERIAL_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
+ OnPropertySet(index, value);
+}
+
+Property::Value Material::GetDefaultProperty( Property::Index index ) const
+{
+ BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
+ Property::Value value;
+
+ switch( index )
+ {
+ case Dali::Material::Property::COLOR:
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mColor[bufferIndex];
+ }
+ break;
+ }
+ case Dali::Material::Property::FACE_CULLING_MODE:
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mFaceCullingMode[bufferIndex];
+ }
+ break;
+ }
+ case Dali::Material::Property::BLENDING_MODE:
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mBlendingMode[bufferIndex];
+ }
+ break;
+ }
+ case Dali::Material::Property::BLEND_EQUATION_RGB:
+ {
+ value = static_cast<int>( mBlendingOptions.GetBlendEquationRgb() );
+ break;
+ }
+ case Dali::Material::Property::BLEND_EQUATION_ALPHA:
+ {
+ value = static_cast<int>( mBlendingOptions.GetBlendEquationAlpha() );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( srcFactorRgb );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( destFactorRgb );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( srcFactorAlpha );
+ break;
+ }
+ case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( destFactorAlpha );
+ break;
+ }
+ case Dali::Material::Property::BLEND_COLOR:
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mBlendColor[bufferIndex];
+ }
+ break;
+ }
+ }
+
+ return value;
+}
+
+const SceneGraph::PropertyOwner* Material::GetPropertyOwner() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyOwner* Material::GetSceneObject() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyBase* Material::GetSceneObjectAnimatableProperty( Property::Index index ) const
+{
+ DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
+
+ const SceneGraph::PropertyBase* property = NULL;
+
+ if( OnStage() )
+ {
+ property = MATERIAL_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Material::FindAnimatableProperty,
+ &Material::FindCustomProperty,
+ index );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ switch(index)
+ {
+ case Dali::Material::Property::COLOR:
+ {
+ property = &mSceneObject->mColor;
+ break;
+ }
+ case Dali::Material::Property::BLEND_COLOR:
+ {
+ property = &mSceneObject->mBlendColor;
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property is not animatable");
+ break;
+ }
+ }
+ }
+ }
+
+ return property;
+}
+
+const PropertyInputImpl* Material::GetSceneObjectInputProperty( Property::Index index ) const
+{
+ const PropertyInputImpl* property = NULL;
+
+ if( OnStage() )
+ {
+ const SceneGraph::PropertyBase* baseProperty =
+ MATERIAL_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Material::FindAnimatableProperty,
+ &Material::FindCustomProperty,
+ index );
+ property = static_cast<const PropertyInputImpl*>( baseProperty );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ switch(index)
+ {
+ case Dali::Material::Property::COLOR:
+ {
+ property = &mSceneObject->mColor;
+ break;
+ }
+ case Dali::Material::Property::FACE_CULLING_MODE:
+ {
+ property = &mSceneObject->mFaceCullingMode;
+ break;
+ }
+ case Dali::Material::Property::BLEND_COLOR:
+ {
+ property = &mSceneObject->mBlendColor;
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property cannot be a constraint input");
+ break;
+ }
+ }
+ }
+ }
+
+ return property;
+}
+
+int Material::GetPropertyComponentIndex( Property::Index index ) const
+{
+ // @todo MESH_REWORK - Change this if component properties are added for color/blend-color
+ return Property::INVALID_COMPONENT_INDEX;
+}
+
+bool Material::OnStage() const
+{
+ return mOnStage;
+}
+
+void Material::Connect()
+{
+ mOnStage = true;
+
+ SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end();
+ for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin();
+ it < end;
+ ++it )
+ {
+ it->OnStageConnect();
+ }
+ mShaderConnector.OnStageConnect();
+}
+
+void Material::Disconnect()
+{
+ mOnStage = false;
+
+ SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end();
+ for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin();
+ it < end;
+ ++it )
+ {
+ it->OnStageDisconnect();
+ }
+ mShaderConnector.OnStageDisconnect();
+}
+
+Material::Material()
+: mSceneObject( NULL ),
+ mOnStage( false )
+{
+}
+
+void Material::Initialize()
+{
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+
+ mSceneObject = new SceneGraph::Material();
+ AddMessage( updateManager, updateManager.GetMaterialOwner(), *mSceneObject );
+
+ eventThreadServices.RegisterObject( this );
+}
+
+Material::~Material()
+{
+ if( EventThreadServices::IsCoreRunning() )
+ {
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveMessage( updateManager, updateManager.GetMaterialOwner(), *mSceneObject );
+
+ eventThreadServices.UnregisterObject( this );
+ }
+}
+
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_MATERIAL_H
+#define DALI_INTERNAL_MATERIAL_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h> // std::vector
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/shader-effects/material.h> // Dali::Material
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
+#include <dali/internal/event/effects/sampler-impl.h> // Dali::Internal::Sampler
+#include <dali/internal/event/effects/shader-impl.h> // Dali::Internal::Shader
+#include <dali/internal/common/blending-options.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class Material;
+}
+
+
+class Material;
+typedef IntrusivePtr<Material> MaterialPtr;
+
+/**
+ * Material is an object that connects a Shader with Samplers and can be used
+ * to shade a Geometry.
+ */
+class Material : public Object, public Connectable
+{
+public:
+
+ /**
+ * @copydoc Dali::Material::New()
+ */
+ static MaterialPtr New();
+
+ /**
+ * @copydoc Dali::Material::SetShader()
+ */
+ void SetShader( Shader& shader );
+
+ /**
+ * @copydoc Dali::Material::GetShader()
+ */
+ Shader* GetShader() const;
+
+ /**
+ * @copydoc Dali::Material::AddSampler()
+ */
+ void AddSampler( Sampler& sampler );
+
+ /**
+ * @copydoc Dali::Material::GetNumberOfSamplers()
+ */
+ std::size_t GetNumberOfSamplers() const;
+
+ /**
+ * @copydoc Dali::Material::RemoveSampler()
+ */
+ void RemoveSampler( std::size_t index );
+
+ /**
+ * @copydoc Dali::Material::GetSamplerAt()
+ */
+ Sampler* GetSamplerAt( unsigned int index ) const;
+
+ /**
+ * @copydoc Dali::Material::SetFaceCullingMode()
+ */
+ void SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode );
+
+ /**
+ * @copydoc Dali::Material::SetBlendMode()
+ */
+ void SetBlendMode( BlendingMode::Type mode );
+
+ /**
+ * @copydoc Dali::Material::GetBlendMode()
+ */
+ BlendingMode::Type GetBlendMode() const;
+
+ /**
+ * @copydoc Dali::Material::SetBlendFunc()
+ */
+ void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
+
+ /**
+ * @copydoc Dali::Material::SetBlendFunc()
+ */
+ void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
+ BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
+
+ /**
+ * @copydoc Dali::Material::GetBlendFunc()
+ */
+ void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
+ BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
+
+ /**
+ * @copydoc Dali::Material::SetBlendEquation()
+ */
+ void SetBlendEquation( BlendingEquation::Type equationRgba );
+
+ /**
+ * @copydoc Dali::Material::SetBlendEquation()
+ */
+ void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
+
+ /**
+ * @copydoc Dali::Material::GetBlendEquation()
+ */
+ void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
+
+ /**
+ * @copydoc Dali::Material::SetBlendColor()
+ */
+ void SetBlendColor( const Vector4& color );
+
+ /**
+ * @copydoc Dali::Material::GetBlendColor()
+ */
+ const Vector4& GetBlendColor() const;
+
+ /**
+ * @brief Get the material scene object
+ *
+ * @return the material scene object
+ */
+ const SceneGraph::Material* GetMaterialSceneObject() const;
+
+public: // Default property extensions from Object
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
+ */
+ virtual unsigned int GetDefaultPropertyCount() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
+ */
+ virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
+ */
+ virtual const char* GetDefaultPropertyName(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
+ */
+ virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
+ */
+ virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
+ */
+ virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
+ */
+ virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::SetDefaultProperty()
+ */
+ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+
+ /**
+ * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
+ */
+ virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultProperty()
+ */
+ virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyOwner()
+ */
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObject()
+ */
+ virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
+ */
+ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
+ */
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ */
+ virtual int GetPropertyComponentIndex( Property::Index index ) const;
+
+public: // Functions from Connectable
+ /**
+ * @copydoc Dali::Internal::Connectable::OnStage()
+ */
+ virtual bool OnStage() const;
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Connect()
+ */
+ virtual void Connect();
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Disconnect()
+ */
+ virtual void Disconnect();
+
+private: // implementation
+ Material();
+
+ /**
+ * Second stage initialization
+ */
+ void Initialize();
+
+protected:
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Material();
+
+private: // unimplemented methods
+ Material( const Material& );
+ Material& operator=( const Material& );
+
+private: //data
+ typedef ObjectConnector<Shader> ShaderConnector;
+ ShaderConnector mShaderConnector; ///< Connector that holds the shader used by this material
+
+ typedef ObjectConnector<Sampler> SamplerConnector;
+ typedef std::vector< SamplerConnector > SamplerConnectorContainer;
+ SamplerConnectorContainer mSamplerConnectors; ///< Vector of connectors that hold the samplers used by this material
+
+ SceneGraph::Material* mSceneObject;
+
+ BlendingMode::Type mBlendingMode; ///< Local store
+ BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
+ bool mOnStage;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Internal::Material& GetImplementation( Dali::Material& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "Material handle is empty");
+
+ BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<Internal::Material&>(object);
+}
+
+inline const Internal::Material& GetImplementation( const Dali::Material& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "Material handle is empty");
+
+ const BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<const Internal::Material&>(object);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_MATERIAL_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/event/effects/sampler-impl.h> // Dali::Internal::Sampler
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/shader-effects/sampler.h> // Dali::Internal::Sampler
+#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/update/effects/scene-graph-sampler.h> // Dali::Internal::SceneGraph::Sampler
+#include <dali/internal/update/manager/update-manager.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace
+{
+
+/**
+ * |name |type |writable|animatable|constraint-input|enum for index-checking|
+ */
+DALI_PROPERTY_TABLE_BEGIN
+DALI_PROPERTY( "minification-filter", STRING, true, false, true, Dali::Sampler::Property::MINIFICATION_FILTER )
+DALI_PROPERTY( "magnification-filter", STRING, true, false, true, Dali::Sampler::Property::MAGNIGICATION_FILTER )
+DALI_PROPERTY( "u-wrap", STRING, true, false, true, Dali::Sampler::Property::U_WRAP )
+DALI_PROPERTY( "v-wrap", STRING, true, false, true, Dali::Sampler::Property::V_WRAP )
+DALI_PROPERTY( "affects-transparency", BOOLEAN, true, false, true, Dali::Sampler::Property::AFFECTS_TRANSPARENCY )
+DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
+
+const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> SAMPLER_IMPL = { DEFAULT_PROPERTY_DETAILS };
+
+BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+TypeRegistration mType( typeid( Dali::Sampler ), typeid( Dali::Handle ), Create );
+
+} // unnamed namespace
+
+SamplerPtr Sampler::New( const std::string& textureUnitUniformName )
+{
+ SamplerPtr sampler( new Sampler() );
+ sampler->Initialize( textureUnitUniformName );
+ return sampler;
+}
+
+void Sampler::SetTextureUnitUniformName( const std::string& name )
+{
+ SetTextureUnitUniformNameMessage( GetEventThreadServices(), *mSceneObject, name);
+}
+
+void Sampler::SetImage( ImagePtr& image )
+{
+ // Keep a reference to the image object
+ mImageConnector.Set( image, OnStage() );
+
+ // sceneObject is being used in a separate thread; queue a message to set
+ if( mOnStage )
+ {
+ unsigned int resourceId = image->GetResourceId();
+ if( resourceId != 0 )
+ {
+ SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
+ }
+ }
+}
+
+ImagePtr Sampler::GetImage() const
+{
+ return mImageConnector.Get();
+}
+
+void Sampler::SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter )
+{
+ if( NULL != mSceneObject )
+ {
+ SetFilterModeMessage( GetEventThreadServices(), *mSceneObject, minFilter, magFilter );
+ }
+}
+
+void Sampler::SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap )
+{
+ if( NULL != mSceneObject )
+ {
+ SetWrapModeMessage( GetEventThreadServices(), *mSceneObject, uWrap, vWrap );
+ }
+}
+
+void Sampler::SetAffectsTransparency( bool affectsTransparency )
+{
+ if( NULL != mSceneObject )
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mAffectsTransparency, &SceneGraph::DoubleBufferedProperty<bool>::Set, affectsTransparency );
+ }
+}
+
+const SceneGraph::Sampler* Sampler::GetSamplerSceneObject() const
+{
+ return mSceneObject;
+}
+
+unsigned int Sampler::GetDefaultPropertyCount() const
+{
+ return SAMPLER_IMPL.GetDefaultPropertyCount();
+}
+
+void Sampler::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
+{
+ SAMPLER_IMPL.GetDefaultPropertyIndices( indices );
+}
+
+const char* Sampler::GetDefaultPropertyName(Property::Index index) const
+{
+ return SAMPLER_IMPL.GetDefaultPropertyName( index );
+}
+
+Property::Index Sampler::GetDefaultPropertyIndex( const std::string& name ) const
+{
+ return SAMPLER_IMPL.GetDefaultPropertyIndex( name );
+}
+
+bool Sampler::IsDefaultPropertyWritable( Property::Index index ) const
+{
+ return SAMPLER_IMPL.IsDefaultPropertyWritable( index );
+}
+
+bool Sampler::IsDefaultPropertyAnimatable( Property::Index index ) const
+{
+ return SAMPLER_IMPL.IsDefaultPropertyAnimatable( index );
+}
+
+bool Sampler::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return SAMPLER_IMPL.IsDefaultPropertyAConstraintInput( index );
+}
+
+Property::Type Sampler::GetDefaultPropertyType( Property::Index index ) const
+{
+ return SAMPLER_IMPL.GetDefaultPropertyType( index );
+}
+
+void Sampler::SetDefaultProperty( Property::Index index,
+ const Property::Value& propertyValue )
+{
+ switch( index )
+ {
+ case Dali::Sampler::Property::MINIFICATION_FILTER:
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mMinFilter, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ break;
+ }
+ case Dali::Sampler::Property::MAGNIGICATION_FILTER:
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mMagFilter, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ break;
+ }
+ case Dali::Sampler::Property::U_WRAP:
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mUWrapMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ break;
+ }
+ case Dali::Sampler::Property::V_WRAP:
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mVWrapMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ break;
+ }
+ case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mAffectsTransparency, &SceneGraph::DoubleBufferedProperty<bool>::Set, propertyValue.Get<bool>() );
+ break;
+ }
+ }
+}
+
+void Sampler::SetSceneGraphProperty( Property::Index index,
+ const PropertyMetadata& entry,
+ const Property::Value& value )
+{
+ SAMPLER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
+ OnPropertySet(index, value);
+}
+
+Property::Value Sampler::GetDefaultProperty( Property::Index index ) const
+{
+ BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
+ Property::Value value;
+
+ switch( index )
+ {
+ case Dali::Sampler::Property::MINIFICATION_FILTER:
+ {
+ value = mSceneObject->mMinFilter[bufferIndex];
+ break;
+ }
+ case Dali::Sampler::Property::MAGNIGICATION_FILTER:
+ {
+ value = mSceneObject->mMagFilter[bufferIndex];
+ break;
+ }
+ case Dali::Sampler::Property::U_WRAP:
+ {
+ value = mSceneObject->mUWrapMode[bufferIndex];
+ break;
+ }
+ case Dali::Sampler::Property::V_WRAP:
+ {
+ value = mSceneObject->mVWrapMode[bufferIndex];
+ break;
+ }
+ case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
+ {
+ value = mSceneObject->mAffectsTransparency[bufferIndex];
+ break;
+ }
+ }
+ return value;
+}
+
+const SceneGraph::PropertyOwner* Sampler::GetPropertyOwner() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyOwner* Sampler::GetSceneObject() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyBase* Sampler::GetSceneObjectAnimatableProperty( Property::Index index ) const
+{
+ DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
+
+ const SceneGraph::PropertyBase* property = NULL;
+
+ if( OnStage() )
+ {
+ property = SAMPLER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Sampler::FindAnimatableProperty,
+ &Sampler::FindCustomProperty,
+ index );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ // No animatable default props
+ DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
+ }
+ }
+
+ return property;
+}
+
+const PropertyInputImpl* Sampler::GetSceneObjectInputProperty( Property::Index index ) const
+{
+ const PropertyInputImpl* property = NULL;
+
+ if( OnStage() )
+ {
+ const SceneGraph::PropertyBase* baseProperty =
+ SAMPLER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Sampler::FindAnimatableProperty,
+ &Sampler::FindCustomProperty,
+ index );
+ property = static_cast<const PropertyInputImpl*>( baseProperty );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ switch( index )
+ {
+ case Dali::Sampler::Property::MINIFICATION_FILTER:
+ {
+ property = &mSceneObject->mMinFilter;
+ break;
+ }
+ case Dali::Sampler::Property::MAGNIGICATION_FILTER:
+ {
+ property = &mSceneObject->mMagFilter;
+ break;
+ }
+ case Dali::Sampler::Property::U_WRAP:
+ {
+ property = &mSceneObject->mUWrapMode;
+ break;
+ }
+ case Dali::Sampler::Property::V_WRAP:
+ {
+ property = &mSceneObject->mVWrapMode;
+ break;
+ }
+ case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
+ {
+ property = &mSceneObject->mAffectsTransparency;
+ break;
+ }
+ }
+ }
+ }
+
+ return property;
+}
+
+int Sampler::GetPropertyComponentIndex( Property::Index index ) const
+{
+ return Property::INVALID_COMPONENT_INDEX;
+}
+
+bool Sampler::OnStage() const
+{
+ return mOnStage;
+}
+
+void Sampler::Connect()
+{
+ mOnStage = true;
+
+ mImageConnector.OnStageConnect();
+
+ // sceneObject is being used in a separate thread; queue a message to set
+ unsigned int resourceId = mImageConnector.Get()->GetResourceId();
+ SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
+}
+
+void Sampler::Disconnect()
+{
+ mOnStage = false;
+
+ mImageConnector.OnStageDisconnect();
+}
+
+Sampler::Sampler()
+: mSceneObject( NULL ),
+ mOnStage( false )
+{
+}
+
+void Sampler::Initialize( const std::string& textureUnitUniformName )
+{
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+
+ mSceneObject = new SceneGraph::Sampler( textureUnitUniformName );
+ AddMessage( updateManager, updateManager.GetSamplerOwner(), *mSceneObject );
+
+ eventThreadServices.RegisterObject( this );
+}
+
+Sampler::~Sampler()
+{
+ if( EventThreadServices::IsCoreRunning() )
+ {
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveMessage( updateManager, updateManager.GetSamplerOwner(), *mSceneObject );
+
+ eventThreadServices.UnregisterObject( this );
+ }
+}
+
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SAMPLER_H
+#define DALI_INTERNAL_SAMPLER_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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/shader-effects/sampler.h> // Dali::Sampler
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/images/image-connector.h> // Dali::Internal::ImageConnector
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class Sampler;
+}
+
+class Sampler;
+typedef IntrusivePtr<Sampler> SamplerPtr;
+
+/**
+ * Sampler is an object that contains an array of structures of values that
+ * can be accessed as properties.
+ */
+class Sampler : public Object, public Connectable
+{
+public:
+
+ /**
+ * Create a new Sampler.
+ * @return A smart-pointer to the newly allocated Sampler.
+ */
+ static SamplerPtr New( const std::string& textureUnitUniformName );
+
+ /**
+ * @copydoc Dali::Sampler::SetUniformName()
+ */
+ void SetTextureUnitUniformName( const std::string& name );
+
+ /**
+ * @copydoc Dali::Sampler::SetImage()
+ */
+ void SetImage( ImagePtr& image );
+
+ /**
+ * @copydoc Dali::Sampler::GetImage()
+ */
+ ImagePtr GetImage() const;
+
+ /**
+ * @copydoc Dali::Sampler::SetFilterMode()
+ */
+ void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
+
+ /**
+ * @copydoc Dali::Sampler::SetWrapMode()
+ */
+ void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
+
+ /**
+ * @copydoc Dali::Sampler::SetAffectsTransparency()
+ */
+ void SetAffectsTransparency( bool affectsTransparency );
+
+ /**
+ * @brief Get the sampler scene object
+ *
+ * @return the sampler scene object
+ */
+ const SceneGraph::Sampler* GetSamplerSceneObject() const;
+
+public: // Default property extensions from Object
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
+ */
+ virtual unsigned int GetDefaultPropertyCount() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
+ */
+ virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
+ */
+ virtual const char* GetDefaultPropertyName(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
+ */
+ virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
+ */
+ virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
+ */
+ virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
+ */
+ virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::SetDefaultProperty()
+ */
+ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+
+ /**
+ * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
+ */
+ virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultProperty()
+ */
+ virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyOwner()
+ */
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObject()
+ */
+ virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
+ */
+ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
+ */
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ */
+ virtual int GetPropertyComponentIndex( Property::Index index ) const;
+
+public: // Functions from Connectable
+ /**
+ * @copydoc Dali::Internal::Connectable::OnStage()
+ */
+ virtual bool OnStage() const;
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Connect()
+ */
+ virtual void Connect();
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Disconnect()
+ */
+ virtual void Disconnect();
+
+private:
+ Sampler();
+
+ /**
+ * Second stage initialization
+ */
+ void Initialize( const std::string& textureUnitUniformName );
+
+protected:
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Sampler();
+
+private: // data
+ //TODO: MESH_REWORK : change to ObjectConnector
+ ImageConnector mImageConnector;
+ SceneGraph::Sampler* mSceneObject;
+ bool mOnStage;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
+{
+ DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
+
+ BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<Internal::Sampler&>(object);
+}
+
+inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
+{
+ DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
+
+ const BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<const Internal::Sampler&>(object);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SAMPLER_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/event/effects/shader-impl.h> // Dali::Internal::Shader
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/shader-effects/shader.h> // Dali::Shader
+#include <dali/public-api/shader-effects/shader-effect.h> // Dali::ShaderEffect::GeometryHints // TODO: MESH_REWORK REMOVE
+
+#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/event/effects/shader-factory.h>
+#include <dali/internal/event/resources/resource-ticket.h>
+#include <dali/internal/update/manager/update-manager.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace
+{
+
+/**
+ * |name |type |writable|animatable|constraint-input|enum for index-checking|
+ */
+DALI_PROPERTY_TABLE_BEGIN
+DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM )
+DALI_PROPERTY( "shader-hints", UNSIGNED_INTEGER, true, false, true, Dali::Shader::Property::SHADER_HINTS )
+DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
+
+const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> SHADER_IMPL = { DEFAULT_PROPERTY_DETAILS };
+
+BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+TypeRegistration mType( typeid( Dali::Shader ), typeid( Dali::Handle ), Create );
+
+} // unnamed namespace
+
+ShaderPtr Shader::New( const std::string& vertexShader,
+ const std::string& fragmentShader,
+ Dali::Shader::ShaderHints hints )
+{
+ //TODO: MESH_REWORK
+ ShaderPtr shader( new Shader() );
+ shader->Initialize( vertexShader, fragmentShader, hints );
+ return shader;
+}
+
+const SceneGraph::Shader* Shader::GetShaderSceneObject() const
+{
+ return mSceneObject;
+}
+
+unsigned int Shader::GetDefaultPropertyCount() const
+{
+ return SHADER_IMPL.GetDefaultPropertyCount();
+}
+
+void Shader::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
+{
+ SHADER_IMPL.GetDefaultPropertyIndices( indices );
+}
+
+const char* Shader::GetDefaultPropertyName(Property::Index index) const
+{
+ return SHADER_IMPL.GetDefaultPropertyName( index );
+}
+
+Property::Index Shader::GetDefaultPropertyIndex( const std::string& name ) const
+{
+ return SHADER_IMPL.GetDefaultPropertyIndex( name );
+}
+
+bool Shader::IsDefaultPropertyWritable( Property::Index index ) const
+{
+ return SHADER_IMPL.IsDefaultPropertyWritable( index );
+}
+
+bool Shader::IsDefaultPropertyAnimatable( Property::Index index ) const
+{
+ return SHADER_IMPL.IsDefaultPropertyAnimatable( index );
+}
+
+bool Shader::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return SHADER_IMPL.IsDefaultPropertyAConstraintInput( index );
+}
+
+Property::Type Shader::GetDefaultPropertyType( Property::Index index ) const
+{
+ return SHADER_IMPL.GetDefaultPropertyType( index );
+}
+
+void Shader::SetDefaultProperty( Property::Index index,
+ const Property::Value& propertyValue )
+{
+ switch(index)
+ {
+ case Dali::Shader::Property::PROGRAM:
+ {
+ // @todo MESH_REWORK Set program again?
+ DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
+ break;
+ }
+ case Dali::Shader::Property::SHADER_HINTS:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
+ break;
+ }
+ }
+}
+
+void Shader::SetSceneGraphProperty( Property::Index index,
+ const PropertyMetadata& entry,
+ const Property::Value& value )
+{
+ SHADER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
+ OnPropertySet(index, value);
+}
+
+Property::Value Shader::GetDefaultProperty( Property::Index index ) const
+{
+ Property::Value value;
+
+ switch(index)
+ {
+ case Dali::Shader::Property::PROGRAM:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
+ break;
+ }
+ case Dali::Shader::Property::SHADER_HINTS:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
+ break;
+ }
+ }
+
+ return value;
+}
+
+const SceneGraph::PropertyOwner* Shader::GetPropertyOwner() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyOwner* Shader::GetSceneObject() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyBase* Shader::GetSceneObjectAnimatableProperty( Property::Index index ) const
+{
+ DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
+ const SceneGraph::PropertyBase* property = NULL;
+
+ if( OnStage() )
+ {
+ property = SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Shader::FindAnimatableProperty,
+ &Shader::FindCustomProperty,
+ index );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
+ }
+ }
+
+ return property;
+}
+
+const PropertyInputImpl* Shader::GetSceneObjectInputProperty( Property::Index index ) const
+{
+ const PropertyInputImpl* property = NULL;
+
+ if( OnStage() )
+ {
+ const SceneGraph::PropertyBase* baseProperty =
+ SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Shader::FindAnimatableProperty,
+ &Shader::FindCustomProperty,
+ index );
+ property = static_cast<const PropertyInputImpl*>( baseProperty );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ if( index == Dali::Shader::Property::SHADER_HINTS )
+ {
+ // @todo MESH_REWORK - return the property
+ }
+ else
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property is not a valid constraint input" );
+ }
+ }
+ }
+
+ return property;
+}
+
+int Shader::GetPropertyComponentIndex( Property::Index index ) const
+{
+ return Property::INVALID_COMPONENT_INDEX;
+}
+
+bool Shader::OnStage() const
+{
+ return mOnStage;
+}
+
+void Shader::Connect()
+{
+ mOnStage = true;
+}
+
+void Shader::Disconnect()
+{
+ mOnStage = false;
+}
+
+Shader::Shader()
+: mSceneObject( NULL ),
+ mOnStage( false )
+{
+}
+
+void Shader::Initialize(
+ const std::string& vertexSource,
+ const std::string& fragmentSource,
+ Dali::Shader::ShaderHints hints )
+{
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+
+ // @todo MESH_REWORK - Pass hints directly to a new scene graph shader
+ int effectHint = Dali::ShaderEffect::HINT_NONE;
+ if( hints & Dali::Shader::HINT_OUTPUT_IS_TRANSPARENT )
+ {
+ effectHint |= Dali::ShaderEffect::HINT_BLENDING;
+ }
+
+ if( hints & Dali::Shader::HINT_REQUIRES_SELF_DEPTH_TEST )
+ {
+ effectHint |= Dali::ShaderEffect::HINT_DEPTH_BUFFER;
+ }
+
+ if( (hints & Dali::Shader::HINT_MODIFIES_GEOMETRY) == 0x0 )
+ {
+ effectHint |= Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY;
+ }
+ Dali::ShaderEffect::GeometryHints shaderEffectHint = static_cast<Dali::ShaderEffect::GeometryHints>( effectHint );
+
+ mSceneObject = new SceneGraph::Shader(shaderEffectHint);
+
+ // Add to update manager
+ AddShaderMessage( updateManager, *mSceneObject );
+
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ ShaderFactory& shaderFactory = tls.GetShaderFactory();
+ size_t shaderHash;
+
+ mTicket = ResourceTicketPtr( shaderFactory.Load(vertexSource, fragmentSource, shaderHash) );
+
+ // Add shader program to scene-object using a message to the UpdateManager
+ SetShaderProgramMessage( updateManager, *mSceneObject, mTicket->GetId(), shaderHash, false );
+
+ eventThreadServices.RegisterObject( this );
+}
+
+Shader::~Shader()
+{
+ if( EventThreadServices::IsCoreRunning() )
+ {
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveShaderMessage( updateManager, *mSceneObject);
+
+ eventThreadServices.UnregisterObject( this );
+ }
+}
+
+
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SHADER_H
+#define DALI_INTERNAL_SHADER_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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/shader-effects/shader.h> // Dali::Shader
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/resources/resource-ticket.h> // Dali::Internal::ResourceTicketPtr
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class Shader;
+}
+
+class Shader;
+typedef IntrusivePtr<Shader> ShaderPtr;
+
+/**
+ * Shader is an object that contains an array of structures of values that
+ * can be accessed as properties.
+ */
+class Shader : public Object, public Connectable
+{
+public:
+
+ /**
+ * @copydoc Dali::Shader::New()
+ */
+ static ShaderPtr New( const std::string& vertexShader,
+ const std::string& fragmentShader,
+ Dali::Shader::ShaderHints hints );
+
+ /**
+ * @brief Get the shader scene object
+ *
+ * @return the shader scene object
+ */
+ const SceneGraph::Shader* GetShaderSceneObject() const;
+
+public: // Default property extensions from Object
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
+ */
+ virtual unsigned int GetDefaultPropertyCount() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
+ */
+ virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
+ */
+ virtual const char* GetDefaultPropertyName(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
+ */
+ virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
+ */
+ virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
+ */
+ virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
+ */
+ virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::SetDefaultProperty()
+ */
+ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+
+ /**
+ * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
+ */
+ virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultProperty()
+ */
+ virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyOwner()
+ */
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObject()
+ */
+ virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
+ */
+ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
+ */
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ */
+ virtual int GetPropertyComponentIndex( Property::Index index ) const;
+
+public: // Functions from Connectable
+ /**
+ * @copydoc Dali::Internal::Connectable::OnStage()
+ */
+ virtual bool OnStage() const;
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Connect()
+ */
+ virtual void Connect();
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Disconnect()
+ */
+ virtual void Disconnect();
+
+private: // implementation
+ Shader();
+
+ /**
+ * Second stage initialization
+ */
+ void Initialize( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::ShaderHints hints );
+
+protected:
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Shader();
+
+private: // unimplemented methods
+ Shader( const Shader& );
+ Shader& operator=( const Shader& );
+
+private:
+ SceneGraph::Shader* mSceneObject;
+ ResourceTicketPtr mTicket;
+ bool mOnStage;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Internal::Shader& GetImplementation( Dali::Shader& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
+
+ BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<Internal::Shader&>(object);
+}
+
+inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
+
+ const BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<const Internal::Shader&>(object);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SHADER_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/event/geometry/geometry-impl.h> // Dali::Internal::Geometry
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/update/common/double-buffered-property.h>
+#include <dali/internal/update/manager/update-manager.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace
+{
+
+/**
+ * |name |type |writable|animatable|constraint-input|enum for index-checking|
+ */
+DALI_PROPERTY_TABLE_BEGIN
+DALI_PROPERTY( "geometry-type", STRING, true, false, true, Dali::Geometry::Property::GEOMETRY_TYPE )
+DALI_PROPERTY( "geometry-center", VECTOR3, true, true, true, Dali::Geometry::Property::GEOMETRY_CENTER )
+DALI_PROPERTY( "geometry-half-extents", VECTOR3, true, true, true, Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS )
+DALI_PROPERTY( "requires-depth-test", BOOLEAN, true, false, true, Dali::Geometry::Property::REQUIRES_DEPTH_TEST )
+DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
+
+const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> GEOMETRY_IMPL = { DEFAULT_PROPERTY_DETAILS };
+
+BaseHandle Create()
+{
+ return Dali::Geometry::New();
+}
+
+TypeRegistration mType( typeid( Dali::Geometry ), typeid( Dali::Handle ), Create );
+
+} // unnamed namespace
+
+GeometryPtr Geometry::New()
+{
+ GeometryPtr geometry( new Geometry() );
+ geometry->Initialize();
+ return geometry;
+}
+
+std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer )
+{
+ PropertyBufferConnector connector;
+ connector.Set( vertexBuffer, OnStage() );
+ mVertexBufferConnectors.push_back( connector );
+
+ const SceneGraph::PropertyBuffer& sceneGraphPropertyBuffer = dynamic_cast<const SceneGraph::PropertyBuffer&>( *vertexBuffer.GetSceneObject() );
+
+ SceneGraph::AddVertexBufferMessage( GetEventThreadServices(), *mSceneObject, sceneGraphPropertyBuffer );
+
+ return mVertexBufferConnectors.size() - 1u;
+}
+
+std::size_t Geometry::GetNumberOfVertexBuffers() const
+{
+ return mVertexBufferConnectors.size();
+}
+
+void Geometry::RemoveVertexBuffer( std::size_t index )
+{
+ mVertexBufferConnectors.erase( mVertexBufferConnectors.begin() + index );
+}
+
+void Geometry::SetIndexBuffer( PropertyBuffer& indexBuffer )
+{
+ mIndexBufferConnector.Set( indexBuffer, OnStage() );
+
+ const SceneGraph::PropertyBuffer& sceneGraphPropertyBuffer = dynamic_cast<const SceneGraph::PropertyBuffer&>( *indexBuffer.GetSceneObject() );
+
+ SceneGraph::SetIndexBufferMessage( GetEventThreadServices(), *mSceneObject, sceneGraphPropertyBuffer );
+}
+
+void Geometry::SetGeometryType( Dali::Geometry::GeometryType geometryType )
+{
+ if( NULL != mSceneObject )
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send(
+ GetEventThreadServices(),
+ mSceneObject,
+ &mSceneObject->mGeometryType,
+ &SceneGraph::DoubleBufferedProperty<int>::Set,
+ static_cast<int>(geometryType) );
+ }
+}
+
+Dali::Geometry::GeometryType Geometry::GetGeometryType() const
+{
+ return mSceneObject->GetGeometryType(GetEventThreadServices().GetEventBufferIndex());
+}
+
+void Geometry::SetRequiresDepthTesting( bool requiresDepthTest )
+{
+ if( NULL != mSceneObject )
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mRequiresDepthTest, &SceneGraph::DoubleBufferedProperty<bool>::Set, static_cast<int>(requiresDepthTest) );
+ }
+}
+
+bool Geometry::GetRequiresDepthTesting() const
+{
+ if( mSceneObject )
+ {
+ // mSceneObject is being used in a separate thread; copy the value from the previous update
+ return mSceneObject->GetRequiresDepthTesting(GetEventThreadServices().GetEventBufferIndex());
+ }
+ return false;
+}
+
+const SceneGraph::Geometry* Geometry::GetGeometrySceneObject() const
+{
+ return mSceneObject;
+}
+
+unsigned int Geometry::GetDefaultPropertyCount() const
+{
+ return GEOMETRY_IMPL.GetDefaultPropertyCount();
+}
+
+void Geometry::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
+{
+ GEOMETRY_IMPL.GetDefaultPropertyIndices( indices );
+}
+
+const char* Geometry::GetDefaultPropertyName(Property::Index index) const
+{
+ return GEOMETRY_IMPL.GetDefaultPropertyName( index );
+}
+
+Property::Index Geometry::GetDefaultPropertyIndex( const std::string& name ) const
+{
+ return GEOMETRY_IMPL.GetDefaultPropertyIndex( name );
+}
+
+bool Geometry::IsDefaultPropertyWritable( Property::Index index ) const
+{
+ return GEOMETRY_IMPL.IsDefaultPropertyWritable( index );
+}
+
+bool Geometry::IsDefaultPropertyAnimatable( Property::Index index ) const
+{
+ return GEOMETRY_IMPL.IsDefaultPropertyAnimatable( index );
+}
+
+bool Geometry::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return GEOMETRY_IMPL.IsDefaultPropertyAConstraintInput( index );
+}
+
+Property::Type Geometry::GetDefaultPropertyType( Property::Index index ) const
+{
+ return GEOMETRY_IMPL.GetDefaultPropertyType( index );
+}
+
+void Geometry::SetDefaultProperty( Property::Index index,
+ const Property::Value& propertyValue )
+{
+ switch( index )
+ {
+ case Dali::Geometry::Property::GEOMETRY_TYPE :
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mGeometryType, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ break;
+ }
+ case Dali::Geometry::Property::GEOMETRY_CENTER :
+ {
+ SceneGraph::AnimatablePropertyMessage<Vector3>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mCenter, &SceneGraph::AnimatableProperty<Vector3>::Bake, propertyValue.Get<Vector3>() );
+ break;
+ }
+
+ case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
+ {
+ SceneGraph::AnimatablePropertyMessage<Vector3>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mHalfExtents, &SceneGraph::AnimatableProperty<Vector3>::Bake, propertyValue.Get<Vector3>() );
+ break;
+ }
+
+ case Dali::Geometry::Property::REQUIRES_DEPTH_TEST :
+ {
+ SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mRequiresDepthTest, &SceneGraph::DoubleBufferedProperty<bool>::Set, propertyValue.Get<bool>() );
+ break;
+ }
+ }
+}
+
+void Geometry::SetSceneGraphProperty( Property::Index index,
+ const PropertyMetadata& entry,
+ const Property::Value& value )
+{
+ GEOMETRY_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
+}
+
+Property::Value Geometry::GetDefaultProperty( Property::Index index ) const
+{
+ BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
+ Property::Value value;
+
+ switch( index )
+ {
+ case Dali::Geometry::Property::GEOMETRY_TYPE :
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mGeometryType[bufferIndex];
+ }
+ break;
+ }
+ case Dali::Geometry::Property::GEOMETRY_CENTER :
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mCenter[bufferIndex];
+ }
+ break;
+ }
+
+ case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mHalfExtents[bufferIndex];
+ }
+ break;
+ }
+
+ case Dali::Geometry::Property::REQUIRES_DEPTH_TEST :
+ {
+ if( mSceneObject )
+ {
+ value = mSceneObject->mRequiresDepthTest[bufferIndex];
+ }
+ break;
+ }
+ }
+
+ return value;
+}
+
+const SceneGraph::PropertyOwner* Geometry::GetPropertyOwner() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyOwner* Geometry::GetSceneObject() const
+{
+ return mSceneObject;
+}
+
+const SceneGraph::PropertyBase* Geometry::GetSceneObjectAnimatableProperty( Property::Index index ) const
+{
+ const SceneGraph::PropertyBase* property = NULL;
+
+ if( OnStage() )
+ {
+ property = GEOMETRY_IMPL.GetRegisteredSceneGraphProperty ( this,
+ &Geometry::FindAnimatableProperty,
+ &Geometry::FindCustomProperty,
+ index );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ switch(index)
+ {
+ case Dali::Geometry::Property::GEOMETRY_CENTER :
+ {
+ property = &mSceneObject->mCenter;
+ break;
+ }
+ case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
+ {
+ property = &mSceneObject->mHalfExtents;
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
+ break;
+ }
+ }
+ }
+ }
+ return property;
+}
+
+const PropertyInputImpl* Geometry::GetSceneObjectInputProperty( Property::Index index ) const
+{
+ const PropertyInputImpl* property = NULL;
+
+ if( OnStage() )
+ {
+ const SceneGraph::PropertyBase* baseProperty =
+ GEOMETRY_IMPL.GetRegisteredSceneGraphProperty ( this,
+ &Geometry::FindAnimatableProperty,
+ &Geometry::FindCustomProperty,
+ index );
+
+ property = static_cast<const PropertyInputImpl*>( baseProperty );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ switch(index)
+ {
+ case Dali::Geometry::Property::GEOMETRY_TYPE :
+ {
+ property = &mSceneObject->mGeometryType;
+ break;
+ }
+ case Dali::Geometry::Property::GEOMETRY_CENTER :
+ {
+ property = &mSceneObject->mCenter;
+ break;
+ }
+ case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
+ {
+ property = &mSceneObject->mHalfExtents;
+ break;
+ }
+ case Dali::Geometry::Property::REQUIRES_DEPTH_TEST :
+ {
+ property = &mSceneObject->mRequiresDepthTest;
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property cannot be a constraint input");
+ break;
+ }
+ }
+ }
+ }
+
+ return property;
+}
+
+int Geometry::GetPropertyComponentIndex( Property::Index index ) const
+{
+ // @todo MESH_REWORK - Change this if component properties are added for center/half-extent
+ return Property::INVALID_COMPONENT_INDEX;
+}
+
+bool Geometry::OnStage() const
+{
+ return mOnStage;
+}
+
+void Geometry::Connect()
+{
+ mOnStage = true;
+
+ PropertyBufferConnectorContainer::const_iterator end = mVertexBufferConnectors.end();
+ for( PropertyBufferConnectorContainer::iterator it = mVertexBufferConnectors.begin();
+ it < end;
+ ++it )
+ {
+ it->OnStageConnect();
+ }
+ mIndexBufferConnector.OnStageConnect();
+}
+
+void Geometry::Disconnect()
+{
+ mOnStage = false;
+
+ PropertyBufferConnectorContainer::const_iterator end = mVertexBufferConnectors.end();
+ for( PropertyBufferConnectorContainer::iterator it = mVertexBufferConnectors.begin();
+ it < end;
+ ++it )
+ {
+ it->OnStageDisconnect();
+ }
+ mIndexBufferConnector.OnStageDisconnect();
+}
+
+Geometry::Geometry()
+: mSceneObject( NULL ),
+ mOnStage( false )
+{
+}
+
+void Geometry::Initialize()
+{
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+
+ mSceneObject = new SceneGraph::Geometry();
+ AddMessage( updateManager, updateManager.GetGeometryOwner(), *mSceneObject );
+
+ eventThreadServices.RegisterObject( this );
+}
+
+Geometry::~Geometry()
+{
+ if( EventThreadServices::IsCoreRunning() )
+ {
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveMessage( updateManager, updateManager.GetGeometryOwner(), *mSceneObject );
+
+ eventThreadServices.UnregisterObject( this );
+ }
+}
+
+
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GEOMETRY_H
+#define DALI_INTERNAL_GEOMETRY_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h> // std::vector
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/geometry/geometry.h> // Dali::Geometry
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class Geometry;
+}
+
+class Geometry;
+typedef IntrusivePtr<Geometry> GeometryPtr;
+
+/**
+ * Geometry is an object that contains an array of structures of values that
+ * can be accessed as properties.
+ */
+class Geometry : public Object, public Connectable
+{
+public:
+
+ /**
+ * Create a new Geometry.
+ * @return A smart-pointer to the newly allocated Geometry.
+ */
+ static GeometryPtr New();
+
+ /**
+ * @copydoc Dali::Geometry::AddVertexBuffer()
+ */
+ std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
+
+ /**
+ * @copydoc Dali::Geometry::GetNumberOfVertexBuffers()
+ */
+ std::size_t GetNumberOfVertexBuffers() const;
+
+ /**
+ * @copydoc Dali::Geometry::RemoveVertexBuffer()
+ */
+ void RemoveVertexBuffer( std::size_t index );
+
+ /**
+ * @copydoc Dali::Geometry::SetIndexBuffer()
+ */
+ void SetIndexBuffer( PropertyBuffer& indexBuffer );
+
+ /**
+ * @copydoc Dali::Geometry::SetGeometryType()
+ */
+ void SetGeometryType( Dali::Geometry::GeometryType geometryType );
+
+ /**
+ * @copydoc Dali::Geometry::GetGeometryType()
+ */
+ Dali::Geometry::GeometryType GetGeometryType() const;
+
+ /**
+ * @copydoc Dali::Geometry::SetRequiresDepthTesting()
+ */
+ void SetRequiresDepthTesting( bool requiresDepthTest );
+
+ /**
+ * @copydoc Dali::Geometry::GetRequiresDepthTesting()
+ */
+ bool GetRequiresDepthTesting() const;
+
+ /**
+ * @brief Get the geometry scene object
+ *
+ * @return the geometry scene object
+ */
+ const SceneGraph::Geometry* GetGeometrySceneObject() const;
+
+public: // Default property extensions from Object
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
+ */
+ virtual unsigned int GetDefaultPropertyCount() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
+ */
+ virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
+ */
+ virtual const char* GetDefaultPropertyName(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
+ */
+ virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
+ */
+ virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
+ */
+ virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
+ */
+ virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::SetDefaultProperty()
+ */
+ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+
+ /**
+ * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
+ */
+ virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
+
+ /**
+ * @copydoc Dali::Internal::Object::GetDefaultProperty()
+ */
+ virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyOwner()
+ */
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObject()
+ */
+ virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
+ */
+ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
+ */
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ */
+ virtual int GetPropertyComponentIndex( Property::Index index ) const;
+
+public: // Functions from Connectable
+ /**
+ * @copydoc Dali::Internal::Connectable::OnStage()
+ */
+ virtual bool OnStage() const;
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Connect()
+ */
+ virtual void Connect();
+
+ /**
+ * @copydoc Dali::Internal::Connectable::Disconnect()
+ */
+ virtual void Disconnect();
+
+private: // implementation
+ Geometry();
+
+ /**
+ * Second stage initialization of the Geometry
+ */
+ void Initialize();
+
+protected:
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Geometry();
+
+private: // unimplemented methods
+ Geometry( const Geometry& );
+ Geometry& operator=( const Geometry& );
+
+private: // data
+ typedef ObjectConnector<PropertyBuffer> PropertyBufferConnector;
+ typedef std::vector< PropertyBufferConnector > PropertyBufferConnectorContainer;
+ PropertyBufferConnectorContainer mVertexBufferConnectors; ///< Vector of connectors that hold the property buffers used by this geometry
+ PropertyBufferConnector mIndexBufferConnector; ///< Connector that holds the index buffer used by this geometry
+ SceneGraph::Geometry* mSceneObject;
+ bool mOnStage;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Internal::Geometry& GetImplementation(Dali::Geometry& handle)
+{
+ DALI_ASSERT_ALWAYS(handle && "Geometry handle is empty");
+
+ BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<Internal::Geometry&>(object);
+}
+
+inline const Internal::Geometry& GetImplementation(const Dali::Geometry& handle)
+{
+ DALI_ASSERT_ALWAYS(handle && "Geometry handle is empty");
+
+ const BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<const Internal::Geometry&>(object);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GEOMETRY_H
// INTERNAL INCLUDES
#include <dali/devel-api/geometry/cloth.h>
#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/rendering/geometry-impl.h>
+#include <dali/internal/event/geometry/geometry-impl.h>
namespace Dali
{
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/update/common/double-buffered-property.h>
-#include <dali/internal/update/manager/update-manager.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-namespace
-{
-
-/**
- * |name |type |writable|animatable|constraint-input|enum for index-checking|
- */
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "geometry-type", STRING, true, false, true, Dali::Geometry::Property::GEOMETRY_TYPE )
-DALI_PROPERTY( "geometry-center", VECTOR3, true, true, true, Dali::Geometry::Property::GEOMETRY_CENTER )
-DALI_PROPERTY( "geometry-half-extents", VECTOR3, true, true, true, Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS )
-DALI_PROPERTY( "requires-depth-test", BOOLEAN, true, false, true, Dali::Geometry::Property::REQUIRES_DEPTH_TEST )
-DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
-
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> GEOMETRY_IMPL = { DEFAULT_PROPERTY_DETAILS };
-
-BaseHandle Create()
-{
- return Dali::Geometry::New();
-}
-
-TypeRegistration mType( typeid( Dali::Geometry ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
-GeometryPtr Geometry::New()
-{
- GeometryPtr geometry( new Geometry() );
- geometry->Initialize();
- return geometry;
-}
-
-std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer )
-{
- PropertyBufferConnector connector;
- connector.Set( vertexBuffer, OnStage() );
- mVertexBufferConnectors.push_back( connector );
-
- const SceneGraph::PropertyBuffer& sceneGraphPropertyBuffer = dynamic_cast<const SceneGraph::PropertyBuffer&>( *vertexBuffer.GetSceneObject() );
-
- SceneGraph::AddVertexBufferMessage( GetEventThreadServices(), *mSceneObject, sceneGraphPropertyBuffer );
-
- return mVertexBufferConnectors.size() - 1u;
-}
-
-std::size_t Geometry::GetNumberOfVertexBuffers() const
-{
- return mVertexBufferConnectors.size();
-}
-
-void Geometry::RemoveVertexBuffer( std::size_t index )
-{
- mVertexBufferConnectors.erase( mVertexBufferConnectors.begin() + index );
-}
-
-void Geometry::SetIndexBuffer( PropertyBuffer& indexBuffer )
-{
- mIndexBufferConnector.Set( indexBuffer, OnStage() );
-
- const SceneGraph::PropertyBuffer& sceneGraphPropertyBuffer = dynamic_cast<const SceneGraph::PropertyBuffer&>( *indexBuffer.GetSceneObject() );
-
- SceneGraph::SetIndexBufferMessage( GetEventThreadServices(), *mSceneObject, sceneGraphPropertyBuffer );
-}
-
-void Geometry::SetGeometryType( Dali::Geometry::GeometryType geometryType )
-{
- if( NULL != mSceneObject )
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send(
- GetEventThreadServices(),
- mSceneObject,
- &mSceneObject->mGeometryType,
- &SceneGraph::DoubleBufferedProperty<int>::Set,
- static_cast<int>(geometryType) );
- }
-}
-
-Dali::Geometry::GeometryType Geometry::GetGeometryType() const
-{
- return mSceneObject->GetGeometryType(GetEventThreadServices().GetEventBufferIndex());
-}
-
-void Geometry::SetRequiresDepthTesting( bool requiresDepthTest )
-{
- if( NULL != mSceneObject )
- {
- SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mRequiresDepthTest, &SceneGraph::DoubleBufferedProperty<bool>::Set, static_cast<int>(requiresDepthTest) );
- }
-}
-
-bool Geometry::GetRequiresDepthTesting() const
-{
- if( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; copy the value from the previous update
- return mSceneObject->GetRequiresDepthTesting(GetEventThreadServices().GetEventBufferIndex());
- }
- return false;
-}
-
-const SceneGraph::Geometry* Geometry::GetGeometrySceneObject() const
-{
- return mSceneObject;
-}
-
-unsigned int Geometry::GetDefaultPropertyCount() const
-{
- return GEOMETRY_IMPL.GetDefaultPropertyCount();
-}
-
-void Geometry::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- GEOMETRY_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* Geometry::GetDefaultPropertyName(Property::Index index) const
-{
- return GEOMETRY_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index Geometry::GetDefaultPropertyIndex( const std::string& name ) const
-{
- return GEOMETRY_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool Geometry::IsDefaultPropertyWritable( Property::Index index ) const
-{
- return GEOMETRY_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool Geometry::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- return GEOMETRY_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool Geometry::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return GEOMETRY_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type Geometry::GetDefaultPropertyType( Property::Index index ) const
-{
- return GEOMETRY_IMPL.GetDefaultPropertyType( index );
-}
-
-void Geometry::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
-{
- switch( index )
- {
- case Dali::Geometry::Property::GEOMETRY_TYPE :
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mGeometryType, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- break;
- }
- case Dali::Geometry::Property::GEOMETRY_CENTER :
- {
- SceneGraph::AnimatablePropertyMessage<Vector3>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mCenter, &SceneGraph::AnimatableProperty<Vector3>::Bake, propertyValue.Get<Vector3>() );
- break;
- }
-
- case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
- {
- SceneGraph::AnimatablePropertyMessage<Vector3>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mHalfExtents, &SceneGraph::AnimatableProperty<Vector3>::Bake, propertyValue.Get<Vector3>() );
- break;
- }
-
- case Dali::Geometry::Property::REQUIRES_DEPTH_TEST :
- {
- SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mRequiresDepthTest, &SceneGraph::DoubleBufferedProperty<bool>::Set, propertyValue.Get<bool>() );
- break;
- }
- }
-}
-
-void Geometry::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- GEOMETRY_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
-}
-
-Property::Value Geometry::GetDefaultProperty( Property::Index index ) const
-{
- BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
- Property::Value value;
-
- switch( index )
- {
- case Dali::Geometry::Property::GEOMETRY_TYPE :
- {
- if( mSceneObject )
- {
- value = mSceneObject->mGeometryType[bufferIndex];
- }
- break;
- }
- case Dali::Geometry::Property::GEOMETRY_CENTER :
- {
- if( mSceneObject )
- {
- value = mSceneObject->mCenter[bufferIndex];
- }
- break;
- }
-
- case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
- {
- if( mSceneObject )
- {
- value = mSceneObject->mHalfExtents[bufferIndex];
- }
- break;
- }
-
- case Dali::Geometry::Property::REQUIRES_DEPTH_TEST :
- {
- if( mSceneObject )
- {
- value = mSceneObject->mRequiresDepthTest[bufferIndex];
- }
- break;
- }
- }
-
- return value;
-}
-
-const SceneGraph::PropertyOwner* Geometry::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Geometry::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* Geometry::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- const SceneGraph::PropertyBase* property = NULL;
-
- if( OnStage() )
- {
- property = GEOMETRY_IMPL.GetRegisteredSceneGraphProperty ( this,
- &Geometry::FindAnimatableProperty,
- &Geometry::FindCustomProperty,
- index );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch(index)
- {
- case Dali::Geometry::Property::GEOMETRY_CENTER :
- {
- property = &mSceneObject->mCenter;
- break;
- }
- case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
- {
- property = &mSceneObject->mHalfExtents;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
- break;
- }
- }
- }
- }
- return property;
-}
-
-const PropertyInputImpl* Geometry::GetSceneObjectInputProperty( Property::Index index ) const
-{
- const PropertyInputImpl* property = NULL;
-
- if( OnStage() )
- {
- const SceneGraph::PropertyBase* baseProperty =
- GEOMETRY_IMPL.GetRegisteredSceneGraphProperty ( this,
- &Geometry::FindAnimatableProperty,
- &Geometry::FindCustomProperty,
- index );
-
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch(index)
- {
- case Dali::Geometry::Property::GEOMETRY_TYPE :
- {
- property = &mSceneObject->mGeometryType;
- break;
- }
- case Dali::Geometry::Property::GEOMETRY_CENTER :
- {
- property = &mSceneObject->mCenter;
- break;
- }
- case Dali::Geometry::Property::GEOMETRY_HALF_EXTENTS :
- {
- property = &mSceneObject->mHalfExtents;
- break;
- }
- case Dali::Geometry::Property::REQUIRES_DEPTH_TEST :
- {
- property = &mSceneObject->mRequiresDepthTest;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Property cannot be a constraint input");
- break;
- }
- }
- }
- }
-
- return property;
-}
-
-int Geometry::GetPropertyComponentIndex( Property::Index index ) const
-{
- // @todo MESH_REWORK - Change this if component properties are added for center/half-extent
- return Property::INVALID_COMPONENT_INDEX;
-}
-
-bool Geometry::OnStage() const
-{
- return mOnStage;
-}
-
-void Geometry::Connect()
-{
- mOnStage = true;
-
- PropertyBufferConnectorContainer::const_iterator end = mVertexBufferConnectors.end();
- for( PropertyBufferConnectorContainer::iterator it = mVertexBufferConnectors.begin();
- it < end;
- ++it )
- {
- it->OnStageConnect();
- }
- mIndexBufferConnector.OnStageConnect();
-}
-
-void Geometry::Disconnect()
-{
- mOnStage = false;
-
- PropertyBufferConnectorContainer::const_iterator end = mVertexBufferConnectors.end();
- for( PropertyBufferConnectorContainer::iterator it = mVertexBufferConnectors.begin();
- it < end;
- ++it )
- {
- it->OnStageDisconnect();
- }
- mIndexBufferConnector.OnStageDisconnect();
-}
-
-Geometry::Geometry()
-: mSceneObject( NULL ),
- mOnStage( false )
-{
-}
-
-void Geometry::Initialize()
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
- mSceneObject = new SceneGraph::Geometry();
- AddMessage( updateManager, updateManager.GetGeometryOwner(), *mSceneObject );
-
- eventThreadServices.RegisterObject( this );
-}
-
-Geometry::~Geometry()
-{
- if( EventThreadServices::IsCoreRunning() )
- {
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveMessage( updateManager, updateManager.GetGeometryOwner(), *mSceneObject );
-
- eventThreadServices.UnregisterObject( this );
- }
-}
-
-
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_GEOMETRY_H
-#define DALI_INTERNAL_GEOMETRY_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h> // std::vector
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class Geometry;
-}
-
-class Geometry;
-typedef IntrusivePtr<Geometry> GeometryPtr;
-
-/**
- * Geometry is an object that contains an array of structures of values that
- * can be accessed as properties.
- */
-class Geometry : public Object, public Connectable
-{
-public:
-
- /**
- * Create a new Geometry.
- * @return A smart-pointer to the newly allocated Geometry.
- */
- static GeometryPtr New();
-
- /**
- * @copydoc Dali::Geometry::AddVertexBuffer()
- */
- std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
-
- /**
- * @copydoc Dali::Geometry::GetNumberOfVertexBuffers()
- */
- std::size_t GetNumberOfVertexBuffers() const;
-
- /**
- * @copydoc Dali::Geometry::RemoveVertexBuffer()
- */
- void RemoveVertexBuffer( std::size_t index );
-
- /**
- * @copydoc Dali::Geometry::SetIndexBuffer()
- */
- void SetIndexBuffer( PropertyBuffer& indexBuffer );
-
- /**
- * @copydoc Dali::Geometry::SetGeometryType()
- */
- void SetGeometryType( Dali::Geometry::GeometryType geometryType );
-
- /**
- * @copydoc Dali::Geometry::GetGeometryType()
- */
- Dali::Geometry::GeometryType GetGeometryType() const;
-
- /**
- * @copydoc Dali::Geometry::SetRequiresDepthTesting()
- */
- void SetRequiresDepthTesting( bool requiresDepthTest );
-
- /**
- * @copydoc Dali::Geometry::GetRequiresDepthTesting()
- */
- bool GetRequiresDepthTesting() const;
-
- /**
- * @brief Get the geometry scene object
- *
- * @return the geometry scene object
- */
- const SceneGraph::Geometry* GetGeometrySceneObject() const;
-
-public: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
- /**
- * @copydoc Dali::Internal::Connectable::OnStage()
- */
- virtual bool OnStage() const;
-
- /**
- * @copydoc Dali::Internal::Connectable::Connect()
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Connectable::Disconnect()
- */
- virtual void Disconnect();
-
-private: // implementation
- Geometry();
-
- /**
- * Second stage initialization of the Geometry
- */
- void Initialize();
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Geometry();
-
-private: // unimplemented methods
- Geometry( const Geometry& );
- Geometry& operator=( const Geometry& );
-
-private: // data
- typedef ObjectConnector<PropertyBuffer> PropertyBufferConnector;
- typedef std::vector< PropertyBufferConnector > PropertyBufferConnectorContainer;
- PropertyBufferConnectorContainer mVertexBufferConnectors; ///< Vector of connectors that hold the property buffers used by this geometry
- PropertyBufferConnector mIndexBufferConnector; ///< Connector that holds the index buffer used by this geometry
- SceneGraph::Geometry* mSceneObject;
- bool mOnStage;
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-inline Internal::Geometry& GetImplementation(Dali::Geometry& handle)
-{
- DALI_ASSERT_ALWAYS(handle && "Geometry handle is empty");
-
- BaseObject& object = handle.GetBaseObject();
-
- return static_cast<Internal::Geometry&>(object);
-}
-
-inline const Internal::Geometry& GetImplementation(const Dali::Geometry& handle)
-{
- DALI_ASSERT_ALWAYS(handle && "Geometry handle is empty");
-
- const BaseObject& object = handle.GetBaseObject();
-
- return static_cast<const Internal::Geometry&>(object);
-}
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_GEOMETRY_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/rendering/material-impl.h> // Dali::Internal::Material
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/rendering/material.h> // Dali::Internal::Material
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-namespace
-{
-
-/**
- * |name |type |writable|animatable|constraint-input|enum for index-checking|
- */
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "color", VECTOR4, true, true, true, Dali::Material::Property::COLOR )
-DALI_PROPERTY( "face-culling-mode", STRING, true, false, false, Dali::Material::Property::FACE_CULLING_MODE )
-DALI_PROPERTY( "blending-mode", STRING, true, false, false, Dali::Material::Property::BLENDING_MODE )
-DALI_PROPERTY( "blend-equation-rgb", STRING, true, false, false, Dali::Material::Property::BLEND_EQUATION_RGB )
-DALI_PROPERTY( "blend-equation-alpha", STRING, true, false, false, Dali::Material::Property::BLEND_EQUATION_ALPHA )
-DALI_PROPERTY( "source-blend-factor-rgb", STRING, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_RGB )
-DALI_PROPERTY( "destination-blend-factor-rgb", STRING, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_RGB )
-DALI_PROPERTY( "source-blend-factor-alpha", STRING, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA )
-DALI_PROPERTY( "destination-blend-factor-alpha", STRING, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA )
-DALI_PROPERTY( "blend-color", VECTOR4, true, true, true, Dali::Material::Property::BLEND_COLOR )
-DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
-
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> MATERIAL_IMPL = { DEFAULT_PROPERTY_DETAILS };
-
-BaseHandle Create()
-{
- return Dali::BaseHandle();
-}
-
-TypeRegistration mType( typeid( Dali::Material ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
-MaterialPtr Material::New()
-{
- MaterialPtr material( new Material() );
- material->Initialize();
- return material;
-}
-
-void Material::SetShader( Shader& shader )
-{
- DALI_ASSERT_DEBUG( mSceneObject )
- mShaderConnector.Set( shader, OnStage() );
-
- const SceneGraph::Shader& sceneGraphShader = dynamic_cast<const SceneGraph::Shader&>( *shader.GetSceneObject() );
- SceneGraph::SetShaderMessage( GetEventThreadServices(), *mSceneObject, sceneGraphShader );
-}
-
-Shader* Material::GetShader() const
-{
- return mShaderConnector.Get().Get();
-}
-
-void Material::AddSampler( Sampler& sampler )
-{
- SamplerConnector connector;
- connector.Set( sampler, OnStage() );
- mSamplerConnectors.push_back( connector );
-
- const SceneGraph::Sampler& sceneGraphSampler = dynamic_cast<const SceneGraph::Sampler&>( *sampler.GetSceneObject() );
- SceneGraph::AddSamplerMessage( GetEventThreadServices(), *mSceneObject, sceneGraphSampler );
-}
-
-std::size_t Material::GetNumberOfSamplers() const
-{
- return mSamplerConnectors.size();
-}
-
-void Material::RemoveSampler( std::size_t index )
-{
- mSamplerConnectors.erase( mSamplerConnectors.begin() + index );
-}
-
-Sampler* Material::GetSamplerAt( unsigned int index ) const
-{
- return mSamplerConnectors[index].Get().Get();
-}
-
-void Material::SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode )
-{
- if( NULL != mSceneObject )
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mFaceCullingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, static_cast<int>(cullingMode) );
- }
-}
-
-void Material::SetBlendMode( BlendingMode::Type mode )
-{
- mBlendingMode = mode;
-
- if( NULL != mSceneObject )
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, static_cast<int>(mode) );
- }
-}
-
-BlendingMode::Type Material::GetBlendMode() const
-{
- return mBlendingMode;
-}
-
-void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
-{
- mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
-}
-
-void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
- BlendingFactor::Type destFactorRgb,
- BlendingFactor::Type srcFactorAlpha,
- BlendingFactor::Type destFactorAlpha )
-{
- mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
-}
-
-void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
- BlendingFactor::Type& destFactorRgb,
- BlendingFactor::Type& srcFactorAlpha,
- BlendingFactor::Type& destFactorAlpha ) const
-{
- srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
- destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
- srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha();
- destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
-}
-
-void Material::SetBlendEquation( BlendingEquation::Type equationRgba )
-{
- mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
-}
-
-void Material::SetBlendEquation( BlendingEquation::Type equationRgb,
- BlendingEquation::Type equationAlpha )
-{
- mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
-}
-
-void Material::GetBlendEquation( BlendingEquation::Type& equationRgb,
- BlendingEquation::Type& equationAlpha ) const
-{
- // These are not animatable, the cached values are up-to-date.
- equationRgb = mBlendingOptions.GetBlendEquationRgb();
- equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
-}
-
-void Material::SetBlendColor( const Vector4& color )
-{
- if( mSceneObject )
- {
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, color );
- }
-}
-
-const Vector4& Material::GetBlendColor() const
-{
- return mSceneObject->mBlendColor[ GetEventThreadServices().GetEventBufferIndex() ];
-}
-
-const SceneGraph::Material* Material::GetMaterialSceneObject() const
-{
- return mSceneObject;
-}
-
-unsigned int Material::GetDefaultPropertyCount() const
-{
- return MATERIAL_IMPL.GetDefaultPropertyCount();
-}
-
-void Material::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- MATERIAL_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* Material::GetDefaultPropertyName(Property::Index index) const
-{
- return MATERIAL_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index Material::GetDefaultPropertyIndex( const std::string& name ) const
-{
- return MATERIAL_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool Material::IsDefaultPropertyWritable( Property::Index index ) const
-{
- return MATERIAL_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool Material::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- return MATERIAL_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool Material::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return MATERIAL_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type Material::GetDefaultPropertyType( Property::Index index ) const
-{
- return MATERIAL_IMPL.GetDefaultPropertyType( index );
-}
-
-void Material::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
-{
- switch( index )
- {
- case Dali::Material::Property::COLOR:
- {
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, propertyValue.Get<Vector4>() );
- break;
- }
- case Dali::Material::Property::FACE_CULLING_MODE:
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mFaceCullingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- break;
- }
- case Dali::Material::Property::BLENDING_MODE:
- {
- if( mSceneObject )
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- }
- break;
- }
- case Dali::Material::Property::BLEND_EQUATION_RGB:
- {
- BlendingEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
- mBlendingOptions.SetBlendEquation( static_cast<BlendingEquation::Type>(propertyValue.Get<int>()), alphaEquation );
- break;
- }
- case Dali::Material::Property::BLEND_EQUATION_ALPHA:
- {
- BlendingEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
- mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendingEquation::Type>(propertyValue.Get<int>()) );
- break;
- }
- case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendFunc( static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
- destFactorRgb,
- srcFactorAlpha,
- destFactorAlpha );
- break;
- }
- case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendFunc( srcFactorRgb,
- static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
- srcFactorAlpha,
- destFactorAlpha );
- break;
- }
- case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendFunc( srcFactorRgb,
- destFactorRgb,
- static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
- destFactorAlpha );
- break;
- }
- case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendFunc( srcFactorRgb,
- destFactorRgb,
- srcFactorAlpha,
- static_cast<BlendingFactor::Type>(propertyValue.Get<int>()) );
- break;
- }
- case Dali::Material::Property::BLEND_COLOR:
- {
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, propertyValue.Get<Vector4>() );
- break;
- }
- }
-}
-
-void Material::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- MATERIAL_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
-Property::Value Material::GetDefaultProperty( Property::Index index ) const
-{
- BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
- Property::Value value;
-
- switch( index )
- {
- case Dali::Material::Property::COLOR:
- {
- if( mSceneObject )
- {
- value = mSceneObject->mColor[bufferIndex];
- }
- break;
- }
- case Dali::Material::Property::FACE_CULLING_MODE:
- {
- if( mSceneObject )
- {
- value = mSceneObject->mFaceCullingMode[bufferIndex];
- }
- break;
- }
- case Dali::Material::Property::BLENDING_MODE:
- {
- if( mSceneObject )
- {
- value = mSceneObject->mBlendingMode[bufferIndex];
- }
- break;
- }
- case Dali::Material::Property::BLEND_EQUATION_RGB:
- {
- value = static_cast<int>( mBlendingOptions.GetBlendEquationRgb() );
- break;
- }
- case Dali::Material::Property::BLEND_EQUATION_ALPHA:
- {
- value = static_cast<int>( mBlendingOptions.GetBlendEquationAlpha() );
- break;
- }
- case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( srcFactorRgb );
- break;
- }
- case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( destFactorRgb );
- break;
- }
- case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( srcFactorAlpha );
- break;
- }
- case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
- {
- BlendingFactor::Type srcFactorRgb;
- BlendingFactor::Type destFactorRgb;
- BlendingFactor::Type srcFactorAlpha;
- BlendingFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( destFactorAlpha );
- break;
- }
- case Dali::Material::Property::BLEND_COLOR:
- {
- if( mSceneObject )
- {
- value = mSceneObject->mBlendColor[bufferIndex];
- }
- break;
- }
- }
-
- return value;
-}
-
-const SceneGraph::PropertyOwner* Material::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Material::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* Material::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
-
- const SceneGraph::PropertyBase* property = NULL;
-
- if( OnStage() )
- {
- property = MATERIAL_IMPL.GetRegisteredSceneGraphProperty( this,
- &Material::FindAnimatableProperty,
- &Material::FindCustomProperty,
- index );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch(index)
- {
- case Dali::Material::Property::COLOR:
- {
- property = &mSceneObject->mColor;
- break;
- }
- case Dali::Material::Property::BLEND_COLOR:
- {
- property = &mSceneObject->mBlendColor;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable");
- break;
- }
- }
- }
- }
-
- return property;
-}
-
-const PropertyInputImpl* Material::GetSceneObjectInputProperty( Property::Index index ) const
-{
- const PropertyInputImpl* property = NULL;
-
- if( OnStage() )
- {
- const SceneGraph::PropertyBase* baseProperty =
- MATERIAL_IMPL.GetRegisteredSceneGraphProperty( this,
- &Material::FindAnimatableProperty,
- &Material::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch(index)
- {
- case Dali::Material::Property::COLOR:
- {
- property = &mSceneObject->mColor;
- break;
- }
- case Dali::Material::Property::FACE_CULLING_MODE:
- {
- property = &mSceneObject->mFaceCullingMode;
- break;
- }
- case Dali::Material::Property::BLEND_COLOR:
- {
- property = &mSceneObject->mBlendColor;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Property cannot be a constraint input");
- break;
- }
- }
- }
- }
-
- return property;
-}
-
-int Material::GetPropertyComponentIndex( Property::Index index ) const
-{
- // @todo MESH_REWORK - Change this if component properties are added for color/blend-color
- return Property::INVALID_COMPONENT_INDEX;
-}
-
-bool Material::OnStage() const
-{
- return mOnStage;
-}
-
-void Material::Connect()
-{
- mOnStage = true;
-
- SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end();
- for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin();
- it < end;
- ++it )
- {
- it->OnStageConnect();
- }
- mShaderConnector.OnStageConnect();
-}
-
-void Material::Disconnect()
-{
- mOnStage = false;
-
- SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end();
- for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin();
- it < end;
- ++it )
- {
- it->OnStageDisconnect();
- }
- mShaderConnector.OnStageDisconnect();
-}
-
-Material::Material()
-: mSceneObject( NULL ),
- mOnStage( false )
-{
-}
-
-void Material::Initialize()
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
- mSceneObject = new SceneGraph::Material();
- AddMessage( updateManager, updateManager.GetMaterialOwner(), *mSceneObject );
-
- eventThreadServices.RegisterObject( this );
-}
-
-Material::~Material()
-{
- if( EventThreadServices::IsCoreRunning() )
- {
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveMessage( updateManager, updateManager.GetMaterialOwner(), *mSceneObject );
-
- eventThreadServices.UnregisterObject( this );
- }
-}
-
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_MATERIAL_H
-#define DALI_INTERNAL_MATERIAL_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h> // std::vector
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/devel-api/rendering/material.h> // Dali::Material
-#include <dali/internal/common/blending-options.h>
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
-#include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
-#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class Material;
-}
-
-
-class Material;
-typedef IntrusivePtr<Material> MaterialPtr;
-
-/**
- * Material is an object that connects a Shader with Samplers and can be used
- * to shade a Geometry.
- */
-class Material : public Object, public Connectable
-{
-public:
-
- /**
- * @copydoc Dali::Material::New()
- */
- static MaterialPtr New();
-
- /**
- * @copydoc Dali::Material::SetShader()
- */
- void SetShader( Shader& shader );
-
- /**
- * @copydoc Dali::Material::GetShader()
- */
- Shader* GetShader() const;
-
- /**
- * @copydoc Dali::Material::AddSampler()
- */
- void AddSampler( Sampler& sampler );
-
- /**
- * @copydoc Dali::Material::GetNumberOfSamplers()
- */
- std::size_t GetNumberOfSamplers() const;
-
- /**
- * @copydoc Dali::Material::RemoveSampler()
- */
- void RemoveSampler( std::size_t index );
-
- /**
- * @copydoc Dali::Material::GetSamplerAt()
- */
- Sampler* GetSamplerAt( unsigned int index ) const;
-
- /**
- * @copydoc Dali::Material::SetFaceCullingMode()
- */
- void SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode );
-
- /**
- * @copydoc Dali::Material::SetBlendMode()
- */
- void SetBlendMode( BlendingMode::Type mode );
-
- /**
- * @copydoc Dali::Material::GetBlendMode()
- */
- BlendingMode::Type GetBlendMode() const;
-
- /**
- * @copydoc Dali::Material::SetBlendFunc()
- */
- void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
-
- /**
- * @copydoc Dali::Material::SetBlendFunc()
- */
- void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
- BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
-
- /**
- * @copydoc Dali::Material::GetBlendFunc()
- */
- void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
- BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
-
- /**
- * @copydoc Dali::Material::SetBlendEquation()
- */
- void SetBlendEquation( BlendingEquation::Type equationRgba );
-
- /**
- * @copydoc Dali::Material::SetBlendEquation()
- */
- void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
-
- /**
- * @copydoc Dali::Material::GetBlendEquation()
- */
- void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
-
- /**
- * @copydoc Dali::Material::SetBlendColor()
- */
- void SetBlendColor( const Vector4& color );
-
- /**
- * @copydoc Dali::Material::GetBlendColor()
- */
- const Vector4& GetBlendColor() const;
-
- /**
- * @brief Get the material scene object
- *
- * @return the material scene object
- */
- const SceneGraph::Material* GetMaterialSceneObject() const;
-
-public: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
- /**
- * @copydoc Dali::Internal::Connectable::OnStage()
- */
- virtual bool OnStage() const;
-
- /**
- * @copydoc Dali::Internal::Connectable::Connect()
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Connectable::Disconnect()
- */
- virtual void Disconnect();
-
-private: // implementation
- Material();
-
- /**
- * Second stage initialization
- */
- void Initialize();
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Material();
-
-private: // unimplemented methods
- Material( const Material& );
- Material& operator=( const Material& );
-
-private: //data
- typedef ObjectConnector<Shader> ShaderConnector;
- ShaderConnector mShaderConnector; ///< Connector that holds the shader used by this material
-
- typedef ObjectConnector<Sampler> SamplerConnector;
- typedef std::vector< SamplerConnector > SamplerConnectorContainer;
- SamplerConnectorContainer mSamplerConnectors; ///< Vector of connectors that hold the samplers used by this material
-
- SceneGraph::Material* mSceneObject;
-
- BlendingMode::Type mBlendingMode; ///< Local store
- BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
- bool mOnStage;
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-inline Internal::Material& GetImplementation( Dali::Material& handle )
-{
- DALI_ASSERT_ALWAYS(handle && "Material handle is empty");
-
- BaseObject& object = handle.GetBaseObject();
-
- return static_cast<Internal::Material&>(object);
-}
-
-inline const Internal::Material& GetImplementation( const Dali::Material& handle )
-{
- DALI_ASSERT_ALWAYS(handle && "Material handle is empty");
-
- const BaseObject& object = handle.GetBaseObject();
-
- return static_cast<const Internal::Material&>(object);
-}
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_MATERIAL_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/rendering/renderer-impl.h> // Dali::Internal::Renderer
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/event/common/property-input-impl.h>
-#include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
-#include <dali/internal/update/manager/update-manager.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-namespace
-{
-
-/**
- * |name |type |writable|animatable|constraint-input|enum for index-checking|
- */
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "depth-index", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
-
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
-
-BaseHandle Create()
-{
- return Dali::BaseHandle();
-}
-
-TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
-RendererPtr Renderer::New()
-{
- RendererPtr rendererPtr( new Renderer() );
- rendererPtr->Initialize();
- return rendererPtr;
-}
-
-void Renderer::SetGeometry( Geometry& geometry )
-{
- mGeometryConnector.Set( geometry, OnStage() );
- const SceneGraph::Geometry* geometrySceneObject = geometry.GetGeometrySceneObject();
-
- SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject );
-}
-
-Geometry* Renderer::GetGeometry() const
-{
- return mGeometryConnector.Get().Get();
-}
-
-void Renderer::SetMaterial( Material& material )
-{
- mMaterialConnector.Set( material, OnStage() );
- const SceneGraph::Material* materialSceneObject = material.GetMaterialSceneObject();
- SetMaterialMessage( GetEventThreadServices(), *mSceneObject, *materialSceneObject );
-}
-
-Material* Renderer::GetMaterial() const
-{
- return mMaterialConnector.Get().Get();
-}
-
-void Renderer::SetDepthIndex( int depthIndex )
-{
- if ( mDepthIndex != depthIndex )
- {
- mDepthIndex = depthIndex;
- SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex );
- }
-}
-
-int Renderer::GetDepthIndex() const
-{
- return mDepthIndex;
-}
-
-SceneGraph::RendererAttachment* Renderer::GetRendererSceneObject()
-{
- return mSceneObject;
-}
-
-unsigned int Renderer::GetDefaultPropertyCount() const
-{
- return RENDERER_IMPL.GetDefaultPropertyCount();
-}
-
-void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- RENDERER_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* Renderer::GetDefaultPropertyName(Property::Index index) const
-{
- return RENDERER_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const
-{
- return RENDERER_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const
-{
- return RENDERER_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- return RENDERER_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const
-{
- return RENDERER_IMPL.GetDefaultPropertyType( index );
-}
-
-void Renderer::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
-{
- switch( index )
- {
- case Dali::Renderer::Property::DEPTH_INDEX:
- {
- SetDepthIndex( propertyValue.Get<int>() );
- }
- break;
- }
-}
-
-void Renderer::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- RENDERER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
-Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
-{
- Property::Value value;
- switch( index )
- {
- case Dali::Renderer::Property::DEPTH_INDEX:
- {
- value = GetDepthIndex();
- }
- break;
- }
- return value;
-}
-
-const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
- const SceneGraph::PropertyBase* property = NULL;
-
- if( OnStage() )
- {
- property = RENDERER_IMPL.GetRegisteredSceneGraphProperty(
- this,
- &Renderer::FindAnimatableProperty,
- &Renderer::FindCustomProperty,
- index );
- }
-
- return property;
-}
-
-const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
-{
- const PropertyInputImpl* property = NULL;
-
- if( OnStage() )
- {
- const SceneGraph::PropertyBase* baseProperty =
- RENDERER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Renderer::FindAnimatableProperty,
- &Renderer::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
- }
-
- return property;
-}
-
-int Renderer::GetPropertyComponentIndex( Property::Index index ) const
-{
- return Property::INVALID_COMPONENT_INDEX;
-}
-
-bool Renderer::OnStage() const
-{
- return mOnStage;
-}
-
-void Renderer::Connect()
-{
- // @todo: MESH_REWORK : check this
- mGeometryConnector.OnStageConnect();
- mMaterialConnector.OnStageConnect();
- mOnStage = true;
-}
-
-void Renderer::Disconnect()
-{
- // @todo: MESH_REWORK : check this
- mGeometryConnector.OnStageDisconnect();
- mMaterialConnector.OnStageDisconnect();
- mOnStage = false;
-}
-
-Renderer::Renderer()
-: mSceneObject(NULL),
- mDepthIndex(0),
- mOnStage(false)
-{
-}
-
-void Renderer::Initialize()
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
- // Transfer object ownership of scene-object to message
- mSceneObject = SceneGraph::RendererAttachment::New();
-
- // Send message to update to connect to scene graph:
- AttachToSceneGraphMessage( updateManager, mSceneObject );
-
- eventThreadServices.RegisterObject( this );
-}
-
-Renderer::~Renderer()
-{
- if( EventThreadServices::IsCoreRunning() )
- {
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveObjectMessage( updateManager, mSceneObject );
-
- eventThreadServices.UnregisterObject( this );
- }
-}
-
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_RENDERER_H
-#define DALI_INTERNAL_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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/event/rendering/material-impl.h> // Dali::Internal::Material
-#include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class RendererAttachment;
-}
-
-class Renderer;
-typedef IntrusivePtr<Renderer> RendererPtr;
-
-/**
- * Renderer is an object that can be used to show content by combining a Geometry with a material.
- */
-class Renderer : public Object, public Connectable
-{
-public:
-
- /**
- * Create a new Renderer.
- * @return A smart-pointer to the newly allocated Renderer.
- */
- static RendererPtr New();
-
- /**
- * @copydoc Dali::Renderer::SetGeometry()
- */
- void SetGeometry( Geometry& geometry );
-
- /**
- * @copydoc Dali::Renderer::GetGeometry()
- */
- Geometry* GetGeometry() const;
-
- /**
- * @copydoc Dali::Renderer::SetMaterial()
- */
- void SetMaterial( Material& material );
-
- /**
- * @copydoc Dali::Renderer::GetMaterial()
- */
- Material* GetMaterial() const;
-
- /**
- * @copydoc Dali::Renderer::SetDepthIndex()
- */
- void SetDepthIndex( int depthIndex );
-
- /**
- * @copydoc Dali::Renderer::GetDepthIndex()
- */
- int GetDepthIndex() const;
-
- /**
- * @brief Get the scene graph object ( the node attachment )
- *
- * @return the scene object
- */
- SceneGraph::RendererAttachment* GetRendererSceneObject();
-
-public: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
- /**
- * @copydoc Dali::Internal::Connectable::OnStage()
- */
- virtual bool OnStage() const;
-
- /**
- * @copydoc Dali::Internal::Connectable::Connect()
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Connectable::Disconnect()
- */
- virtual void Disconnect();
-
-private: // implementation
- Renderer();
-
- void Initialize();
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Renderer();
-
-private: // unimplemented methods
- Renderer( const Renderer& );
- Renderer& operator=( const Renderer& );
-
-private: // data
- SceneGraph::RendererAttachment* mSceneObject;
- ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
- ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
- int mDepthIndex;
- bool mOnStage;
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
-{
- DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
-
- BaseObject& object = handle.GetBaseObject();
-
- return static_cast<Internal::Renderer&>(object);
-}
-
-inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
-{
- DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
-
- const BaseObject& object = handle.GetBaseObject();
-
- return static_cast<const Internal::Renderer&>(object);
-}
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_RENDERER_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/rendering/sampler.h> // Dali::Internal::Sampler
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/update/rendering/scene-graph-sampler.h> // Dali::Internal::SceneGraph::Sampler
-#include <dali/internal/update/manager/update-manager.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-namespace
-{
-
-/**
- * |name |type |writable|animatable|constraint-input|enum for index-checking|
- */
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "minification-filter", STRING, true, false, true, Dali::Sampler::Property::MINIFICATION_FILTER )
-DALI_PROPERTY( "magnification-filter", STRING, true, false, true, Dali::Sampler::Property::MAGNIGICATION_FILTER )
-DALI_PROPERTY( "u-wrap", STRING, true, false, true, Dali::Sampler::Property::U_WRAP )
-DALI_PROPERTY( "v-wrap", STRING, true, false, true, Dali::Sampler::Property::V_WRAP )
-DALI_PROPERTY( "affects-transparency", BOOLEAN, true, false, true, Dali::Sampler::Property::AFFECTS_TRANSPARENCY )
-DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
-
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> SAMPLER_IMPL = { DEFAULT_PROPERTY_DETAILS };
-
-BaseHandle Create()
-{
- return Dali::BaseHandle();
-}
-
-TypeRegistration mType( typeid( Dali::Sampler ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
-SamplerPtr Sampler::New( const std::string& textureUnitUniformName )
-{
- SamplerPtr sampler( new Sampler() );
- sampler->Initialize( textureUnitUniformName );
- return sampler;
-}
-
-void Sampler::SetTextureUnitUniformName( const std::string& name )
-{
- SetTextureUnitUniformNameMessage( GetEventThreadServices(), *mSceneObject, name);
-}
-
-void Sampler::SetImage( ImagePtr& image )
-{
- // Keep a reference to the image object
- mImageConnector.Set( image, OnStage() );
-
- // sceneObject is being used in a separate thread; queue a message to set
- if( mOnStage )
- {
- unsigned int resourceId = image->GetResourceId();
- if( resourceId != 0 )
- {
- SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
- }
- }
-}
-
-ImagePtr Sampler::GetImage() const
-{
- return mImageConnector.Get();
-}
-
-void Sampler::SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter )
-{
- if( NULL != mSceneObject )
- {
- SetFilterModeMessage( GetEventThreadServices(), *mSceneObject, minFilter, magFilter );
- }
-}
-
-void Sampler::SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap )
-{
- if( NULL != mSceneObject )
- {
- SetWrapModeMessage( GetEventThreadServices(), *mSceneObject, uWrap, vWrap );
- }
-}
-
-void Sampler::SetAffectsTransparency( bool affectsTransparency )
-{
- if( NULL != mSceneObject )
- {
- SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mAffectsTransparency, &SceneGraph::DoubleBufferedProperty<bool>::Set, affectsTransparency );
- }
-}
-
-const SceneGraph::Sampler* Sampler::GetSamplerSceneObject() const
-{
- return mSceneObject;
-}
-
-unsigned int Sampler::GetDefaultPropertyCount() const
-{
- return SAMPLER_IMPL.GetDefaultPropertyCount();
-}
-
-void Sampler::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- SAMPLER_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* Sampler::GetDefaultPropertyName(Property::Index index) const
-{
- return SAMPLER_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index Sampler::GetDefaultPropertyIndex( const std::string& name ) const
-{
- return SAMPLER_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool Sampler::IsDefaultPropertyWritable( Property::Index index ) const
-{
- return SAMPLER_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool Sampler::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- return SAMPLER_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool Sampler::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return SAMPLER_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type Sampler::GetDefaultPropertyType( Property::Index index ) const
-{
- return SAMPLER_IMPL.GetDefaultPropertyType( index );
-}
-
-void Sampler::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
-{
- switch( index )
- {
- case Dali::Sampler::Property::MINIFICATION_FILTER:
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mMinFilter, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- break;
- }
- case Dali::Sampler::Property::MAGNIGICATION_FILTER:
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mMagFilter, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- break;
- }
- case Dali::Sampler::Property::U_WRAP:
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mUWrapMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- break;
- }
- case Dali::Sampler::Property::V_WRAP:
- {
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mVWrapMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
- break;
- }
- case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
- {
- SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mAffectsTransparency, &SceneGraph::DoubleBufferedProperty<bool>::Set, propertyValue.Get<bool>() );
- break;
- }
- }
-}
-
-void Sampler::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- SAMPLER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
-Property::Value Sampler::GetDefaultProperty( Property::Index index ) const
-{
- BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
- Property::Value value;
-
- switch( index )
- {
- case Dali::Sampler::Property::MINIFICATION_FILTER:
- {
- value = mSceneObject->mMinFilter[bufferIndex];
- break;
- }
- case Dali::Sampler::Property::MAGNIGICATION_FILTER:
- {
- value = mSceneObject->mMagFilter[bufferIndex];
- break;
- }
- case Dali::Sampler::Property::U_WRAP:
- {
- value = mSceneObject->mUWrapMode[bufferIndex];
- break;
- }
- case Dali::Sampler::Property::V_WRAP:
- {
- value = mSceneObject->mVWrapMode[bufferIndex];
- break;
- }
- case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
- {
- value = mSceneObject->mAffectsTransparency[bufferIndex];
- break;
- }
- }
- return value;
-}
-
-const SceneGraph::PropertyOwner* Sampler::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Sampler::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* Sampler::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
-
- const SceneGraph::PropertyBase* property = NULL;
-
- if( OnStage() )
- {
- property = SAMPLER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Sampler::FindAnimatableProperty,
- &Sampler::FindCustomProperty,
- index );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- // No animatable default props
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
- }
- }
-
- return property;
-}
-
-const PropertyInputImpl* Sampler::GetSceneObjectInputProperty( Property::Index index ) const
-{
- const PropertyInputImpl* property = NULL;
-
- if( OnStage() )
- {
- const SceneGraph::PropertyBase* baseProperty =
- SAMPLER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Sampler::FindAnimatableProperty,
- &Sampler::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch( index )
- {
- case Dali::Sampler::Property::MINIFICATION_FILTER:
- {
- property = &mSceneObject->mMinFilter;
- break;
- }
- case Dali::Sampler::Property::MAGNIGICATION_FILTER:
- {
- property = &mSceneObject->mMagFilter;
- break;
- }
- case Dali::Sampler::Property::U_WRAP:
- {
- property = &mSceneObject->mUWrapMode;
- break;
- }
- case Dali::Sampler::Property::V_WRAP:
- {
- property = &mSceneObject->mVWrapMode;
- break;
- }
- case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
- {
- property = &mSceneObject->mAffectsTransparency;
- break;
- }
- }
- }
- }
-
- return property;
-}
-
-int Sampler::GetPropertyComponentIndex( Property::Index index ) const
-{
- return Property::INVALID_COMPONENT_INDEX;
-}
-
-bool Sampler::OnStage() const
-{
- return mOnStage;
-}
-
-void Sampler::Connect()
-{
- mOnStage = true;
-
- mImageConnector.OnStageConnect();
-
- // sceneObject is being used in a separate thread; queue a message to set
- unsigned int resourceId = mImageConnector.Get()->GetResourceId();
- SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
-}
-
-void Sampler::Disconnect()
-{
- mOnStage = false;
-
- mImageConnector.OnStageDisconnect();
-}
-
-Sampler::Sampler()
-: mSceneObject( NULL ),
- mOnStage( false )
-{
-}
-
-void Sampler::Initialize( const std::string& textureUnitUniformName )
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
- mSceneObject = new SceneGraph::Sampler( textureUnitUniformName );
- AddMessage( updateManager, updateManager.GetSamplerOwner(), *mSceneObject );
-
- eventThreadServices.RegisterObject( this );
-}
-
-Sampler::~Sampler()
-{
- if( EventThreadServices::IsCoreRunning() )
- {
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveMessage( updateManager, updateManager.GetSamplerOwner(), *mSceneObject );
-
- eventThreadServices.UnregisterObject( this );
- }
-}
-
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_SAMPLER_H
-#define DALI_INTERNAL_SAMPLER_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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/devel-api/rendering/sampler.h> // Dali::Sampler
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/event/images/image-connector.h> // Dali::Internal::ImageConnector
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class Sampler;
-}
-
-class Sampler;
-typedef IntrusivePtr<Sampler> SamplerPtr;
-
-/**
- * Sampler is an object that contains an array of structures of values that
- * can be accessed as properties.
- */
-class Sampler : public Object, public Connectable
-{
-public:
-
- /**
- * Create a new Sampler.
- * @return A smart-pointer to the newly allocated Sampler.
- */
- static SamplerPtr New( const std::string& textureUnitUniformName );
-
- /**
- * @copydoc Dali::Sampler::SetUniformName()
- */
- void SetTextureUnitUniformName( const std::string& name );
-
- /**
- * @copydoc Dali::Sampler::SetImage()
- */
- void SetImage( ImagePtr& image );
-
- /**
- * @copydoc Dali::Sampler::GetImage()
- */
- ImagePtr GetImage() const;
-
- /**
- * @copydoc Dali::Sampler::SetFilterMode()
- */
- void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
-
- /**
- * @copydoc Dali::Sampler::SetWrapMode()
- */
- void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
-
- /**
- * @copydoc Dali::Sampler::SetAffectsTransparency()
- */
- void SetAffectsTransparency( bool affectsTransparency );
-
- /**
- * @brief Get the sampler scene object
- *
- * @return the sampler scene object
- */
- const SceneGraph::Sampler* GetSamplerSceneObject() const;
-
-public: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
- /**
- * @copydoc Dali::Internal::Connectable::OnStage()
- */
- virtual bool OnStage() const;
-
- /**
- * @copydoc Dali::Internal::Connectable::Connect()
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Connectable::Disconnect()
- */
- virtual void Disconnect();
-
-private:
- Sampler();
-
- /**
- * Second stage initialization
- */
- void Initialize( const std::string& textureUnitUniformName );
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Sampler();
-
-private: // data
- //TODO: MESH_REWORK : change to ObjectConnector
- ImageConnector mImageConnector;
- SceneGraph::Sampler* mSceneObject;
- bool mOnStage;
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
-{
- DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
-
- BaseObject& object = handle.GetBaseObject();
-
- return static_cast<Internal::Sampler&>(object);
-}
-
-inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
-{
- DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
-
- const BaseObject& object = handle.GetBaseObject();
-
- return static_cast<const Internal::Sampler&>(object);
-}
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_SAMPLER_H
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/shader-effects/shader-effect.h> // Dali::ShaderEffect::GeometryHints // TODO: MESH_REWORK REMOVE
-#include <dali/devel-api/rendering/shader.h> // Dali::Shader
-
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/update/manager/update-manager.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-namespace
-{
-
-/**
- * |name |type |writable|animatable|constraint-input|enum for index-checking|
- */
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM )
-DALI_PROPERTY( "shader-hints", UNSIGNED_INTEGER, true, false, true, Dali::Shader::Property::SHADER_HINTS )
-DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
-
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> SHADER_IMPL = { DEFAULT_PROPERTY_DETAILS };
-
-BaseHandle Create()
-{
- return Dali::BaseHandle();
-}
-
-TypeRegistration mType( typeid( Dali::Shader ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
-ShaderPtr Shader::New( const std::string& vertexShader,
- const std::string& fragmentShader,
- Dali::Shader::ShaderHints hints )
-{
- //TODO: MESH_REWORK
- ShaderPtr shader( new Shader() );
- shader->Initialize( vertexShader, fragmentShader, hints );
- return shader;
-}
-
-const SceneGraph::Shader* Shader::GetShaderSceneObject() const
-{
- return mSceneObject;
-}
-
-unsigned int Shader::GetDefaultPropertyCount() const
-{
- return SHADER_IMPL.GetDefaultPropertyCount();
-}
-
-void Shader::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- SHADER_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* Shader::GetDefaultPropertyName(Property::Index index) const
-{
- return SHADER_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index Shader::GetDefaultPropertyIndex( const std::string& name ) const
-{
- return SHADER_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool Shader::IsDefaultPropertyWritable( Property::Index index ) const
-{
- return SHADER_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool Shader::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- return SHADER_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool Shader::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return SHADER_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type Shader::GetDefaultPropertyType( Property::Index index ) const
-{
- return SHADER_IMPL.GetDefaultPropertyType( index );
-}
-
-void Shader::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
-{
- switch(index)
- {
- case Dali::Shader::Property::PROGRAM:
- {
- // @todo MESH_REWORK Set program again?
- DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
- break;
- }
- case Dali::Shader::Property::SHADER_HINTS:
- {
- DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
- break;
- }
- }
-}
-
-void Shader::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- SHADER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
-Property::Value Shader::GetDefaultProperty( Property::Index index ) const
-{
- Property::Value value;
-
- switch(index)
- {
- case Dali::Shader::Property::PROGRAM:
- {
- DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
- break;
- }
- case Dali::Shader::Property::SHADER_HINTS:
- {
- DALI_ASSERT_ALWAYS( 0 && "MESH_REWORK" );
- break;
- }
- }
-
- return value;
-}
-
-const SceneGraph::PropertyOwner* Shader::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Shader::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* Shader::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
- const SceneGraph::PropertyBase* property = NULL;
-
- if( OnStage() )
- {
- property = SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Shader::FindAnimatableProperty,
- &Shader::FindCustomProperty,
- index );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
- }
- }
-
- return property;
-}
-
-const PropertyInputImpl* Shader::GetSceneObjectInputProperty( Property::Index index ) const
-{
- const PropertyInputImpl* property = NULL;
-
- if( OnStage() )
- {
- const SceneGraph::PropertyBase* baseProperty =
- SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Shader::FindAnimatableProperty,
- &Shader::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- if( index == Dali::Shader::Property::SHADER_HINTS )
- {
- // @todo MESH_REWORK - return the property
- }
- else
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not a valid constraint input" );
- }
- }
- }
-
- return property;
-}
-
-int Shader::GetPropertyComponentIndex( Property::Index index ) const
-{
- return Property::INVALID_COMPONENT_INDEX;
-}
-
-bool Shader::OnStage() const
-{
- return mOnStage;
-}
-
-void Shader::Connect()
-{
- mOnStage = true;
-}
-
-void Shader::Disconnect()
-{
- mOnStage = false;
-}
-
-Shader::Shader()
-: mSceneObject( NULL ),
- mOnStage( false )
-{
-}
-
-void Shader::Initialize(
- const std::string& vertexSource,
- const std::string& fragmentSource,
- Dali::Shader::ShaderHints hints )
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
- // @todo MESH_REWORK - Pass hints directly to a new scene graph shader
- int effectHint = Dali::ShaderEffect::HINT_NONE;
- if( hints & Dali::Shader::HINT_OUTPUT_IS_TRANSPARENT )
- {
- effectHint |= Dali::ShaderEffect::HINT_BLENDING;
- }
-
- if( hints & Dali::Shader::HINT_REQUIRES_SELF_DEPTH_TEST )
- {
- effectHint |= Dali::ShaderEffect::HINT_DEPTH_BUFFER;
- }
-
- if( (hints & Dali::Shader::HINT_MODIFIES_GEOMETRY) == 0x0 )
- {
- effectHint |= Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY;
- }
- Dali::ShaderEffect::GeometryHints shaderEffectHint = static_cast<Dali::ShaderEffect::GeometryHints>( effectHint );
-
- mSceneObject = new SceneGraph::Shader(shaderEffectHint);
-
- // Add to update manager
- AddShaderMessage( updateManager, *mSceneObject );
-
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
- ShaderFactory& shaderFactory = tls.GetShaderFactory();
- size_t shaderHash;
-
- mTicket = ResourceTicketPtr( shaderFactory.Load(vertexSource, fragmentSource, shaderHash) );
-
- // Add shader program to scene-object using a message to the UpdateManager
- SetShaderProgramMessage( updateManager, *mSceneObject, mTicket->GetId(), shaderHash, false );
-
- eventThreadServices.RegisterObject( this );
-}
-
-Shader::~Shader()
-{
- if( EventThreadServices::IsCoreRunning() )
- {
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveShaderMessage( updateManager, *mSceneObject);
-
- eventThreadServices.UnregisterObject( this );
- }
-}
-
-
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_SHADER_H
-#define DALI_INTERNAL_SHADER_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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/devel-api/rendering/shader.h> // Dali::Shader
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/event/resources/resource-ticket.h> // Dali::Internal::ResourceTicketPtr
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class Shader;
-}
-
-class Shader;
-typedef IntrusivePtr<Shader> ShaderPtr;
-
-/**
- * Shader is an object that contains an array of structures of values that
- * can be accessed as properties.
- */
-class Shader : public Object, public Connectable
-{
-public:
-
- /**
- * @copydoc Dali::Shader::New()
- */
- static ShaderPtr New( const std::string& vertexShader,
- const std::string& fragmentShader,
- Dali::Shader::ShaderHints hints );
-
- /**
- * @brief Get the shader scene object
- *
- * @return the shader scene object
- */
- const SceneGraph::Shader* GetShaderSceneObject() const;
-
-public: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
- /**
- * @copydoc Dali::Internal::Connectable::OnStage()
- */
- virtual bool OnStage() const;
-
- /**
- * @copydoc Dali::Internal::Connectable::Connect()
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Connectable::Disconnect()
- */
- virtual void Disconnect();
-
-private: // implementation
- Shader();
-
- /**
- * Second stage initialization
- */
- void Initialize( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::ShaderHints hints );
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Shader();
-
-private: // unimplemented methods
- Shader( const Shader& );
- Shader& operator=( const Shader& );
-
-private:
- SceneGraph::Shader* mSceneObject;
- ResourceTicketPtr mTicket;
- bool mOnStage;
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-inline Internal::Shader& GetImplementation( Dali::Shader& handle )
-{
- DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
-
- BaseObject& object = handle.GetBaseObject();
-
- return static_cast<Internal::Shader&>(object);
-}
-
-inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
-{
- DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
-
- const BaseObject& object = handle.GetBaseObject();
-
- return static_cast<const Internal::Shader&>(object);
-}
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_SHADER_H
$(internal_src_dir)/event/actors/image-actor-impl.cpp \
$(internal_src_dir)/event/actors/layer-impl.cpp \
$(internal_src_dir)/event/actors/layer-list.cpp \
+ $(internal_src_dir)/event/actors/renderer-impl.cpp \
$(internal_src_dir)/event/actors/camera-actor-impl.cpp \
$(internal_src_dir)/event/actors/renderable-actor-impl.cpp \
$(internal_src_dir)/event/animation/animation-impl.cpp \
$(internal_src_dir)/event/common/thread-local-storage.cpp \
$(internal_src_dir)/event/common/type-info-impl.cpp \
$(internal_src_dir)/event/common/type-registry-impl.cpp \
+ $(internal_src_dir)/event/effects/material-impl.cpp \
+ $(internal_src_dir)/event/effects/sampler-impl.cpp \
$(internal_src_dir)/event/effects/shader-effect-impl.cpp \
$(internal_src_dir)/event/effects/shader-factory.cpp \
+ $(internal_src_dir)/event/effects/shader-impl.cpp \
$(internal_src_dir)/event/events/actor-gesture-data.cpp \
$(internal_src_dir)/event/events/actor-observer.cpp \
$(internal_src_dir)/event/events/event-processor.cpp \
$(internal_src_dir)/event/events/tap-gesture-detector-impl.cpp \
$(internal_src_dir)/event/events/tap-gesture-processor.cpp \
$(internal_src_dir)/event/events/touch-event-processor.cpp \
+ $(internal_src_dir)/event/geometry/geometry-impl.cpp \
$(internal_src_dir)/event/images/atlas-impl.cpp \
$(internal_src_dir)/event/images/bitmap-external.cpp \
$(internal_src_dir)/event/images/bitmap-packed-pixel.cpp \
$(internal_src_dir)/event/object/custom-object-internal.cpp \
$(internal_src_dir)/event/render-tasks/render-task-impl.cpp \
$(internal_src_dir)/event/render-tasks/render-task-list-impl.cpp \
- $(internal_src_dir)/event/rendering/geometry-impl.cpp \
- $(internal_src_dir)/event/rendering/material-impl.cpp \
- $(internal_src_dir)/event/rendering/renderer-impl.cpp \
- $(internal_src_dir)/event/rendering/sampler-impl.cpp \
- $(internal_src_dir)/event/rendering/shader-impl.cpp \
$(internal_src_dir)/event/resources/archive.cpp \
$(internal_src_dir)/event/resources/image-ticket.cpp \
$(internal_src_dir)/event/resources/resource-client.cpp \
$(internal_src_dir)/update/common/uniform-map.cpp \
$(internal_src_dir)/update/controllers/render-message-dispatcher.cpp \
$(internal_src_dir)/update/controllers/scene-controller-impl.cpp \
+ $(internal_src_dir)/update/effects/scene-graph-material.cpp \
+ $(internal_src_dir)/update/effects/scene-graph-sampler.cpp \
+ $(internal_src_dir)/update/geometry/scene-graph-geometry.cpp \
$(internal_src_dir)/update/gestures/pan-gesture-profiling.cpp \
$(internal_src_dir)/update/gestures/scene-graph-pan-gesture.cpp \
$(internal_src_dir)/update/queue/update-message-queue.cpp \
$(internal_src_dir)/update/nodes/scene-graph-layer.cpp \
$(internal_src_dir)/update/render-tasks/scene-graph-render-task.cpp \
$(internal_src_dir)/update/render-tasks/scene-graph-render-task-list.cpp \
- $(internal_src_dir)/update/rendering/scene-graph-geometry.cpp \
- $(internal_src_dir)/update/rendering/scene-graph-material.cpp \
- $(internal_src_dir)/update/rendering/scene-graph-sampler.cpp \
$(internal_src_dir)/update/resources/bitmap-metadata.cpp \
$(internal_src_dir)/update/resources/resource-manager.cpp \
$(internal_src_dir)/update/resources/resource-tracker.cpp \
*
*/
-#include <dali/devel-api/rendering/geometry.h>
+#include <dali/public-api/geometry/geometry.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/owner-container.h>
#include <dali/internal/render/data-providers/property-buffer-data-provider.h>
* limitations under the License.
*/
-#include <dali/devel-api/rendering/sampler.h>
+#include <dali/public-api/shader-effects/sampler.h>
#include <dali/integration-api/resource-declarations.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/render/renderers/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/update/rendering/scene-graph-geometry.h>
#include <dali/internal/render/data-providers/render-data-provider.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
#include <dali/internal/update/nodes/node-declarations.h>
#include <dali/internal/update/node-attachments/node-attachment-declarations.h>
#include <dali/internal/update/common/scene-graph-property-buffer.h>
-#include <dali/internal/update/rendering/scene-graph-geometry.h>
-#include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/effects/scene-graph-sampler.h>
namespace Dali
{
--- /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.
+ */
+
+// CLASS HEADER
+#include "scene-graph-material.h"
+
+// INTERNAL HEADERS
+#include <dali/public-api/shader-effects/material.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/internal/common/internal-constants.h>
+#include <dali/internal/update/effects/scene-graph-sampler.h>
+#include <dali/internal/render/data-providers/sampler-data-provider.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/public-api/actors/blending.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+
+namespace
+{
+const unsigned int DEFAULT_BLENDING_OPTIONS( BlendingOptions().GetBitmask() );
+}
+
+Material::Material()
+: mColor( Color::WHITE ),
+ mBlendColor( Color::TRANSPARENT ),
+ mFaceCullingMode(Dali::Material::NONE),
+ mBlendingMode(Dali::BlendingMode::AUTO),
+ mBlendingOptions( DEFAULT_BLENDING_OPTIONS ),
+ mShader(NULL),
+ mBlendPolicy(OPAQUE)
+{
+ // Observe own property-owner's uniform map
+ AddUniformMapObserver( *this );
+}
+
+Material::~Material()
+{
+}
+
+void Material::SetShader( Shader* shader )
+{
+ mShader = shader;
+ mShader->AddUniformMapObserver( *this );
+
+ // Inform NewRenderer about this shader: (Will force a re-load of the
+ // shader from the data providers)
+ mConnectionObservers.ConnectionsChanged(*this);
+}
+
+Shader* Material::GetShader() const
+{
+ // @todo - Fix this - move shader setup to the Renderer connect to stage...
+ return mShader;
+}
+
+void Material::AddSampler( Sampler* sampler )
+{
+ mSamplers.PushBack( sampler );
+
+ sampler->AddConnectionObserver( *this );
+ sampler->AddUniformMapObserver( *this );
+
+ mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Material::RemoveSampler( Sampler* sampler )
+{
+ Vector<Sampler*>::Iterator match = std::find( mSamplers.Begin(), mSamplers.End(), sampler );
+
+ DALI_ASSERT_DEBUG( mSamplers.End() != match );
+ if( mSamplers.End() != match )
+ {
+ sampler->RemoveConnectionObserver( *this );
+ sampler->RemoveUniformMapObserver( *this );
+ mSamplers.Erase( match );
+ mConnectionObservers.ConnectionsChanged(*this);
+ }
+ else
+ {
+ DALI_ASSERT_DEBUG( 0 && "Sampler not found" );
+ }
+}
+
+void Material::PrepareRender( BufferIndex bufferIndex )
+{
+ mBlendPolicy = OPAQUE;
+
+ // @todo MESH_REWORK Add dirty flags to reduce processing.
+
+ switch(mBlendingMode[bufferIndex])
+ {
+ case BlendingMode::OFF:
+ {
+ mBlendPolicy = OPAQUE;
+ break;
+ }
+ case BlendingMode::ON:
+ {
+ mBlendPolicy = TRANSPARENT;
+ break;
+ }
+ case BlendingMode::AUTO:
+ {
+ bool opaque = true;
+
+ // @todo: MESH_REWORK - Change hints for new SceneGraphShader:
+ // If shader hint OUTPUT_IS_OPAQUE is enabled, set policy to ALWAYS_OPAQUE
+ // If shader hint OUTPUT_IS_TRANSPARENT is enabled, set policy to ALWAYS_TRANSPARENT
+ // else test remainder, and set policy to either ALWAYS_TRANSPARENT or USE_ACTOR_COLOR
+
+ if( mShader->GeometryHintEnabled( Dali::ShaderEffect::HINT_BLENDING ) )
+ {
+ opaque = false;
+ }
+
+ if( opaque )
+ {
+ // Check the material color:
+ opaque = ( mColor[ bufferIndex ].a >= FULLY_OPAQUE );
+ }
+
+ if( opaque )
+ {
+ // Require that all affecting samplers are opaque
+ unsigned int opaqueCount=0;
+ unsigned int affectingCount=0;
+
+ for( Vector<Sampler*>::ConstIterator iter = mSamplers.Begin();
+ iter != mSamplers.End(); ++iter )
+ {
+ const Sampler* sampler = *iter;
+ if( sampler != NULL )
+ {
+ if( sampler->AffectsTransparency( bufferIndex ) )
+ {
+ affectingCount++;
+ if( sampler->IsFullyOpaque( bufferIndex ) )
+ {
+ opaqueCount++;
+ }
+ }
+ }
+ }
+ opaque = (opaqueCount == affectingCount);
+ }
+
+ mBlendPolicy = opaque ? Material::USE_ACTOR_COLOR : Material::TRANSPARENT;
+ }
+ }
+}
+
+Vector<Sampler*>& Material::GetSamplers()
+{
+ return mSamplers;
+}
+
+Material::BlendPolicy Material::GetBlendPolicy() const
+{
+ return mBlendPolicy;
+}
+
+void Material::SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options )
+{
+ mBlendingOptions.Set( updateBufferIndex, options );
+}
+
+const Vector4& Material::GetBlendColor(BufferIndex bufferIndex) const
+{
+ return mBlendColor[bufferIndex];
+}
+
+BlendingFactor::Type Material::GetBlendSrcFactorRgb( BufferIndex bufferIndex ) const
+{
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendSrcFactorRgb();
+}
+
+BlendingFactor::Type Material::GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const
+{
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendSrcFactorAlpha();
+}
+
+BlendingFactor::Type Material::GetBlendDestFactorRgb( BufferIndex bufferIndex ) const
+{
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendDestFactorRgb();
+}
+
+BlendingFactor::Type Material::GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const
+{
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendDestFactorAlpha();
+}
+
+BlendingEquation::Type Material::GetBlendEquationRgb( BufferIndex bufferIndex ) const
+{
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendEquationRgb();
+}
+
+BlendingEquation::Type Material::GetBlendEquationAlpha( BufferIndex bufferIndex ) const
+{
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendEquationAlpha();
+}
+
+void Material::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+{
+}
+
+void Material::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+{
+}
+
+void Material::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
+{
+ mConnectionObservers.Add(observer);
+}
+
+void Material::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
+{
+ mConnectionObservers.Remove(observer);
+}
+
+void Material::UniformMappingsChanged( const UniformMap& mappings )
+{
+ // Our uniform map, or that of one of the watched children has changed.
+ // Inform connected observers.
+ mConnectionObservers.ConnectedUniformMapChanged();
+}
+
+void Material::ConnectionsChanged( PropertyOwner& owner )
+{
+ mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Material::ConnectedUniformMapChanged( )
+{
+ mConnectionObservers.ConnectedUniformMapChanged();
+}
+
+void Material::ResetDefaultProperties( BufferIndex updateBufferIndex )
+{
+ mColor.ResetToBaseValue( updateBufferIndex );
+ mBlendColor.ResetToBaseValue( updateBufferIndex );
+ mFaceCullingMode.CopyPrevious( updateBufferIndex );
+
+ mBlendingMode.CopyPrevious( updateBufferIndex );
+ mBlendingOptions.CopyPrevious( updateBufferIndex );
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
+#define DALI_INTERNAL_SCENE_GRAPH_MATERIAL_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/actors/renderable-actor.h> // For CullFaceMode
+#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/common/blending-options.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/double-buffered-property.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
+#include <dali/internal/update/common/uniform-map.h>
+#include <dali/internal/render/data-providers/material-data-provider.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class Sampler;
+class Shader;
+class ConnectionObserver;
+class SceneController;
+
+class Material : public PropertyOwner, public MaterialDataProvider, public UniformMap::Observer, public ConnectionChangePropagator::Observer
+{
+public:
+ /**
+ * This enum defines the outputs of the PrepareRender step, and is used
+ * by the Renderer to determine final opacity.
+ */
+ enum BlendPolicy
+ {
+ OPAQUE, ///< If the renderer should always be opaque
+ TRANSPARENT, ///< If the renderer should always be transparent
+ USE_ACTOR_COLOR ///< If the renderer should determine opacity using the actor color
+ };
+
+ /**
+ * Constructor
+ */
+ Material();
+
+ /**
+ * Destructor
+ */
+ virtual ~Material();
+
+ /**
+ * Set the shader effect for this material
+ * @param[in] shader The shader effect to use
+ */
+ void SetShader( Shader* shader );
+
+ /**
+ * Add a sampler (image + sampler modes) to the material
+ * @param[in] sampler A sampler to add
+ */
+ void AddSampler( Sampler* sampler );
+
+ /**
+ * Remove a sampler (image + sampler modes) from the material
+ * @param[in] sampler A sampler to remove
+ */
+ void RemoveSampler( Sampler* sampler );
+
+ /**
+ * Prepare the material for rendering.
+ *
+ * Determine whether blending is enabled for this material, and store the result.
+ * @param[in] bufferIndex The current buffer index
+ */
+ void PrepareRender( BufferIndex bufferIndex );
+
+ /**
+ * Return the blend policy ( a combination of all the different shader hints, color, samper and image properties ).
+ * This should only be called from the update thread
+ * @return The material's blend policy
+ */
+ BlendPolicy GetBlendPolicy() const;
+
+ /**
+ * Set the blending options. This should only be called from the update thread.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] options A bitmask of blending options.
+ */
+ void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
+
+public: // Implementation of MaterialDataProvider
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendColor
+ */
+ virtual const Vector4& GetBlendColor(BufferIndex bufferIndex) const;
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendSrcFactorRgb
+ */
+ virtual BlendingFactor::Type GetBlendSrcFactorRgb(BufferIndex bufferIndex) const;
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendSrcFactorAlpha
+ */
+ virtual BlendingFactor::Type GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const;
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendDestFactorRgb
+ */
+ virtual BlendingFactor::Type GetBlendDestFactorRgb( BufferIndex bufferIndex ) const;
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendDestFactorAlpha
+ */
+ virtual BlendingFactor::Type GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const;
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendEquationRgb
+ */
+ virtual BlendingEquation::Type GetBlendEquationRgb( BufferIndex bufferIndex ) const;
+
+ /**
+ * @copydoc MaterialDataProvider::GetBlendEquationAlpha
+ */
+ virtual BlendingEquation::Type GetBlendEquationAlpha( BufferIndex bufferIndex ) const;
+
+public: // Implementation of ObjectOwnerContainer template methods
+ /**
+ * Connect the object to the scene graph
+ *
+ * @param[in] sceneController The scene controller - used for sending messages to render thread
+ * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
+ */
+ void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
+ /**
+ * Disconnect the object from the scene graph
+ * @param[in] sceneController The scene controller - used for sending messages to render thread
+ * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
+ */
+ void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
+public: // Implementation of ConnectionChangePropagator
+ /**
+ * @copydoc ConnectionChangePropagator::AddObserver
+ */
+ void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+ /**
+ * @copydoc ConnectionChangePropagator::RemoveObserver
+ */
+ void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+public:
+ /**
+ * Get the shader effect of this material
+ * @return the shader effect;
+ */
+ Shader* GetShader() const;
+
+ /**
+ * Get the samplers this material uses.
+ * @return the samplers
+ */
+ Vector<Sampler*>& GetSamplers();
+
+public: // UniformMap::Observer
+ /**
+ * @copydoc UniformMap::Observer::UniformMappingsChanged
+ */
+ virtual void UniformMappingsChanged( const UniformMap& mappings );
+
+public: // ConnectionChangePropagator::Observer
+
+ /**
+ * @copydoc ConnectionChangePropagator::ConnectionsChanged
+ */
+ virtual void ConnectionsChanged( PropertyOwner& owner );
+
+ /**
+ * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
+ */
+ virtual void ConnectedUniformMapChanged( );
+
+public: // PropertyOwner implementation
+ /**
+ * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
+ */
+ virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
+
+public: // Property data
+ AnimatableProperty<Vector4> mColor;
+ AnimatableProperty<Vector4> mBlendColor;
+ DoubleBufferedProperty<int> mFaceCullingMode;
+ DoubleBufferedProperty<int> mBlendingMode;
+ DoubleBufferedProperty<int> mBlendingOptions;
+
+private:
+ Shader* mShader;
+ Vector<Sampler*> mSamplers; // Not owned
+ ConnectionChangePropagator mConnectionObservers;
+ BlendPolicy mBlendPolicy; ///< The blend policy as determined by PrepareRender
+};
+
+inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Material& material, const Shader& shader )
+{
+ typedef MessageValue1< Material, Shader* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &material, &Material::SetShader, const_cast<Shader*>(&shader) );
+}
+
+inline void AddSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, const Sampler& sampler )
+{
+ typedef MessageValue1< Material, Sampler* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &material, &Material::AddSampler, const_cast<Sampler*>(&sampler) );
+}
+
+inline void RemoveSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, Sampler& sampler )
+{
+ typedef MessageValue1< Material, Sampler* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &material, &Material::RemoveSampler, const_cast<Sampler*>(&sampler) );
+}
+
+inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Material& material, unsigned int options )
+{
+ typedef MessageDoubleBuffered1< Material, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &material, &Material::SetBlendingOptions, options );
+}
+
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
--- /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.
+ */
+
+// CLASS HEADER
+#include "scene-graph-sampler.h"
+
+// EXTERNAL HEADERS
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+
+Sampler::Sampler( const std::string& textureUnitUniformName )
+: mMinFilter( Dali::Sampler::DEFAULT ),
+ mMagFilter( Dali::Sampler::DEFAULT ),
+ mUWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
+ mVWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
+ mAffectsTransparency( true ),
+ mTextureUnitUniformName( textureUnitUniformName ),
+ mTextureId( 0u ),
+ mFullyOpaque(true)
+{
+}
+
+Sampler::~Sampler()
+{
+}
+
+void Sampler::SetTextureUnitUniformName( const std::string& textureUnitUniformName )
+{
+ mTextureUnitUniformName = textureUnitUniformName;
+}
+
+void Sampler::SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId )
+{
+ if( mTextureId[bufferIndex] != textureId )
+ {
+ mTextureId.Set( bufferIndex, textureId );
+ mConnectionObservers.ConnectionsChanged(*this);
+ }
+}
+
+void Sampler::SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter )
+{
+ mMinFilter.Set(bufferIndex, minFilter);
+ mMagFilter.Set(bufferIndex, magFilter);
+}
+
+void Sampler::SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap )
+{
+}
+
+const std::string& Sampler::GetTextureUnitUniformName() const
+{
+ return mTextureUnitUniformName;
+}
+
+Integration::ResourceId Sampler::GetTextureId( BufferIndex bufferIndex ) const
+{
+ return mTextureId[bufferIndex];
+}
+
+Sampler::FilterMode Sampler::GetMinifyFilterMode( BufferIndex bufferIndex ) const
+{
+ return static_cast<Sampler::FilterMode>(mMinFilter[bufferIndex]);
+}
+
+Sampler::FilterMode Sampler::GetMagnifyFilterMode( BufferIndex bufferIndex ) const
+{
+ return static_cast<Sampler::FilterMode>(mMagFilter[bufferIndex]);
+}
+
+Sampler::WrapMode Sampler::GetUWrapMode( BufferIndex bufferIndex ) const
+{
+ return static_cast<Sampler::WrapMode>(mUWrapMode[bufferIndex]);
+}
+
+Sampler::WrapMode Sampler::GetVWrapMode( BufferIndex bufferIndex ) const
+{
+ return static_cast<Sampler::WrapMode>(mVWrapMode[bufferIndex]);
+}
+
+bool Sampler::AffectsTransparency( BufferIndex bufferIndex ) const
+{
+ return mAffectsTransparency[bufferIndex] ;
+}
+
+void Sampler::SetFullyOpaque( bool fullyOpaque )
+{
+ mFullyOpaque = fullyOpaque;
+}
+
+bool Sampler::IsFullyOpaque( BufferIndex bufferIndex ) const
+{
+ return mFullyOpaque;
+}
+
+void Sampler::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+{
+}
+
+void Sampler::DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex)
+{
+}
+
+void Sampler::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
+{
+ mConnectionObservers.Add(observer);
+}
+
+void Sampler::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
+{
+ mConnectionObservers.Remove(observer);
+}
+
+void Sampler::ResetDefaultProperties( BufferIndex bufferIndex )
+{
+ mTextureId.CopyPrevious( bufferIndex );
+ mMinFilter.CopyPrevious( bufferIndex );
+ mMagFilter.CopyPrevious( bufferIndex );
+ mUWrapMode.CopyPrevious( bufferIndex );
+ mVWrapMode.CopyPrevious( bufferIndex );
+ mAffectsTransparency.CopyPrevious( bufferIndex );
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
+#define DALI_INTERNAL_SCENE_GRAPH_SAMPLER_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/shader-effects/sampler.h>
+#include <dali/integration-api/resource-declarations.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/update/common/double-buffered.h>
+#include <dali/internal/update/common/double-buffered-property.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
+#include <dali/internal/update/resources/bitmap-metadata.h>
+#include <dali/internal/render/data-providers/sampler-data-provider.h>
+
+#include <string>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class SceneController;
+
+class Sampler : public PropertyOwner, public SamplerDataProvider
+{
+public:
+ typedef Dali::Sampler::FilterMode FilterMode;
+ typedef Dali::Sampler::WrapMode WrapMode;
+
+ /**
+ * Constructor
+ */
+ Sampler( const std::string& samplerName );
+
+ /**
+ * Destructor
+ */
+ virtual ~Sampler();
+
+ /**
+ * Set the uniform name of this sampler. This allows the shader to find the
+ * GL index of this sampler.
+ */
+ void SetTextureUnitUniformName( const std::string& textureUnitUniformName );
+
+ /**
+ * 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
+ */
+ void SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId );
+
+ /**
+ * Set the filter modes for minify and magnify filters
+ * @param[in] bufferIndex The buffer index to use
+ * @param[in] minFilter The minify filter
+ * @param[in] magFilter The magnify filter
+ */
+ void SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter );
+
+ /**
+ * @param[in] bufferIndex The buffer index to use
+ */
+ void SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap );
+
+ /**
+ * @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;
+
+ /**
+ * Sets whether the associated texture is fully opaque or not.
+ * @param[in] fullyOpaque true if it's fully opaque
+ */
+ void SetFullyOpaque( bool fullyOpaque );
+
+ /**
+ * @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
+ */
+ virtual const std::string& GetTextureUnitUniformName() const;
+
+ /**
+ * Get the texture ID
+ * @param[in] bufferIndex The buffer index to use
+ * @return the identity of the associated texture
+ */
+ 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 ) const;
+
+ /**
+ * Get the filter mode
+ * @param[in] bufferIndex The buffer index to use
+ * @return The magnify filter mode
+ */
+ 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 ) const;
+
+ /**
+ * Get the vertical wrap mode
+ * @param[in] bufferIndex The buffer index to use
+ * @return The vertical wrap mode
+ */
+ virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) const;
+
+ /**
+ * Connect the object to the scene graph
+ *
+ * @param[in] sceneController The scene controller - used for sending messages to render thread
+ * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
+ */
+ void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
+ /**
+ * Disconnect the object from the scene graph
+ * @param[in] sceneController The scene controller - used for sending messages to render thread
+ * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
+ */
+ void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
+ /**
+ * @copydoc ConnectionChangePropagator::AddObserver
+ */
+ void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+ /**
+ * @copydoc ConnectionChangePropagator::RemoveObserver
+ */
+ void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+public: // PropertyOwner implementation
+ /**
+ * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
+ */
+ virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
+
+public: // Properties
+ DoubleBufferedProperty<int> mMinFilter; ///< The minify filter
+ DoubleBufferedProperty<int> mMagFilter; ///< The magnify filter
+ DoubleBufferedProperty<int> mUWrapMode; ///< The horizontal wrap mode
+ DoubleBufferedProperty<int> mVWrapMode; ///< The vertical wrap mode
+ DoubleBufferedProperty<bool> mAffectsTransparency; ///< If this sampler affects renderer transparency
+
+private:
+ std::string mTextureUnitUniformName; ///< The name of the uniform of the texture unit
+ DoubleBufferedProperty<unsigned int> mTextureId;
+ ConnectionChangePropagator mConnectionObservers; ///< Connection observers that will be informed when textures change.
+ bool mFullyOpaque; // Update only flag - no need for double buffering
+};
+
+} // namespace SceneGraph
+
+inline void SetTextureUnitUniformNameMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, const std::string& name )
+{
+ typedef MessageValue1< SceneGraph::Sampler, std::string > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetTextureUnitUniformName, name );
+}
+
+
+inline void SetTextureMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, unsigned int resourceId )
+{
+ typedef MessageDoubleBuffered1< SceneGraph::Sampler, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetTexture, resourceId );
+}
+
+// Declare enum as a message parameter type outside the SceneGraph namespace
+template <> struct ParameterType< SceneGraph::Sampler::FilterMode > : public BasicType< SceneGraph::Sampler::FilterMode > {};
+
+
+inline void SetFilterModeMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::FilterMode minFilter, SceneGraph::Sampler::FilterMode magFilter )
+{
+ typedef MessageDoubleBuffered2< SceneGraph::Sampler, SceneGraph::Sampler::FilterMode, SceneGraph::Sampler::FilterMode > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetFilterMode, minFilter, magFilter );
+}
+
+// Declare enum as a message parameter type
+template <> struct ParameterType< SceneGraph::Sampler::WrapMode > : public BasicType< SceneGraph::Sampler::WrapMode > {};
+
+
+inline void SetWrapModeMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::WrapMode horizontalWrap, SceneGraph::Sampler::WrapMode verticalWrap )
+{
+ typedef MessageDoubleBuffered2< SceneGraph::Sampler, SceneGraph::Sampler::WrapMode, SceneGraph::Sampler::WrapMode > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetWrapMode, horizontalWrap, verticalWrap );
+}
+
+} // namespace Internal
+} // namespace Dali
+
+
+#endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
--- /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 "scene-graph-geometry.h"
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+
+Geometry::Geometry()
+: mIndexBuffer( NULL ),
+ mCenter(),
+ mHalfExtents(),
+ mRadius( 0.0f ),
+ mGeometryType(Dali::Geometry::TRIANGLES),
+ mRequiresDepthTest(false)
+{
+
+ // Observe our own PropertyOwner's uniform map
+ AddUniformMapObserver( *this );
+}
+
+Geometry::~Geometry()
+{
+ // @todo Inform renderers of deletion of buffers?
+
+ // could remove self from own uniform map observer, but it's about to be destroyed.
+}
+
+void Geometry::AddVertexBuffer( PropertyBuffer* vertexBuffer )
+{
+ mVertexBuffers.PushBack( vertexBuffer );
+ CalculateExtents( vertexBuffer );
+ vertexBuffer->AddUniformMapObserver(*this);
+ mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Geometry::RemoveVertexBuffer( PropertyBuffer* vertexBuffer )
+{
+ DALI_ASSERT_DEBUG( NULL != vertexBuffer );
+
+ // Find the object and destroy it
+ Vector<PropertyBuffer*>::Iterator match = std::find(
+ mVertexBuffers.Begin(),
+ mVertexBuffers.End(),
+ vertexBuffer );
+
+ DALI_ASSERT_DEBUG( mVertexBuffers.End() != match );
+ if( mVertexBuffers.End() != match )
+ {
+ vertexBuffer->RemoveUniformMapObserver(*this);
+ mVertexBuffers.Erase( match );
+ mConnectionObservers.ConnectionsChanged(*this);
+ }
+}
+
+void Geometry::SetIndexBuffer( PropertyBuffer* indexBuffer )
+{
+ if( mIndexBuffer != indexBuffer )
+ {
+ mIndexBuffer = indexBuffer;
+ indexBuffer->AddUniformMapObserver(*this);
+ mConnectionObservers.ConnectionsChanged(*this);
+ }
+}
+
+void Geometry::ClearIndexBuffer()
+{
+ // @todo Actually delete, or put on Discard Queue and tell Renderer in render thread?
+ if( mIndexBuffer )
+ {
+ mIndexBuffer->RemoveUniformMapObserver(*this);
+ }
+ mIndexBuffer = 0;
+ mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Geometry::SetGeometryType( BufferIndex bufferIndex, Geometry::GeometryType geometryType )
+{
+ mGeometryType.Set( bufferIndex, geometryType);
+}
+
+Vector<PropertyBuffer*>& Geometry::GetVertexBuffers()
+{
+ return mVertexBuffers;
+}
+
+PropertyBuffer* Geometry::GetIndexBuffer()
+{
+ return mIndexBuffer;
+}
+
+Geometry::GeometryType Geometry::GetGeometryType( BufferIndex bufferIndex) const
+{
+ int geometryType = mGeometryType[ bufferIndex ];
+ return static_cast< GeometryDataProvider::GeometryType > ( geometryType );
+}
+
+bool Geometry::GetRequiresDepthTesting( BufferIndex bufferIndex ) const
+{
+ return mRequiresDepthTest.GetBoolean( bufferIndex );
+}
+
+void Geometry::ResetDefaultProperties( BufferIndex updateBufferIndex )
+{
+ // Reset the animated properties
+ mCenter.ResetToBaseValue( updateBufferIndex );
+ mHalfExtents.ResetToBaseValue( updateBufferIndex );
+ mRadius.ResetToBaseValue( updateBufferIndex );
+
+ // Age the double buffered properties
+ mGeometryType.CopyPrevious(updateBufferIndex);
+ mRequiresDepthTest.CopyPrevious(updateBufferIndex);
+}
+
+void Geometry::CalculateExtents( PropertyBuffer* vertexBuffer )
+{
+ // TODO calculate extents for all vertex buffers attached to geometry
+ unsigned int elementIndex = 0;
+ unsigned int elementCount = vertexBuffer->GetElementCount( 0 );
+ unsigned int elementCount1 = vertexBuffer->GetElementCount( 1 );
+
+ // Select the double buffered element list that is the largest...
+ if ( elementCount < elementCount1 )
+ {
+ elementCount = elementCount1;
+ elementIndex = 1;
+ }
+
+ unsigned int attributeCount = vertexBuffer->GetAttributeCount( elementIndex );
+ unsigned int elementSize = vertexBuffer->GetElementSize( elementIndex );
+
+ std::string posName( "aPos" );
+ std::size_t found;
+
+ float left = 0.0f;
+ float right = 0.0f;
+ float top = 0.0f;
+ float bottom = 0.0f;
+
+ // Find the position attribute index
+ for ( unsigned int i = 0; i < attributeCount; ++i )
+ {
+ found = vertexBuffer->GetAttributeName( 0, i ).find( posName );
+ if ( found != std::string::npos )
+ {
+ unsigned int offset = vertexBuffer->GetAttributeOffset( elementIndex, i );
+ const PropertyBufferDataProvider::BufferType& data = vertexBuffer->GetData( elementIndex );
+
+ // Check attribute type to determine correct position type
+ Property::Type positionType = vertexBuffer->GetAttributeType( elementIndex, i );
+ Vector3 halfExtents;
+ Vector3 center;
+ switch ( positionType )
+ {
+ case Property::VECTOR2:
+ {
+ for ( unsigned int j = 0; j < elementCount; ++j )
+ {
+ const Vector2* position = reinterpret_cast< const Vector2* >( &data[ offset ] );
+ offset += elementSize;
+
+ if ( position->x < left )
+ {
+ left = position->x;
+ }
+ if ( position->x > right )
+ {
+ right = position->x;
+ }
+ if ( position->y < top )
+ {
+ top = position->y;
+ }
+ if ( position->y > bottom )
+ {
+ bottom = position->y;
+ }
+ }
+
+ halfExtents = Vector3( ( right - left ) * 0.5f, ( bottom - top ) * 0.5f, 0.0f );
+ center = Vector3( halfExtents.x + left , halfExtents.y + top, 0.0f );
+ break;
+ }
+ case Property::VECTOR3:
+ {
+ float near = 0.0f;
+ float far = 0.0f;
+ for ( unsigned int j = 0; j < elementCount; ++j )
+ {
+ const Vector3* position = reinterpret_cast< const Vector3* >( &data[ offset ] );
+ offset += elementSize;
+
+ if ( position->x < left )
+ {
+ left = position->x;
+ }
+ if ( position->x > right )
+ {
+ right = position->x;
+ }
+ if ( position->y < top )
+ {
+ top = position->y;
+ }
+ if ( position->y > bottom )
+ {
+ bottom = position->y;
+ }
+ if ( position->z > far )
+ {
+ far = position->z;
+ }
+ if ( position->z < near )
+ {
+ near = position->z;
+ }
+ }
+ halfExtents = Vector3( ( right - left ) * 0.5f, ( bottom - top ) * 0.5f, ( far - near ) * 0.5f );
+ center = Vector3( halfExtents.x + left , halfExtents.y + top, halfExtents.z + near );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ mCenter.Bake( 0, center );
+ mCenter.Bake( 1, center );
+ mHalfExtents.Bake( 0, halfExtents );
+ mHalfExtents.Bake( 1, halfExtents );
+
+ float radius = halfExtents.x;
+ if ( radius < halfExtents.y )
+ {
+ radius = halfExtents.y;
+ }
+ mRadius.SetInitial( radius );
+ }
+ }
+}
+
+void Geometry::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+{
+}
+
+void Geometry::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+{
+}
+
+void Geometry::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
+{
+ mConnectionObservers.Add(observer);
+}
+
+void Geometry::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
+{
+ mConnectionObservers.Remove(observer);
+}
+
+void Geometry::UniformMappingsChanged( const UniformMap& mappings )
+{
+ // Our uniform map, or that of one of the watched children has changed.
+ // Inform connected observers.
+ mConnectionObservers.ConnectedUniformMapChanged();
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_H
+#define DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_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/event/common/event-thread-services.h>
+#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/double-buffered.h>
+#include <dali/internal/update/common/double-buffered-property.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/property-boolean.h>
+#include <dali/internal/update/common/uniform-map.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
+#include <dali/internal/update/common/scene-graph-property-buffer.h>
+#include <dali/internal/render/data-providers/geometry-data-provider.h>
+#include <dali/internal/render/data-providers/render-data-provider.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+class SceneController;
+
+/**
+ * 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, public GeometryDataProvider, public UniformMap::Observer
+{
+public:
+
+ /**
+ * Constructor
+ */
+ Geometry();
+
+ /**
+ * Destructor
+ */
+ virtual ~Geometry();
+
+ /**
+ * Add a property buffer to be used as a vertex buffer
+ */
+ void AddVertexBuffer( PropertyBuffer* vertexBuffer );
+
+ /**
+ * Remove a property buffer to be used as a vertex buffer
+ * @param[in] vertexBuffer the associated vertex buffer to remove
+ */
+ void RemoveVertexBuffer( PropertyBuffer* vertexBuffer );
+
+ /**
+ * Set the buffer to be used as a source of indices for the geometry
+ * @param[in] indexBuffer the Property buffer describing the indexes for Line, Triangle tyes.
+ */
+ void SetIndexBuffer( PropertyBuffer* indexBuffer );
+
+ /**
+ * Clear the index buffer if it is no longer required, e.g. if changing geometry type
+ * to POINTS.
+ */
+ void ClearIndexBuffer();
+
+ /**
+ * Set the type of geometry to draw (Points, Lines, Triangles, etc)
+ * @param[in] bufferIndex Index for double buffered values
+ * @param[in] geometryType The geometry type
+ */
+ void SetGeometryType( BufferIndex bufferIndex, GeometryType geometryType );
+
+ /**
+ * Connect the object to the scene graph
+ *
+ * @param[in] sceneController The scene controller - used for sending messages to render thread
+ * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
+ */
+ void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
+ /**
+ * Disconnect the object from the scene graph
+ * @param[in] sceneController The scene controller - used for sending messages to render thread
+ * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
+ */
+ void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
+ /**
+ * @copydoc ConnectionObservers::AddObserver
+ */
+ void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+ /**
+ * @copydoc ConnectionObservers::RemoveObserver
+ */
+ void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+public: // UniformMap::Observer
+ /**
+ * @copydoc UniformMap::Observer::UniformMappingsChanged
+ */
+ virtual void UniformMappingsChanged( const UniformMap& mappings );
+
+ /**
+ * Get the vertex buffers of the geometry
+ * @return A const reference to the vertex buffers
+ */
+ Vector<PropertyBuffer*>& GetVertexBuffers();
+
+ /**
+ * Get the index buffer of the geometry
+ * @return A pointer to the index buffer if it exists, or NULL if it doesn't.
+ */
+ PropertyBuffer* GetIndexBuffer();
+
+public: // GeometryDataProvider
+ /**
+ * Get the type of geometry to draw
+ * @param[in] bufferIndex Index for double buffered values
+ */
+ 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
+ * @param[in] bufferIndex Index for double buffered values
+ */
+ virtual bool GetRequiresDepthTesting( BufferIndex bufferIndex ) const;
+
+protected: // From PropertyOwner
+ /**
+ * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
+ */
+ virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
+
+private:
+
+ /**
+ * @brief Calculate the extents of geometry contained in a vertex buffer.
+ *
+ * @param[in] vertexBuffer pointer to a vertex buffer.
+ */
+ void CalculateExtents( PropertyBuffer* vertexBuffer );
+
+ Vector<PropertyBuffer*> mVertexBuffers; ///< The vertex buffers
+ PropertyBuffer* mIndexBuffer; ///< The index buffer if required
+ ConnectionChangePropagator mConnectionObservers;
+
+public: // Properties
+ AnimatableProperty<Vector3> mCenter;
+ AnimatableProperty<Vector3> mHalfExtents;
+ AnimatableProperty<float> mRadius;
+ DoubleBufferedProperty<int> mGeometryType;
+ DoubleBufferedProperty<bool> mRequiresDepthTest;
+};
+
+inline void AddVertexBufferMessage( EventThreadServices& eventThreadServices , const Geometry& geometry, const PropertyBuffer& vertexBuffer )
+{
+ typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::AddVertexBuffer, const_cast<PropertyBuffer*>(&vertexBuffer) );
+}
+
+inline void RemoveVertexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, const PropertyBuffer& vertexBuffer )
+{
+ typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::RemoveVertexBuffer, const_cast<PropertyBuffer*>(&vertexBuffer) );
+}
+
+inline void SetIndexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, const PropertyBuffer& indexBuffer )
+{
+ typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::SetIndexBuffer, const_cast<PropertyBuffer*>(&indexBuffer) );
+}
+
+inline void ClearIndexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry )
+{
+ typedef Message< Geometry > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::ClearIndexBuffer );
+}
+
+} // namespace SceneGraph
+
+// Declare enum as a message parameter type
+template <> struct ParameterType< SceneGraph::Geometry::GeometryType > : public BasicType< SceneGraph::Geometry::GeometryType > {};
+
+namespace SceneGraph
+{
+
+inline void SetGeometryTypeMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, SceneGraph::Geometry::GeometryType geometryType )
+{
+ typedef MessageDoubleBuffered1< Geometry, SceneGraph::Geometry::GeometryType > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::SetGeometryType, geometryType );
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_H
#include <dali/public-api/shader-effects/shader-effect.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/layer-impl.h> // for the default sorting function
+#include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
#include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
-#include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
-#include <dali/internal/update/nodes/scene-graph-layer.h>
+#include <dali/internal/update/resources/resource-manager-declarations.h>
#include <dali/internal/update/manager/sorted-layers.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-geometry.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
+#include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
+#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/render/common/render-item.h>
#include <dali/internal/render/common/render-tracker.h>
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/update/common/scene-graph-property-buffer.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.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/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/manager/object-owner-container.h>
#include <dali/internal/update/manager/prepare-render-algorithms.h>
#include <dali/internal/update/queue/update-message-queue.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
-#include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
-#include <dali/internal/update/rendering/scene-graph-geometry.h>
#include <dali/internal/update/resources/resource-manager.h>
#include <dali/internal/update/resources/complete-status-manager.h>
#include <dali/internal/update/touch/touch-resampler.h>
*/
#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/common/uniform-map.h>
#include <dali/internal/update/manager/prepare-render-instructions.h>
-#include <dali/internal/update/rendering/scene-graph-geometry.h>
-#include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/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/data-providers/render-data-provider.h>
+++ /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 "scene-graph-geometry.h"
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-
-Geometry::Geometry()
-: mIndexBuffer( NULL ),
- mCenter(),
- mHalfExtents(),
- mRadius( 0.0f ),
- mGeometryType(Dali::Geometry::TRIANGLES),
- mRequiresDepthTest(false)
-{
-
- // Observe our own PropertyOwner's uniform map
- AddUniformMapObserver( *this );
-}
-
-Geometry::~Geometry()
-{
- // @todo Inform renderers of deletion of buffers?
-
- // could remove self from own uniform map observer, but it's about to be destroyed.
-}
-
-void Geometry::AddVertexBuffer( PropertyBuffer* vertexBuffer )
-{
- mVertexBuffers.PushBack( vertexBuffer );
- CalculateExtents( vertexBuffer );
- vertexBuffer->AddUniformMapObserver(*this);
- mConnectionObservers.ConnectionsChanged(*this);
-}
-
-void Geometry::RemoveVertexBuffer( PropertyBuffer* vertexBuffer )
-{
- DALI_ASSERT_DEBUG( NULL != vertexBuffer );
-
- // Find the object and destroy it
- Vector<PropertyBuffer*>::Iterator match = std::find(
- mVertexBuffers.Begin(),
- mVertexBuffers.End(),
- vertexBuffer );
-
- DALI_ASSERT_DEBUG( mVertexBuffers.End() != match );
- if( mVertexBuffers.End() != match )
- {
- vertexBuffer->RemoveUniformMapObserver(*this);
- mVertexBuffers.Erase( match );
- mConnectionObservers.ConnectionsChanged(*this);
- }
-}
-
-void Geometry::SetIndexBuffer( PropertyBuffer* indexBuffer )
-{
- if( mIndexBuffer != indexBuffer )
- {
- mIndexBuffer = indexBuffer;
- indexBuffer->AddUniformMapObserver(*this);
- mConnectionObservers.ConnectionsChanged(*this);
- }
-}
-
-void Geometry::ClearIndexBuffer()
-{
- // @todo Actually delete, or put on Discard Queue and tell Renderer in render thread?
- if( mIndexBuffer )
- {
- mIndexBuffer->RemoveUniformMapObserver(*this);
- }
- mIndexBuffer = 0;
- mConnectionObservers.ConnectionsChanged(*this);
-}
-
-void Geometry::SetGeometryType( BufferIndex bufferIndex, Geometry::GeometryType geometryType )
-{
- mGeometryType.Set( bufferIndex, geometryType);
-}
-
-Vector<PropertyBuffer*>& Geometry::GetVertexBuffers()
-{
- return mVertexBuffers;
-}
-
-PropertyBuffer* Geometry::GetIndexBuffer()
-{
- return mIndexBuffer;
-}
-
-Geometry::GeometryType Geometry::GetGeometryType( BufferIndex bufferIndex) const
-{
- int geometryType = mGeometryType[ bufferIndex ];
- return static_cast< GeometryDataProvider::GeometryType > ( geometryType );
-}
-
-bool Geometry::GetRequiresDepthTesting( BufferIndex bufferIndex ) const
-{
- return mRequiresDepthTest.GetBoolean( bufferIndex );
-}
-
-void Geometry::ResetDefaultProperties( BufferIndex updateBufferIndex )
-{
- // Reset the animated properties
- mCenter.ResetToBaseValue( updateBufferIndex );
- mHalfExtents.ResetToBaseValue( updateBufferIndex );
- mRadius.ResetToBaseValue( updateBufferIndex );
-
- // Age the double buffered properties
- mGeometryType.CopyPrevious(updateBufferIndex);
- mRequiresDepthTest.CopyPrevious(updateBufferIndex);
-}
-
-void Geometry::CalculateExtents( PropertyBuffer* vertexBuffer )
-{
- // TODO calculate extents for all vertex buffers attached to geometry
- unsigned int elementIndex = 0;
- unsigned int elementCount = vertexBuffer->GetElementCount( 0 );
- unsigned int elementCount1 = vertexBuffer->GetElementCount( 1 );
-
- // Select the double buffered element list that is the largest...
- if ( elementCount < elementCount1 )
- {
- elementCount = elementCount1;
- elementIndex = 1;
- }
-
- unsigned int attributeCount = vertexBuffer->GetAttributeCount( elementIndex );
- unsigned int elementSize = vertexBuffer->GetElementSize( elementIndex );
-
- std::string posName( "aPos" );
- std::size_t found;
-
- float left = 0.0f;
- float right = 0.0f;
- float top = 0.0f;
- float bottom = 0.0f;
-
- // Find the position attribute index
- for ( unsigned int i = 0; i < attributeCount; ++i )
- {
- found = vertexBuffer->GetAttributeName( 0, i ).find( posName );
- if ( found != std::string::npos )
- {
- unsigned int offset = vertexBuffer->GetAttributeOffset( elementIndex, i );
- const PropertyBufferDataProvider::BufferType& data = vertexBuffer->GetData( elementIndex );
-
- // Check attribute type to determine correct position type
- Property::Type positionType = vertexBuffer->GetAttributeType( elementIndex, i );
- Vector3 halfExtents;
- Vector3 center;
- switch ( positionType )
- {
- case Property::VECTOR2:
- {
- for ( unsigned int j = 0; j < elementCount; ++j )
- {
- const Vector2* position = reinterpret_cast< const Vector2* >( &data[ offset ] );
- offset += elementSize;
-
- if ( position->x < left )
- {
- left = position->x;
- }
- if ( position->x > right )
- {
- right = position->x;
- }
- if ( position->y < top )
- {
- top = position->y;
- }
- if ( position->y > bottom )
- {
- bottom = position->y;
- }
- }
-
- halfExtents = Vector3( ( right - left ) * 0.5f, ( bottom - top ) * 0.5f, 0.0f );
- center = Vector3( halfExtents.x + left , halfExtents.y + top, 0.0f );
- break;
- }
- case Property::VECTOR3:
- {
- float near = 0.0f;
- float far = 0.0f;
- for ( unsigned int j = 0; j < elementCount; ++j )
- {
- const Vector3* position = reinterpret_cast< const Vector3* >( &data[ offset ] );
- offset += elementSize;
-
- if ( position->x < left )
- {
- left = position->x;
- }
- if ( position->x > right )
- {
- right = position->x;
- }
- if ( position->y < top )
- {
- top = position->y;
- }
- if ( position->y > bottom )
- {
- bottom = position->y;
- }
- if ( position->z > far )
- {
- far = position->z;
- }
- if ( position->z < near )
- {
- near = position->z;
- }
- }
- halfExtents = Vector3( ( right - left ) * 0.5f, ( bottom - top ) * 0.5f, ( far - near ) * 0.5f );
- center = Vector3( halfExtents.x + left , halfExtents.y + top, halfExtents.z + near );
- break;
- }
- default:
- {
- break;
- }
- }
- mCenter.Bake( 0, center );
- mCenter.Bake( 1, center );
- mHalfExtents.Bake( 0, halfExtents );
- mHalfExtents.Bake( 1, halfExtents );
-
- float radius = halfExtents.x;
- if ( radius < halfExtents.y )
- {
- radius = halfExtents.y;
- }
- mRadius.SetInitial( radius );
- }
- }
-}
-
-void Geometry::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Geometry::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Geometry::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Add(observer);
-}
-
-void Geometry::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Remove(observer);
-}
-
-void Geometry::UniformMappingsChanged( const UniformMap& mappings )
-{
- // Our uniform map, or that of one of the watched children has changed.
- // Inform connected observers.
- mConnectionObservers.ConnectedUniformMapChanged();
-}
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_H
-#define DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_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/devel-api/rendering/geometry.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/double-buffered.h>
-#include <dali/internal/update/common/double-buffered-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/property-boolean.h>
-#include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-#include <dali/internal/update/common/scene-graph-property-buffer.h>
-#include <dali/internal/render/data-providers/geometry-data-provider.h>
-#include <dali/internal/render/data-providers/render-data-provider.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class SceneController;
-
-/**
- * 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, public GeometryDataProvider, public UniformMap::Observer
-{
-public:
-
- /**
- * Constructor
- */
- Geometry();
-
- /**
- * Destructor
- */
- virtual ~Geometry();
-
- /**
- * Add a property buffer to be used as a vertex buffer
- */
- void AddVertexBuffer( PropertyBuffer* vertexBuffer );
-
- /**
- * Remove a property buffer to be used as a vertex buffer
- * @param[in] vertexBuffer the associated vertex buffer to remove
- */
- void RemoveVertexBuffer( PropertyBuffer* vertexBuffer );
-
- /**
- * Set the buffer to be used as a source of indices for the geometry
- * @param[in] indexBuffer the Property buffer describing the indexes for Line, Triangle tyes.
- */
- void SetIndexBuffer( PropertyBuffer* indexBuffer );
-
- /**
- * Clear the index buffer if it is no longer required, e.g. if changing geometry type
- * to POINTS.
- */
- void ClearIndexBuffer();
-
- /**
- * Set the type of geometry to draw (Points, Lines, Triangles, etc)
- * @param[in] bufferIndex Index for double buffered values
- * @param[in] geometryType The geometry type
- */
- void SetGeometryType( BufferIndex bufferIndex, GeometryType geometryType );
-
- /**
- * Connect the object to the scene graph
- *
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
- /**
- * Disconnect the object from the scene graph
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
- /**
- * @copydoc ConnectionObservers::AddObserver
- */
- void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
- /**
- * @copydoc ConnectionObservers::RemoveObserver
- */
- void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-public: // UniformMap::Observer
- /**
- * @copydoc UniformMap::Observer::UniformMappingsChanged
- */
- virtual void UniformMappingsChanged( const UniformMap& mappings );
-
- /**
- * Get the vertex buffers of the geometry
- * @return A const reference to the vertex buffers
- */
- Vector<PropertyBuffer*>& GetVertexBuffers();
-
- /**
- * Get the index buffer of the geometry
- * @return A pointer to the index buffer if it exists, or NULL if it doesn't.
- */
- PropertyBuffer* GetIndexBuffer();
-
-public: // GeometryDataProvider
- /**
- * Get the type of geometry to draw
- * @param[in] bufferIndex Index for double buffered values
- */
- 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
- * @param[in] bufferIndex Index for double buffered values
- */
- virtual bool GetRequiresDepthTesting( BufferIndex bufferIndex ) const;
-
-protected: // From PropertyOwner
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
- */
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
-private:
-
- /**
- * @brief Calculate the extents of geometry contained in a vertex buffer.
- *
- * @param[in] vertexBuffer pointer to a vertex buffer.
- */
- void CalculateExtents( PropertyBuffer* vertexBuffer );
-
- Vector<PropertyBuffer*> mVertexBuffers; ///< The vertex buffers
- PropertyBuffer* mIndexBuffer; ///< The index buffer if required
- ConnectionChangePropagator mConnectionObservers;
-
-public: // Properties
- AnimatableProperty<Vector3> mCenter;
- AnimatableProperty<Vector3> mHalfExtents;
- AnimatableProperty<float> mRadius;
- DoubleBufferedProperty<int> mGeometryType;
- DoubleBufferedProperty<bool> mRequiresDepthTest;
-};
-
-inline void AddVertexBufferMessage( EventThreadServices& eventThreadServices , const Geometry& geometry, const PropertyBuffer& vertexBuffer )
-{
- typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &geometry, &Geometry::AddVertexBuffer, const_cast<PropertyBuffer*>(&vertexBuffer) );
-}
-
-inline void RemoveVertexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, const PropertyBuffer& vertexBuffer )
-{
- typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &geometry, &Geometry::RemoveVertexBuffer, const_cast<PropertyBuffer*>(&vertexBuffer) );
-}
-
-inline void SetIndexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, const PropertyBuffer& indexBuffer )
-{
- typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &geometry, &Geometry::SetIndexBuffer, const_cast<PropertyBuffer*>(&indexBuffer) );
-}
-
-inline void ClearIndexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry )
-{
- typedef Message< Geometry > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &geometry, &Geometry::ClearIndexBuffer );
-}
-
-} // namespace SceneGraph
-
-// Declare enum as a message parameter type
-template <> struct ParameterType< SceneGraph::Geometry::GeometryType > : public BasicType< SceneGraph::Geometry::GeometryType > {};
-
-namespace SceneGraph
-{
-
-inline void SetGeometryTypeMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, SceneGraph::Geometry::GeometryType geometryType )
-{
- typedef MessageDoubleBuffered1< Geometry, SceneGraph::Geometry::GeometryType > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &geometry, &Geometry::SetGeometryType, geometryType );
-}
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
-
-#endif // DALI_INTERNAL_SCENE_GRAPH_GEOMETRY_H
+++ /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.
- */
-
-// CLASS HEADER
-#include "scene-graph-material.h"
-
-// INTERNAL HEADERS
-#include <dali/public-api/actors/blending.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
-#include <dali/devel-api/rendering/material.h>
-#include <dali/internal/common/internal-constants.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
-#include <dali/internal/render/data-providers/sampler-data-provider.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-
-namespace
-{
-const unsigned int DEFAULT_BLENDING_OPTIONS( BlendingOptions().GetBitmask() );
-}
-
-Material::Material()
-: mColor( Color::WHITE ),
- mBlendColor( Color::TRANSPARENT ),
- mFaceCullingMode(Dali::Material::NONE),
- mBlendingMode(Dali::BlendingMode::AUTO),
- mBlendingOptions( DEFAULT_BLENDING_OPTIONS ),
- mShader(NULL),
- mBlendPolicy(OPAQUE)
-{
- // Observe own property-owner's uniform map
- AddUniformMapObserver( *this );
-}
-
-Material::~Material()
-{
-}
-
-void Material::SetShader( Shader* shader )
-{
- mShader = shader;
- mShader->AddUniformMapObserver( *this );
-
- // Inform NewRenderer about this shader: (Will force a re-load of the
- // shader from the data providers)
- mConnectionObservers.ConnectionsChanged(*this);
-}
-
-Shader* Material::GetShader() const
-{
- // @todo - Fix this - move shader setup to the Renderer connect to stage...
- return mShader;
-}
-
-void Material::AddSampler( Sampler* sampler )
-{
- mSamplers.PushBack( sampler );
-
- sampler->AddConnectionObserver( *this );
- sampler->AddUniformMapObserver( *this );
-
- mConnectionObservers.ConnectionsChanged(*this);
-}
-
-void Material::RemoveSampler( Sampler* sampler )
-{
- Vector<Sampler*>::Iterator match = std::find( mSamplers.Begin(), mSamplers.End(), sampler );
-
- DALI_ASSERT_DEBUG( mSamplers.End() != match );
- if( mSamplers.End() != match )
- {
- sampler->RemoveConnectionObserver( *this );
- sampler->RemoveUniformMapObserver( *this );
- mSamplers.Erase( match );
- mConnectionObservers.ConnectionsChanged(*this);
- }
- else
- {
- DALI_ASSERT_DEBUG( 0 && "Sampler not found" );
- }
-}
-
-void Material::PrepareRender( BufferIndex bufferIndex )
-{
- mBlendPolicy = OPAQUE;
-
- // @todo MESH_REWORK Add dirty flags to reduce processing.
-
- switch(mBlendingMode[bufferIndex])
- {
- case BlendingMode::OFF:
- {
- mBlendPolicy = OPAQUE;
- break;
- }
- case BlendingMode::ON:
- {
- mBlendPolicy = TRANSPARENT;
- break;
- }
- case BlendingMode::AUTO:
- {
- bool opaque = true;
-
- // @todo: MESH_REWORK - Change hints for new SceneGraphShader:
- // If shader hint OUTPUT_IS_OPAQUE is enabled, set policy to ALWAYS_OPAQUE
- // If shader hint OUTPUT_IS_TRANSPARENT is enabled, set policy to ALWAYS_TRANSPARENT
- // else test remainder, and set policy to either ALWAYS_TRANSPARENT or USE_ACTOR_COLOR
-
- if( mShader->GeometryHintEnabled( Dali::ShaderEffect::HINT_BLENDING ) )
- {
- opaque = false;
- }
-
- if( opaque )
- {
- // Check the material color:
- opaque = ( mColor[ bufferIndex ].a >= FULLY_OPAQUE );
- }
-
- if( opaque )
- {
- // Require that all affecting samplers are opaque
- unsigned int opaqueCount=0;
- unsigned int affectingCount=0;
-
- for( Vector<Sampler*>::ConstIterator iter = mSamplers.Begin();
- iter != mSamplers.End(); ++iter )
- {
- const Sampler* sampler = *iter;
- if( sampler != NULL )
- {
- if( sampler->AffectsTransparency( bufferIndex ) )
- {
- affectingCount++;
- if( sampler->IsFullyOpaque( bufferIndex ) )
- {
- opaqueCount++;
- }
- }
- }
- }
- opaque = (opaqueCount == affectingCount);
- }
-
- mBlendPolicy = opaque ? Material::USE_ACTOR_COLOR : Material::TRANSPARENT;
- }
- }
-}
-
-Vector<Sampler*>& Material::GetSamplers()
-{
- return mSamplers;
-}
-
-Material::BlendPolicy Material::GetBlendPolicy() const
-{
- return mBlendPolicy;
-}
-
-void Material::SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options )
-{
- mBlendingOptions.Set( updateBufferIndex, options );
-}
-
-const Vector4& Material::GetBlendColor(BufferIndex bufferIndex) const
-{
- return mBlendColor[bufferIndex];
-}
-
-BlendingFactor::Type Material::GetBlendSrcFactorRgb( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendSrcFactorRgb();
-}
-
-BlendingFactor::Type Material::GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendSrcFactorAlpha();
-}
-
-BlendingFactor::Type Material::GetBlendDestFactorRgb( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendDestFactorRgb();
-}
-
-BlendingFactor::Type Material::GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendDestFactorAlpha();
-}
-
-BlendingEquation::Type Material::GetBlendEquationRgb( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendEquationRgb();
-}
-
-BlendingEquation::Type Material::GetBlendEquationAlpha( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendEquationAlpha();
-}
-
-void Material::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Material::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Material::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Add(observer);
-}
-
-void Material::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Remove(observer);
-}
-
-void Material::UniformMappingsChanged( const UniformMap& mappings )
-{
- // Our uniform map, or that of one of the watched children has changed.
- // Inform connected observers.
- mConnectionObservers.ConnectedUniformMapChanged();
-}
-
-void Material::ConnectionsChanged( PropertyOwner& owner )
-{
- mConnectionObservers.ConnectionsChanged(*this);
-}
-
-void Material::ConnectedUniformMapChanged( )
-{
- mConnectionObservers.ConnectedUniformMapChanged();
-}
-
-void Material::ResetDefaultProperties( BufferIndex updateBufferIndex )
-{
- mColor.ResetToBaseValue( updateBufferIndex );
- mBlendColor.ResetToBaseValue( updateBufferIndex );
- mFaceCullingMode.CopyPrevious( updateBufferIndex );
-
- mBlendingMode.CopyPrevious( updateBufferIndex );
- mBlendingOptions.CopyPrevious( updateBufferIndex );
-}
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
-#define DALI_INTERNAL_SCENE_GRAPH_MATERIAL_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/actors/renderable-actor.h> // For CullFaceMode
-#include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/blending-options.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/double-buffered-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-#include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/render/data-providers/material-data-provider.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class Sampler;
-class Shader;
-class ConnectionObserver;
-class SceneController;
-
-class Material : public PropertyOwner, public MaterialDataProvider, public UniformMap::Observer, public ConnectionChangePropagator::Observer
-{
-public:
- /**
- * This enum defines the outputs of the PrepareRender step, and is used
- * by the Renderer to determine final opacity.
- */
- enum BlendPolicy
- {
- OPAQUE, ///< If the renderer should always be opaque
- TRANSPARENT, ///< If the renderer should always be transparent
- USE_ACTOR_COLOR ///< If the renderer should determine opacity using the actor color
- };
-
- /**
- * Constructor
- */
- Material();
-
- /**
- * Destructor
- */
- virtual ~Material();
-
- /**
- * Set the shader effect for this material
- * @param[in] shader The shader effect to use
- */
- void SetShader( Shader* shader );
-
- /**
- * Add a sampler (image + sampler modes) to the material
- * @param[in] sampler A sampler to add
- */
- void AddSampler( Sampler* sampler );
-
- /**
- * Remove a sampler (image + sampler modes) from the material
- * @param[in] sampler A sampler to remove
- */
- void RemoveSampler( Sampler* sampler );
-
- /**
- * Prepare the material for rendering.
- *
- * Determine whether blending is enabled for this material, and store the result.
- * @param[in] bufferIndex The current buffer index
- */
- void PrepareRender( BufferIndex bufferIndex );
-
- /**
- * Return the blend policy ( a combination of all the different shader hints, color, samper and image properties ).
- * This should only be called from the update thread
- * @return The material's blend policy
- */
- BlendPolicy GetBlendPolicy() const;
-
- /**
- * Set the blending options. This should only be called from the update thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] options A bitmask of blending options.
- */
- void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
-
-public: // Implementation of MaterialDataProvider
-
- /**
- * @copydoc MaterialDataProvider::GetBlendColor
- */
- virtual const Vector4& GetBlendColor(BufferIndex bufferIndex) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendSrcFactorRgb
- */
- virtual BlendingFactor::Type GetBlendSrcFactorRgb(BufferIndex bufferIndex) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendSrcFactorAlpha
- */
- virtual BlendingFactor::Type GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendDestFactorRgb
- */
- virtual BlendingFactor::Type GetBlendDestFactorRgb( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendDestFactorAlpha
- */
- virtual BlendingFactor::Type GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendEquationRgb
- */
- virtual BlendingEquation::Type GetBlendEquationRgb( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendEquationAlpha
- */
- virtual BlendingEquation::Type GetBlendEquationAlpha( BufferIndex bufferIndex ) const;
-
-public: // Implementation of ObjectOwnerContainer template methods
- /**
- * Connect the object to the scene graph
- *
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
- /**
- * Disconnect the object from the scene graph
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
-public: // Implementation of ConnectionChangePropagator
- /**
- * @copydoc ConnectionChangePropagator::AddObserver
- */
- void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
- /**
- * @copydoc ConnectionChangePropagator::RemoveObserver
- */
- void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-public:
- /**
- * Get the shader effect of this material
- * @return the shader effect;
- */
- Shader* GetShader() const;
-
- /**
- * Get the samplers this material uses.
- * @return the samplers
- */
- Vector<Sampler*>& GetSamplers();
-
-public: // UniformMap::Observer
- /**
- * @copydoc UniformMap::Observer::UniformMappingsChanged
- */
- virtual void UniformMappingsChanged( const UniformMap& mappings );
-
-public: // ConnectionChangePropagator::Observer
-
- /**
- * @copydoc ConnectionChangePropagator::ConnectionsChanged
- */
- virtual void ConnectionsChanged( PropertyOwner& owner );
-
- /**
- * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
- */
- virtual void ConnectedUniformMapChanged( );
-
-public: // PropertyOwner implementation
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
- */
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
-public: // Property data
- AnimatableProperty<Vector4> mColor;
- AnimatableProperty<Vector4> mBlendColor;
- DoubleBufferedProperty<int> mFaceCullingMode;
- DoubleBufferedProperty<int> mBlendingMode;
- DoubleBufferedProperty<int> mBlendingOptions;
-
-private:
- Shader* mShader;
- Vector<Sampler*> mSamplers; // Not owned
- ConnectionChangePropagator mConnectionObservers;
- BlendPolicy mBlendPolicy; ///< The blend policy as determined by PrepareRender
-};
-
-inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Material& material, const Shader& shader )
-{
- typedef MessageValue1< Material, Shader* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::SetShader, const_cast<Shader*>(&shader) );
-}
-
-inline void AddSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, const Sampler& sampler )
-{
- typedef MessageValue1< Material, Sampler* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::AddSampler, const_cast<Sampler*>(&sampler) );
-}
-
-inline void RemoveSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, Sampler& sampler )
-{
- typedef MessageValue1< Material, Sampler* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::RemoveSampler, const_cast<Sampler*>(&sampler) );
-}
-
-inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Material& material, unsigned int options )
-{
- typedef MessageDoubleBuffered1< Material, unsigned int > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
- new (slot) LocalType( &material, &Material::SetBlendingOptions, options );
-}
-
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
-
-#endif // DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
+++ /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.
- */
-
-// CLASS HEADER
-#include "scene-graph-sampler.h"
-
-// EXTERNAL HEADERS
-
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-
-Sampler::Sampler( const std::string& textureUnitUniformName )
-: mMinFilter( Dali::Sampler::DEFAULT ),
- mMagFilter( Dali::Sampler::DEFAULT ),
- mUWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
- mVWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
- mAffectsTransparency( true ),
- mTextureUnitUniformName( textureUnitUniformName ),
- mTextureId( 0u ),
- mFullyOpaque(true)
-{
-}
-
-Sampler::~Sampler()
-{
-}
-
-void Sampler::SetTextureUnitUniformName( const std::string& textureUnitUniformName )
-{
- mTextureUnitUniformName = textureUnitUniformName;
-}
-
-void Sampler::SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId )
-{
- if( mTextureId[bufferIndex] != textureId )
- {
- mTextureId.Set( bufferIndex, textureId );
- mConnectionObservers.ConnectionsChanged(*this);
- }
-}
-
-void Sampler::SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter )
-{
- mMinFilter.Set(bufferIndex, minFilter);
- mMagFilter.Set(bufferIndex, magFilter);
-}
-
-void Sampler::SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap )
-{
-}
-
-const std::string& Sampler::GetTextureUnitUniformName() const
-{
- return mTextureUnitUniformName;
-}
-
-Integration::ResourceId Sampler::GetTextureId( BufferIndex bufferIndex ) const
-{
- return mTextureId[bufferIndex];
-}
-
-Sampler::FilterMode Sampler::GetMinifyFilterMode( BufferIndex bufferIndex ) const
-{
- return static_cast<Sampler::FilterMode>(mMinFilter[bufferIndex]);
-}
-
-Sampler::FilterMode Sampler::GetMagnifyFilterMode( BufferIndex bufferIndex ) const
-{
- return static_cast<Sampler::FilterMode>(mMagFilter[bufferIndex]);
-}
-
-Sampler::WrapMode Sampler::GetUWrapMode( BufferIndex bufferIndex ) const
-{
- return static_cast<Sampler::WrapMode>(mUWrapMode[bufferIndex]);
-}
-
-Sampler::WrapMode Sampler::GetVWrapMode( BufferIndex bufferIndex ) const
-{
- return static_cast<Sampler::WrapMode>(mVWrapMode[bufferIndex]);
-}
-
-bool Sampler::AffectsTransparency( BufferIndex bufferIndex ) const
-{
- return mAffectsTransparency[bufferIndex] ;
-}
-
-void Sampler::SetFullyOpaque( bool fullyOpaque )
-{
- mFullyOpaque = fullyOpaque;
-}
-
-bool Sampler::IsFullyOpaque( BufferIndex bufferIndex ) const
-{
- return mFullyOpaque;
-}
-
-void Sampler::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Sampler::DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex)
-{
-}
-
-void Sampler::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Add(observer);
-}
-
-void Sampler::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Remove(observer);
-}
-
-void Sampler::ResetDefaultProperties( BufferIndex bufferIndex )
-{
- mTextureId.CopyPrevious( bufferIndex );
- mMinFilter.CopyPrevious( bufferIndex );
- mMagFilter.CopyPrevious( bufferIndex );
- mUWrapMode.CopyPrevious( bufferIndex );
- mVWrapMode.CopyPrevious( bufferIndex );
- mAffectsTransparency.CopyPrevious( bufferIndex );
-}
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
-#define DALI_INTERNAL_SCENE_GRAPH_SAMPLER_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/devel-api/rendering/sampler.h>
-#include <dali/integration-api/resource-declarations.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/double-buffered.h>
-#include <dali/internal/update/common/double-buffered-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-#include <dali/internal/update/resources/bitmap-metadata.h>
-#include <dali/internal/render/data-providers/sampler-data-provider.h>
-
-#include <string>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class SceneController;
-
-class Sampler : public PropertyOwner, public SamplerDataProvider
-{
-public:
- typedef Dali::Sampler::FilterMode FilterMode;
- typedef Dali::Sampler::WrapMode WrapMode;
-
- /**
- * Constructor
- */
- Sampler( const std::string& samplerName );
-
- /**
- * Destructor
- */
- virtual ~Sampler();
-
- /**
- * Set the uniform name of this sampler. This allows the shader to find the
- * GL index of this sampler.
- */
- void SetTextureUnitUniformName( const std::string& textureUnitUniformName );
-
- /**
- * 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
- */
- void SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId );
-
- /**
- * Set the filter modes for minify and magnify filters
- * @param[in] bufferIndex The buffer index to use
- * @param[in] minFilter The minify filter
- * @param[in] magFilter The magnify filter
- */
- void SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter );
-
- /**
- * @param[in] bufferIndex The buffer index to use
- */
- void SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap );
-
- /**
- * @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;
-
- /**
- * Sets whether the associated texture is fully opaque or not.
- * @param[in] fullyOpaque true if it's fully opaque
- */
- void SetFullyOpaque( bool fullyOpaque );
-
- /**
- * @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
- */
- virtual const std::string& GetTextureUnitUniformName() const;
-
- /**
- * Get the texture ID
- * @param[in] bufferIndex The buffer index to use
- * @return the identity of the associated texture
- */
- 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 ) const;
-
- /**
- * Get the filter mode
- * @param[in] bufferIndex The buffer index to use
- * @return The magnify filter mode
- */
- 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 ) const;
-
- /**
- * Get the vertical wrap mode
- * @param[in] bufferIndex The buffer index to use
- * @return The vertical wrap mode
- */
- virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) const;
-
- /**
- * Connect the object to the scene graph
- *
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
- /**
- * Disconnect the object from the scene graph
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
- /**
- * @copydoc ConnectionChangePropagator::AddObserver
- */
- void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
- /**
- * @copydoc ConnectionChangePropagator::RemoveObserver
- */
- void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-public: // PropertyOwner implementation
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
- */
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
-public: // Properties
- DoubleBufferedProperty<int> mMinFilter; ///< The minify filter
- DoubleBufferedProperty<int> mMagFilter; ///< The magnify filter
- DoubleBufferedProperty<int> mUWrapMode; ///< The horizontal wrap mode
- DoubleBufferedProperty<int> mVWrapMode; ///< The vertical wrap mode
- DoubleBufferedProperty<bool> mAffectsTransparency; ///< If this sampler affects renderer transparency
-
-private:
- std::string mTextureUnitUniformName; ///< The name of the uniform of the texture unit
- DoubleBufferedProperty<unsigned int> mTextureId;
- ConnectionChangePropagator mConnectionObservers; ///< Connection observers that will be informed when textures change.
- bool mFullyOpaque; // Update only flag - no need for double buffering
-};
-
-} // namespace SceneGraph
-
-inline void SetTextureUnitUniformNameMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, const std::string& name )
-{
- typedef MessageValue1< SceneGraph::Sampler, std::string > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetTextureUnitUniformName, name );
-}
-
-
-inline void SetTextureMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, unsigned int resourceId )
-{
- typedef MessageDoubleBuffered1< SceneGraph::Sampler, unsigned int > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetTexture, resourceId );
-}
-
-// Declare enum as a message parameter type outside the SceneGraph namespace
-template <> struct ParameterType< SceneGraph::Sampler::FilterMode > : public BasicType< SceneGraph::Sampler::FilterMode > {};
-
-
-inline void SetFilterModeMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::FilterMode minFilter, SceneGraph::Sampler::FilterMode magFilter )
-{
- typedef MessageDoubleBuffered2< SceneGraph::Sampler, SceneGraph::Sampler::FilterMode, SceneGraph::Sampler::FilterMode > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetFilterMode, minFilter, magFilter );
-}
-
-// Declare enum as a message parameter type
-template <> struct ParameterType< SceneGraph::Sampler::WrapMode > : public BasicType< SceneGraph::Sampler::WrapMode > {};
-
-
-inline void SetWrapModeMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::WrapMode horizontalWrap, SceneGraph::Sampler::WrapMode verticalWrap )
-{
- typedef MessageDoubleBuffered2< SceneGraph::Sampler, SceneGraph::Sampler::WrapMode, SceneGraph::Sampler::WrapMode > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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, &SceneGraph::Sampler::SetWrapMode, horizontalWrap, verticalWrap );
-}
-
-} // namespace Internal
-} // namespace Dali
-
-
-#endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
-#include <dali/internal/event/rendering/renderer-impl.h>
+#include <dali/internal/event/actors/renderer-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/actors/renderer.h> // Dali::Renderer
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/actors/renderer-impl.h> // Dali::Internal::Renderer
+
+namespace Dali
+{
+
+Renderer Renderer::New( Geometry& geometry, Material& material )
+{
+ Internal::RendererPtr renderer = Internal::Renderer::New( );
+ renderer->SetGeometry( GetImplementation(geometry) );
+ renderer->SetMaterial( GetImplementation(material) );
+ return Renderer( renderer.Get() );
+}
+
+Renderer::Renderer()
+{
+}
+
+Renderer::~Renderer()
+{
+}
+
+Renderer::Renderer( const Renderer& handle )
+: Handle( handle )
+{
+}
+
+Renderer Renderer::DownCast( BaseHandle handle )
+{
+ return Renderer( dynamic_cast<Dali::Internal::Renderer*>(handle.GetObjectPtr()));
+}
+
+Renderer& Renderer::operator=( const Renderer& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+void Renderer::SetGeometry( Geometry& geometry )
+{
+ DALI_ASSERT_ALWAYS( geometry && "Geometry handle not initialized" );
+ GetImplementation(*this).SetGeometry( GetImplementation(geometry) );
+}
+
+Geometry Renderer::GetGeometry() const
+{
+ Internal::Geometry* geometryPtr( GetImplementation(*this).GetGeometry() );
+ return Dali::Geometry( geometryPtr );
+}
+
+void Renderer::SetMaterial( Material& material )
+{
+ DALI_ASSERT_ALWAYS( material && "Material handle not initialized" );
+ GetImplementation(*this).SetMaterial( GetImplementation(material) );
+}
+
+Material Renderer::GetMaterial() const
+{
+ Internal::Material* materialPtr( GetImplementation(*this).GetMaterial() );
+ return Dali::Material( materialPtr );
+}
+
+void Renderer::SetDepthIndex( int depthIndex )
+{
+ GetImplementation(*this).SetDepthIndex( depthIndex );
+}
+
+int Renderer::GetDepthIndex()
+{
+ return GetImplementation(*this).GetDepthIndex();
+}
+
+Renderer::Renderer( Internal::Renderer* pointer )
+: Handle( pointer )
+{
+}
+
+} //namespace Dali
--- /dev/null
+#ifndef DALI_RENDERER_H
+#define DALI_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string> // std::string
+
+// INTERNAL INCLUDES
+#include <dali/public-api/geometry/geometry.h> // Dali::Geometry
+#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+#include <dali/public-api/shader-effects/material.h> // Dali::Material
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class Renderer;
+}
+
+/**
+ * @brief Renderer is a handle to an object that can be used to provide an image to a material.
+ */
+class DALI_IMPORT_API Renderer : public Handle
+{
+public:
+
+ /**
+ * @brief An enumeration of properties belonging to the Renderer class.
+ */
+ struct Property
+ {
+ enum
+ {
+ DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depth-index", type INTEGER
+ };
+ };
+
+ /**
+ * @brief Creates a new Renderer object
+ *
+ * @param[in] geometry Geometry to be used by this renderer
+ * @param[in] material Material to be used by this renderer
+ */
+ static Renderer New( Geometry& geometry, Material& material );
+
+ /**
+ * @brief Default constructor, creates an empty handle
+ */
+ Renderer();
+
+ /**
+ * @brief Destructor
+ */
+ ~Renderer();
+
+ /**
+ * @brief Copy constructor, creates a new handle to the same object
+ *
+ * @param[in] handle Handle to an object
+ */
+ Renderer( const Renderer& handle );
+
+ /**
+ * @brief Downcast to a renderer handle.
+ *
+ * If not a renderer the returned renderer handle is left uninitialized.
+ * @param[in] handle to an object
+ * @return renderer handle or an uninitialized handle
+ */
+ static Renderer DownCast( BaseHandle handle );
+
+ /**
+ * @brief Assignment operator, changes this handle to point at the same object
+ *
+ * @param[in] handle Handle to an object
+ * @return Reference to the assigned object
+ */
+ Renderer& operator=( const Renderer& handle );
+
+ /**
+ * @brief Sets the geometry to be used by this renderer
+ *
+ * @param[in] geometry The geometry to be used by this renderer
+ */
+ void SetGeometry( Geometry& geometry );
+
+ /**
+ * @brief Gets the geometry used by this renderer
+ *
+ * @return The geometry used by the renderer
+ */
+ Geometry GetGeometry() const;
+
+ /**
+ * @brief Sets the material to be used by this renderer
+ *
+ * @param[in] material The material to be used by this renderer
+ */
+ void SetMaterial( Material& material );
+
+ /**
+ * @brief Gets the material used by this renderer
+ *
+ * @return The material used by the renderer
+ */
+ Material GetMaterial() const;
+
+ /**
+ * @brief Set the depth index of this renderer
+ *
+ * Renderer with higher depth indices are rendered in front of other renderers with smaller values
+ *
+ * @param[in] depthIndex The depth index of this renderer
+ */
+ void SetDepthIndex( int depthIndex );
+
+ //@todo No interface to remove geometry / material? I guess you have to throw away
+ // this renderer if you don't want it to work any more...
+
+ /**
+ * @brief Get the depth index of this renderer
+ *
+ * @sa SetDepthIndex()
+ * @return the depth index
+ */
+ int GetDepthIndex();
+
+public:
+ /**
+ * @brief The constructor
+ *
+ * @param [in] pointer A pointer to a newly allocated Renderer
+ */
+ explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer );
+};
+
+} //namespace Dali
+
+#endif // DALI_RENDERER_H
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/actors/renderable-actor.h>
+#include <dali/public-api/actors/renderer.h>
#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/animation/alpha-function.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/geometry/geometry.h>
#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/images/encoded-buffer-image.h>
#include <dali/public-api/images/frame-buffer-image.h>
#include <dali/public-api/signals/signal-slot-observers.h>
#include <dali/public-api/signals/slot-delegate.h>
+#include <dali/public-api/shader-effects/material.h>
+#include <dali/public-api/shader-effects/sampler.h>
+#include <dali/public-api/shader-effects/shader.h>
#include <dali/public-api/shader-effects/shader-effect.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
$(public_api_src_dir)/actors/custom-actor-impl.cpp \
$(public_api_src_dir)/actors/image-actor.cpp \
$(public_api_src_dir)/actors/layer.cpp \
+ $(public_api_src_dir)/actors/renderer.cpp \
$(public_api_src_dir)/actors/renderable-actor.cpp \
$(public_api_src_dir)/animation/animation.cpp \
$(public_api_src_dir)/animation/alpha-function.cpp \
$(public_api_src_dir)/events/tap-gesture-detector.cpp \
$(public_api_src_dir)/events/touch-point.cpp \
$(public_api_src_dir)/events/touch-event.cpp \
+ $(public_api_src_dir)/geometry/geometry.cpp \
$(public_api_src_dir)/images/image.cpp \
$(public_api_src_dir)/images/pixel.cpp \
$(public_api_src_dir)/images/buffer-image.cpp \
$(public_api_src_dir)/object/object-registry.cpp \
$(public_api_src_dir)/object/property.cpp \
$(public_api_src_dir)/object/property-array.cpp \
+ $(public_api_src_dir)/object/property-buffer.cpp \
$(public_api_src_dir)/object/property-conditions.cpp \
$(public_api_src_dir)/object/property-input.cpp \
$(public_api_src_dir)/object/property-map.cpp \
$(public_api_src_dir)/object/ref-object.cpp \
$(public_api_src_dir)/render-tasks/render-task.cpp \
$(public_api_src_dir)/render-tasks/render-task-list.cpp \
+ $(public_api_src_dir)/shader-effects/material.cpp \
+ $(public_api_src_dir)/shader-effects/sampler.cpp \
+ $(public_api_src_dir)/shader-effects/shader.cpp \
$(public_api_src_dir)/shader-effects/shader-effect.cpp \
$(public_api_src_dir)/signals/callback.cpp \
$(public_api_src_dir)/signals/connection-tracker.cpp \
$(public_api_src_dir)/actors/image-actor.h \
$(public_api_src_dir)/actors/layer.h \
$(public_api_src_dir)/actors/renderable-actor.h \
+ $(public_api_src_dir)/actors/renderer.h \
$(public_api_src_dir)/actors/sampling.h
public_api_core_animation_header_files = \
$(public_api_src_dir)/events/touch-point.h \
$(public_api_src_dir)/events/touch-event.h
+public_api_core_geometry_header_files = \
+ $(public_api_src_dir)/geometry/geometry.h
+
public_api_core_images_header_files = \
$(public_api_src_dir)/images/buffer-image.h \
$(public_api_src_dir)/images/encoded-buffer-image.h \
$(public_api_src_dir)/object/handle.h \
$(public_api_src_dir)/object/object-registry.h \
$(public_api_src_dir)/object/property-array.h \
+ $(public_api_src_dir)/object/property-buffer.h \
$(public_api_src_dir)/object/property-conditions.h \
$(public_api_src_dir)/object/property-index-ranges.h \
$(public_api_src_dir)/object/property-input.h \
$(public_api_src_dir)/render-tasks/render-task-list.h
public_api_core_shader_effects_header_files = \
+ $(public_api_src_dir)/shader-effects/material.h \
+ $(public_api_src_dir)/shader-effects/sampler.h \
+ $(public_api_src_dir)/shader-effects/shader.h \
$(public_api_src_dir)/shader-effects/shader-effect.h
public_api_core_size_negotiation_header_files = \
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/geometry/geometry.h> // Dali::Geometry
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/geometry/geometry-impl.h> // Dali::Internal::Geometry
+
+namespace Dali
+{
+
+Geometry Geometry::New()
+{
+ Internal::GeometryPtr geometry = Internal::Geometry::New();
+ return Geometry( geometry.Get() );
+}
+
+Geometry::Geometry()
+{
+}
+
+Geometry::~Geometry()
+{
+}
+
+Geometry::Geometry( const Geometry& handle )
+: Handle( handle )
+{
+}
+
+Geometry Geometry::DownCast( BaseHandle handle )
+{
+ return Geometry( dynamic_cast<Dali::Internal::Geometry*>(handle.GetObjectPtr()));
+}
+
+Geometry& Geometry::operator=( const Geometry& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer )
+{
+ DALI_ASSERT_ALWAYS( vertexBuffer && "VertexBuffer is not initialized ");
+ return GetImplementation(*this).AddVertexBuffer( GetImplementation( vertexBuffer ) );
+}
+
+std::size_t Geometry::GetNumberOfVertexBuffers() const
+{
+ return GetImplementation(*this).GetNumberOfVertexBuffers();
+}
+
+void Geometry::RemoveVertexBuffer( std::size_t index )
+{
+ GetImplementation(*this).RemoveVertexBuffer( index );
+}
+
+void Geometry::SetIndexBuffer( PropertyBuffer& indexBuffer )
+{
+ DALI_ASSERT_ALWAYS( indexBuffer && "indexBuffer is not initialized ");
+ GetImplementation(*this).SetIndexBuffer( GetImplementation( indexBuffer ) );
+}
+
+void Geometry::SetGeometryType( GeometryType geometryType )
+{
+ GetImplementation(*this).SetGeometryType( geometryType );
+}
+
+Geometry::GeometryType Geometry::GetGeometryType() const
+{
+ return GetImplementation(*this).GetGeometryType();
+}
+
+void Geometry::SetRequiresDepthTesting( bool requiresDepthTest )
+{
+ GetImplementation(*this).SetRequiresDepthTesting( requiresDepthTest );
+}
+
+bool Geometry::GetRequiresDepthTesting() const
+{
+ return GetImplementation(*this).GetRequiresDepthTesting();
+}
+
+Geometry::Geometry( Internal::Geometry* pointer )
+: Handle( pointer )
+{
+}
+
+} //namespace Dali
--- /dev/null
+#ifndef DALI_GEOMETRY_H
+#define DALI_GEOMETRY_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstddef> // std::size_t
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/object/property-buffer.h> // Dali::PropertyBuffer
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class Geometry;
+}
+
+/**
+ * @brief Geometry is handle to an object that can be used to define a geometric elements.
+ */
+class DALI_IMPORT_API Geometry : public Handle
+{
+public:
+
+ enum GeometryType
+ {
+ POINTS,
+ LINES,
+ LINE_LOOP,
+ LINE_STRIP,
+ TRIANGLES,
+ TRIANGLE_FAN,
+ TRIANGLE_STRIP
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the Geometry class.
+ */
+ struct Property
+ {
+ enum
+ {
+ GEOMETRY_TYPE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depth-index", type STRING
+ GEOMETRY_CENTER, ///< name "geometry-center", type VECTOR3
+ GEOMETRY_HALF_EXTENTS, ///< name "geometry-half-extents", type VECTOR3
+ REQUIRES_DEPTH_TEST, ///< name "requires-depth-testing", type BOOLEAN
+ };
+ };
+
+ /**
+ * @brief Creates a new Geometry object
+ *
+ * @return An handle to a newly allocated Geometry
+ */
+ static Geometry New();
+
+ /**
+ * @brief Default constructor, creates an empty handle
+ */
+ Geometry();
+
+ /**
+ * @brief Destructor
+ */
+ ~Geometry();
+
+ /**
+ * @brief Copy constructor, creates a new handle to the same object
+ *
+ * @param[in] handle Handle to an object
+ */
+ Geometry( const Geometry& handle );
+
+ /**
+ * @brief Downcast to a geometry.
+ *
+ * If not the returned handle is left uninitialized.
+ * @param[in] handle to an object
+ * @return geometry handle or an uninitialized handle
+ */
+ static Geometry DownCast( BaseHandle handle );
+
+ /**
+ * @brief Assignment operator, changes this handle to point at the same object
+ *
+ * @param[in] handle Handle to an object
+ * @return Reference to the assigned object
+ */
+ Geometry& operator=( const Geometry& handle );
+
+ /**
+ * @brief Add a PropertyBuffer to be used as source of geometry vertices
+ *
+ * @param[in] vertexBuffer PropertyBuffer to be used as source of geometry vertices
+ * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
+ * this buffer if no longer required
+ */
+ std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
+
+ /**
+ * @brief Retrieve the number of vertex buffers that have been added to this geometry
+ *
+ * @return Number of vertex buffers that have been added to this geometry
+ */
+ std::size_t GetNumberOfVertexBuffers() const;
+
+ /**
+ * @brief Remove a vertex buffer
+ *
+ * The index must be between 0 and GetNumberOfVertexBuffers()
+ *
+ * @param[in] index Index to the vertex buffer to remove
+ */
+ void RemoveVertexBuffer( std::size_t index );
+
+ /**
+ * @brief Set a PropertyBuffer to be used as a source of indices for the geometry
+ *
+ * This buffer is required to have exactly one component and it must be of the type Property::INTEGER
+ *
+ * By setting this buffer the will case the geometry to be rendered using indices.
+ * To unset call SetIndexBuffer with an empty handle.
+ *
+ * @param[in] indexBuffer PropertyBuffer to be used as a source of indices for the geometry
+ */
+ void SetIndexBuffer( PropertyBuffer& indexBuffer );
+
+ /**
+ * @brief Set the type of primitives this geometry contains
+ *
+ * @param[in] geometryType Type of primitives this geometry contains
+ */
+ void SetGeometryType( GeometryType geometryType );
+
+ /**
+ * @brief Get the type of primitives this geometry contains
+ *
+ * Calling this function sets the property GEOMETRY_TYPE
+ *
+ * @return Type of primitives this geometry contains
+ */
+ GeometryType GetGeometryType() const;
+
+ /**
+ * @brief Set if the geometry requires depth testing
+ *
+ * Should be set to true if this geometry has overlapping triangles in arbitrary order
+ *
+ * Calling this function is equivalent to setting the REQUIRES_DEPTH_TESTING property
+ *
+ * @param[in] requiresDepthTest Specifies if the geometry requires depth testing
+ */
+ void SetRequiresDepthTesting( bool requiresDepthTest );
+
+ /**
+ * @brief Return if the geometry requires depth testing
+ *
+ * @return True if the geometry requires depth testing
+ */
+ bool GetRequiresDepthTesting() const;
+
+public:
+ /**
+ * @brief The constructor
+ *
+ * @param [in] pointer A pointer to a newly allocated Geometry
+ */
+ explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
+};
+
+} //namespace Dali
+
+#endif // DALI_GEOMETRY_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/object/property-buffer.h> // Dali::PropertyBuffer
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/property-map.h> // Dali::Property::Map
+#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
+
+namespace Dali
+{
+
+PropertyBuffer PropertyBuffer::New( Dali::Property::Map& bufferFormat, std::size_t size )
+{
+ Internal::PropertyBufferPtr propertyBuffer = Internal::PropertyBuffer::New();
+
+ propertyBuffer->SetFormat( bufferFormat );
+ propertyBuffer->SetSize( size );
+
+ return PropertyBuffer( propertyBuffer.Get() );
+}
+
+PropertyBuffer::PropertyBuffer()
+{
+}
+
+PropertyBuffer::~PropertyBuffer()
+{
+}
+
+PropertyBuffer::PropertyBuffer( const PropertyBuffer& handle )
+: Handle( handle )
+{
+}
+
+PropertyBuffer PropertyBuffer::DownCast( BaseHandle handle )
+{
+ return PropertyBuffer( dynamic_cast<Dali::Internal::PropertyBuffer*>(handle.GetObjectPtr()));
+}
+
+PropertyBuffer& PropertyBuffer::operator=( const PropertyBuffer& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+void PropertyBuffer::SetSize( std::size_t size )
+{
+ GetImplementation(*this).SetSize( size );
+}
+
+std::size_t PropertyBuffer::GetSize() const
+{
+ return GetImplementation(*this).GetSize();
+}
+
+void PropertyBuffer::SetData( void* data )
+{
+ GetImplementation(*this).SetData( data );
+}
+
+PropertyBuffer::PropertyBuffer( Internal::PropertyBuffer* pointer )
+: Handle( pointer )
+{
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_PROPERTY_BUFFER_H
+#define DALI_PROPERTY_BUFFER_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstddef> // std::size_t
+#include <string> // std::string
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/object/property.h> // Dali::Property::Index
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+#include <dali/public-api/object/property-map.h> // Dali::Property::Map
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class PropertyBuffer;
+}
+
+/**
+ * @brief PropertyBuffer is a handle to an object that contains a buffer of structured properties
+ *
+ * PropertyBuffers can be used to provide data to Geometry objects.
+ *
+ * Example:
+ *
+ * const float halfQuadSize = .5f;
+ * struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
+ * TexturedQuadVertex texturedQuadVertexData[4] = {
+ * { Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
+ * { Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
+ * { Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
+ * { Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
+ *
+ * Property::Map texturedQuadVertexFormat;
+ * texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
+ * texturedQuadVertexFormat["aTexCoord"] = Property::VECTOR2;
+ * PropertyBuffer texturedQuadVertices = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
+ * texturedQuadVertices.SetData(texturedQuadVertexData);
+ *
+ * // Create indices
+ * unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
+ * Property::Map indexFormat;
+ * indexFormat["indices"] = Property::UNSIGNED_INTEGER;
+ * PropertyBuffer indices = PropertyBuffer::New( indexFormat, 6 );
+ * indices.SetData(indexData);
+ *
+ * // Create the geometry object
+ * Geometry texturedQuadGeometry = Geometry::New();
+ * texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
+ * texturedQuadGeometry.SetIndexBuffer( indices );
+ *
+ */
+class DALI_IMPORT_API PropertyBuffer : public Handle
+{
+public:
+
+ /**
+ * @brief An enumeration of properties belonging to the PropertyBuffer class.
+ */
+ struct Property
+ {
+ enum
+ {
+ SIZE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "size", type UNSIGNED_INT
+ BUFFER_FORMAT, ///< name "buffer-format", type MAP
+ };
+ };
+
+ /**
+ * @brief Create a PropertyBuffer
+ *
+ * Static property buffers use less memory.
+ *
+ * @param[in] bufferFormat Map of names and types that describes the components of the buffer
+ * @param[in] size The number of elements in the property buffer
+ * @return Handle to a newly allocated PropertyBuffer
+ */
+ static PropertyBuffer New( Dali::Property::Map& bufferFormat, std::size_t size );
+
+ /**
+ * @brief Default constructor, creates an empty handle
+ */
+ PropertyBuffer();
+
+ /**
+ * @brief Destructor
+ */
+ ~PropertyBuffer();
+
+ /**
+ * @brief Copy constructor, creates a new handle to the same object
+ *
+ * @param[in] handle Handle to an object
+ */
+ PropertyBuffer( const PropertyBuffer& handle );
+
+ /**
+ * @brief Downcast to a property buffer handle.
+ *
+ * If not a property buffer the returned property buffer handle is left uninitialized.
+ * @param[in] handle to an object
+ * @return property buffer handle or an uninitialized handle
+ */
+ static PropertyBuffer DownCast( BaseHandle handle );
+
+ /**
+ * @brief Assignment operator, changes this handle to point at the same object
+ *
+ * @param[in] handle Handle to an object
+ * @return Reference to the assigned object
+ */
+ PropertyBuffer& operator=( const PropertyBuffer& handle );
+
+ /**
+ * @brief Set the number of elements in the buffer
+ *
+ * Calling this function is equivalent to setting the property SIZE
+ *
+ * @param[in] size Number of elements to expand or contract the buffer
+ */
+ void SetSize( std::size_t size );
+
+ /**
+ * @brief Get the number of elements in the buffer
+ *
+ * @return Number of elements to expand or contract the buffer
+ */
+ std::size_t GetSize() const;
+
+ /**
+ * @brief Update the whole buffer information
+ *
+ * This function expects a pointer to an array of structures with the same
+ * format that was given in the construction, and the number of elements to
+ * be the sane as the size of the buffer.
+ *
+ * If the initial structure was: { { "position", VECTOR3}, { "uv", VECTOR2 } }
+ * and a size of 10 elements, this function should be called with a pointer equivalent to:
+ * <pre>
+ * struct Vertex {
+ * Dali::Vector3 position;
+ * Dali::Vector2 uv;
+ * };
+ * Vertex vertices[ 10 ] = { ... };
+ * propertyBuffer.SetData( vertices );
+ * </pre>
+ *
+ * @param[in] data A pointer to the data that will be copied to the buffer.
+ */
+ void SetData( void* data );
+
+public:
+ /**
+ * @brief The constructor
+ *
+ * @param [in] pointer A pointer to a newly allocated PropertyBuffer
+ */
+ explicit DALI_INTERNAL PropertyBuffer( Internal::PropertyBuffer* pointer );
+};
+
+} // namespace Dali
+
+#endif // DALI_PROPERTY_BUFFER_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/shader-effects/material.h> // Dali::Material
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/effects/material-impl.h> // Dali::Internal::Material
+#include <dali/internal/event/effects/sampler-impl.h> // Dali::Internal::Sampler
+#include <dali/internal/event/effects/shader-impl.h> // Dali::Internal::Shader
+
+namespace Dali
+{
+
+Material Material::New( Shader shader )
+{
+ // TODO: MESH_REWORK
+ Internal::MaterialPtr material = Internal::Material::New();
+ material->SetShader( GetImplementation(shader) );
+
+ return Material( material.Get() );
+}
+
+Material::Material()
+{
+}
+
+Material::~Material()
+{
+}
+
+Material::Material( const Material& handle )
+: Handle( handle )
+{
+}
+
+Material Material::DownCast( BaseHandle handle )
+{
+ return Material( dynamic_cast<Dali::Internal::Material*>(handle.GetObjectPtr()));
+}
+
+Material& Material::operator=( const Material& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+void Material::SetShader( Shader& shader )
+{
+ DALI_ASSERT_ALWAYS( shader && "Shader handle is uninitialized" );
+ GetImplementation(*this).SetShader( GetImplementation( shader ) );
+}
+
+Shader Material::GetShader() const
+{
+ Internal::Shader* shaderPtr( GetImplementation(*this).GetShader() );
+ return Dali::Shader( shaderPtr );
+}
+
+void Material::AddSampler( Sampler& sampler )
+{
+ DALI_ASSERT_ALWAYS( sampler && "Sampler handle is uninitialized" );
+ GetImplementation(*this).AddSampler( GetImplementation( sampler ) );
+}
+
+std::size_t Material::GetNumberOfSamplers() const
+{
+ return GetImplementation(*this).GetNumberOfSamplers();
+}
+
+void Material::RemoveSampler( std::size_t index )
+{
+ GetImplementation(*this).RemoveSampler( index );
+}
+
+Sampler Material::GetSamplerAt( unsigned int index ) const
+{
+ Internal::Sampler* samplerPtr( GetImplementation(*this).GetSamplerAt(index) );
+ return Dali::Sampler( samplerPtr );
+}
+
+void Material::SetFaceCullingMode( FaceCullingMode cullingMode )
+{
+ GetImplementation(*this).SetFaceCullingMode( cullingMode );
+}
+
+void Material::SetBlendMode( BlendingMode::Type mode )
+{
+ GetImplementation(*this).SetBlendMode( mode );
+}
+
+BlendingMode::Type Material::GetBlendMode() const
+{
+ return GetImplementation(*this).GetBlendMode();
+}
+
+void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba,
+ BlendingFactor::Type destFactorRgba )
+{
+ GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba );
+}
+
+void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
+ BlendingFactor::Type destFactorRgb,
+ BlendingFactor::Type srcFactorAlpha,
+ BlendingFactor::Type destFactorAlpha )
+{
+ GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+}
+
+void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
+ BlendingFactor::Type& destFactorRgb,
+ BlendingFactor::Type& srcFactorAlpha,
+ BlendingFactor::Type& destFactorAlpha ) const
+{
+ GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+}
+
+void Material::SetBlendEquation( BlendingEquation::Type equationRgba )
+{
+ GetImplementation(*this).SetBlendEquation( equationRgba );
+}
+
+void Material::SetBlendEquation( BlendingEquation::Type equationRgb,
+ BlendingEquation::Type equationAlpha )
+{
+ GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha );
+}
+
+void Material::GetBlendEquation( BlendingEquation::Type& equationRgb,
+ BlendingEquation::Type& equationAlpha ) const
+{
+ GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha );
+}
+
+void Material::SetBlendColor( const Vector4& color )
+{
+ GetImplementation(*this).SetBlendColor( color );
+}
+
+const Vector4& Material::GetBlendColor() const
+{
+ return GetImplementation(*this).GetBlendColor();
+}
+
+Material::Material( Internal::Material* pointer )
+: Handle( pointer )
+{
+}
+
+} //namespace Dali
--- /dev/null
+#ifndef DALI_MATERIAL_H
+#define DALI_MATERIAL_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstddef> // std::size_t
+#include <string> // std::string
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/blending.h> // Dali::BlendingMode, Dali::BlendingEquation, Dali::BlendingFactor
+#include <dali/public-api/images/image.h> // Dali::Image
+#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+#include <dali/public-api/shader-effects/sampler.h> // Dali::Sampler
+#include <dali/public-api/shader-effects/shader.h> // Dali::Shader
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class Material;
+}
+
+/**
+ * @brief Material is a handle to an object that specifies the visual properties of the renderer.
+ */
+class DALI_IMPORT_API Material : public Handle
+{
+public:
+
+ /**
+ * @brief Set face culling mode.
+ */
+ enum FaceCullingMode
+ {
+ NONE, ///< None of the faces should be culled
+ CULL_BACK, ///< Cull back face, back face should never be shown
+ CULL_BACK_HINT, ///< Cull back face hinting, will still display correctly if no culling is done
+ CULL_FRONT, ///< Cull front face, back face should never be shown
+ CULL_FRONT_HINT, ///< Cull front face hinting, will still display correctly if no culling is done
+ CULL_BACK_AND_FRONT, ///< Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
+ CULL_BACK_AND_FRONT_HINT, ///< Cull back and front hint, will still display correctly if no culling is done
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the Material class.
+ */
+ struct Property
+ {
+ enum
+ {
+ COLOR = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "color", type VECTOR4
+ FACE_CULLING_MODE, ///< name "face-culling-mode", type STRING
+ BLENDING_MODE, ///< name "blending-mode", type STRING
+ BLEND_EQUATION_RGB, ///< name "blend-equation-rgb", type STRING
+ BLEND_EQUATION_ALPHA, ///< name "blend-equation-alpha", type STRING
+ BLENDING_SRC_FACTOR_RGB, ///< name "source-blend-factor-rgb", type STRING
+ BLENDING_DEST_FACTOR_RGB, ///< name "destination-blend-factor-rgb", type STRING
+ BLENDING_SRC_FACTOR_ALPHA, ///< name "source-blend-factor-alpha", type STRING
+ BLENDING_DEST_FACTOR_ALPHA, ///< name "destination-blend-factor-alpha", type STRING
+ BLEND_COLOR, ///< name "blend-color", type VECTOR4
+ };
+ };
+
+ /// @name Uniform Mapping
+ /** @{ */
+ ///< property "COLOR", uniform "uMaterialColor"
+ /** @} */
+
+ /**
+ * @brief Creates a new Material object
+ *
+ * @return A handle to a newly allocated Material
+ */
+ static Material New( Shader shader );
+
+ /**
+ * @brief Default constructor, creates an empty handle
+ */
+ Material();
+
+ /**
+ * @brief Destructor
+ */
+ ~Material();
+
+ /**
+ * @brief Copy constructor, creates a new handle to the same object
+ *
+ * @param[in] handle Handle to an object
+ */
+ Material( const Material& handle );
+
+ /**
+ * @brief Downcast to a material handle.
+ *
+ * If handle is not a material, the returned handle is left uninitialized.
+ * @param[in] handle to an object
+ * @return material handle or an uninitialized handle
+ */
+ static Material DownCast( BaseHandle handle );
+
+ /**
+ * @brief Assignment operator, changes this handle to point at the same object
+ *
+ * @param[in] handle Handle to an object
+ */
+ Material& operator=( const Material& handle );
+
+ /**
+ * @brief Sets the Shader used by this material
+ *
+ * @param[in] shader Handle to a shader
+ */
+ void SetShader( Shader& shader );
+
+ /**
+ * @brief Gets the shader used by this material
+ *
+ * @return The shader used by the material
+ */
+ Shader GetShader() const;
+
+ /**
+ * @brief Add a sampler to this material
+ *
+ * param[in] sampler The sampler to add to this material
+ */
+ void AddSampler( Sampler& sampler );
+
+ /**
+ * @brief Get the number of samplers
+ *
+ * @return The number of samplers
+ */
+ std::size_t GetNumberOfSamplers() const;
+
+ /**
+ * @brief Remove a sampler
+ *
+ * The index must be between 0 and GetNumberOfSamplers()-1
+ *
+ * @param[in] index The index of the sampler to remove
+ */
+ void RemoveSampler( std::size_t index );
+
+ /**
+ * @brief Get the sampler at the given index for this material
+ *
+ * The index must be between 0 and GetNumberOfSamplers()-1
+ *
+ * @param[in] index The index of the sampler
+ * @return The sampler at that index
+ */
+ Sampler GetSamplerAt( unsigned int index ) const;
+
+ /**
+ * @brief Set the culling mode for this material
+ *
+ * Calling this function sets the properties CULLING_MODE
+ *
+ * @param[in] cullingMode The culling mode for this material
+ */
+ void SetFaceCullingMode( FaceCullingMode cullingMode );
+
+ /**
+ * @brief Sets the blending mode.
+ *
+ * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
+ *
+ * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work.
+ *
+ * <ul>
+ * <li> \e OFF Blending is disabled.
+ * <li> \e AUTO Blending is enabled only if the renderable actor has alpha channel.
+ * <li> \e ON Blending is enabled.
+ * </ul>
+ *
+ * @param[in] mode The blending mode.
+ */
+ void SetBlendMode( BlendingMode::Type mode );
+
+ /**
+ * @brief Retrieves the blending mode.
+ *
+ * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON.
+ */
+ BlendingMode::Type GetBlendMode() const;
+
+ /**
+ * @brief Specify the pixel arithmetic used when the actor is blended.
+ *
+ * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
+ *
+ * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
+ */
+ void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
+
+ /**
+ * @brief Specify the pixel arithmetic used when the actor is blended.
+ *
+ * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
+ *
+ * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
+ *
+ * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
+ * The options are the same as for srcFactorRgb.
+ *
+ * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
+ * The options are the same as for destFactorRgb.
+ */
+ void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
+ BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
+
+ /**
+ * @brief Query the pixel arithmetic used when the actor is blended.
+ *
+ * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
+ * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
+ * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ */
+ void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
+ BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
+
+ /**
+ * @brief Specify the equation used when the actor is blended.
+ *
+ * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
+ * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
+ */
+ void SetBlendEquation( BlendingEquation::Type equationRgba );
+
+ /**
+ * @brief Specify the equation used when the actor is blended.
+ *
+ * @param[in] equationRgb The equation used for combining red, green, and blue components.
+ * @param[in] equationAlpha The equation used for combining the alpha component.
+ * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
+ */
+ void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
+
+ /**
+ * @brief Query the equation used when the actor is blended.
+ *
+ * @param[out] equationRgb The equation used for combining red, green, and blue components.
+ * @param[out] equationAlpha The equation used for combining the alpha component.
+ */
+ void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
+
+ /**
+ * @brief Specify the color used when the actor is blended; the default is Vector4::ZERO.
+ *
+ * @param[in] color The blend color.
+ */
+ void SetBlendColor( const Vector4& color );
+
+ /**
+ * @brief Query the color used when the actor is blended.
+ *
+ * @return The blend color.
+ */
+ const Vector4& GetBlendColor() const;
+
+public:
+ /**
+ * @brief The constructor
+ *
+ * @param [in] pointer A pointer to a newly allocated Material
+ */
+ explicit DALI_INTERNAL Material( Internal::Material* pointer );
+};
+
+} //namespace Dali
+
+
+
+#endif // DALI_MATERIAL_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/shader-effects/sampler.h> // Dali::Sampler
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/effects/sampler-impl.h> // Dali::Internal::Sampler
+
+namespace Dali
+{
+
+Sampler Sampler::New( Image& image, const std::string& textureUnitUniformName )
+{
+ Internal::SamplerPtr sampler = Internal::Sampler::New(textureUnitUniformName);
+ Internal::ImagePtr imagePtr = &GetImplementation( image );
+ sampler->SetImage( imagePtr );
+ return Sampler( sampler.Get() );
+}
+
+Sampler::Sampler()
+{
+}
+
+Sampler::~Sampler()
+{
+}
+
+Sampler::Sampler( const Sampler& handle )
+: Handle( handle )
+{
+}
+
+Sampler Sampler::DownCast( BaseHandle handle )
+{
+ return Sampler( dynamic_cast<Dali::Internal::Sampler*>(handle.GetObjectPtr()));
+}
+
+Sampler& Sampler::operator=( const Sampler& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+void Sampler::SetUniformName( const std::string& name )
+{
+ GetImplementation(*this).SetTextureUnitUniformName( name );
+}
+
+void Sampler::SetImage( Image& image )
+{
+ Internal::ImagePtr imagePtr = &GetImplementation( image );
+ GetImplementation(*this).SetImage( imagePtr );
+}
+
+Image Sampler::GetImage() const
+{
+ Internal::ImagePtr imagePtr( GetImplementation(*this).GetImage() );
+ return Dali::Image( imagePtr.Get() );
+}
+
+void Sampler::SetFilterMode( FilterMode minFilter, FilterMode magFilter )
+{
+ GetImplementation(*this).SetFilterMode( minFilter, magFilter );
+}
+
+void Sampler::SetWrapMode( WrapMode uWrap, WrapMode vWrap )
+{
+ GetImplementation(*this).SetWrapMode( uWrap, vWrap );
+}
+
+void Sampler::SetAffectsTransparency( bool affectsTransparency )
+{
+ GetImplementation(*this).SetAffectsTransparency( affectsTransparency );
+}
+
+Sampler::Sampler(Internal::Sampler* pointer)
+: Handle( pointer )
+{
+}
+
+} //namespace Dali
--- /dev/null
+#ifndef DALI_SAMPLER_H
+#define DALI_SAMPLER_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstddef> // std::size_t
+#include <string> // std::string
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/images/image.h> // Dali::Image
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class Sampler;
+}
+
+/**
+ * @brief Sampler is a handle to an object that can be used to provide an image to a material.
+ */
+class DALI_IMPORT_API Sampler : public Handle
+{
+public:
+
+ /**
+ * @brief Texture filter mode.
+ */
+ enum FilterMode
+ {
+ NONE, ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
+ DEFAULT, ///< Use dali defaults (minification LINEAR, magnification LINEAR)
+ NEAREST, ///< Filter nearest
+ LINEAR ///< Filter linear
+ };
+
+ /**
+ * @brief Texture wrap mode.
+ */
+ enum WrapMode
+ {
+ CLAMP_TO_EDGE, ///< The texture coordinates get clamped to the range [0, 1]
+ REPEAT, ///< Only the fractional part of the texture coordinates is used
+ MIRRORED_REPEAT, ///< If the integer part of the texture coordinate is odd then it uses
+ ///< the fractional part, if it's even it uses 1 - the fractional part
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the Sampler class.
+ */
+ struct Property
+ {
+ enum
+ {
+ MINIFICATION_FILTER = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "minification-filter", type STRING
+ MAGNIGICATION_FILTER, ///< name "magnification-filter", type STRING
+ U_WRAP, ///< name "u-wrap", type STRING
+ V_WRAP, ///< name "v-wrap", type STRING
+ AFFECTS_TRANSPARENCY, ///< name "affects-transparency", type BOOLEAN
+ };
+ };
+
+ /**
+ * @brief Creates a new Sampler object
+ *
+ * @param[in] image Image used by this sampler
+ * @param[in] uniformName String with the name of the uniform
+ */
+ static Sampler New( Image& image, const std::string& uniformName );
+
+ /**
+ * @brief Default constructor, creates an empty handle
+ */
+ Sampler();
+
+ /**
+ * @brief Destructor
+ */
+ ~Sampler();
+
+ /**
+ * @brief Copy constructor, creates a new handle to the same object
+ *
+ * @param[in] handle Handle to an object
+ */
+ Sampler( const Sampler& handle );
+
+ /**
+ * @brief Downcast to a sampler handle.
+ *
+ * If not the returned handle is left uninitialized.
+ * @param[in] handle to An object
+ * @return handle or an uninitialized handle
+ */
+ static Sampler DownCast( BaseHandle handle );
+
+ /**
+ * @brief Assignment operator, changes this handle to point at the same object
+ *
+ * @param[in] handle Handle to an object
+ * @return Reference to the assigned object
+ */
+ Sampler& operator=( const Sampler& handle );
+
+ /**
+ * @brief Sets the name of the shader uniform that will use this sampler
+ *
+ * @param[in] name String with the name of the uniform
+ */
+ void SetUniformName( const std::string& name );
+
+ /**
+ * @brief Set the image used by this sampler
+ *
+ * @param[in] image Image used by this sampler
+ */
+ void SetImage( Image& image );
+
+ /**
+ * @brief Retrieve the image used by this sampler
+ *
+ * If no image is assigned, an empty handle is returned
+ * @return The image.
+ */
+ Image GetImage() const;
+
+ /**
+ * @brief Set the filter modes for this sampler
+ *
+ * Calling this function sets the properties MINIFICATION_FILTER
+ * and MAGNIFICATION_FILTER
+ *
+ * @param[in] minFilter The minification filter that will be used
+ * @param[in] magFilter The magnification filter that will be used
+ */
+ void SetFilterMode( FilterMode minFilter, FilterMode magFilter );
+
+ /**
+ * @brief Set the wrap modes for this sampler
+ *
+ * Calling this function sets the properties U_WRAP and V_WRAP
+ *
+ * param[in] uWrap Wrap mode for u coordinates
+ * param[in] vWrap Wrap mode for v coordinates
+ */
+ void SetWrapMode( WrapMode uWrap, WrapMode vWrap );
+
+ /**
+ * @brief Set if this sampler should be considered for opacity hinting
+ *
+ * Calling this function sets the property AFFECTS_TRANSPARENCY
+ *
+ * param[in] affectsTransparency Specifies if this sampler should be considered for opacity hinting
+ */
+ void SetAffectsTransparency( bool affectsTransparency );
+
+public:
+ /**
+ * @brief The constructor
+ *
+ * @param [in] pointer A pointer to a newly allocated Sampler
+ */
+ explicit DALI_INTERNAL Sampler( Internal::Sampler* pointer );
+};
+
+} //namespace Dali
+
+#endif // DALI_SAMPLER_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/shader-effects/shader.h> // Dali::Shader
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/effects/shader-impl.h> // Dali::Internal::Shader
+
+namespace Dali
+{
+
+Shader Shader::New( const std::string& vertexShader,
+ const std::string& fragmentShader,
+ ShaderHints hints )
+{
+ Internal::ShaderPtr renderer = Internal::Shader::New( vertexShader, fragmentShader, hints );
+ return Shader( renderer.Get() );
+}
+
+Shader::Shader()
+{
+}
+
+Shader::~Shader()
+{
+}
+
+Shader::Shader( const Shader& handle )
+: Handle( handle )
+{
+}
+
+Shader Shader::DownCast( BaseHandle handle )
+{
+ return Shader( dynamic_cast<Dali::Internal::Shader*>(handle.GetObjectPtr()));
+}
+
+Shader& Shader::operator=( const Shader& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+Shader::Shader( Internal::Shader* pointer )
+: Handle( pointer )
+{
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_SHADER_H
+#define DALI_SHADER_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string> // std::string
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+
+/**
+ * @brief DALI_COMPOSE_SHADER macro provides a convenient way to write shader source code.
+ *
+ * We normally use double quotation marks to write a string such as "Hello World".
+ * However many symbols are needed to add multiple lines of string.
+ * We don't need to write quotation marks using this macro at every line.
+ *
+ * [An example of double quotation marks usage]
+ * <pre>
+ * const string FRAGMENT_SHADER_SOURCE = \
+ * " void main()\n"
+ * " {\n"
+ * " gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
+ * " }\n";
+ * </pre><br/>
+ * [An example of DALI_COMPOSE_SHADER usage]
+ * <pre>
+ * const string VERTEX_SHADER_SOURCE = DALI_COMPOSE_SHADER (
+ * void main()
+ * {
+ * gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);
+ * vTexCoord = aTexCoord;
+ * }
+ * );
+ * </pre>
+ */
+#define DALI_COMPOSE_SHADER(STR) #STR
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class Shader;
+}
+
+/**
+ * @brief Shaders allows custom vertex and color transformations in the GPU
+ */
+class DALI_IMPORT_API Shader : public Handle
+{
+public:
+ /**
+ * @brief Hints for rendering/subdividing geometry.
+ */
+ enum ShaderHints
+ {
+ HINT_NONE = 0x00, ///< no hints
+ HINT_REQUIRES_SELF_DEPTH_TEST = 0x01, ///< Expects depth testing enabled
+ HINT_OUTPUT_IS_TRANSPARENT = 0x02, ///< Might generate transparent alpha from opaque inputs
+ HINT_OUTPUT_IS_OPAQUE = 0x04, ///< Outputs opaque colors even if the inputs are transparent
+ HINT_MODIFIES_GEOMETRY = 0x08, ///< Might change position of vertices,
+ ///< this option disables any culling optimizations
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the Shader class.
+ */
+ struct Property
+ {
+ enum
+ {
+ PROGRAM = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "program", type MAP; {"vertex-prefix":"","fragment-prefix":"","vertex":"","fragment":""}
+ SHADER_HINTS, ///< name "shader-hints", type UNSIGNED_INTEGER; (bitfield) values from enum Shader::Hints
+ };
+ };
+
+ /**
+ * @brief Create Shader.
+ *
+ * @param vertexShader code for the effect. If you pass in an empty string, the default version will be used
+ * @param fragmentShader code for the effect. If you pass in an empty string, the default version will be used
+ * @param hints GeometryHints to define the geometry of the rendered object
+ * @return A handle to a shader effect
+ */
+ static Shader New( const std::string& vertexShader,
+ const std::string& fragmentShader,
+ ShaderHints hints = ShaderHints(HINT_NONE) );
+
+ /**
+ * @brief Default constructor, creates an empty handle
+ */
+ Shader();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Shader();
+
+ /**
+ * @brief Copy constructor
+ *
+ * @param handle A handle to a Shader object
+ */
+ Shader( const Shader& handle );
+
+ /**
+ * @brief Downcast to a shader handle.
+ *
+ * If not a shader the returned shader handle is left uninitialized.
+ * @param[in] handle to an object
+ * @return shader handle or an uninitialized handle
+ */
+ static Shader DownCast( BaseHandle handle );
+
+ /**
+ * @brief Assignment operator, changes this handle to point at the same object
+ *
+ * @param[in] handle Handle to an object
+ * @return Reference to the assigned object
+ */
+ Shader& operator=( const Shader& handle );
+
+public: // Not intended for application developers
+ /**
+ * @brief This constructor is used by Dali New() methods.
+ * @param [in] effect A pointer to a newly allocated Dali resource.
+ */
+ explicit DALI_INTERNAL Shader( Internal::Shader* effect );
+};
+
+} // namespace Dali
+
+#endif // DALI_SHADER_H