END_TEST;
}
-
-
-
int UtcDaliRendererUniformMapPrecendence01(void)
{
TestApplication application;
application.Render(0);
renderer.RegisterProperty( "uFadeColor", Color::RED );
-
actor.RegisterProperty( "uFadeColor", Color::GREEN );
-
- Property::Index textureSetFadeColorIndex = textureSet.RegisterProperty( "uFadeColor", Color::BLUE );
-
- shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
+ Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
- // Animate texture set's fade color property. Should be no change to uniform
+ // Animate shader's fade color property. Should be no change to uniform
Animation animation = Animation::New(1.0f);
KeyFrames keyFrames = KeyFrames::New();
keyFrames.Add(0.0f, Color::WHITE);
keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( textureSet, textureSetFadeColorIndex ), keyFrames );
+ animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
animation.Play();
application.SendNotification();
application.Render(0);
// Don't add property / uniform map to renderer
-
actor.RegisterProperty( "uFadeColor", Color::GREEN );
-
- Property::Index textureSetFadeColorIndex = textureSet.RegisterProperty( "uFadeColor", Color::BLUE );
-
- shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
-
+ Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
TestGlAbstraction& gl = application.GetGlAbstraction();
KeyFrames keyFrames = KeyFrames::New();
keyFrames.Add(0.0f, Color::WHITE);
keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( textureSet, textureSetFadeColorIndex ), keyFrames );
+ animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
animation.Play();
application.SendNotification();
application.Render(0);
// Don't add property / uniform map to renderer or actor
-
- textureSet.RegisterProperty( "uFadeColor", Color::BLUE );
-
- Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLACK );
+ shader.RegisterProperty( "uFadeColor", Color::BLACK );
TestGlAbstraction& gl = application.GetGlAbstraction();
application.SendNotification();
application.Render(0);
- // Expect that the texture set's fade color property is accessed
+ // Expect that the shader's fade color property is accessed
Vector4 actualValue(Vector4::ZERO);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
-
- // Animate geometry's fade color property. Should be no change to uniform
- Animation animation = Animation::New(1.0f);
- KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, Color::WHITE);
- keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
- animation.Play();
-
- application.SendNotification();
- application.Render(500);
-
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
-
- application.Render(500);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
+ DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
END_TEST;
}
renderer.RegisterProperty( "uUniform1", Color::RED );
actor.RegisterProperty( "uUniform2", Color::GREEN );
- textureSet.RegisterProperty( "uUniform3", Color::BLUE );
- shader.RegisterProperty( "uUniform4", Color::MAGENTA );
+ shader.RegisterProperty( "uUniform3", Color::MAGENTA );
TestGlAbstraction& gl = application.GetGlAbstraction();
Vector4 uniform3Value(Vector4::ZERO);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
- DALI_TEST_EQUALS( uniform3Value, Color::BLUE, TEST_LOCATION );
-
- Vector4 uniform4Value(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform4", uniform4Value ) );
- DALI_TEST_EQUALS( uniform4Value, Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
END_TEST;
}
Property::Value value2(1.0f);
actor.RegisterProperty( "uFadeProgress", value2 );
- Property::Value value3(Vector3(0.5f, 0.5f, 1.0f));
- textureSet.RegisterProperty( "uFadePosition", value3);
-
- Property::Value value5(Matrix3::IDENTITY);
- shader.RegisterProperty( "uANormalMatrix", value5 );
+ Property::Value value3(Matrix3::IDENTITY);
+ shader.RegisterProperty( "uANormalMatrix", value3 );
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
- Vector3 uniform3Value(Vector3::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "uFadePosition", uniform3Value ) );
- DALI_TEST_EQUALS( uniform3Value, value3.Get<Vector3>(), TEST_LOCATION );
-
- Matrix3 uniform5Value;
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform5Value ) );
- DALI_TEST_EQUALS( uniform5Value, value5.Get<Matrix3>(), TEST_LOCATION );
+ Matrix3 uniform3Value;
+ DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
+ DALI_TEST_EQUALS( uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION );
END_TEST;
}
END_TEST;
}
-int UtcDaliTextureSetConstraint(void)
-{
- TestApplication application;
-
- tet_infoline("Test that a custom texture set property can be constrained");
-
- Shader shader = Shader::New( "VertexSource", "FragmentSource");
- TextureSet textureSet = TextureSet::New();
-
- Geometry geometry = CreateQuadGeometry();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = textureSet.RegisterProperty( "uFadeColor", initialColor );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
-
- // Apply constraint
- Constraint constraint = Constraint::New<Vector4>( textureSet, colorIndex, TestConstraintNoBlue );
- constraint.Apply();
- application.SendNotification();
- application.Render(0);
-
- // Expect no blue component in either buffer - yellow
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
- application.Render(0);
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
-
- textureSet.RemoveConstraints();
- textureSet.SetProperty(colorIndex, Color::WHITE );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliTextureSetConstraint02(void)
-{
- TestApplication application;
-
- tet_infoline("Test that a uniform map texture set property can be constrained");
-
- Shader shader = Shader::New( "VertexSource", "FragmentSource");
- TextureSet textureSet = TextureSet::New();
-
- Geometry geometry = CreateQuadGeometry();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = textureSet.RegisterProperty( "uFadeColor", initialColor );
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
- application.SendNotification();
- application.Render(0);
-
- Vector4 actualValue(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
-
- // Apply constraint
- Constraint constraint = Constraint::New<Vector4>( textureSet, colorIndex, TestConstraintNoBlue );
- constraint.Apply();
- application.SendNotification();
- application.Render(0);
-
- // Expect no blue component in either buffer - yellow
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
-
- application.Render(0);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
-
- textureSet.RemoveConstraints();
- textureSet.SetProperty(colorIndex, Color::WHITE );
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliTextureSetAnimatedProperty01(void)
-{
- TestApplication application;
-
- tet_infoline("Test that a non-uniform texture set property can be animated");
-
- Shader shader = Shader::New( "VertexSource", "FragmentSource");
- TextureSet textureSet = TextureSet::New();
-
- Geometry geometry = CreateQuadGeometry();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = textureSet.RegisterProperty( "uFadeColor", initialColor );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
-
- Animation animation = Animation::New(1.0f);
- KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, initialColor);
- keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( textureSet, colorIndex ), keyFrames );
- animation.Play();
-
- application.SendNotification();
- application.Render(500);
-
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
-
- application.Render(500);
-
- DALI_TEST_EQUALS( textureSet.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliTextureSetAnimatedProperty02(void)
-{
- TestApplication application;
-
- tet_infoline("Test that a uniform map texture set property can be animated");
-
- Shader shader = Shader::New( "VertexSource", "FragmentSource");
- TextureSet textureSet = TextureSet::New();
-
- Geometry geometry = CreateQuadGeometry();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(0);
-
- Vector4 initialColor = Color::WHITE;
- Property::Index colorIndex = textureSet.RegisterProperty( "uFadeColor", initialColor );
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
- application.SendNotification();
- application.Render(0);
-
- Vector4 actualValue(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
-
- Animation animation = Animation::New(1.0f);
- KeyFrames keyFrames = KeyFrames::New();
- keyFrames.Add(0.0f, initialColor);
- keyFrames.Add(1.0f, Color::TRANSPARENT);
- animation.AnimateBetween( Property( textureSet, colorIndex ), keyFrames );
- animation.Play();
-
- application.SendNotification();
- application.Render(500);
-
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
-
- application.Render(500);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
-
- END_TEST;
-}
-
int UtcDaliTextureSetSetImage01(void)
{
TestApplication application;
}
TextureSet::TextureSet( const TextureSet& handle )
-: Handle( handle )
+: BaseHandle( handle )
{
}
}
TextureSet::TextureSet( Internal::TextureSet* pointer )
-: Handle( pointer )
+: BaseHandle( pointer )
{
}
* @brief TextureSet is a handle to an object that specifies the set of images used as textures by a renderer
* The images have to be ordered in the same order they are declared in the shader
*/
-class DALI_IMPORT_API TextureSet : public Handle
+class DALI_IMPORT_API TextureSet : public BaseHandle
{
public:
textureRect.w = vScale * float(mPixelArea.y + mPixelArea.height);
}
- TextureSet* textureSet = mRenderer->GetTextures();
- textureSet->RegisterProperty( TEXTURE_RECT_UNIFORM_NAME, textureRect );
+ mRenderer->RegisterProperty( TEXTURE_RECT_UNIFORM_NAME, textureRect );
}
unsigned int ImageActor::GetDefaultPropertyCount() const
#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
#include <dali/internal/update/manager/update-manager.h>
namespace Dali
namespace Internal
{
-namespace
-{
-
-BaseHandle Create()
-{
- return Dali::Geometry::New();
-}
-
-TypeRegistration mType( typeid( Dali::Geometry ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
GeometryPtr Geometry::New()
{
GeometryPtr geometry( new Geometry() );
// CLASS HEADER
#include <dali/internal/event/rendering/texture-set-impl.h> // Dali::Internal::TextureSet
-//EXTERNAL INCLUDES
-#include <string>
-
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/rendering/texture-set.h> // Dali::Internal::Render::TextureSet
#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/rendering/scene-graph-texture-set.h>
namespace Internal
{
-namespace
-{
-
-const ObjectImplHelper<0> TEXTURE_SET_IMPL = { NULL };
-
-BaseHandle Create()
-{
- return Dali::BaseHandle();
-}
-
-TypeRegistration mType( typeid( Dali::TextureSet ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
TextureSetPtr TextureSet::New()
{
TextureSetPtr textureSet( new TextureSet() );
{
image->Connect();
}
- SceneGraph::SetImageMessage( GetEventThreadServices(), *mSceneObject, index, image->GetResourceId() );
+ SceneGraph::SetImageMessage( mEventThreadServices, *mSceneObject, index, image->GetResourceId() );
}
else
{
- SceneGraph::SetImageMessage( GetEventThreadServices(), *mSceneObject, index, Integration::InvalidResourceId );
+ SceneGraph::SetImageMessage( mEventThreadServices, *mSceneObject, index, Integration::InvalidResourceId );
}
}
renderSampler = sampler->GetSamplerRenderObject();
}
- SceneGraph::SetSamplerMessage( GetEventThreadServices(), *mSceneObject, index, renderSampler );
+ SceneGraph::SetSamplerMessage( mEventThreadServices, *mSceneObject, index, renderSampler );
}
Sampler* TextureSet::GetSampler( size_t index ) const
return mSceneObject;
}
-unsigned int TextureSet::GetDefaultPropertyCount() const
-{
- return TEXTURE_SET_IMPL.GetDefaultPropertyCount();
-}
-
-void TextureSet::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- TEXTURE_SET_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* TextureSet::GetDefaultPropertyName(Property::Index index) const
-{
- return TEXTURE_SET_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index TextureSet::GetDefaultPropertyIndex( const std::string& name ) const
-{
- return TEXTURE_SET_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool TextureSet::IsDefaultPropertyWritable( Property::Index index ) const
-{
- return TEXTURE_SET_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool TextureSet::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- return TEXTURE_SET_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool TextureSet::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return TEXTURE_SET_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type TextureSet::GetDefaultPropertyType( Property::Index index ) const
-{
- return TEXTURE_SET_IMPL.GetDefaultPropertyType( index );
-}
-
-void TextureSet::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
-{
-}
-
-void TextureSet::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- TEXTURE_SET_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
-Property::Value TextureSet::GetDefaultProperty( Property::Index index ) const
-{
- Property::Value value;
- return value;
-}
-
-const SceneGraph::PropertyOwner* TextureSet::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* TextureSet::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* TextureSet::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- PropertyMetadata* property = index >= PROPERTY_CUSTOM_START_INDEX ? static_cast<PropertyMetadata*>(FindCustomProperty( index )) : static_cast<PropertyMetadata*>(FindAnimatableProperty( index ));
- DALI_ASSERT_ALWAYS( property && "Property index is invalid" );
- return property->GetSceneGraphProperty();
-}
-
-const PropertyInputImpl* TextureSet::GetSceneObjectInputProperty( Property::Index index ) const
-{
- return GetSceneObjectAnimatableProperty( index );
-}
-
-int TextureSet::GetPropertyComponentIndex( Property::Index index ) const
-{
- return Property::INVALID_COMPONENT_INDEX;
-}
-
bool TextureSet::OnStage() const
{
return mOnStage;
if( mTextures[i].image )
{
mTextures[i].image->Connect();
- SceneGraph::SetImageMessage( GetEventThreadServices(), *mSceneObject, i, mTextures[i].image->GetResourceId() );
+ SceneGraph::SetImageMessage( mEventThreadServices, *mSceneObject, i, mTextures[i].image->GetResourceId() );
}
else
{
- SceneGraph::SetImageMessage( GetEventThreadServices(), *mSceneObject, i, Integration::InvalidResourceId );
+ SceneGraph::SetImageMessage( mEventThreadServices, *mSceneObject, i, Integration::InvalidResourceId );
}
}
}
}
TextureSet::TextureSet()
-: mSceneObject( NULL ),
- mTextures(),
- mOnStage( false )
+:mEventThreadServices( *Stage::GetCurrent() ),
+ mSceneObject( NULL ),
+ mTextures(),
+ mOnStage( false )
{
}
void TextureSet::Initialize()
{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
mSceneObject = SceneGraph::TextureSet::New();
- AddMessage( updateManager, updateManager.GetTexturesOwner(), *mSceneObject );
-
- eventThreadServices.RegisterObject( this );
+ AddTextureSetMessage( updateManager, *mSceneObject );
}
TextureSet::~TextureSet()
{
if( EventThreadServices::IsCoreRunning() )
{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveMessage( updateManager, updateManager.GetTexturesOwner(), *mSceneObject );
-
- eventThreadServices.UnregisterObject( this );
+ SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
+ RemoveTextureSetMessage( updateManager, *mSceneObject );
}
}
/**
* TextureSet is an object that holds all the textures used by a renderer
*/
-class TextureSet : public Object, public Connectable
+class TextureSet : public BaseObject, public Connectable
{
public:
*/
const SceneGraph::TextureSet* GetTextureSetSceneObject() const;
-public: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
public: // Functions from Connectable
/**
* @copydoc Dali::Internal::Connectable::OnStage()
TextureSet& operator=( const TextureSet& );
private: // Data
-
+ EventThreadServices& mEventThreadServices; ///<Used to send messages to the update thread
SceneGraph::TextureSet* mSceneObject;
std::vector<Texture> mTextures;
bool mOnStage;
}
}
-void DiscardQueue::Add( BufferIndex updateBufferIndex, TextureSet* textureSet )
-{
- DALI_ASSERT_DEBUG( NULL != textureSet );
-
- // The GL resources will now be freed in frame N
- // The Update for frame N+1 may occur in parallel with the rendering of frame N
- // Queue the node for destruction in frame N+2
- if ( 0u == updateBufferIndex )
- {
- mTextureSetQueue0.PushBack( textureSet );
- }
- else
- {
- mTextureSetQueue1.PushBack( textureSet );
- }
-}
-
-
void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
{
DALI_ASSERT_DEBUG( NULL != shader );
{
mNodeQueue0.Clear();
mShaderQueue0.Clear();
- mTextureSetQueue0.Clear();
mRendererQueue0.Clear();
}
else
{
mNodeQueue1.Clear();
mShaderQueue1.Clear();
- mTextureSetQueue1.Clear();
mRendererQueue1.Clear();
}
}
public:
typedef OwnerContainer< Shader* > ShaderQueue;
- typedef OwnerContainer< TextureSet* > TextureSetQueue;
typedef OwnerContainer< Renderer* > RendererQueue;
/**
void Add( BufferIndex updateBufferIndex, Node* node );
/**
- * Adds an unwanted texture set to the discard queue.
- * A message will be sent to clean up GL resources in the next Render.
- */
- void Add( BufferIndex updateBufferIndex, TextureSet* textureSet );
-
- /**
* Adds an unwanted shader to the discard queue.
* A message will be sent to clean-up GL resources in the next Render.
* @pre This method is not thread-safe, and should only be called from the update-thread.
// Messages are queued here when the update buffer index == 0
NodeOwnerContainer mNodeQueue0;
ShaderQueue mShaderQueue0;
- TextureSetQueue mTextureSetQueue0;
RendererQueue mRendererQueue0;
// Messages are queued here when the update buffer index == 1
NodeOwnerContainer mNodeQueue1;
ShaderQueue mShaderQueue1;
- TextureSetQueue mTextureSetQueue1;
RendererQueue mRendererQueue1;
};
typedef GestureContainer::Iterator GestureIter;
typedef GestureContainer::ConstIterator GestureConstIter;
+typedef OwnerContainer< TextureSet* > TextureSetContainer;
+typedef TextureSetContainer::Iterator TextureSetIter;
+typedef TextureSetContainer::ConstIterator TextureSetConstIter;
/**
* Structure to contain UpdateManager internal data
root( NULL ),
systemLevelRoot( NULL ),
renderers( sceneGraphBuffers, discardQueue ),
- textureSets( sceneGraphBuffers, discardQueue ),
+ textureSets(),
messageQueue( renderController, sceneGraphBuffers ),
keepRenderingSeconds( 0.0f ),
animationFinishedDuringUpdate( false ),
sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue, textureCache );
renderers.SetSceneController( *sceneController );
- textureSets.SetSceneController( *sceneController );
// create first 'dummy' node
nodes.PushBack(0u);
PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
ObjectOwnerContainer<Renderer> renderers;
- ObjectOwnerContainer<TextureSet> textureSets; ///< A container of texture sets
+ TextureSetContainer textureSets; ///< A container of texture sets
ShaderContainer shaders; ///< A container of owned shaders
return mImpl->renderers;
}
-
-ObjectOwnerContainer<TextureSet>& UpdateManager::GetTexturesOwner()
-{
- return mImpl->textureSets;
-}
-
void UpdateManager::AddShader( Shader* shader )
{
DALI_ASSERT_DEBUG( NULL != shader );
DALI_ASSERT_DEBUG(false);
}
+void UpdateManager::AddTextureSet( TextureSet* textureSet )
+{
+ DALI_ASSERT_DEBUG( NULL != textureSet );
+ mImpl->textureSets.PushBack( textureSet );
+}
+
+void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
+{
+ DALI_ASSERT_DEBUG(textureSet != NULL);
+ size_t textureSetCount( mImpl->textureSets.Size() );
+ for( size_t i(0); i<textureSetCount; ++i )
+ {
+ if( textureSet == mImpl->textureSets[i] )
+ {
+ mImpl->textureSets.Remove( mImpl->textureSets.Begin() + i );
+ return;
+ }
+ }
+}
+
unsigned int* UpdateManager::ReserveMessageSlot( std::size_t size, bool updateScene )
{
return mImpl->messageQueue.ReserveMessageSlot( size, updateScene );
(*iter)->ResetToBaseValues( bufferIndex );
}
- mImpl->textureSets.ResetToBaseValues( bufferIndex );
mImpl->renderers.ResetToBaseValues( bufferIndex );
// Reset animatable shader properties to base values
void UpdateManager::PrepareTextureSets( BufferIndex bufferIndex )
{
- ObjectOwnerContainer<TextureSet>::Iterator iter = mImpl->textureSets.GetObjectContainer().Begin();
- const ObjectOwnerContainer<TextureSet>::Iterator end = mImpl->textureSets.GetObjectContainer().End();
- for( ; iter != end; ++iter )
+ size_t textureSetCount( mImpl->textureSets.Size() );
+ for( size_t i(0); i<textureSetCount; ++i )
{
- //Apply constraints
- ConstrainPropertyOwner( *(*iter), bufferIndex );
-
//Prepare texture set
- (*iter)->Prepare( mImpl->resourceManager );
+ mImpl->textureSets[i]->Prepare( mImpl->resourceManager );
}
}
ObjectOwnerContainer< Renderer >& GetRendererOwner();
/**
- * @brief Get the texture set owner
- *
- * @return The texture set owner
- */
- ObjectOwnerContainer< TextureSet >& GetTexturesOwner();
-
- /**
* @brief Get the property buffer owner
*
* @return The property buffer owner
void RemoveShader(Shader* shader);
/**
+ * Add a newly created TextureSet.
+ * @param[in] textureSet The texture set to add.
+ * @post The TextureSet is owned by the UpdateManager.
+ */
+ void AddTextureSet(TextureSet* textureSet);
+
+ /**
+ * Remove a TextureSet.
+ * @pre The TextureSet has been added to the UpdateManager.
+ * @param[in] textureSet The TextureSet to remove.
+ * @post The TextureSet is destroyed.
+ */
+ void RemoveTextureSet(TextureSet* textureSet);
+
+ /**
* Set the shader program for a Shader object
* @param[in] shader The shader to modify
* @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program
new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
}
+// The render thread can safely change the Shader
+inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
+{
+ typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet );
+}
+
+// The render thread can safely change the Shader
+inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet )
+{
+ typedef MessageValue1< UpdateManager, TextureSet* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet );
+}
+
inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
{
typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
{
if (mTextureSet)
{
- mTextureSet->RemoveConnectionObserver(*this);
+ mTextureSet->RemoveObserver(this);
mTextureSet=NULL;
}
if( mShader )
const UniformMap& rendererUniformMap = PropertyOwner::GetUniformMap();
AddMappings( localMap, rendererUniformMap );
-
- if( mTextureSet )
- {
- AddMappings( localMap, mTextureSet->GetUniformMap() );
- }
-
AddMappings( localMap, mShader->GetUniformMap() );
}
else if( mRegenerateUniformMap == COPY_UNIFORM_MAP )
new (slot) DerivedType( mRenderer, &Render::Renderer::SetIndexedDrawElementsCount, mIndexedDrawElementsCount );
mResendFlag &= ~RESEND_INDEXED_DRAW_FIRST_ELEMENT;
}
-
-
}
void Renderer::SetTextures( TextureSet* textureSet )
if( mTextureSet )
{
- mTextureSet->RemoveConnectionObserver(*this);
+ mTextureSet->RemoveObserver(this);
}
mTextureSet = textureSet;
- mTextureSet->AddConnectionObserver( *this );
+ mTextureSet->AddObserver( this );
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
mResendFlag |= RESEND_DATA_PROVIDER;
}
return opacity;
}
+void Renderer::TextureSetChanged()
+{
+ mResendFlag |= RESEND_DATA_PROVIDER;
+}
+
void Renderer::ConnectionsChanged( PropertyOwner& object )
{
// One of our child objects has changed it's connections. Ensure the uniform
return mReferenceCount > 0;
}
+ /**
+ * Called by the TextureSet to notify to the renderer that it has changed
+ */
+ void TextureSetChanged();
public: // Implementation of ObjectOwnerContainer template methods
/**
#include "scene-graph-texture-set.h"
// INTERNAL HEADERS
-#include <dali/public-api/actors/blending.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
#include <dali/devel-api/rendering/texture-set.h>
#include <dali/integration-api/resource-declarations.h>
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/update/resources/texture-metadata.h>
#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
+#include <dali/internal/update/rendering/scene-graph-renderer.h>
namespace //Unnamed namespace
{
TextureSet::TextureSet()
: mSamplers(),
mTextureId(),
- mConnectionObservers(),
+ mRenderers(),
mResourcesReady( false ),
mFinishedResourceAcquisition( false ),
mChanged( true ),
mHasAlpha( false )
{
- // Observe own property-owner's uniform map
- AddUniformMapObserver( *this );
}
TextureSet::~TextureSet()
{
- mConnectionObservers.Destroy( *this );
}
void TextureSet::operator delete( void* ptr )
mTextureId[index] = imageId;
mChanged = true;
- mConnectionObservers.ConnectionsChanged(*this);
+ NotifyChangeToRenderers();
}
void TextureSet::SetSampler( size_t index, Render::Sampler* sampler )
mSamplers[index] = sampler;
mChanged = true;
- mConnectionObservers.ConnectionsChanged(*this);
+ NotifyChangeToRenderers();
}
bool TextureSet::HasAlpha() const
finishedResourceAcquisition = mFinishedResourceAcquisition;
}
-void TextureSet::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+void TextureSet::AddObserver( Renderer* renderer )
{
-}
+ size_t rendererCount( mRenderers.Size() );
+ for( size_t i(0); i<rendererCount; ++i )
+ {
+ if( mRenderers[i] == renderer )
+ {
+ //Renderer already in the list
+ return;
+ }
+ }
-void TextureSet::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
+ mRenderers.PushBack( renderer );
}
-void TextureSet::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
+void TextureSet::RemoveObserver( Renderer* renderer )
{
- mConnectionObservers.Add(observer);
-}
-
-void TextureSet::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
- mConnectionObservers.Remove(observer);
+ size_t rendererCount( mRenderers.Size() );
+ for( size_t i(0); i<rendererCount; ++i )
+ {
+ if( mRenderers[i] == renderer )
+ {
+ mRenderers.Remove( mRenderers.Begin() + i );
+ return;
+ }
+ }
}
-void TextureSet::UniformMappingsChanged( const UniformMap& mappings )
+void TextureSet::NotifyChangeToRenderers()
{
- // Our uniform map has changed.
- // Inform connected observers.
- mConnectionObservers.ConnectedUniformMapChanged();
+ size_t rendererCount = mRenderers.Size();
+ for( size_t i(0); i<rendererCount; ++i )
+ {
+ mRenderers[i]->TextureSetChanged();
+ }
}
} // namespace SceneGraph
// INTERNAL INCLUDES
#include <dali/devel-api/rendering/texture-set.h>
#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-#include <dali/internal/update/common/uniform-map.h>
#include <dali/internal/update/resources/resource-manager-declarations.h>
namespace Dali
}
namespace SceneGraph
{
+class Renderer;
class Sampler;
-class Shader;
-class ConnectionObserver;
-class SceneController;
-class TextureSet : public PropertyOwner, public UniformMap::Observer
+class TextureSet
{
public:
*/
void GetResourcesStatus( bool& resourcesReady, bool& finishedResourceAcquisition );
-
-public: // Implementation of ObjectOwnerContainer template methods
-
/**
- * Connect the object to the scene graph
+ * Adds a renderer to the Renderers list of the texture set.
+ * Renderers using the TextureSet get a notification when the texture set changes
*
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
- /**
- * Disconnect the object from the scene graph
- * @param[in] sceneController The scene controller - used for sending messages to render thread
- * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
- */
- void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
-public: // Implementation of ConnectionChangePropagator
-
- /**
- * @copydoc ConnectionChangePropagator::AddObserver
+ * @param[in] renderer The renderer using the TextureSet
*/
- void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
+ void AddObserver( Renderer* renderer );
/**
- * @copydoc ConnectionChangePropagator::RemoveObserver
+ * Removes a renderer from the TextureSet renderers list
+ *
+ * @param[in] renderer The renderer no longer using the TextureSet
*/
- void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-public:
+ void RemoveObserver( Renderer* renderer );
/**
* Get the ResourceId of a texture in the TextureSet
return mTextureId.Size();
}
-public: // UniformMap::Observer
- /**
- * @copydoc UniformMap::Observer::UniformMappingsChanged
- */
- virtual void UniformMappingsChanged( const UniformMap& mappings );
private:
*/
TextureSet();
+ /**
+ * Helper method to notify the renderers observing the TextureSet
+ * that the TextureSet has changed
+ */
+ void NotifyChangeToRenderers();
+
private: // Data
- Vector< Render::Sampler* > mSamplers; // Not owned
- Vector< ResourceId > mTextureId;
- ConnectionChangePropagator mConnectionObservers;
- bool mResourcesReady; ///< if the textures are ready to be used for rendering
+ Vector< Render::Sampler* > mSamplers; ///< List of samplers used by each texture. Not owned
+ Vector< ResourceId > mTextureId; ///< List of texture ids
+ Vector<Renderer*> mRenderers; ///< List of renderers using the TextureSet
+ bool mResourcesReady; ///< if the textures are ready to be used for rendering
bool mFinishedResourceAcquisition; ///< if resource loading is completed
- bool mChanged; ///< if the texture set has changed since the last frame
- bool mHasAlpha; ///< if any of the textures has an alpha channel
+ bool mChanged; ///< if the texture set has changed since the last frame
+ bool mHasAlpha; ///< if any of the textures has an alpha channel
};
inline void SetImageMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, ResourceId resourceId )