SetUnitNameMessage( GetEventThreadServices(), *mSceneObject, name);
}
-void Sampler::SetImage( Image& image )
+void Sampler::SetImage( ImagePtr& image )
{
- unsigned int resourceId = image.GetResourceId();
+ // Keep a reference to the image object
+ mImageConnector.Set( image, OnStage() );
// sceneObject is being used in a separate thread; queue a message to set
+ unsigned int resourceId = image->GetResourceId();
SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
+
}
void Sampler::SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter )
/**
* @copydoc Dali::Sampler::SetImage()
*/
- void SetImage( Image& image );
+ void SetImage( ImagePtr& image );
/**
* @copydoc Dali::Sampler::SetFilterMode()
{
namespace SceneGraph
{
-class SamplerDataProvider;
-class Shader;
/**
* Interface to provide data of the material to the renderer.
namespace SceneGraph
{
class PropertyBuffer;
+class Shader;
/**
* Wraps all the data providers for the renderer. This allows the
};
-
/**
- * A float doubleBuffered property of a scene-graph object.
+ * A double buffered integer property of a scene-graph object.
*/
template <>
-class DoubleBufferedProperty<float> : public DoubleBufferedPropertyBase
+class DoubleBufferedProperty<int> : public DoubleBufferedPropertyBase
{
public:
/**
- * Create a doubleBuffered property.
- * @param[in] initialValue The initial value of the property.
+ * Create a double buffered property.
+ * @param [in] initialValue The initial value of the property.
*/
- DoubleBufferedProperty( float initialValue )
+ DoubleBufferedProperty( int initialValue )
: mValue( initialValue )
{
}
*/
virtual Dali::Property::Type GetType() const
{
- return Dali::PropertyTypes::Get<float>();
+ return Dali::PropertyTypes::Get<int>();
}
/**
}
/**
- * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
+ * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
*/
- virtual const float& GetFloat( BufferIndex bufferIndex ) const
+ virtual const int& GetInteger( BufferIndex bufferIndex ) const
{
return mValue[ bufferIndex ];
}
* @param[in] bufferIndex The buffer to write.
* @param[in] value The new property value.
*/
- void Set(BufferIndex bufferIndex, float value)
+ void Set(BufferIndex bufferIndex, int value)
{
- mValue[bufferIndex] = value;
- OnSet();
+ // check if the value actually changed to avoid dirtying nodes unnecessarily
+ if( mValue[bufferIndex] != value )
+ {
+ mValue[bufferIndex] = value;
+
+ OnSet();
+ }
}
/**
* @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
*/
- float& Get(size_t bufferIndex)
+ int& Get(size_t bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
*/
- const float& Get(size_t bufferIndex) const
+ const int& Get(size_t bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- float& operator[](size_t bufferIndex)
+ int& operator[](size_t bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const float& operator[](size_t bufferIndex) const
+ const int& operator[](size_t bufferIndex) const
{
return mValue[bufferIndex];
}
DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
private:
- DoubleBuffered<float> mValue; ///< The double-buffered property value
+ DoubleBuffered<int> mValue; ///< The double-buffered property value
};
/**
- * A double buffered integer property of a scene-graph object.
+ * A double buffered unsigned integer property of a scene-graph object.
*/
template <>
-class DoubleBufferedProperty<int> : public DoubleBufferedPropertyBase
+class DoubleBufferedProperty<unsigned int> : public DoubleBufferedPropertyBase
{
public:
+ typedef unsigned int OwnType;
/**
* Create a double buffered property.
* @param [in] initialValue The initial value of the property.
*/
- DoubleBufferedProperty( int initialValue )
+ DoubleBufferedProperty( OwnType initialValue )
: mValue( initialValue )
{
}
*/
virtual Dali::Property::Type GetType() const
{
- return Dali::PropertyTypes::Get<int>();
+ return Dali::PropertyTypes::Get<OwnType>();
}
/**
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
*/
- virtual const int& GetInteger( BufferIndex bufferIndex ) const
+ virtual const OwnType& GetUnsignedInteger( BufferIndex bufferIndex ) const
{
return mValue[ bufferIndex ];
}
* @param[in] bufferIndex The buffer to write.
* @param[in] value The new property value.
*/
- void Set(BufferIndex bufferIndex, int value)
+ void Set(BufferIndex bufferIndex, OwnType value)
{
// check if the value actually changed to avoid dirtying nodes unnecessarily
if( mValue[bufferIndex] != value )
/**
* @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
*/
- int& Get(size_t bufferIndex)
+ OwnType& Get(size_t bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
*/
- const int& Get(size_t bufferIndex) const
+ const OwnType& Get(size_t bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- int& operator[](size_t bufferIndex)
+ OwnType& operator[](size_t bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const int& operator[](size_t bufferIndex) const
+ const OwnType& operator[](size_t bufferIndex) const
{
return mValue[bufferIndex];
}
DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
private:
- DoubleBuffered<int> mValue; ///< The double-buffered property value
+ DoubleBuffered<OwnType> mValue; ///< The double-buffered property value
+};
+
+
+/**
+ * A float doubleBuffered property of a scene-graph object.
+ */
+template <>
+class DoubleBufferedProperty<float> : public DoubleBufferedPropertyBase
+{
+public:
+
+ /**
+ * Create a doubleBuffered property.
+ * @param[in] initialValue The initial value of the property.
+ */
+ DoubleBufferedProperty( float initialValue )
+ : mValue( initialValue )
+ {
+ }
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~DoubleBufferedProperty()
+ {
+ }
+
+ /**
+ * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
+ */
+ virtual Dali::Property::Type GetType() const
+ {
+ return Dali::PropertyTypes::Get<float>();
+ }
+
+ /**
+ * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
+ */
+ virtual void CopyPrevious( BufferIndex updateBufferIndex )
+ {
+ if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
+ {
+ mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
+ mDirtyFlags = ( mDirtyFlags >> 1 );
+ }
+ }
+
+ /**
+ * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
+ */
+ virtual const float& GetFloat( BufferIndex bufferIndex ) const
+ {
+ return mValue[ bufferIndex ];
+ }
+
+ /**
+ * Set the property value. This will persist for the current frame, and will
+ * be copied to the other buffer next frame (unless it is set again)
+ * @param[in] bufferIndex The buffer to write.
+ * @param[in] value The new property value.
+ */
+ void Set(BufferIndex bufferIndex, float value)
+ {
+ mValue[bufferIndex] = value;
+ OnSet();
+ }
+
+ /**
+ * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
+ */
+ float& Get(size_t bufferIndex)
+ {
+ return mValue[bufferIndex];
+ }
+
+ /**
+ * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
+ */
+ const float& Get(size_t bufferIndex) const
+ {
+ return mValue[bufferIndex];
+ }
+
+ /**
+ * Retrieve the property value.
+ * @param[in] bufferIndex The buffer to read.
+ * @return The property value.
+ */
+ float& operator[](size_t bufferIndex)
+ {
+ return mValue[bufferIndex];
+ }
+
+ /**
+ * Retrieve the property value.
+ * @param[in] bufferIndex The buffer to read.
+ * @return The property value.
+ */
+ const float& operator[](size_t bufferIndex) const
+ {
+ return mValue[bufferIndex];
+ }
+
+private:
+ // Undefined
+ DoubleBufferedProperty(const DoubleBufferedProperty& property);
+
+ // Undefined
+ DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
+
+private:
+ DoubleBuffered<float> mValue; ///< The double-buffered property value
};
/**
void Material::SetShader( const Shader* shader )
{
mShader = shader;
- // @todo inform NewRenderer about this shader
+ // Inform NewRenderer about this shader: (Will force a re-load of the
+ // shader from the data providers)
mConnectionObservers.ConnectionsChanged(*this);
}
const SamplerDataProvider* sdp = static_cast< const SamplerDataProvider*>( sampler );
mSamplers.PushBack( sdp );
+ Sampler* mutableSampler = const_cast<Sampler*>(sampler);
+ mutableSampler->AddConnectionObserver( *this );
+ mutableSampler->AddUniformMapObserver( *this );
+
mConnectionObservers.ConnectionsChanged(*this);
}
if( found )
{
+ Sampler* mutableSampler = const_cast<Sampler*>(sampler);
+ mutableSampler->RemoveConnectionObserver( *this );
+ mutableSampler->RemoveUniformMapObserver( *this );
mSamplers.Erase(iter);
mConnectionObservers.ConnectionsChanged(*this);
}
mConnectionObservers.ConnectedUniformMapChanged();
}
+void Material::ConnectionsChanged( PropertyOwner& owner )
+{
+ mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Material::ConnectedUniformMapChanged( )
+{
+ mConnectionObservers.ConnectedUniformMapChanged();
+}
+
void Material::ResetDefaultProperties( BufferIndex updateBufferIndex )
{
mColor.ResetToBaseValue( updateBufferIndex );
class ConnectionObserver;
class SceneController;
-class Material : public PropertyOwner, public MaterialDataProvider, public UniformMap::Observer
+class Material : public PropertyOwner, public MaterialDataProvider, public UniformMap::Observer, public ConnectionObservers::Observer
{
public:
/**
*/
virtual void UniformMappingsChanged( const UniformMap& mappings );
+public: // ConnectionObserver::Observer
+
+ /**
+ * @copydoc ConnectionObservers::ConnectionsChanged
+ */
+ virtual void ConnectionsChanged( PropertyOwner& owner );
+
+ /**
+ * @copydoc ConnectionObservers::ConnectedUniformMapChanged
+ */
+ virtual void ConnectedUniformMapChanged( );
+
public: // PropertyOwner implementation
/**
* @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
Sampler::Sampler( const std::string& unitName )
: mUnitName( unitName ),
+ mTextureId( 0u ),
mMinFilter( Dali::Sampler::DEFAULT ),
mMagFilter( Dali::Sampler::DEFAULT ),
mUWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
mVWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
- mAffectsTransparency( false )
+ mAffectsTransparency( false ),
+ mFullyOpaque(true)
{
- mTextureId[0] = 0;
- mTextureId[1] = 0;
}
Sampler::~Sampler()
void Sampler::SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId )
{
- mTextureId[bufferIndex] = textureId;
-
- // @todo MESH_REWORK
- //const BitmapMetadata& metadata - get it from ResourceManager
- //mBitmapMetadata[bufferIndex] = metadata;
+ if( mTextureId[bufferIndex] != textureId )
+ {
+ mTextureId.Set( bufferIndex, textureId );
+ mConnectionObservers.ConnectionsChanged(*this);
+ }
}
void Sampler::SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter )
return mAffectsTransparency[bufferIndex] ;
}
+void Sampler::SetFullyOpaque( bool fullyOpaque )
+{
+ mFullyOpaque = fullyOpaque;
+}
+
bool Sampler::IsFullyOpaque( BufferIndex bufferIndex ) const
{
- return mBitmapMetadata[bufferIndex].IsFullyOpaque();
+ return mFullyOpaque;
}
void Sampler::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
{
}
+void Sampler::AddConnectionObserver( ConnectionObservers::Observer& observer )
+{
+ mConnectionObservers.Add(observer);
+}
+
+void Sampler::RemoveConnectionObserver( ConnectionObservers::Observer& observer )
+{
+ mConnectionObservers.Remove(observer);
+}
+
+void Sampler::ResetDefaultProperties( BufferIndex bufferIndex )
+{
+ mTextureId.CopyPrevious( bufferIndex );
+ mMinFilter.CopyPrevious( bufferIndex );
+ mMagFilter.CopyPrevious( bufferIndex );
+ mUWrapMode.CopyPrevious( bufferIndex );
+ mVWrapMode.CopyPrevious( bufferIndex );
+ mAffectsTransparency.CopyPrevious( bufferIndex );
+}
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/double-buffered-property.h>
#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/scene-graph-connection-observers.h>
#include <dali/internal/update/resources/bitmap-metadata.h>
#include <dali/internal/render/data-providers/sampler-data-provider.h>
bool AffectsTransparency( BufferIndex bufferIndex ) const;
/**
+ * Sets whether the associated texture is fully opaque or not.
+ * @param[in] fullyOpaque true if it's fully opaque
+ */
+ void SetFullyOpaque( bool fullyOpaque );
+
+ /**
* @param[in] bufferIndex The buffer index to use
* @return true if the texture is fully opaque
* @note this should only be called from Update thread
* @param[in] bufferIndex The current buffer index - used for sending messages to render thread
*/
void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+ /**
+ * @copydoc ConnectionObservers::AddObserver
+ */
+ void AddConnectionObserver(ConnectionObservers::Observer& observer);
-private:
- std::string mUnitName; ///< The name of the uniform of the texture unit
-
- // @todo MESH_REWORK Need these to automatically copy
- // new value into old value on frame change
+ /**
+ * @copydoc ConnectionObservers::RemoveObserver
+ */
+ void RemoveConnectionObserver(ConnectionObservers::Observer& observer);
- ResourceId mTextureId[2]; ///< The identity of the associated texture for this frame (Can be read from RenderThread)
+public: // PropertyOwner implementation
+ /**
+ * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
+ */
+ virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
- BitmapMetadata mBitmapMetadata[2]; /// The meta data of the associated texture for this frame (Not needed in RenderThread)
+private:
+ std::string mUnitName; ///< The name of the uniform of the texture unit
+ DoubleBufferedProperty<unsigned int> mTextureId;
DoubleBufferedProperty<int> mMinFilter; ///< The minify filter
DoubleBufferedProperty<int> mMagFilter; ///< The magnify filter
DoubleBufferedProperty<int> mUWrapMode; ///< The horizontal wrap mode
// Note, this is only called from UpdateThread
DoubleBufferedProperty<bool> mAffectsTransparency; ///< If this sampler affects renderer transparency
+
+ ConnectionObservers mConnectionObservers; ///< Connection observers that will be informed when textures change.
+ bool mFullyOpaque; // Update only flag - no need for double buffering
};
} // namespace SceneGraph
void RendererAttachment::ConnectedToSceneGraph()
{
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
- mParent->AddUniformMapObserver( *this );
+ mParent->AddUniformMapObserver( *this ); // Watch actor's uniform maps
DALI_ASSERT_DEBUG( mParent != NULL );
const Sampler* sampler = static_cast<const Sampler*>(*iter);
ResourceId textureId = sampler->GetTextureId( updateBufferIndex );
+ BitmapMetadata metaData = resourceManager.GetBitmapMetadata( textureId );
+
+ Sampler* mutableSampler = const_cast<Sampler*>(sampler);
+ mutableSampler->SetFullyOpaque( metaData.IsFullyOpaque() );
+
switch( completeStatusManager.GetStatus( textureId ) )
{
case CompleteStatusManager::NOT_READY:
{
ready = false;
- BitmapMetadata metaData = resourceManager.GetBitmapMetadata( textureId );
if( metaData.GetIsFramebuffer() )
{
frameBufferCount++;
Sampler Sampler::New( Image& image, const std::string& textureUnitUniformName )
{
Internal::SamplerPtr sampler = Internal::Sampler::New(textureUnitUniformName);
- sampler->SetImage( GetImplementation( image ) );
+ Internal::ImagePtr imagePtr = &GetImplementation( image );
+ sampler->SetImage( imagePtr );
return Sampler( sampler.Get() );
}
void Sampler::SetImage( Image& image )
{
- GetImplementation(*this).SetImage( GetImplementation( image ) );
+ Internal::ImagePtr imagePtr = &GetImplementation( image );
+ GetImplementation(*this).SetImage( imagePtr );
}
void Sampler::SetFilterMode( FilterMode minFilter, FilterMode magFilter )