X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Factors%2Fimage-actor-impl.cpp;h=92016de44e3f766b9c65f3981057cad1ae16cd68;hb=42f84c7a9fc4182693570eb0b5c2bde428410a20;hp=c447508d999a3836d6e9c5b1600c8b6f5ca3377f;hpb=1d9c469a16c2a2503bc89bd50489d6964ae1037a;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index c447508..92016de 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include // for EqualToConstraint #include +#include #include #include #include @@ -59,39 +60,17 @@ TypeRegistration mType( typeid( Dali::ImageActor ), typeid( Dali::Actor ), Creat 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, int imageWidth, 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, int imageWidth, int imageHeight, const Dali::ImageActor::PixelArea& pixelArea ) +GeometryPtr CreateGeometry( unsigned int gridWidth, unsigned int gridHeight, const Vector2& size ) { // Create vertices std::vector< GridVertex > vertices; @@ -103,17 +82,12 @@ GeometryPtr CreateGridGeometry( const Vector2& size, unsigned int gridWidth, uns 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 ) @@ -138,48 +112,25 @@ GeometryPtr CreateGridGeometry( const Vector2& size, unsigned int gridWidth, uns } } - 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( @@ -188,15 +139,12 @@ 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 ); @@ -211,9 +159,10 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( }\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() @@ -226,13 +175,13 @@ 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; } @@ -258,7 +207,9 @@ void ImageActor::SetImage( ImagePtr& image ) 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 ) { @@ -271,12 +222,13 @@ void ImageActor::SetImage( ImagePtr& image ) } RelayoutRequest(); + UpdateTexureRect(); } } ImagePtr ImageActor::GetImage() const { - return mRenderer->GetMaterial()->GetTexture( mTextureIndex ); + return mRenderer->GetTextures()->GetImage( 0u ); } void ImageActor::SetPixelArea( const PixelArea& pixelArea ) @@ -285,6 +237,7 @@ void ImageActor::SetPixelArea( const PixelArea& pixelArea ) mIsPixelAreaSet = true; RelayoutRequest(); + UpdateTexureRect(); } const ImageActor::PixelArea& ImageActor::GetPixelArea() const @@ -313,15 +266,41 @@ void ImageActor::ClearPixelArea() mPixelArea = PixelArea( 0, 0, imageWidth, imageHeight ); RelayoutRequest(); + UpdateTexureRect(); +} + +void ImageActor::SetStyle( Dali::ImageActor::Style style ) +{ + DALI_LOG_WARNING( "SetStyle Deprecated. Only STYLE_QUAD supported.\n" ); + mStyle = style; +} + +Dali::ImageActor::Style ImageActor::GetStyle() const +{ + DALI_LOG_WARNING( "GetStyle Deprecated. Only STYLE_QUAD supported.\n" ); + return mStyle; +} + +void ImageActor::SetNinePatchBorder( const Vector4& border ) +{ + DALI_LOG_WARNING( "SetNinePatchBorder Deprecated. Only STYLE_QUAD supported.\n" ); + mNinePatchBorder = border; +} + +Vector4 ImageActor::GetNinePatchBorder() const +{ + DALI_LOG_WARNING( "GetNinePatchBorder Deprecated. Only STYLE_QUAD supported.\n" ); + 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 ) { } @@ -359,84 +338,44 @@ Vector2 ImageActor::CalculateNaturalSize() const return size; } -void ImageActor::OnRelayout( const Vector2& size, RelayoutContainer& container ) +void ImageActor::UpdateGeometry() { - int imageWidth = 1; - int imageHeight = 1; - - ImagePtr image = GetImage(); + uint16_t gridWidth = 1u; + uint16_t gridHeight = 1u; - if( image ) - { - imageWidth = image->GetWidth(); - imageHeight = image->GetHeight(); - } - - unsigned int gridWidth = 1; - 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( 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(gridSize.width) ); + gridHeight = std::min( MAXIMUM_GRID_SIZE, static_cast(gridSize.height) ); } - 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 ); - if( mIsPixelAreaSet ) - { - ImagePtr image = GetImage(); - if( image ) - { - int imageWidth = image->GetWidth(); - int imageHeight = image->GetHeight(); - - 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); - - // bottom left - textureRect.x = x; - textureRect.y = y; - - // top right - textureRect.z = x + width; - textureRect.w = y + height; - } - } - Material* material = mRenderer->GetMaterial(); - Property::Index index = material->GetPropertyIndex( "sTextureRect" ); - if( index != Property::INVALID_INDEX ) - { - material->SetProperty( index, textureRect ); - } - else + ImagePtr image = GetImage(); + if( mIsPixelAreaSet && image ) { - material->RegisterProperty( "sTextureRect", textureRect ); + const float uScale = 1.0f / float(image->GetWidth()); + const float vScale = 1.0f / float(image->GetHeight()); + // bottom left + textureRect.x = uScale * float(mPixelArea.x); + textureRect.y = vScale * float(mPixelArea.y); + // top right + textureRect.z = uScale * float(mPixelArea.x + mPixelArea.width); + textureRect.w = vScale * float(mPixelArea.y + mPixelArea.height); } + + mRenderer->RegisterProperty( TEXTURE_RECT_UNIFORM_NAME, textureRect ); } unsigned int ImageActor::GetDefaultPropertyCount() const @@ -666,62 +605,52 @@ float ImageActor::GetSortModifier() 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( mode ) ); } BlendingMode::Type ImageActor::GetBlendMode() const { - return mRenderer->GetMaterial()->GetBlendMode(); + return static_cast( mRenderer->GetBlendMode() ); } void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ) { - mRenderer->GetMaterial()->SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba ); + mRenderer->SetBlendFunc( static_cast(srcFactorRgba), static_cast(destFactorRgba), static_cast(srcFactorRgba), static_cast(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(srcFactorRgb), static_cast(destFactorRgb), static_cast(srcFactorAlpha), static_cast(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(srcFactorRgb), reinterpret_cast(destFactorRgb), reinterpret_cast(srcFactorAlpha), reinterpret_cast(destFactorAlpha) ); } void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgba ) { - mRenderer->GetMaterial()->SetBlendEquation( equationRgba, equationRgba ); + mRenderer->SetBlendEquation( static_cast(equationRgba), static_cast(equationRgba) ); } void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) { - mRenderer->GetMaterial()->SetBlendEquation( equationRgb, equationAlpha ); + mRenderer->SetBlendEquation( static_cast(equationRgb), static_cast(equationAlpha) ); } void ImageActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const { - mRenderer->GetMaterial()->GetBlendEquation( equationRgb, equationAlpha ); + mRenderer->GetBlendEquation( reinterpret_cast(equationRgb), reinterpret_cast(equationAlpha) ); } void ImageActor::SetBlendColor( const Vector4& color ) { mBlendColor = color; - mRenderer->GetMaterial()->SetBlendColor( mBlendColor ); + mRenderer->SetBlendColor( mBlendColor ); } const Vector4& ImageActor::GetBlendColor() const @@ -734,13 +663,9 @@ void ImageActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type mag 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 @@ -759,118 +684,12 @@ 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 ) ); - 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 @@ -880,22 +699,16 @@ 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() @@ -906,32 +719,31 @@ 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(); } }