From 21b6e28037c862516071f649cc0383957f501143 Mon Sep 17 00:00:00 2001 From: Xiangyin Ma Date: Fri, 20 Nov 2015 14:35:29 +0000 Subject: [PATCH] Modify ShaderEffect to be the wrapper class of Shader Change-Id: Ie146bf2b2670ebbbca879edbcc90f6ca0ff29ad9 --- dali/internal/event/actors/image-actor-impl.cpp | 164 +------------ dali/internal/event/actors/image-actor-impl.h | 7 - dali/internal/event/effects/shader-effect-impl.cpp | 265 +++++++++++++++------ dali/internal/event/effects/shader-effect-impl.h | 156 +++++++----- dali/internal/event/effects/shader-factory.h | 1 + dali/public-api/shader-effects/shader-effect.h | 2 +- 6 files changed, 309 insertions(+), 286 deletions(-) diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index d3a9e1f..b6b14f8 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -170,18 +170,6 @@ GeometryPtr CreateGridGeometry( const Vector2& size, unsigned int gridWidth, uns } - -template< typename T> -ConstraintBase* CreateEqualConstraint(Object& target, Property::Index index, Internal::SourceContainer& sources ) -{ - typedef typename Dali::Internal::PropertyConstraintPtr< T >::Type PropertyConstraintPtrType; - - CallbackBase* callback = new Dali::Constraint::Function< T >( EqualToConstraint() ); - PropertyConstraintPtrType funcPtr( new Internal::PropertyConstraint< T >( reinterpret_cast< Dali::Constraint::Function< T >* >( callback ) ) ); - - return Internal::Constraint< T >::New( target, index, sources, funcPtr ); -} - const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( attribute mediump vec3 aPosition;\n attribute mediump vec2 aTexCoord;\n @@ -365,23 +353,11 @@ void ImageActor::OnRelayout( const Vector2& size, RelayoutContainer& container ) unsigned int gridHeight = 1; if( mShaderEffect ) { - Dali::ShaderEffect::GeometryHints hints = mShaderEffect->GetGeometryHints(); - Property::Value gridDensityValue = mShaderEffect->GetDefaultProperty( Dali::ShaderEffect::Property::GRID_DENSITY ); - int gridDensity = Dali::ShaderEffect::DEFAULT_GRID_DENSITY; - gridDensityValue.Get( gridDensity ); - - if( ( hints & Dali::ShaderEffect::HINT_GRID_X ) ) - { - gridWidth = size.width / gridDensity; - } - if( ( hints & Dali::ShaderEffect::HINT_GRID_Y ) ) - { - gridHeight = size.height / gridDensity; - } + Vector2 gridSize = mShaderEffect->GetGridSize( size ); //limit the grid size - gridWidth = std::min( MAXIMUM_GRID_SIZE, gridWidth ); - gridHeight = std::min( MAXIMUM_GRID_SIZE, gridHeight ); + gridWidth = std::min( MAXIMUM_GRID_SIZE, static_cast(gridSize.width) ); + gridHeight = std::min( MAXIMUM_GRID_SIZE, static_cast(gridSize.height) ); } unsigned int imageWidth = 1u; @@ -393,11 +369,11 @@ void ImageActor::OnRelayout( const Vector2& size, RelayoutContainer& container ) imageHeight = image->GetHeight(); } - GeometryPtr quad = gridWidth <= 1 && gridHeight <= 1 ? - CreateQuadGeometry( size, imageWidth, imageHeight, mPixelArea ) : - CreateGridGeometry( size, gridWidth, gridHeight, imageWidth, imageHeight, mPixelArea ); + GeometryPtr geometry = gridWidth <= 1 && gridHeight <= 1 ? + CreateQuadGeometry( size, imageWidth, imageHeight, mPixelArea ) : + CreateGridGeometry( size, gridWidth, gridHeight, imageWidth, imageHeight, mPixelArea ); - mRenderer->SetGeometry( *quad ); + mRenderer->SetGeometry( *geometry ); Vector4 textureRect( 0.f, 0.f, 1.f, 1.f ); if( mIsPixelAreaSet && image ) @@ -419,15 +395,7 @@ void ImageActor::OnRelayout( const Vector2& size, RelayoutContainer& container ) } Material* material = mRenderer->GetMaterial(); - Property::Index index = material->GetPropertyIndex( "sTextureRect" ); - if( index != Property::INVALID_INDEX ) - { - material->SetProperty( index, textureRect ); - } - else - { - material->RegisterProperty( "sTextureRect", textureRect ); - } + material->RegisterProperty( "sTextureRect", textureRect ); } unsigned int ImageActor::GetDefaultPropertyCount() const @@ -750,118 +718,10 @@ void ImageActor::SetShaderEffect( ShaderEffect& effect ) mShaderEffect = ShaderEffectPtr( &effect ); effect.Connect( this ); - Dali::ShaderEffect::GeometryHints hints = effect.GetGeometryHints(); - - int shaderHints = Dali::Shader::HINT_NONE; - - if( hints & Dali::ShaderEffect::HINT_DEPTH_BUFFER ) - { - shaderHints |= Dali::Shader::HINT_REQUIRES_SELF_DEPTH_TEST; - } - if( hints & Dali::ShaderEffect::HINT_BLENDING ) - { - shaderHints |= Dali::Shader::HINT_OUTPUT_IS_TRANSPARENT; - } - if( !(hints & Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY) ) - { - shaderHints |= Dali::Shader::HINT_MODIFIES_GEOMETRY; - } - - ShaderPtr shader = Shader::New( effect.GetVertexShader(), effect.GetFragmentShader(), static_cast< Dali::Shader::ShaderHints >( shaderHints ) ); + ShaderPtr shader = mShaderEffect->GetShader(); mRenderer->GetMaterial()->SetShader( *shader ); - //get the uniforms and apply them to the renderer - const ShaderEffect::UniformArray& uniforms = mShaderEffect->GetUniforms(); - for( ShaderEffect::UniformArray::const_iterator it = uniforms.begin(); it != uniforms.end(); ++it ) - { - const ShaderEffect::Uniform& uniform = *it; - EffectUniformUpdated( uniform ); - } - - if( mShaderEffect->GetEffectImage() ) - { - EffectImageUpdated(); - } -} - -void ImageActor::EffectUniformUpdated( const ShaderEffect::Uniform& uniform ) -{ - if( !mShaderEffect ) - { - return; - } - - Shader* shader = mRenderer->GetMaterial()->GetShader(); - - Property::Index index = shader->GetPropertyIndex( uniform.mName ); - if( index == Property::INVALID_INDEX ) - { - index = shader->RegisterProperty( uniform.mName, uniform.mValue ); - - //Constrain the shader's uniform properties to the ShaderEffect properties - Internal::ConstraintBase* constraint = NULL; - Internal::SourceContainer sources; - - switch( uniform.mValue.GetType() ) - { - case Property::INTEGER: - case Property::FLOAT: - { - constraint = CreateEqualConstraint< float >(*shader, index, sources ); - break; - } - case Property::VECTOR2: - { - constraint = CreateEqualConstraint< Vector2 >(*shader, index, sources ); - break; - } - case Property::VECTOR3: - { - constraint = CreateEqualConstraint< Vector3 >(*shader, index, sources ); - break; - } - case Property::VECTOR4: - { - constraint = CreateEqualConstraint< Vector4 >(*shader, index, sources ); - break; - } - case Property::MATRIX3: - { - constraint = CreateEqualConstraint< Matrix3 >(*shader, index, sources ); - break; - } - case Property::MATRIX: - { - constraint = CreateEqualConstraint< Matrix >(*shader, index, sources ); - break; - } - case Property::BOOLEAN: - case Property::ARRAY: - case Property::ROTATION: - case Property::STRING: - case Property::RECTANGLE: - case Property::MAP: - case Property::NONE: - //not supported - break; - } - - //constrain the renderers property to the ShaderEffect - if( constraint ) - { - Source source; - source.sourceType = OBJECT_PROPERTY; - source.propertyIndex = uniform.mIndex; - source.object = mShaderEffect.Get(); - - constraint->AddSource( source ); - constraint->Apply(); - } - } - else - { - shader->SetProperty( index, uniform.mValue ); - } + EffectImageUpdated(); } ShaderEffectPtr ImageActor::GetShaderEffect() const @@ -876,9 +736,7 @@ void ImageActor::RemoveShaderEffect() { mShaderEffect->Disconnect( this ); - Dali::ShaderEffect::GeometryHints hints = mShaderEffect->GetGeometryHints(); - if( ( hints & Dali::ShaderEffect::HINT_GRID_X ) || - ( hints & Dali::ShaderEffect::HINT_GRID_Y ) ) + if( mShaderEffect->GetGridSize( Vector2(INFINITY, INFINITY) ) != Vector2::ONE ) { RelayoutRequest(); } diff --git a/dali/internal/event/actors/image-actor-impl.h b/dali/internal/event/actors/image-actor-impl.h index 654e7fe..1fa96ea 100644 --- a/dali/internal/event/actors/image-actor-impl.h +++ b/dali/internal/event/actors/image-actor-impl.h @@ -181,13 +181,6 @@ public: void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const; /** - * @brief Allows this ImageActor to respond to the event that the a shader effect's uniform has updated - * - * @param[in] uniform The shader effect uniform that has been updated - */ - void EffectUniformUpdated( const ShaderEffect::Uniform& uniform ); - - /** * @brief Allows this ImageActor to respond to the eventa that the shader effect's effect texture has been changed */ void EffectImageUpdated(); diff --git a/dali/internal/event/effects/shader-effect-impl.cpp b/dali/internal/event/effects/shader-effect-impl.cpp index fe1acb7..a7e6ee0 100644 --- a/dali/internal/event/effects/shader-effect-impl.cpp +++ b/dali/internal/event/effects/shader-effect-impl.cpp @@ -18,6 +18,9 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#include // for strcmp + // INTERNAL INCLUDES #include #include @@ -27,24 +30,9 @@ #include #include #include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include #include "dali-shaders.h" -using Dali::Internal::SceneGraph::UpdateManager; -using Dali::Internal::SceneGraph::UniformMeta; -using Dali::Internal::SceneGraph::Shader; -using Dali::Internal::SceneGraph::AnimatableProperty; -using Dali::Internal::SceneGraph::PropertyBase; -using Dali::Internal::SceneGraph::RenderQueue; using std::string; namespace Dali @@ -133,7 +121,7 @@ std::string WrapFragmentShader( const std::string& fragmentPrefix, const std::st return fragmentSource; } -std::string GetShader(const std::string& field, const Property::Value& property) +std::string GetStringProperty(const std::string& field, const Property::Value& property) { std::string retval; const Property::Map* map = property.GetMap(); @@ -149,48 +137,44 @@ std::string GetShader(const std::string& field, const Property::Value& property) return retval; } -} // unnamed namespace - -ShaderEffectPtr ShaderEffect::New( Dali::ShaderEffect::GeometryHints hints ) +Dali::Shader::ShaderHints ConvertHints( Dali::ShaderEffect::GeometryHints hints) { - Stage* stage = Stage::GetCurrent(); - - if( stage ) + int convertedHints = Dali::Shader::HINT_NONE; + if( hints & Dali::ShaderEffect::HINT_DEPTH_BUFFER ) { - ShaderEffectPtr shaderEffect( new ShaderEffect( *stage, hints ) ); - shaderEffect->RegisterObject(); - return shaderEffect; + convertedHints |= Dali::Shader::HINT_REQUIRES_SELF_DEPTH_TEST; } - else + if( hints & Dali::ShaderEffect::HINT_BLENDING ) + { + convertedHints |= Dali::Shader::HINT_OUTPUT_IS_TRANSPARENT; + } + if( !(hints & Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY) ) { - return NULL; + convertedHints |= Dali::Shader::HINT_MODIFIES_GEOMETRY; } + + return Dali::Shader::ShaderHints( convertedHints ); } -ShaderEffect::ShaderEffect( EventThreadServices& eventThreadServices, Dali::ShaderEffect::GeometryHints hints ) -: mEventThreadServices( eventThreadServices ), - mGeometryHints( hints ), - mGridDensity( Dali::ShaderEffect::DEFAULT_GRID_DENSITY ) +} // unnamed namespace + +ShaderEffectPtr ShaderEffect::New( Dali::ShaderEffect::GeometryHints hints ) { - mSceneObject = new SceneGraph::Shader( hints ); - DALI_ASSERT_DEBUG( NULL != mSceneObject ); + ShaderEffectPtr shaderEffect( new ShaderEffect( hints ) ); + shaderEffect->RegisterObject(); + return shaderEffect; +} - // Transfer shader ownership to a scene message - AddShaderMessage( eventThreadServices.GetUpdateManager(), *mSceneObject ); +ShaderEffect::ShaderEffect( Dali::ShaderEffect::GeometryHints hints ) +: mGridDensity( Dali::ShaderEffect::DEFAULT_GRID_DENSITY ), + mGeometryHints( hints ) +{ } ShaderEffect::~ShaderEffect() { // Guard to allow handle destruction after Core has been destroyed - if ( Stage::IsInstalled() ) - { - // Remove scene-object using a message to the UpdateManager - if( mSceneObject ) - { - RemoveShaderMessage( mEventThreadServices.GetUpdateManager(), *mSceneObject ); - } - UnregisterObject(); - } + UnregisterObject(); } void ShaderEffect::SetEffectImage( Dali::Image image ) @@ -233,20 +217,7 @@ void ShaderEffect::SetEffectImage( Dali::Image image ) void ShaderEffect::SetUniform( const std::string& name, Property::Value value, UniformCoordinateType uniformCoordinateType ) { // Register the property if it does not exist - Property::Index index = RegisterProperty( name, value ); - - Uniform uniform = { name, index, value }; - mUniforms.push_back( uniform ); - - //inform any connected actors - for(std::vector< ActorPtr >::iterator it = mConnectedActors.begin(); it != mConnectedActors.end(); ++it) - { - ImageActor* imageActor = dynamic_cast< ImageActor* >( (*it).Get() ); - if( imageActor ) - { - imageActor->EffectUniformUpdated( uniform ); - } - } + mShader->RegisterProperty( name, value ); } void ShaderEffect::SetPrograms( const string& vertexSource, const string& fragmentSource ) @@ -257,8 +228,28 @@ void ShaderEffect::SetPrograms( const string& vertexSource, const string& fragme void ShaderEffect::SetPrograms( const std::string& vertexPrefix, const std::string& fragmentPrefix, const std::string& vertexSource, const std::string& fragmentSource ) { - mVertexSource = WrapVertexShader( vertexPrefix, vertexSource ); - mFragmentSource = WrapFragmentShader( fragmentPrefix, fragmentSource ); + mShader = Shader::New( WrapVertexShader( vertexPrefix, vertexSource ), + WrapFragmentShader( fragmentPrefix, fragmentSource ), + ConvertHints( mGeometryHints ) ); +} + +Vector2 ShaderEffect::GetGridSize( const Vector2& size ) +{ + Vector2 gridSize( 1.f, 1.f ); + + if( mGridDensity > 0 ) + { + if( ( mGeometryHints & Dali::ShaderEffect::HINT_GRID_X ) ) + { + gridSize.x = ceil( size.width / mGridDensity ); + } + if( ( mGeometryHints & Dali::ShaderEffect::HINT_GRID_Y ) ) + { + gridSize.y = ceil( size.height / mGridDensity ); + } + } + + return gridSize; } void ShaderEffect::Connect( ActorPtr actor ) @@ -296,6 +287,135 @@ void ShaderEffect::Disconnect( ActorPtr actor ) } } +unsigned int ShaderEffect::GetPropertyCount() const +{ + return GetDefaultPropertyCount() + mShader->GetPropertyCount(); +} + +std::string ShaderEffect::GetPropertyName( Property::Index index ) const +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + return GetDefaultPropertyName( index ); + } + else + { + return mShader->GetPropertyName( index ); + } +} + +Property::Index ShaderEffect::GetPropertyIndex( const std::string& name ) const +{ + Property::Index index = GetDefaultPropertyIndex( name ); + if( index == Property::INVALID_INDEX ) + { + return mShader->GetPropertyIndex( name ); + } + else + { + return index; + } +} + +bool ShaderEffect::IsPropertyWritable( Property::Index index ) const +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + return IsDefaultPropertyWritable( index ); + } + else + { + return mShader->IsPropertyWritable( index ); + } +} + +bool ShaderEffect::IsPropertyAnimatable( Property::Index index ) const +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + return IsDefaultPropertyAnimatable( index ); + } + else + { + return mShader->IsPropertyAnimatable( index ); + } +} + +bool ShaderEffect::IsPropertyAConstraintInput( Property::Index index ) const +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + return IsDefaultPropertyAConstraintInput( index ); + } + else + { + return mShader->IsPropertyAConstraintInput( index ); + } +} + +Property::Type ShaderEffect::GetPropertyType( Property::Index index ) const +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + return GetDefaultPropertyType( index ); + } + return mShader->GetPropertyType( index ); +} + +void ShaderEffect::SetProperty( Property::Index index, const Property::Value& propertyValue ) +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + SetDefaultProperty( index, propertyValue ); + } + else + { + mShader->SetProperty( index, propertyValue ); + } +} + +Property::Value ShaderEffect::GetProperty( Property::Index index ) const +{ + if ( index < DEFAULT_PROPERTY_COUNT ) + { + return GetDefaultProperty( index ); + } + return mShader->GetProperty( index ); +} + +void ShaderEffect::GetPropertyIndices( Property::IndexContainer& indices ) const +{ + mShader->GetPropertyIndices( indices ); + GetDefaultPropertyIndices( indices ); +} + +Property::Index ShaderEffect::RegisterProperty( const std::string& name, const Property::Value& propertyValue ) +{ + return mShader->RegisterProperty( name, propertyValue ); +} + +Property::Index ShaderEffect::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ) +{ + return mShader->RegisterProperty( name, propertyValue, accessMode ); +} + +Dali::PropertyNotification ShaderEffect::AddPropertyNotification( Property::Index index, + int componentIndex, + const Dali::PropertyCondition& condition ) +{ + return mShader->AddPropertyNotification( index, componentIndex, condition ); +} + +void ShaderEffect::RemovePropertyNotification( Dali::PropertyNotification propertyNotification ) +{ + mShader->RemovePropertyNotification( propertyNotification ); +} + +void ShaderEffect::RemovePropertyNotifications() +{ + mShader->RemovePropertyNotifications(); +} + unsigned int ShaderEffect::GetDefaultPropertyCount() const { return DEFAULT_PROPERTY_COUNT; @@ -303,7 +423,7 @@ unsigned int ShaderEffect::GetDefaultPropertyCount() const void ShaderEffect::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const { - indices.Reserve( DEFAULT_PROPERTY_COUNT ); + indices.Reserve( indices.Size() + DEFAULT_PROPERTY_COUNT ); for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { @@ -400,10 +520,10 @@ void ShaderEffect::SetDefaultProperty( Property::Index index, const Property::Va case Dali::ShaderEffect::Property::PROGRAM: { - std::string vertexPrefix = GetShader("vertexPrefix", propertyValue); - std::string fragmentPrefix = GetShader("fragmentPrefix", propertyValue); - std::string vertex = GetShader("vertex", propertyValue); - std::string fragment = GetShader("fragment", propertyValue); + std::string vertexPrefix = GetStringProperty("vertexPrefix", propertyValue); + std::string fragmentPrefix = GetStringProperty("fragmentPrefix", propertyValue); + std::string vertex = GetStringProperty("vertex", propertyValue); + std::string fragment = GetStringProperty("fragment", propertyValue); SetPrograms( vertexPrefix, fragmentPrefix, vertex, fragment ); break; @@ -464,19 +584,22 @@ Property::Value ShaderEffect::GetDefaultProperty(Property::Index /*index*/) cons const SceneGraph::PropertyOwner* ShaderEffect::GetSceneObject() const { - return mSceneObject; + return mShader->GetSceneObject(); } -const PropertyBase* ShaderEffect::GetSceneObjectAnimatableProperty( Property::Index index ) const +const SceneGraph::PropertyBase* ShaderEffect::GetSceneObjectAnimatableProperty( Property::Index index ) const { - PropertyMetadata* property = index >= PROPERTY_CUSTOM_START_INDEX ? static_cast(FindCustomProperty( index )) : static_cast(FindAnimatableProperty( index )); - DALI_ASSERT_ALWAYS( property && "Property index is invalid" ); - return property->GetSceneGraphProperty(); + return mShader->GetSceneObjectAnimatableProperty( index ); } const PropertyInputImpl* ShaderEffect::GetSceneObjectInputProperty( Property::Index index ) const { - return GetSceneObjectAnimatableProperty( index ); + return mShader->GetSceneObjectInputProperty( index ); +} + +int ShaderEffect::GetPropertyComponentIndex( Property::Index index ) const +{ + return mShader->GetPropertyComponentIndex( index ); } } // namespace Internal diff --git a/dali/internal/event/effects/shader-effect-impl.h b/dali/internal/event/effects/shader-effect-impl.h index 2443804..ecbf75c 100644 --- a/dali/internal/event/effects/shader-effect-impl.h +++ b/dali/internal/event/effects/shader-effect-impl.h @@ -24,8 +24,7 @@ #include #include #include -#include -#include +#include namespace Dali { @@ -33,11 +32,6 @@ namespace Dali namespace Internal { -namespace SceneGraph -{ -class UpdateManager; -} - /** * An abstract base class for a shader effect object. * The corresponding scene-graph object is a collection of shader programs, @@ -48,15 +42,6 @@ class ShaderEffect : public Object public: typedef Dali::ShaderEffect::UniformCoordinateType UniformCoordinateType; - struct Uniform - { - std::string mName; - Property::Index mIndex; - Property::Value mValue; - }; - - typedef std::vector< Uniform > UniformArray; - /** * Create a new ShaderEffect with no programs * @param hints GeometryHints to define the geometry of the rendered object @@ -77,20 +62,6 @@ public: UniformCoordinateType uniformCoordinateType ); /** - * Returns the uniforms set for the shaders - * - * @return Returns and array of uniforms set for the shaders - */ - const UniformArray& GetUniforms() {return mUniforms;} - - /** - * Returns the GeometryHints used - * - * @return Returns the GeometryHints used - */ - Dali::ShaderEffect::GeometryHints GetGeometryHints() const {return mGeometryHints;} - - /** * Add a GeometryType specific default program to this ShaderEffect * @param[in] geometryType The GeometryType rendered by the shader program * @param[in] vertexSource The source code for the vertex shader @@ -113,43 +84,122 @@ public: /** * @brief Notify ShaderEffect that it's being used by an Actor. * - * @param[in] actor The Actor that is connecting to this ShaderEffect + * @param[in] actor The Actor that is connecting to this ShaderEffect */ void Connect( ActorPtr actor ); /** * @brief Notify ShaderEffect that an Actor is no longer using it. * - * @param[in] actor The Actor that is disconnecting from this ShaderEffect + * @param[in] actor The Actor that is disconnecting from this ShaderEffect */ void Disconnect( ActorPtr actor ); public: /** - * Returns the vertex shader for this ShaderEffect + * Returns the shader for this ShaderEffect * - * @return Returns the vertex shader for this ShaderEffect + * @return Returns the shader for this ShaderEffect */ - const std::string& GetVertexShader() const {return mVertexSource;} + ShaderPtr GetShader() const { return mShader; } /** - * Returns the fragment shader for this ShaderEffect + * Returns the geometry grid size. * - * @return Returns the fragment shader for this ShaderEffect + * @param[in] size The pixel area size. + * @return Returns the geometry grid size */ - const std::string& GetFragmentShader() const {return mFragmentSource;} + Vector2 GetGridSize( const Vector2& size ); /** - * Returns the fragment shader for this ShaderEffect + * Returns the effect image for this ShaderEffect * - * @return Returns the fragment shader for this ShaderEffect + * @return Returns the effect image for this ShaderEffect */ - Dali::Image GetEffectImage() const {return mEffectImage;} + Dali::Image GetEffectImage() const { return mEffectImage; } -public: // Default property extensions from Object +public: // override property functions from Object + + /** + * @copydoc Dali::Handle::GetPropertyCount() + */ + virtual unsigned int GetPropertyCount() const; + + /** + * @copydoc Dali::Handle::GetPropertyName() + */ + virtual std::string GetPropertyName( Property::Index index ) const; + + /** + * @copydoc Dali::Handle::GetPropertyIndex() + */ + virtual Property::Index GetPropertyIndex( const std::string& name ) const; + + /** + * @copydoc Dali::Handle::IsPropertyWritable() + */ + virtual bool IsPropertyWritable( Property::Index index ) const; /** + * @copydoc Dali::Handle::IsPropertyAnimatable() + */ + virtual bool IsPropertyAnimatable( Property::Index index ) const; + + /** + * @copydoc Dali::Handle::IsPropertyAConstraintInput() + */ + virtual bool IsPropertyAConstraintInput( Property::Index index ) const; + + /** + * @copydoc Dali::Handle::GetPropertyType() + */ + virtual Property::Type GetPropertyType( Property::Index index ) const; + + /** + * @copydoc Dali::Handle::SetProperty() + */ + virtual void SetProperty( Property::Index index, const Property::Value& propertyValue ); + + /** + * @copydoc Dali::Handle::GetProperty() + */ + virtual Property::Value GetProperty( Property::Index index ) const; + + /** + * @copydoc Dali::Handle::GetPropertyIndices() + */ + virtual void GetPropertyIndices( Property::IndexContainer& indices ) const; + + /** + * @copydoc Dali::Handle::RegisterProperty() + */ + virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); + + /** + * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode) + */ + virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); + + /** + * @copydoc Dali::Handle::AddPropertyNotification() + */ + virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index, + int componentIndex, + const Dali::PropertyCondition& condition ); + + /** + * @copydoc Dali::Handle::RemovePropertyNotification() + */ + virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification ); + + /** + * @copydoc Dali::Handle::RemovePropertyNotifications() + */ + virtual void RemovePropertyNotifications(); + +public: // Default property extensions from Object + /** * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() */ virtual unsigned int GetDefaultPropertyCount() const; @@ -214,14 +264,18 @@ public: // Default property extensions from Object */ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const; + /** + * @copydoc Dali::Internal::Object::GetPropertyComponentIndex() + */ + virtual int GetPropertyComponentIndex( Property::Index index ) const; + protected: /** * Protected constructor. - * @param[in] eventThreadServices the interface to use for sending messages to the update thread * @param[in] hints Geometry hints */ - ShaderEffect( EventThreadServices& eventThreadServices, Dali::ShaderEffect::GeometryHints hints ); + ShaderEffect( Dali::ShaderEffect::GeometryHints hints ); /** * A reference counted object may only be deleted by calling Unreference() @@ -236,17 +290,11 @@ private: private: // Data std::vector< ActorPtr > mConnectedActors; ///< The array of actors that are currently connected to this ShaderEffect - UniformArray mUniforms; ///< The array of uniforms set for this ShaderEffect - - std::string mVertexSource; ///< The vertex shader source - std::string mFragmentSource; ///< The fragment shader source - - EventThreadServices& mEventThreadServices; ///< Event thread services, for sending messages - SceneGraph::Shader* mSceneObject; ///< Pointer to the scene shader, should not be changed on this thread + ShaderPtr mShader; ///< The shader pointer + Dali::Image mEffectImage; ///< The Client-side handle to the effect image + float mGridDensity; ///< The grid denisty + Dali::ShaderEffect::GeometryHints mGeometryHints; ///< shader geometry hints for building the geometry - Dali::Image mEffectImage; ///< The Client-side handle to the effect image - Dali::ShaderEffect::GeometryHints mGeometryHints; ///< shader geometry hints for building the geometry - float mGridDensity; ///< The grid denisty }; } // namespace Internal diff --git a/dali/internal/event/effects/shader-factory.h b/dali/internal/event/effects/shader-factory.h index 17a4204..88feff5 100644 --- a/dali/internal/event/effects/shader-factory.h +++ b/dali/internal/event/effects/shader-factory.h @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace Dali diff --git a/dali/public-api/shader-effects/shader-effect.h b/dali/public-api/shader-effects/shader-effect.h index 1ab3fc9..13ff711 100644 --- a/dali/public-api/shader-effects/shader-effect.h +++ b/dali/public-api/shader-effects/shader-effect.h @@ -114,7 +114,7 @@ public: // Default Properties /** - * @brief An enumeration of properties belonging to the Path class. + * @brief An enumeration of properties belonging to the ShaderEffect class. * Grid Density defines the spacing of vertex coordinates in world units. * ie a larger actor will have more grids at the same spacing. * -- 2.7.4