END_TEST;
}
+int UtcDaliShaderEffectMethodApplyConstraintOffStage(void)
+{
+ // The same test as UtcDaliShaderEffectMethodApplyConstraint,
+ // except the Actor is off-stage when the constraint is applied to the shader
+ TestApplication application;
+
+ ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
+ DALI_TEST_CHECK( effect );
+
+ BufferImage image = CreateBufferImage();
+
+ effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
+
+ ImageActor actor = ImageActor::New( image );
+ actor.SetSize( 100.0f, 100.0f );
+ actor.SetName("TestImageFilenameActor");
+ actor.SetShaderEffect(effect);
+ // Note - Do not add actor to stage here
+
+ Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
+
+ Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+ constraint.Apply();
+
+ // Note - Now we add the actor (after constraint was applied to the shader)
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ // Test effects of Constraint.
+ DALI_TEST_CHECK(
+ application.GetGlAbstraction().CheckUniformValue(
+ "uVec3", Vector3( 4.0f, 9.0f, 16.0f ) ) );
+ END_TEST;
+}
int UtcDaliShaderEffectMethodApplyConstraintFromActor(void)
{
void Material::SetShader( Shader& shader )
{
DALI_ASSERT_DEBUG( mSceneObject )
- mShaderConnector.Set( shader, OnStage() );
+ mShader = &shader;
const SceneGraph::Shader& sceneGraphShader = dynamic_cast<const SceneGraph::Shader&>( *shader.GetSceneObject() );
SceneGraph::SetShaderMessage( GetEventThreadServices(), *mSceneObject, sceneGraphShader );
Shader* Material::GetShader() const
{
- return mShaderConnector.Get().Get();
+ return mShader.Get();
}
void Material::AddSampler( Sampler& sampler )
{
it->OnStageConnect();
}
- mShaderConnector.OnStageConnect();
}
void Material::Disconnect()
{
it->OnStageDisconnect();
}
- mShaderConnector.OnStageDisconnect();
}
Material::Material()
Material& operator=( const Material& );
private: //data
- typedef ObjectConnector<Shader> ShaderConnector;
- ShaderConnector mShaderConnector; ///< Connector that holds the shader used by this material
+ IntrusivePtr<Shader> mShader; ///< Connector that holds the shader used by this material
typedef ObjectConnector<Sampler> SamplerConnector;
typedef std::vector< SamplerConnector > SamplerConnectorContainer;
DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
const SceneGraph::PropertyBase* property = NULL;
- if( OnStage() )
- {
- property = SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Shader::FindAnimatableProperty,
- &Shader::FindCustomProperty,
- index );
+ property = SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Shader::FindAnimatableProperty,
+ &Shader::FindCustomProperty,
+ index );
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
- }
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
}
return property;
{
const PropertyInputImpl* property = NULL;
- if( OnStage() )
+ const SceneGraph::PropertyBase* baseProperty =
+ SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
+ &Shader::FindAnimatableProperty,
+ &Shader::FindCustomProperty,
+ index );
+ property = static_cast<const PropertyInputImpl*>( baseProperty );
+
+ if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
{
- const SceneGraph::PropertyBase* baseProperty =
- SHADER_IMPL.GetRegisteredSceneGraphProperty( this,
- &Shader::FindAnimatableProperty,
- &Shader::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
+ if( index == Dali::Shader::Property::SHADER_HINTS )
+ {
+ // @todo MESH_REWORK - return the property
+ }
+ else
{
- if( index == Dali::Shader::Property::SHADER_HINTS )
- {
- // @todo MESH_REWORK - return the property
- }
- else
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not a valid constraint input" );
- }
+ DALI_ASSERT_ALWAYS( 0 && "Property is not a valid constraint input" );
}
}
return Property::INVALID_COMPONENT_INDEX;
}
-bool Shader::OnStage() const
-{
- return mOnStage;
-}
-
-void Shader::Connect()
-{
- mOnStage = true;
-}
-
-void Shader::Disconnect()
-{
- mOnStage = false;
-}
-
Shader::Shader()
-: mSceneObject( NULL ),
- mOnStage( false )
+: mSceneObject( NULL )
{
}
#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
#include <dali/devel-api/rendering/shader.h> // Dali::Shader
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
#include <dali/internal/event/resources/resource-ticket.h> // Dali::Internal::ResourceTicketPtr
* Shader is an object that contains an array of structures of values that
* can be accessed as properties.
*/
-class Shader : public Object, public Connectable
+class Shader : public Object
{
public:
*/
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:
SceneGraph::Shader* mSceneObject;
- bool mOnStage;
};
} // namespace Internal