X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=69a109407b608b8eddda8a3f124713c27c7201da;hb=4ed6dc168df9f847235529aa22d90e316f99a71f;hp=084491aef8b16b8b79486400f10167ee4ef94b8e;hpb=5f03eb8d802b39ab519b15d5bca02f0ed01f2766;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index 084491a..69a1094 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -31,7 +31,7 @@ // INTERNAL HEADER #include -#include +#include #include #include #include @@ -122,7 +122,7 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( void main()\n {\n - mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n + mediump vec4 vertexPosition = uMvpMatrix * ComputeVertexPosition();\n vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n gl_Position = vertexPosition;\n }\n @@ -203,6 +203,18 @@ Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridS ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, + const Property::Map& properties, + ImageDimensions size, + FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode ) +{ + ImageVisualPtr imageVisualPtr( new ImageVisual( factoryCache, imageUrl, size, fittingMode, samplingMode ) ); + imageVisualPtr->SetProperties( properties ); + return imageVisualPtr; +} + +ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache, + const std::string& imageUrl, ImageDimensions size, FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode ) @@ -272,11 +284,14 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) mSamplingMode = Dali::SamplingMode::Type( value ); } + // Use a variable to detect if the width or height have been modified by the property map. + bool desiredSizeSpecified = false; int desiredWidth = 0; Property::Value* desiredWidthValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_WIDTH, IMAGE_DESIRED_WIDTH ); if( desiredWidthValue ) { desiredWidthValue->Get( desiredWidth ); + desiredSizeSpecified = true; } int desiredHeight = 0; @@ -284,6 +299,13 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) if( desiredHeightValue ) { desiredHeightValue->Get( desiredHeight ); + desiredSizeSpecified = true; + } + + // Only update the desired size if specified in the property map. + if( desiredSizeSpecified ) + { + mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); } Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME ); @@ -308,8 +330,6 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) mWrapModeV = Dali::WrapMode::Type( value ); } - mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); - Property::Value* syncLoading = propertyMap.Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING ); if( syncLoading ) { @@ -522,13 +542,11 @@ TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, const std::strin void ImageVisual::InitializeRenderer( const std::string& imageUrl ) { - DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" ); - mImageUrl = imageUrl; mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED; if( !mImpl->mCustomShader && - ( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // ignore remote images + ( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // dont atlas remote images ( strncasecmp( imageUrl.c_str(), HTTPS_URL, sizeof(HTTPS_URL) -1 ) != 0 ) ) { bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE; @@ -586,7 +604,6 @@ void ImageVisual::InitializeRenderer( const std::string& imageUrl ) void ImageVisual::InitializeRenderer( const Image& image ) { - DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" ); mImpl->mFlags &= ~Impl::IS_FROM_CACHE; @@ -669,7 +686,7 @@ void ImageVisual::DoSetOffStage( Actor& actor ) void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); - map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE ); + map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE ); bool sync = IsSynchronousResourceLoading(); map.Insert( SYNCHRONOUS_LOADING, sync ); @@ -699,17 +716,6 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV ); } -void ImageVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) -{ - // TODO -} - -Dali::Property::Value ImageVisual::DoGetProperty( Dali::Property::Index index ) -{ - // TODO - return Dali::Property::Value(); -} - void ImageVisual::OnSetTransform() { if( mImpl->mRenderer )