/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// INTERNAL INCLUDES
#include <dali/public-api/animation/constraints.h> // for EqualToConstraint
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/rendering/renderer.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/common/property-helper.h>
struct GridVertex
{
+ GridVertex( float positionX, float positionY, const Vector2& size )
+ : mPosition( positionX*size.x, positionY*size.y, 0.f ),
+ mTextureCoord( positionX+0.5f, positionY+0.5f )
+ {
+ }
+
Vector3 mPosition;
Vector2 mTextureCoord;
};
-GeometryPtr CreateQuadGeometry( const Vector2& size, unsigned int imageWidth, unsigned int imageHeight, const Dali::ImageActor::PixelArea& pixelArea )
-{
- const float halfWidth = size.width * 0.5f;
- const float halfHeight = size.height * 0.5f;
- GridVertex quadVertexData[4] =
- {
- { Vector3( -halfWidth, -halfHeight, 0.f ), Vector2( ( pixelArea.x ) / (float)imageWidth, ( pixelArea.y ) / (float)imageHeight ) },
- { Vector3( -halfWidth, halfHeight, 0.f ), Vector2( ( pixelArea.x ) / (float)imageWidth, ( pixelArea.y + pixelArea.height ) / (float)imageHeight ) },
- { Vector3( halfWidth, -halfHeight, 0.f ), Vector2( ( pixelArea.x + pixelArea.width ) / (float)imageWidth, ( pixelArea.y ) / (float)imageHeight ) },
- { Vector3( halfWidth, halfHeight, 0.f ), Vector2( ( pixelArea.x + pixelArea.width ) / (float)imageWidth, ( pixelArea.y + pixelArea.height ) / (float)imageHeight ) }
- };
-
- Property::Map quadVertexFormat;
- quadVertexFormat["aPosition"] = Property::VECTOR3;
- quadVertexFormat["aTexCoord"] = Property::VECTOR2;
- PropertyBufferPtr quadVertices = PropertyBuffer::New();
- quadVertices->SetFormat( quadVertexFormat );
- quadVertices->SetSize( 4 );
- quadVertices->SetData(quadVertexData);
-
- // Create the geometry object
- GeometryPtr geometry = Geometry::New();
- geometry->AddVertexBuffer( *quadVertices );
- geometry->SetGeometryType( Dali::Geometry::TRIANGLE_STRIP );
-
- return geometry;
-}
-
-GeometryPtr CreateGridGeometry( const Vector2& size, unsigned int gridWidth, unsigned int gridHeight, unsigned int imageWidth, unsigned int imageHeight, const Dali::ImageActor::PixelArea& pixelArea )
+GeometryPtr CreateGeometry( unsigned int gridWidth, unsigned int gridHeight, const Vector2& size )
{
// Create vertices
std::vector< GridVertex > vertices;
for( unsigned int x = 0u; x < gridWidth + 1; ++x )
{
float xPos = (float)x / gridWidth;
- GridVertex vertex = {
- Vector3( size.width * ( xPos - 0.5f ), size.height * ( yPos - 0.5f ), 0.0f ),
- Vector2( ( pixelArea.x + pixelArea.width * xPos ) / (float)imageWidth,
- ( pixelArea.y + pixelArea.height * yPos ) / (float)imageHeight )
- };
- vertices.push_back( vertex );
+ vertices.push_back( GridVertex( xPos - 0.5f, yPos - 0.5f, size ) );
}
}
// Create indices
- Vector< unsigned int > indices;
+ Vector< unsigned short > indices;
indices.Reserve( ( gridWidth + 2 ) * gridHeight * 2 - 2);
for( unsigned int row = 0u; row < gridHeight; ++row )
}
}
-
Property::Map vertexFormat;
vertexFormat[ "aPosition" ] = Property::VECTOR3;
vertexFormat[ "aTexCoord" ] = Property::VECTOR2;
- PropertyBufferPtr vertexPropertyBuffer = PropertyBuffer::New();
- vertexPropertyBuffer->SetFormat( vertexFormat );
- vertexPropertyBuffer->SetSize( vertices.size() );
+ PropertyBufferPtr vertexPropertyBuffer = PropertyBuffer::New( vertexFormat );
if( vertices.size() > 0 )
{
- vertexPropertyBuffer->SetData( &vertices[ 0 ] );
- }
-
- Property::Map indexFormat;
- indexFormat[ "indices" ] = Property::INTEGER;
- PropertyBufferPtr indexPropertyBuffer = PropertyBuffer::New();
- indexPropertyBuffer->SetFormat( indexFormat );
- indexPropertyBuffer->SetSize( indices.Size() );
- if( indices.Size() > 0 )
- {
- indexPropertyBuffer->SetData( &indices[ 0 ] );
+ vertexPropertyBuffer->SetData( &vertices[ 0 ], vertices.size() );
}
// Create the geometry object
GeometryPtr geometry = Geometry::New();
geometry->AddVertexBuffer( *vertexPropertyBuffer );
- geometry->SetIndexBuffer( *indexPropertyBuffer );
- geometry->SetGeometryType( Dali::Geometry::TRIANGLE_STRIP );
+ if( indices.Size() > 0 )
+ {
+ geometry->SetIndexBuffer( &indices[0], indices.Size() );
+ }
+ geometry->SetType( Dali::Geometry::TRIANGLE_STRIP );
return geometry;
-
-}
-
-
-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(
varying mediump vec2 vTexCoord;\n
uniform mediump mat4 uMvpMatrix;\n
uniform mediump vec3 uSize;\n
- uniform mediump vec4 uTextureRect;\n
+ uniform mediump vec4 sTextureRect;\n
\n
void main()\n
{\n
- mediump vec4 vertexPosition = vec4(aPosition, 1.0);\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
- \n
+ gl_Position = uMvpMatrix * vec4(aPosition, 1.0);\n
vTexCoord = aTexCoord;\n
- gl_Position = vertexPosition;\n
}\n
);
}\n
);
-const size_t INVALID_TEXTURE_ID = (size_t)-1;
+const char * const TEXTURE_RECT_UNIFORM_NAME( "sTextureRect" );
+
const int INVALID_RENDERER_ID = -1;
-const unsigned int MAXIMUM_GRID_SIZE = 2048;
+const uint16_t MAXIMUM_GRID_SIZE = 2048;
}
ImageActorPtr ImageActor::New()
//Create the renderer
actor->mRenderer = Renderer::New();
- GeometryPtr quad = CreateQuadGeometry( Vector2::ONE, 1, 1, PixelArea() );
+ GeometryPtr quad = CreateGeometry( 1u, 1u, Vector2::ONE );
actor->mRenderer->SetGeometry( *quad );
- ShaderPtr shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER, Dali::Shader::HINT_NONE );
- MaterialPtr material = Material::New();
- material->SetShader( *shader );
- actor->mRenderer->SetMaterial( *material );
+ ShaderPtr shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER, Dali::Shader::Hint::NONE );
+ actor->mRenderer->SetShader( *shader );
+ TextureSetPtr textureSet = TextureSet::New();
+ actor->mRenderer->SetTextures( *textureSet );
return actor;
}
SamplerPtr sampler = Sampler::New();
sampler->SetFilterMode( mMinFilter, mMagFilter );
- mTextureIndex = mRenderer->GetMaterial()->AddTexture( image, "sTexture", sampler );
+ TextureSet* textureSet( mRenderer->GetTextures() );
+ textureSet->SetImage( 0u, image.Get() );
+ textureSet->SetSampler( 0u, sampler );
if( mRendererIndex == INVALID_RENDERER_ID )
{
}
RelayoutRequest();
+ UpdateTexureRect();
}
}
ImagePtr ImageActor::GetImage() const
{
- return mRenderer->GetMaterial()->GetTexture( mTextureIndex );
+ return mRenderer->GetTextures()->GetImage( 0u );
}
void ImageActor::SetPixelArea( const PixelArea& pixelArea )
mIsPixelAreaSet = true;
RelayoutRequest();
+ UpdateTexureRect();
}
const ImageActor::PixelArea& ImageActor::GetPixelArea() const
mPixelArea = PixelArea( 0, 0, imageWidth, imageHeight );
RelayoutRequest();
+ UpdateTexureRect();
+}
+
+void ImageActor::SetStyle( Dali::ImageActor::Style style )
+{
+ DALI_LOG_WARNING( "SetStyle Deprecated. Only STYLE_QUAD supported." );
+ mStyle = style;
+}
+
+Dali::ImageActor::Style ImageActor::GetStyle() const
+{
+ DALI_LOG_WARNING( "GetStyle Deprecated. Only STYLE_QUAD supported." );
+ return mStyle;
+}
+
+void ImageActor::SetNinePatchBorder( const Vector4& border )
+{
+ DALI_LOG_WARNING( "SetNinePatchBorder Deprecated. Only STYLE_QUAD supported." );
+ mNinePatchBorder = border;
+}
+
+Vector4 ImageActor::GetNinePatchBorder() const
+{
+ DALI_LOG_WARNING( "GetNinePatchBorder Deprecated. Only STYLE_QUAD supported." );
+ return mNinePatchBorder;
}
ImageActor::ImageActor()
: Actor( Actor::BASIC ),
+ mActorSize( Vector2::ZERO ),
+ mGridSize( 1u, 1u ),
mRendererIndex( INVALID_RENDERER_ID ),
- mTextureIndex( INVALID_TEXTURE_ID ),
- mEffectTextureIndex( INVALID_TEXTURE_ID ),
mMinFilter( FilterMode::DEFAULT ),
mMagFilter( FilterMode::DEFAULT ),
+ mStyle( Dali::ImageActor::STYLE_QUAD ),
mIsPixelAreaSet( false )
{
}
return size;
}
-void ImageActor::OnRelayout( const Vector2& size, RelayoutContainer& container )
+void ImageActor::UpdateGeometry()
{
- unsigned int gridWidth = 1;
- unsigned int gridHeight = 1;
+ uint16_t gridWidth = 1u;
+ uint16_t gridHeight = 1u;
+
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( Vector2(mPixelArea.width, mPixelArea.height) );
//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<uint16_t>(gridSize.width) );
+ gridHeight = std::min( MAXIMUM_GRID_SIZE, static_cast<uint16_t>(gridSize.height) );
}
- unsigned int imageWidth = 1u;
- unsigned int imageHeight = 1u;
- ImagePtr image = GetImage();
- if( image )
- {
- imageWidth = image->GetWidth();
- imageHeight = image->GetHeight();
- }
-
- GeometryPtr quad = gridWidth <= 1 && gridHeight <= 1 ?
- CreateQuadGeometry( size, imageWidth, imageHeight, mPixelArea ) :
- CreateGridGeometry( size, gridWidth, gridHeight, imageWidth, imageHeight, mPixelArea );
-
- mRenderer->SetGeometry( *quad );
+ mGridSize.SetWidth( gridWidth );
+ mGridSize.SetHeight( gridHeight );
+ GeometryPtr geometry = CreateGeometry( gridWidth, gridHeight, mActorSize );
+ mRenderer->SetGeometry( *geometry );
+}
+void ImageActor::UpdateTexureRect()
+{
Vector4 textureRect( 0.f, 0.f, 1.f, 1.f );
+
+ ImagePtr image = GetImage();
if( mIsPixelAreaSet && image )
{
- const float uScale = 1.0f / float(imageWidth);
- const float vScale = 1.0f / float(imageHeight);
- const float x = uScale * float(mPixelArea.x);
- const float y = vScale * float(mPixelArea.y);
- const float width = uScale * float(mPixelArea.width);
- const float height = vScale * float(mPixelArea.height);
-
+ const float uScale = 1.0f / float(image->GetWidth());
+ const float vScale = 1.0f / float(image->GetHeight());
// bottom left
- textureRect.x = x;
- textureRect.y = y;
-
+ textureRect.x = uScale * float(mPixelArea.x);
+ textureRect.y = vScale * float(mPixelArea.y);
// top right
- textureRect.z = x + width;
- textureRect.w = y + height;
+ textureRect.z = uScale * float(mPixelArea.x + mPixelArea.width);
+ textureRect.w = vScale * float(mPixelArea.y + mPixelArea.height);
}
- Material* material = mRenderer->GetMaterial();
- Property::Index index = material->GetPropertyIndex( "sTextureRect" );
- if( index != Property::INVALID_INDEX )
- {
- material->SetProperty( index, textureRect );
- }
- else
- {
- material->RegisterProperty( "sTextureRect", textureRect );
- }
+ mRenderer->RegisterProperty( TEXTURE_RECT_UNIFORM_NAME, textureRect );
}
unsigned int ImageActor::GetDefaultPropertyCount() const
return mRenderer->GetDepthIndex();
}
-void ImageActor::SetCullFace(CullFaceMode mode)
-{
- mRenderer->GetMaterial()->SetFaceCullingMode( static_cast< Dali::Material::FaceCullingMode >( mode ) );
-}
-
-CullFaceMode ImageActor::GetCullFace() const
-{
- return static_cast< CullFaceMode >( mRenderer->GetMaterial()->GetFaceCullingMode() );
-}
-
void ImageActor::SetBlendMode( BlendingMode::Type mode )
{
- mRenderer->GetMaterial()->SetBlendMode( mode );
+ mRenderer->SetBlendMode( static_cast<BlendMode::Type>( mode ) );
}
BlendingMode::Type ImageActor::GetBlendMode() const
{
- return mRenderer->GetMaterial()->GetBlendMode();
+ return static_cast<BlendingMode::Type>( mRenderer->GetBlendMode() );
}
void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
{
- mRenderer->GetMaterial()->SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
+ mRenderer->SetBlendFunc( static_cast<BlendFactor::Type>(srcFactorRgba), static_cast<BlendFactor::Type>(destFactorRgba), static_cast<BlendFactor::Type>(srcFactorRgba), static_cast<BlendFactor::Type>(destFactorRgba) );
}
void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
{
- mRenderer->GetMaterial()->SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ mRenderer->SetBlendFunc( static_cast<BlendFactor::Type>(srcFactorRgb), static_cast<BlendFactor::Type>(destFactorRgb), static_cast<BlendFactor::Type>(srcFactorAlpha), static_cast<BlendFactor::Type>(destFactorAlpha) );
}
void ImageActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const
{
- mRenderer->GetMaterial()->GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ mRenderer->GetBlendFunc( reinterpret_cast<BlendFactor::Type&>(srcFactorRgb), reinterpret_cast<BlendFactor::Type&>(destFactorRgb), reinterpret_cast<BlendFactor::Type&>(srcFactorAlpha), reinterpret_cast<BlendFactor::Type&>(destFactorAlpha) );
}
void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgba )
{
- mRenderer->GetMaterial()->SetBlendEquation( equationRgba, equationRgba );
+ mRenderer->SetBlendEquation( static_cast<BlendEquation::Type>(equationRgba), static_cast<BlendEquation::Type>(equationRgba) );
}
void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha )
{
- mRenderer->GetMaterial()->SetBlendEquation( equationRgb, equationAlpha );
+ mRenderer->SetBlendEquation( static_cast<BlendEquation::Type>(equationRgb), static_cast<BlendEquation::Type>(equationAlpha) );
}
void ImageActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const
{
- mRenderer->GetMaterial()->GetBlendEquation( equationRgb, equationAlpha );
+ mRenderer->GetBlendEquation( reinterpret_cast<BlendEquation::Type&>(equationRgb), reinterpret_cast<BlendEquation::Type&>(equationAlpha) );
}
void ImageActor::SetBlendColor( const Vector4& color )
{
mBlendColor = color;
- mRenderer->GetMaterial()->SetBlendColor( mBlendColor );
+ mRenderer->SetBlendColor( mBlendColor );
}
const Vector4& ImageActor::GetBlendColor() const
mMinFilter = minFilter;
mMagFilter = magFilter;
- if( mTextureIndex != INVALID_TEXTURE_ID )
- {
- SamplerPtr sampler = Sampler::New();
- sampler->SetFilterMode( minFilter, magFilter );
-
- mRenderer->GetMaterial()->SetTextureSampler( mTextureIndex, sampler.Get() );
- }
+ SamplerPtr sampler = Sampler::New();
+ sampler->SetFilterMode( minFilter, magFilter );
+ mRenderer->GetTextures()->SetSampler( 0u, sampler.Get() );
}
void ImageActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const
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 ) );
- 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;
- }
+ ShaderPtr shader = mShaderEffect->GetShader();
+ mRenderer->SetShader( *shader );
- //constrain the renderers property to the ShaderEffect
- if( constraint )
- {
- Source source;
- source.sourceType = OBJECT_PROPERTY;
- source.propertyIndex = uniform.mIndex;
- source.object = mShaderEffect.Get();
+ EffectImageUpdated();
- constraint->AddSource( source );
- constraint->Apply();
- }
- }
- else
- {
- shader->SetProperty( index, uniform.mValue );
- }
+ UpdateGeometry();
}
ShaderEffectPtr ImageActor::GetShaderEffect() const
void ImageActor::RemoveShaderEffect()
{
- //if we previously had a subdivided grid then we need to reset the geometry as well
if( mShaderEffect )
{
mShaderEffect->Disconnect( this );
+ // change to the standard shader and quad geometry
+ ShaderPtr shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER, Dali::Shader::Hint::NONE );
+ mRenderer->SetShader( *shader );
+ mShaderEffect.Reset();
- Dali::ShaderEffect::GeometryHints hints = mShaderEffect->GetGeometryHints();
- if( ( hints & Dali::ShaderEffect::HINT_GRID_X ) ||
- ( hints & Dali::ShaderEffect::HINT_GRID_Y ) )
- {
- RelayoutRequest();
- }
+ UpdateGeometry();
}
-
- ShaderPtr shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER, Dali::Shader::HINT_NONE );
- mRenderer->GetMaterial()->SetShader( *shader );
- mShaderEffect.Reset();
}
void ImageActor::EffectImageUpdated()
if( effectImage )
{
Image& effectImageImpl = GetImplementation( effectImage );
-
- if( mEffectTextureIndex == INVALID_TEXTURE_ID )
- {
- mEffectTextureIndex = mRenderer->GetMaterial()->AddTexture( &effectImageImpl, "sEffect", NULL );
- }
- else
- {
- mRenderer->GetMaterial()->SetTextureImage( mEffectTextureIndex, &effectImageImpl );
- }
+ mRenderer->GetTextures()->SetImage( 1u, &effectImageImpl );
}
else
{
- if( mEffectTextureIndex != INVALID_TEXTURE_ID )
- {
- mRenderer->GetMaterial()->RemoveTexture( mEffectTextureIndex );
- }
- mEffectTextureIndex = INVALID_TEXTURE_ID;
+ mRenderer->GetTextures()->SetImage( 1u, 0 );
}
+ }
+}
- //ensure that the sEffectRect uniform is set
- Shader* shader = mRenderer->GetMaterial()->GetShader();
- Property::Index index = shader->GetPropertyIndex( "sEffectRect" );
- if( index == Property::INVALID_INDEX )
- {
- shader->RegisterProperty( "sEffectRect", Vector4( 0.f, 0.f, 1.f, 1.f) );
- }
+void ImageActor::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ if( mActorSize != size )
+ {
+ mActorSize = size;
+ UpdateGeometry();
+ }
+}
+
+void ImageActor::OnSizeSet( const Vector3& targetSize )
+{
+ Vector2 size( targetSize.x, targetSize.y );
+ if( mActorSize != size )
+ {
+ mActorSize = size;
+ UpdateGeometry();
}
}