AnimatedImageVisual
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image / image-visual.cpp
index 930d631..b61c23b 100644 (file)
@@ -185,11 +185,6 @@ Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridS
   if( gridSize == ImageDimensions( 1, 1 ) )
   {
     geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
-    if( !geometry )
-    {
-      geometry =  VisualFactoryCache::CreateQuadGeometry();
-      factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
-    }
   }
   else
   {
@@ -203,6 +198,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 +279,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,9 +294,14 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
   if( desiredHeightValue )
   {
     desiredHeightValue->Get( desiredHeight );
+    desiredSizeSpecified = true;
   }
 
-  mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+  // 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 );
   if( pixelAreaValue )
@@ -522,13 +537,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 +599,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;