From 349e3c9f5466c448668a0cfce53a49a23cfd97f9 Mon Sep 17 00:00:00 2001 From: Francisco Santos Date: Wed, 11 Mar 2015 18:54:41 +0000 Subject: [PATCH] Event side structure. Change-Id: Ibd5ebb42c0dccbcfeaec89957861d00ae2a61a6d --- dali/internal/event/actors/renderer-impl.cpp | 177 +++++++++++++ dali/internal/event/actors/renderer-impl.h | 201 +++++++++++++++ dali/internal/event/common/connectable.h | 60 +++++ dali/internal/event/common/object-connector.h | 137 ++++++++++ dali/internal/event/common/object-impl-helper.h | 221 +++++++++++++++++ .../internal/event/common/property-buffer-impl.cpp | 185 ++++++++++++++ dali/internal/event/common/property-buffer-impl.h | 200 +++++++++++++++ dali/internal/event/effects/material-impl.cpp | 275 +++++++++++++++++++++ dali/internal/event/effects/material-impl.h | 271 ++++++++++++++++++++ dali/internal/event/effects/sampler-impl.cpp | 191 ++++++++++++++ dali/internal/event/effects/sampler-impl.h | 206 +++++++++++++++ dali/internal/event/effects/shader-impl.cpp | 160 ++++++++++++ dali/internal/event/effects/shader-impl.h | 182 ++++++++++++++ dali/internal/event/geometry/geometry-impl.cpp | 221 +++++++++++++++++ dali/internal/event/geometry/geometry-impl.h | 230 +++++++++++++++++ dali/internal/file.list | 8 +- dali/public-api/actors/renderer.cpp | 72 ++++++ dali/public-api/file.list | 6 + dali/public-api/geometry/geometry.cpp | 97 ++++++++ dali/public-api/object/property-buffer.cpp | 79 ++++++ dali/public-api/shader-effects/material.cpp | 143 +++++++++++ dali/public-api/shader-effects/sampler.cpp | 83 +++++++ dali/public-api/shader-effects/shader.cpp | 59 +++++ 23 files changed, 3463 insertions(+), 1 deletion(-) create mode 100644 dali/internal/event/actors/renderer-impl.cpp create mode 100644 dali/internal/event/actors/renderer-impl.h create mode 100644 dali/internal/event/common/connectable.h create mode 100644 dali/internal/event/common/object-connector.h create mode 100644 dali/internal/event/common/object-impl-helper.h create mode 100644 dali/internal/event/common/property-buffer-impl.cpp create mode 100644 dali/internal/event/common/property-buffer-impl.h create mode 100644 dali/internal/event/effects/material-impl.cpp create mode 100644 dali/internal/event/effects/material-impl.h create mode 100644 dali/internal/event/effects/sampler-impl.cpp create mode 100644 dali/internal/event/effects/sampler-impl.h create mode 100644 dali/internal/event/effects/shader-impl.cpp create mode 100644 dali/internal/event/effects/shader-impl.h create mode 100644 dali/internal/event/geometry/geometry-impl.cpp create mode 100644 dali/internal/event/geometry/geometry-impl.h create mode 100644 dali/public-api/actors/renderer.cpp create mode 100644 dali/public-api/geometry/geometry.cpp create mode 100644 dali/public-api/object/property-buffer.cpp create mode 100644 dali/public-api/shader-effects/material.cpp create mode 100644 dali/public-api/shader-effects/sampler.cpp create mode 100644 dali/public-api/shader-effects/shader.cpp diff --git a/dali/internal/event/actors/renderer-impl.cpp b/dali/internal/event/actors/renderer-impl.cpp new file mode 100644 index 0000000..40e741a --- /dev/null +++ b/dali/internal/event/actors/renderer-impl.cpp @@ -0,0 +1,177 @@ +/* + * 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::Renderer + +// INTERNAL INCLUDES +#include // Dali::Renderer +#include // Dali::Internal::ObjectHelper +#include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END + +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, true, true, Dali::Renderer::Property::DEPTH_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX ) + +const ObjectImplHelper RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS }; + +} // unnamed namespace + +RendererPtr Renderer::New() +{ + return RendererPtr( new Renderer() ); +} + +void Renderer::SetGeometry( Geometry& geometry ) +{ + mGeometryConnector.Set( geometry, OnStage() ); +} + +void Renderer::SetMaterial( Material& material ) +{ + mMaterialConnector.Set( material, OnStage() ); +} + +void Renderer::SetDepthIndex( int depthIndex ) +{ + //SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, &mNode->mPosition, &AnimatableProperty::Bake, position ); + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +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 ) +{ + RENDERER_IMPL.SetDefaultProperty( index, propertyValue ); +} + +void Renderer::SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) +{ + RENDERER_IMPL.SetSceneGraphProperty( index, entry, value ); +} + +Property::Value Renderer::GetDefaultProperty( Property::Index index ) const +{ + return RENDERER_IMPL.GetDefaultProperty( index ); +} + +const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const +{ + return RENDERER_IMPL.GetPropertyOwner(); +} + +const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const +{ + return RENDERER_IMPL.GetSceneObject(); +} + +const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const +{ + return RENDERER_IMPL.GetSceneObjectAnimatableProperty( index ); +} + +const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const +{ + return RENDERER_IMPL.GetSceneObjectInputProperty( index ); +} + +int Renderer::GetPropertyComponentIndex( Property::Index index ) const +{ + return RENDERER_IMPL.GetPropertyComponentIndex( index ); +} + +bool Renderer::OnStage() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return false; +} + +void Renderer::Connect() +{ + // TODO: MESH_REWORK : check this + mGeometryConnector.OnStageConnect(); + mMaterialConnector.OnStageConnect(); +} + +void Renderer::Disconnect() +{ + // TODO: MESH_REWORK : check this + mGeometryConnector.OnStageDisconnect(); + mMaterialConnector.OnStageDisconnect(); +} + +Renderer::Renderer() +{ +} + +} // namespace Internal +} // namespace Dali + diff --git a/dali/internal/event/actors/renderer-impl.h b/dali/internal/event/actors/renderer-impl.h new file mode 100644 index 0000000..ebbc623 --- /dev/null +++ b/dali/internal/event/actors/renderer-impl.h @@ -0,0 +1,201 @@ +#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::Renderer +#include // DALI_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::Internal::Connectable +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object +#include // Dali::Internal::Material +#include // Dali::Internal::Geometry + +namespace Dali +{ +namespace Internal +{ + +class Renderer; +typedef IntrusivePtr 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::SetMaterial() + */ + void SetMaterial( Material& material ); + + /** + * @copydoc Dali::Renderer::SetDepthIndex() + */ + void SetDepthIndex( int depthIndex ); + +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 CustomProperty& 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(); + +private: // unimplemented methods + Renderer( const Renderer& ); + Renderer& operator=( const Renderer& ); + +private: // data + ObjectConnector mGeometryConnector; ///< Connector that holds the geometry used by this renderer + ObjectConnector mMaterialConnector; ///< Connector that holds the material used by this renderer + +}; + +} // 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(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(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_RENDERER_H diff --git a/dali/internal/event/common/connectable.h b/dali/internal/event/common/connectable.h new file mode 100644 index 0000000..643e9b6 --- /dev/null +++ b/dali/internal/event/common/connectable.h @@ -0,0 +1,60 @@ +#ifndef DALI_INTERNAL_CONNECTABLE_H +#define DALI_INTERNAL_CONNECTABLE_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 + +namespace Dali +{ +namespace Internal +{ + +/** + * @brief Interface for objects that can be connected to the stage. + */ +class Connectable +{ +public: + + /** + * @brief Destructor + */ + virtual ~Connectable() {} + + /** + * @brief Check if the object is on stage + */ + virtual bool OnStage() const = 0; + + /** + * @brief Notify this objects that it has been connected to the stage. + */ + virtual void Connect() = 0; + + /** + * @brief Notify this objects that it has been disconnected to the stage. + */ + virtual void Disconnect() = 0; + +}; + +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_CONNECTABLE_H diff --git a/dali/internal/event/common/object-connector.h b/dali/internal/event/common/object-connector.h new file mode 100644 index 0000000..576a829 --- /dev/null +++ b/dali/internal/event/common/object-connector.h @@ -0,0 +1,137 @@ +#ifndef DALI_INTERNAL_OBJECT_CONNECTOR_H +#define DALI_INTERNAL_OBJECT_CONNECTOR_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 + +namespace Dali +{ + +namespace Internal +{ + +/** + * @brief Wrapper class which helps managing intrusive pointer assignments and Connect / Disconnect. + * + * Should be used with objects that implement Dali::Internal::Connectable + */ +template +class ObjectConnector +{ +public: + typedef IntrusivePtr ObjectPtr; + + /** + * @brief Default constructor. + */ + ObjectConnector() {} + + /** + * @brief Destructor. + */ + ~ObjectConnector() {} + + /** + * @brief Copy constructor + */ + ObjectConnector( const ObjectConnector& connector ) + : mObject( connector.mObject ) + { + } + + /** + * @brief Assignment operator + */ + ObjectConnector& operator=( const ObjectConnector& connector ) + { + this->mObject = connector.mObject; + return *this; + } + + /** + * @brief Returns a smart pointer to the object + * @return a smart pointer to the object + */ + ObjectPtr Get() const + { + return mObject; + } + + /** + * @brief Assigns the object, calling Connect and Disconnect methods accordingly, taking onStage into account. + * @param [in] object smart pointer to a object + * @param [in] onStage whether the object is used on stage or not + */ + void Set( Object& object, bool onStage ) + { + if ( mObject.Get() != &object ) + { + // Disconnect from old object + if ( mObject && onStage ) + { + mObject->Disconnect(); + } + + mObject = &object; + + // Connect to new object + if ( mObject && onStage ) + { + mObject->Connect(); + } + } + } + + /** + * @brief Manages connection reference count. + * + * Must be called from owner when connected to stage. + */ + void OnStageConnect() + { + if ( mObject ) + { + mObject->Connect(); + } + } + + /** + * @brief Manages connection reference count. + * + * Must be called from owner when disconnecting from stage. + */ + void OnStageDisconnect() + { + if ( mObject ) + { + mObject->Disconnect(); + } + } + +private: //data + ObjectPtr mObject; ///< intrusive pointer to the Object. ObjectConnector owns this. + +}; + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_OBJECT_CONNECTOR_H diff --git a/dali/internal/event/common/object-impl-helper.h b/dali/internal/event/common/object-impl-helper.h new file mode 100644 index 0000000..27a63dd --- /dev/null +++ b/dali/internal/event/common/object-impl-helper.h @@ -0,0 +1,221 @@ +#ifndef DALI_INTERNAL_OBJECT_IMPL_HELPER_H +#define DALI_INTERNAL_OBJECT_IMPL_HELPER_H + +/* + * Copyright (c) 2014 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::Property +#include // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX +#include // Dali::Internal::PropertyDetails + +namespace Dali +{ +namespace Internal +{ + +class CustomProperty; +class PropertyInputImpl; + +namespace SceneGraph +{ + +class PropertyBase; +class PropertyOwner; + + +} // namespace SceneGraph + +/** + * Helper template class to be used by class that implement Object + * + * Example: + *
+ * typename ObjectImplHelper MyObjectImpl;
+ *
+ * MyObjectImpl::GetDefaultPropertyCount();
+ * 
+ */ + +template +struct ObjectImplHelper +{ + const PropertyDetails* DEFAULT_PROPERTY_DETAILS; + + unsigned int GetDefaultPropertyCount() const + { + return DEFAULT_PROPERTY_COUNT; + } + + void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const + { + indices.reserve( DEFAULT_PROPERTY_COUNT ); + + for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) + { + indices.push_back( DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX + i ); + } + } + + const char* GetDefaultPropertyName( Property::Index index ) const + { + const char* name = NULL; + + if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT ) + { + name = DEFAULT_PROPERTY_DETAILS[index].name; + } + + return name; + } + + Property::Index GetDefaultPropertyIndex( const std::string& name ) const + { + Property::Index index = Property::INVALID_INDEX; + + // Look for name in default properties + for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) + { + const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i; + break; + } + } + + return index; + } + + bool IsDefaultPropertyWritable( Property::Index index ) const + { + bool isWritable = false; + + if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT ) + { + isWritable = DEFAULT_PROPERTY_DETAILS[index].writable; + } + + return isWritable; + } + + bool IsDefaultPropertyAnimatable( Property::Index index ) const + { + bool isAnimatable = false; + + if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT ) + { + isAnimatable = DEFAULT_PROPERTY_DETAILS[index].animatable; + } + + return isAnimatable; + } + + bool IsDefaultPropertyAConstraintInput( Property::Index index ) const + { + bool isConstraintInput = false; + + if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT ) + { + isConstraintInput = DEFAULT_PROPERTY_DETAILS[index].constraintInput; + } + + return isConstraintInput; + } + + Property::Type GetDefaultPropertyType( Property::Index index ) const + { + Property::Type type = Property::NONE; + + if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT ) + { + type = DEFAULT_PROPERTY_DETAILS[index].type; + } + + return type; + } + + void SetDefaultProperty( Property::Index index, + const Property::Value& property ) const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + } + + void SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + } + + Property::Value GetDefaultProperty( Property::Index index ) const + { + Property::Value value; + + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + + return value; + } + + const SceneGraph::PropertyOwner* GetPropertyOwner() const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return 0; + } + + const SceneGraph::PropertyOwner* GetSceneObject() const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return 0; + } + + const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return 0; + } + + const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return 0; + } + + int GetPropertyComponentIndex( Property::Index index ) const + { + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return 0; + } + +}; + + + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_OBJECT_IMPL_HELPER_H + diff --git a/dali/internal/event/common/property-buffer-impl.cpp b/dali/internal/event/common/property-buffer-impl.cpp new file mode 100644 index 0000000..2f59241 --- /dev/null +++ b/dali/internal/event/common/property-buffer-impl.cpp @@ -0,0 +1,185 @@ +/* + * 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::PropertyBuffer + +// INTERNAL INCLUDES +#include // Dali::Internal::PropertyBuffer +#include // Dali::Internal::ObjectHelper +#include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END + + +namespace Dali +{ +namespace Internal +{ + +namespace +{ + +/** + * |name |type |writable|animatable|constraint-input|enum for index-checking| + */ +DALI_PROPERTY_TABLE_BEGIN +DALI_PROPERTY( "size", UNSIGNED_INTEGER, true, false, true, Dali::PropertyBuffer::Property::SIZE ) +DALI_PROPERTY( "buffer-format", MAP, false, false, false, Dali::PropertyBuffer::Property::BUFFER_FORMAT ) +DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX ) + +const ObjectImplHelper PROPERTY_BUFFER_IMPL = { DEFAULT_PROPERTY_DETAILS }; + +} // unnamed namespace + +PropertyBufferPtr PropertyBuffer::New() +{ + return PropertyBufferPtr( new PropertyBuffer() ); +} + +void PropertyBuffer::SetSize( std::size_t size ) +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH_REWORK" ); +} + +std::size_t PropertyBuffer::GetSize() const +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH_REWORK" ); + + return 0; +} + +void PropertyBuffer::SetData( void* data ) +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH_REWORK" ); +} + +Dali::Property::Index PropertyBuffer::GetPropertyIndex( const std::string name, std::size_t index ) +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH_REWORK" ); + return 0; +} + +unsigned int PropertyBuffer::GetDefaultPropertyCount() const +{ + return PROPERTY_BUFFER_IMPL.GetDefaultPropertyCount(); +} + +void PropertyBuffer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const +{ + PROPERTY_BUFFER_IMPL.GetDefaultPropertyIndices( indices ); +} + +const char* PropertyBuffer::GetDefaultPropertyName(Property::Index index) const +{ + return PROPERTY_BUFFER_IMPL.GetDefaultPropertyName( index ); +} + +Property::Index PropertyBuffer::GetDefaultPropertyIndex( const std::string& name ) const +{ + return PROPERTY_BUFFER_IMPL.GetDefaultPropertyIndex( name ); +} + +bool PropertyBuffer::IsDefaultPropertyWritable( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.IsDefaultPropertyWritable( index ); +} + +bool PropertyBuffer::IsDefaultPropertyAnimatable( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.IsDefaultPropertyAnimatable( index ); +} + +bool PropertyBuffer::IsDefaultPropertyAConstraintInput( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.IsDefaultPropertyAConstraintInput( index ); +} + +Property::Type PropertyBuffer::GetDefaultPropertyType( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.GetDefaultPropertyType( index ); +} + +void PropertyBuffer::SetDefaultProperty( Property::Index index, + const Property::Value& propertyValue ) +{ + PROPERTY_BUFFER_IMPL.SetDefaultProperty( index, propertyValue ); +} + +void PropertyBuffer::SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) +{ + PROPERTY_BUFFER_IMPL.SetSceneGraphProperty( index, entry, value ); +} + +Property::Value PropertyBuffer::GetDefaultProperty( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.GetDefaultProperty( index ); +} + +const SceneGraph::PropertyOwner* PropertyBuffer::GetPropertyOwner() const +{ + return PROPERTY_BUFFER_IMPL.GetPropertyOwner(); +} + +const SceneGraph::PropertyOwner* PropertyBuffer::GetSceneObject() const +{ + return PROPERTY_BUFFER_IMPL.GetSceneObject(); +} + +const SceneGraph::PropertyBase* PropertyBuffer::GetSceneObjectAnimatableProperty( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.GetSceneObjectAnimatableProperty( index ); +} + +const PropertyInputImpl* PropertyBuffer::GetSceneObjectInputProperty( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.GetSceneObjectInputProperty( index ); +} + +int PropertyBuffer::GetPropertyComponentIndex( Property::Index index ) const +{ + return PROPERTY_BUFFER_IMPL.GetPropertyComponentIndex( index ); +} + +bool PropertyBuffer::OnStage() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return false; +} + +void PropertyBuffer::Connect() +{ + // TODO: MESH_REWORK +} + +void PropertyBuffer::Disconnect() +{ + // TODO: MESH_REWORK +} + +PropertyBuffer::PropertyBuffer() +{ +} + +} // namespace Internal +} // namespace Dali + diff --git a/dali/internal/event/common/property-buffer-impl.h b/dali/internal/event/common/property-buffer-impl.h new file mode 100644 index 0000000..6b927b7 --- /dev/null +++ b/dali/internal/event/common/property-buffer-impl.h @@ -0,0 +1,200 @@ +#ifndef DALI_INTERNAL_PROPERTY_BUFFER_H +#define DALI_INTERNAL_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. + * + */ + +// INTERNAL INCLUDES +#include // DALI_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::PropertyBuffer +#include // Dali::Internal::Connectable +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object + +namespace Dali +{ +namespace Internal +{ + +class PropertyBuffer; +typedef IntrusivePtr PropertyBufferPtr; + +/** + * PropertyBuffer is an object that contains an array of structures of values that + * can be accessed as properties. + */ +class PropertyBuffer : public Object, public Connectable +{ +public: + + /** + * @copydoc PropertBuffer::New() + */ + static PropertyBufferPtr New(); + + /** + * @copydoc PropertBuffer::SetSize() + */ + void SetSize( std::size_t size ); + + /** + * @copydoc PropertBuffer::GetSize() + */ + std::size_t GetSize() const; + + /** + * @copydoc PropertBuffer::SetData() + */ + void SetData( void* data ); + + /** + * @copydoc PropertBuffer::GetPropertyIndex() + */ + Dali::Property::Index GetPropertyIndex( const std::string name, std::size_t index ); + +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 CustomProperty& 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 + PropertyBuffer(); + +private: // unimplemented methods + PropertyBuffer( const PropertyBuffer& ); + PropertyBuffer& operator=( const PropertyBuffer& ); + +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods +inline Internal::PropertyBuffer& GetImplementation(Dali::PropertyBuffer& handle) +{ + DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty"); + + BaseObject& object = handle.GetBaseObject(); + + return static_cast(object); +} + +inline const Internal::PropertyBuffer& GetImplementation(const Dali::PropertyBuffer& handle) +{ + DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty"); + + const BaseObject& object = handle.GetBaseObject(); + + return static_cast(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_PROPERTY_BUFFER_H diff --git a/dali/internal/event/effects/material-impl.cpp b/dali/internal/event/effects/material-impl.cpp new file mode 100644 index 0000000..8ead008 --- /dev/null +++ b/dali/internal/event/effects/material-impl.cpp @@ -0,0 +1,275 @@ +/* + * 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::Material + +// INTERNAL INCLUDES +#include // Dali::Internal::Material +#include // Dali::Internal::ObjectHelper +#include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END + + +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, true, Dali::Material::Property::FACE_CULLING_MODE ) +DALI_PROPERTY( "blending-mode", STRING, true, false, true, Dali::Material::Property::BLENDING_MODE ) +DALI_PROPERTY( "blend-equation", STRING, true, false, true, Dali::Material::Property::BLEND_EQUATION ) +DALI_PROPERTY( "source-blend-factor-rgb", STRING, true, false, true, Dali::Material::Property::BLENDING_SRC_FACTOR_RGB ) +DALI_PROPERTY( "destination-blend-factor-rgb", STRING, true, false, true, Dali::Material::Property::BLENDING_DEST_FACTOR_RGB ) +DALI_PROPERTY( "source-blend-factor-alpha", STRING, true, false, true, Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA ) +DALI_PROPERTY( "destination-blend-factor-alpha", STRING, true, false, true, 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 MATERIAL_IMPL = { DEFAULT_PROPERTY_DETAILS }; + +} // unnamed namespace + +MaterialPtr Material::New() +{ + return MaterialPtr( new Material() ); +} + +void Material::SetShader( Shader& shader ) +{ + mShaderConnector.Set( shader, OnStage() ); +} + +void Material::AddSampler( Sampler& sampler ) +{ + SamplerConnector connector; + connector.Set( sampler, OnStage() ); + mSamplerConnectors.push_back( connector ); +} + +std::size_t Material::GetNumberOfSamplers() const +{ + return mSamplerConnectors.size(); +} + +void Material::RemoveSampler( std::size_t index ) +{ + mSamplerConnectors.erase( mSamplerConnectors.begin() + index ); +} + +void Material::SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::SetBlendMode( BlendingMode::Type mode ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +BlendingMode::Type Material::GetBlendMode() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return BlendingMode::AUTO; +} + +void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb, + BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, + BlendingFactor::Type destFactorAlpha ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, + BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, + BlendingFactor::Type& destFactorAlpha ) const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::SetBlendEquation( BlendingEquation::Type equationRgba ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::SetBlendEquation( BlendingEquation::Type equationRgb, + BlendingEquation::Type equationAlpha ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::GetBlendEquation( BlendingEquation::Type& equationRgb, + BlendingEquation::Type& equationAlpha ) const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Material::SetBlendColor( const Vector4& color ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +const Vector4& Material::GetBlendColor() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return Color::WHITE; +} + +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 ) +{ + MATERIAL_IMPL.SetDefaultProperty( index, propertyValue ); +} + +void Material::SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) +{ + MATERIAL_IMPL.SetSceneGraphProperty( index, entry, value ); +} + +Property::Value Material::GetDefaultProperty( Property::Index index ) const +{ + return MATERIAL_IMPL.GetDefaultProperty( index ); +} + +const SceneGraph::PropertyOwner* Material::GetPropertyOwner() const +{ + return MATERIAL_IMPL.GetPropertyOwner(); +} + +const SceneGraph::PropertyOwner* Material::GetSceneObject() const +{ + return MATERIAL_IMPL.GetSceneObject(); +} + +const SceneGraph::PropertyBase* Material::GetSceneObjectAnimatableProperty( Property::Index index ) const +{ + return MATERIAL_IMPL.GetSceneObjectAnimatableProperty( index ); +} + +const PropertyInputImpl* Material::GetSceneObjectInputProperty( Property::Index index ) const +{ + return MATERIAL_IMPL.GetSceneObjectInputProperty( index ); +} + +int Material::GetPropertyComponentIndex( Property::Index index ) const +{ + return MATERIAL_IMPL.GetPropertyComponentIndex( index ); +} + +bool Material::OnStage() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return false; +} + +void Material::Connect() +{ + SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end(); + for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin(); + it < end; + ++it ) + { + it->OnStageConnect(); + } +} + +void Material::Disconnect() +{ + SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end(); + for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin(); + it < end; + ++it ) + { + it->OnStageDisconnect(); + } +} + +Material::Material() +{ +} + +} // namespace Internal +} // namespace Dali + diff --git a/dali/internal/event/effects/material-impl.h b/dali/internal/event/effects/material-impl.h new file mode 100644 index 0000000..44717db --- /dev/null +++ b/dali/internal/event/effects/material-impl.h @@ -0,0 +1,271 @@ +#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 // std::vector + +// INTERNAL INCLUDES +#include // DALI_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::Material +#include // Dali::Internal::Connectable +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object +#include // Dali::Internal::PropertyBuffer +#include // Dali::Internal::Sampler +#include // Dali::Internal::Shader + +namespace Dali +{ +namespace Internal +{ + +class Material; +typedef IntrusivePtr 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::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::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; + +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 CustomProperty& 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(); + +private: // unimplemented methods + Material( const Material& ); + Material& operator=( const Material& ); + +private: //data + typedef ObjectConnector ShaderConnector; + ShaderConnector mShaderConnector; ///< Connector that holds the shader used by this material + + typedef ObjectConnector SamplerConnector; + typedef std::vector< SamplerConnector > SamplerConnectorContainer; + SamplerConnectorContainer mSamplerConnectors; ///< Vector of connectors that hold the samplers used by this material + +}; + +} // 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(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(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_MATERIAL_H diff --git a/dali/internal/event/effects/sampler-impl.cpp b/dali/internal/event/effects/sampler-impl.cpp new file mode 100644 index 0000000..d315bff --- /dev/null +++ b/dali/internal/event/effects/sampler-impl.cpp @@ -0,0 +1,191 @@ +/* + * 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::Sampler + +// INTERNAL INCLUDES +#include // Dali::Internal::Sampler +#include // Dali::Internal::ObjectHelper +#include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END + + +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 SAMPLER_IMPL = { DEFAULT_PROPERTY_DETAILS }; + +} // unnamed namespace + +SamplerPtr Sampler::New() +{ + return SamplerPtr( new Sampler() ); +} + +void Sampler::SetUniformName( const std::string& name ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Sampler::SetImage( Image& image ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Sampler::SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Sampler::SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +void Sampler::SetAffectsTransparency( bool affectsTransparency ) +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); +} + +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 ) +{ + SAMPLER_IMPL.SetDefaultProperty( index, propertyValue ); +} + +void Sampler::SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) +{ + SAMPLER_IMPL.SetSceneGraphProperty( index, entry, value ); +} + +Property::Value Sampler::GetDefaultProperty( Property::Index index ) const +{ + return SAMPLER_IMPL.GetDefaultProperty( index ); +} + +const SceneGraph::PropertyOwner* Sampler::GetPropertyOwner() const +{ + return SAMPLER_IMPL.GetPropertyOwner(); +} + +const SceneGraph::PropertyOwner* Sampler::GetSceneObject() const +{ + return SAMPLER_IMPL.GetSceneObject(); +} + +const SceneGraph::PropertyBase* Sampler::GetSceneObjectAnimatableProperty( Property::Index index ) const +{ + return SAMPLER_IMPL.GetSceneObjectAnimatableProperty( index ); +} + +const PropertyInputImpl* Sampler::GetSceneObjectInputProperty( Property::Index index ) const +{ + return SAMPLER_IMPL.GetSceneObjectInputProperty( index ); +} + +int Sampler::GetPropertyComponentIndex( Property::Index index ) const +{ + return SAMPLER_IMPL.GetPropertyComponentIndex( index ); +} + +bool Sampler::OnStage() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return false; +} + +void Sampler::Connect() +{ + mImageConnector.OnStageConnect(); +} + +void Sampler::Disconnect() +{ + mImageConnector.OnStageDisconnect(); +} + +Sampler::Sampler() +{ +} + +} // namespace Internal +} // namespace Dali + diff --git a/dali/internal/event/effects/sampler-impl.h b/dali/internal/event/effects/sampler-impl.h new file mode 100644 index 0000000..ddfdbf5 --- /dev/null +++ b/dali/internal/event/effects/sampler-impl.h @@ -0,0 +1,206 @@ +#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_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::Sampler +#include // Dali::Internal::Connectable +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object +#include // Dali::Internal::ImageConnector + +namespace Dali +{ +namespace Internal +{ + +class Sampler; +typedef IntrusivePtr 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(); + + /** + * @copydoc Dali::Sampler::SetUniformName() + */ + void SetUniformName( const std::string& name ); + + /** + * @copydoc Dali::Sampler::SetImage() + */ + void SetImage( Image& image ); + + /** + * @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 ); + +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 CustomProperty& 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(); + +private: // data + //TODO: MESH_REWORK : change to ObjectConnector + ImageConnector mImageConnector; +}; + +} // 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(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(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_SAMPLER_H diff --git a/dali/internal/event/effects/shader-impl.cpp b/dali/internal/event/effects/shader-impl.cpp new file mode 100644 index 0000000..de7fbd9 --- /dev/null +++ b/dali/internal/event/effects/shader-impl.cpp @@ -0,0 +1,160 @@ +/* + * 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::Shader + +// INTERNAL INCLUDES +#include // Dali::Internal::Shader +#include // Dali::Internal::ObjectHelper +#include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END + + +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 SHADER_IMPL = { DEFAULT_PROPERTY_DETAILS }; + +} // unnamed namespace + +ShaderPtr Shader::New( const std::string& vertexShader, + const std::string& fragmentShader, + Dali::Shader::ShaderHints hints ) +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS(false && "MESH REWORK"); + return ShaderPtr( new Shader() ); +} + +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 ) +{ + SHADER_IMPL.SetDefaultProperty( index, propertyValue ); +} + +void Shader::SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) +{ + SHADER_IMPL.SetSceneGraphProperty( index, entry, value ); +} + +Property::Value Shader::GetDefaultProperty( Property::Index index ) const +{ + return SHADER_IMPL.GetDefaultProperty( index ); +} + +const SceneGraph::PropertyOwner* Shader::GetPropertyOwner() const +{ + return SHADER_IMPL.GetPropertyOwner(); +} + +const SceneGraph::PropertyOwner* Shader::GetSceneObject() const +{ + return SHADER_IMPL.GetSceneObject(); +} + +const SceneGraph::PropertyBase* Shader::GetSceneObjectAnimatableProperty( Property::Index index ) const +{ + return SHADER_IMPL.GetSceneObjectAnimatableProperty( index ); +} + +const PropertyInputImpl* Shader::GetSceneObjectInputProperty( Property::Index index ) const +{ + return SHADER_IMPL.GetSceneObjectInputProperty( index ); +} + +int Shader::GetPropertyComponentIndex( Property::Index index ) const +{ + return SHADER_IMPL.GetPropertyComponentIndex( index ); +} + +bool Shader::OnStage() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return false; +} + +void Shader::Connect() +{ +} + +void Shader::Disconnect() +{ +} + +Shader::Shader() +{ +} + +} // namespace Internal +} // namespace Dali + diff --git a/dali/internal/event/effects/shader-impl.h b/dali/internal/event/effects/shader-impl.h new file mode 100644 index 0000000..e3d5950 --- /dev/null +++ b/dali/internal/event/effects/shader-impl.h @@ -0,0 +1,182 @@ +#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_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::Shader +#include // Dali::Internal::Connectable +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object + +namespace Dali +{ +namespace Internal +{ + +class Shader; +typedef IntrusivePtr 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 ); + +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 CustomProperty& 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(); + +private: // unimplemented methods + Shader( const Shader& ); + Shader& operator=( const Shader& ); + +}; + +} // 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(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(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_SHADER_H diff --git a/dali/internal/event/geometry/geometry-impl.cpp b/dali/internal/event/geometry/geometry-impl.cpp new file mode 100644 index 0000000..3ea0207 --- /dev/null +++ b/dali/internal/event/geometry/geometry-impl.cpp @@ -0,0 +1,221 @@ +/* + * 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::Geometry + +// INTERNAL INCLUDES +#include // Dali::Internal::ObjectHelper +#include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END + + +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 GEOMETRY_IMPL = { DEFAULT_PROPERTY_DETAILS }; + +} // unnamed namespace + +GeometryPtr Geometry::New() +{ + return GeometryPtr( new Geometry() ); +} + +std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer ) +{ + PropertyBufferConnector connector; + connector.Set( vertexBuffer, OnStage() ); + mVertexBufferConnectors.push_back( connector ); + 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() ); +} + +void Geometry::SetGeometryType( Dali::Geometry::GeometryType geometryType ) +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH REWORK" ); +} + +Dali::Geometry::GeometryType Geometry::GetGeometryType() const +{ + //TODO: MESH_REWORK + return Dali::Geometry::TRIANGLES; +} + +void Geometry::SetRequiresDepthTesting( bool requiresDepthTest ) +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH REWORK" ); +} + +bool Geometry::GetRequiresDepthTesting() const +{ + //TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "MESH REWORK" ); + return false; +} + +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 ) +{ + GEOMETRY_IMPL.SetDefaultProperty( index, propertyValue ); +} + +void Geometry::SetSceneGraphProperty( Property::Index index, + const CustomProperty& entry, + const Property::Value& value ) +{ + GEOMETRY_IMPL.SetSceneGraphProperty( index, entry, value ); +} + +Property::Value Geometry::GetDefaultProperty( Property::Index index ) const +{ + return GEOMETRY_IMPL.GetDefaultProperty( index ); +} + +const SceneGraph::PropertyOwner* Geometry::GetPropertyOwner() const +{ + return GEOMETRY_IMPL.GetPropertyOwner(); +} + +const SceneGraph::PropertyOwner* Geometry::GetSceneObject() const +{ + return GEOMETRY_IMPL.GetSceneObject(); +} + +const SceneGraph::PropertyBase* Geometry::GetSceneObjectAnimatableProperty( Property::Index index ) const +{ + return GEOMETRY_IMPL.GetSceneObjectAnimatableProperty( index ); +} + +const PropertyInputImpl* Geometry::GetSceneObjectInputProperty( Property::Index index ) const +{ + return GEOMETRY_IMPL.GetSceneObjectInputProperty( index ); +} + +int Geometry::GetPropertyComponentIndex( Property::Index index ) const +{ + return GEOMETRY_IMPL.GetPropertyComponentIndex( index ); +} + +bool Geometry::OnStage() const +{ + // TODO: MESH_REWORK + DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" ); + return false; +} + +void Geometry::Connect() +{ + PropertyBufferConnectorContainer::const_iterator end = mVertexBufferConnectors.end(); + for( PropertyBufferConnectorContainer::iterator it = mVertexBufferConnectors.begin(); + it < end; + ++it ) + { + it->OnStageConnect(); + } + mIndexBufferConnector.OnStageConnect(); +} + +void Geometry::Disconnect() +{ + PropertyBufferConnectorContainer::const_iterator end = mVertexBufferConnectors.end(); + for( PropertyBufferConnectorContainer::iterator it = mVertexBufferConnectors.begin(); + it < end; + ++it ) + { + it->OnStageDisconnect(); + } + mIndexBufferConnector.OnStageDisconnect(); +} + +Geometry::Geometry() +{ +} + +} // namespace Internal +} // namespace Dali + diff --git a/dali/internal/event/geometry/geometry-impl.h b/dali/internal/event/geometry/geometry-impl.h new file mode 100644 index 0000000..40fce2e --- /dev/null +++ b/dali/internal/event/geometry/geometry-impl.h @@ -0,0 +1,230 @@ +#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 // std::vector + +// INTERNAL INCLUDES +#include // DALI_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::Geometry +#include // Dali::Internal::Connectable +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object +#include // Dali::Internal::PropertyBuffer + +namespace Dali +{ +namespace Internal +{ + +class Geometry; +typedef IntrusivePtr 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; + +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 CustomProperty& 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(); + +private: // unimplemented methods + Geometry( const Geometry& ); + Geometry& operator=( const Geometry& ); + +private: // data + typedef ObjectConnector 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 +}; + +} // 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(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(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_GEOMETRY_H diff --git a/dali/internal/file.list b/dali/internal/file.list index e989aef..236959c 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -19,6 +19,7 @@ internal_src_files = \ $(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/text-actor-impl.cpp \ $(internal_src_dir)/event/actors/camera-actor-impl.cpp \ $(internal_src_dir)/event/actors/renderable-actor-impl.cpp \ @@ -33,14 +34,18 @@ internal_src_files = \ $(internal_src_dir)/event/common/object-impl.cpp \ $(internal_src_dir)/event/common/object-registry-impl.cpp \ $(internal_src_dir)/event/common/projection.cpp \ - $(internal_src_dir)/event/common/property-notification-manager.cpp \ + $(internal_src_dir)/event/common/property-buffer-impl.cpp \ $(internal_src_dir)/event/common/property-conditions-impl.cpp \ $(internal_src_dir)/event/common/property-notification-impl.cpp \ + $(internal_src_dir)/event/common/property-notification-manager.cpp \ $(internal_src_dir)/event/common/stage-impl.cpp \ $(internal_src_dir)/event/common/system-overlay-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-impl.cpp \ $(internal_src_dir)/event/effects/shader-effect-impl.cpp \ $(internal_src_dir)/event/effects/shader-factory.cpp \ $(internal_src_dir)/event/events/actor-gesture-data.cpp \ @@ -63,6 +68,7 @@ internal_src_files = \ $(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 \ diff --git a/dali/public-api/actors/renderer.cpp b/dali/public-api/actors/renderer.cpp new file mode 100644 index 0000000..64f3a03 --- /dev/null +++ b/dali/public-api/actors/renderer.cpp @@ -0,0 +1,72 @@ +/* + * 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::Renderer + +// INTERNAL INCLUDES +#include // Dali::Internal::Renderer + +namespace Dali +{ + +Renderer Renderer::New( Geometry geometry, Material material ) +{ + Internal::RendererPtr renderer = Internal::Renderer::New( ); + return Renderer( renderer.Get() ); +} + +Renderer::Renderer() +{ +} + +Renderer::~Renderer() +{ +} + +Renderer::Renderer( const Renderer& handle ) +: Handle( handle ) +{ +} + +Renderer& Renderer::operator=( const Renderer& handle ) +{ + BaseHandle::operator=( handle ); + return *this; +} + +void Renderer::SetGeometry( Geometry geometry ) +{ + GetImplementation(*this).SetGeometry( GetImplementation(geometry) ); +} + +void Renderer::SetMaterial( Material material ) +{ + GetImplementation(*this).SetMaterial( GetImplementation(material) ); +} + +void Renderer::SetDepthIndex( int depthIndex ) +{ + GetImplementation(*this).SetDepthIndex( depthIndex ); +} + +Renderer::Renderer( Internal::Renderer* pointer ) +: Handle( pointer ) +{ +} + +} //namespace Dali diff --git a/dali/public-api/file.list b/dali/public-api/file.list index 48c600a..34b1c14 100644 --- a/dali/public-api/file.list +++ b/dali/public-api/file.list @@ -8,6 +8,7 @@ public_api_src_files = \ $(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/text-actor.cpp \ $(public_api_src_dir)/actors/renderable-actor.cpp \ $(public_api_src_dir)/animation/active-constraint.cpp \ @@ -48,6 +49,7 @@ public_api_src_files = \ $(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)/geometry/spline.cpp \ $(public_api_src_dir)/images/atlas.cpp \ $(public_api_src_dir)/images/distance-field.cpp \ @@ -77,6 +79,7 @@ public_api_src_files = \ $(public_api_src_dir)/object/base-object.cpp \ $(public_api_src_dir)/object/object-registry.cpp \ $(public_api_src_dir)/object/property.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 \ @@ -86,6 +89,9 @@ public_api_src_files = \ $(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)/scripting/scripting.cpp \ $(public_api_src_dir)/signals/callback.cpp \ diff --git a/dali/public-api/geometry/geometry.cpp b/dali/public-api/geometry/geometry.cpp new file mode 100644 index 0000000..c9351a4 --- /dev/null +++ b/dali/public-api/geometry/geometry.cpp @@ -0,0 +1,97 @@ +/* + * 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::Geometry + +// INTERNAL INCLUDES +#include // Dali::Internal::Geometry + +namespace Dali +{ + +Geometry Geometry::New() +{ + Internal::GeometryPtr renderer = Internal::Geometry::New(); + return Geometry( renderer.Get() ); +} + +Geometry::Geometry() +{ +} + +Geometry::~Geometry() +{ +} + +Geometry::Geometry( const Geometry& handle ) +: Handle( handle ) +{ +} + +Geometry& Geometry::operator=( const Geometry& handle ) +{ + BaseHandle::operator=( handle ); + return *this; +} + +std::size_t Geometry::AddVertexBuffer( PropertyBuffer vertexBuffer ) +{ + 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 ) +{ + 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 diff --git a/dali/public-api/object/property-buffer.cpp b/dali/public-api/object/property-buffer.cpp new file mode 100644 index 0000000..2e89cd5 --- /dev/null +++ b/dali/public-api/object/property-buffer.cpp @@ -0,0 +1,79 @@ +/* + * 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::PropertyBuffer + +// INTERNAL INCLUDES +#include // Dali::Property::Map +#include // Dali::Internal::ObjectHelper +#include // Dali::Internal::PropertyBuffer + +namespace Dali +{ + +PropertyBuffer PropertyBuffer::New( Type type, Dali::Property::Map bufferFormat, std::size_t size ) +{ + Internal::PropertyBufferPtr renderer = Internal::PropertyBuffer::New(); + return PropertyBuffer( renderer.Get() ); +} + +PropertyBuffer::PropertyBuffer() +{ +} + +PropertyBuffer::~PropertyBuffer() +{ +} + +PropertyBuffer::PropertyBuffer( const PropertyBuffer& handle ) +: Handle( handle ) +{ +} + +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 ); +} + +Dali::Property::Index PropertyBuffer::GetPropertyIndex( const std::string name, std::size_t index ) +{ + return GetImplementation(*this).GetPropertyIndex( name, index ); +} + +PropertyBuffer::PropertyBuffer( Internal::PropertyBuffer* pointer ) +: Handle( pointer ) +{ +} + +} // namespace Dali diff --git a/dali/public-api/shader-effects/material.cpp b/dali/public-api/shader-effects/material.cpp new file mode 100644 index 0000000..f4755d5 --- /dev/null +++ b/dali/public-api/shader-effects/material.cpp @@ -0,0 +1,143 @@ +/* + * 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::Material + +// INTERNAL INCLUDES +#include // Dali::Internal::Material +#include // Dali::Internal::Sampler +#include // Dali::Internal::Shader + +namespace Dali +{ + +Material Material::New( Shader shader ) +{ + Internal::MaterialPtr material = Internal::Material::New(); + return Material( material.Get() ); +} + +Material::Material() +{ +} + +Material::~Material() +{ +} + +Material::Material( const Material& handle ) +: Handle( handle ) +{ +} + +Material& Material::operator=( Material& handle ) +{ + BaseHandle::operator=( handle ); + return *this; +} + +void Material::SetShader( Shader shader ) +{ + GetImplementation(*this).SetShader( GetImplementation( shader ) ); +} + +void Material::AddSampler( Sampler sampler ) +{ + 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 ); +} + +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 diff --git a/dali/public-api/shader-effects/sampler.cpp b/dali/public-api/shader-effects/sampler.cpp new file mode 100644 index 0000000..ca0ed29 --- /dev/null +++ b/dali/public-api/shader-effects/sampler.cpp @@ -0,0 +1,83 @@ +/* + * 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::Sampler + +// INTERNAL INCLUDES +#include // Dali::Internal::Sampler + +namespace Dali +{ + +Sampler Sampler::New( const std::string& uniformName ) +{ + Internal::SamplerPtr sampler = Internal::Sampler::New(); + return Sampler( sampler.Get() ); +} + +Sampler::Sampler() +{ +} + +Sampler::~Sampler() +{ +} + +Sampler::Sampler( const Sampler& handle ) +: Handle( handle ) +{ +} + +Sampler& Sampler::operator=( const Sampler& handle ) +{ + BaseHandle::operator=( handle ); + return *this; +} + +void Sampler::SetUniformName( const std::string& name ) +{ + GetImplementation(*this).SetUniformName( name ); +} + +void Sampler::SetImage( Image image ) +{ + GetImplementation(*this).SetImage( GetImplementation( image ) ); +} + +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 + diff --git a/dali/public-api/shader-effects/shader.cpp b/dali/public-api/shader-effects/shader.cpp new file mode 100644 index 0000000..2b53a15 --- /dev/null +++ b/dali/public-api/shader-effects/shader.cpp @@ -0,0 +1,59 @@ +/* + * 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::Shader + +// INTERNAL INCLUDES +#include // 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::operator=( const Shader& handle ) +{ + BaseHandle::operator=( handle ); + return *this; +} + +Shader::Shader( Internal::Shader* pointer ) +: Handle( pointer ) +{ +} + +} // namespace Dali -- 2.7.4