Remove Setter/Getter public APIs from Dali::Layer
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image / image-visual.cpp
index 7ecfb81..07ead87 100644 (file)
@@ -56,15 +56,6 @@ namespace Internal
 namespace
 {
 
-// property names
-const char * const IMAGE_FITTING_MODE( "fittingMode" );
-const char * const IMAGE_SAMPLING_MODE( "samplingMode" );
-const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
-const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
-const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
-const char * const IMAGE_ATLASING("atlasing");
-const char * const ALPHA_MASK_URL("alphaMaskUrl");
-
 // fitting modes
 DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::FittingMode, SHRINK_TO_FIT )
@@ -131,6 +122,7 @@ Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridS
 
 } // unnamed namespace
 
+
 ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
                                  ImageVisualShaderFactory& shaderFactory,
                                  const VisualUrl& imageUrl,
@@ -191,7 +183,7 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
 }
 
 ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const Image& image )
-: Visual::Base( factoryCache, Visual::FittingMode::FIT_KEEP_ASPECT_RATIO ),
+: Visual::Base( factoryCache, Visual::FittingMode::FILL ),
   mImage( image ),
   mPixelArea( FULL_TEXTURE_RECT ),
   mPlacementActor(),
@@ -212,7 +204,8 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFac
   mLoading( false ),
   mOrientationCorrection( true )
 {
-  EnablePreMultipliedAlpha( mFactoryCache.GetPreMultiplyOnLoad() );
+  // PreMultiplied alpha should be disabled when the Image is used.
+  EnablePreMultipliedAlpha( false );
 }
 
 ImageVisual::~ImageVisual()
@@ -227,7 +220,7 @@ ImageVisual::~ImageVisual()
       if( mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID )
       {
         TextureManager& textureManager = mFactoryCache.GetTextureManager();
-        textureManager.Remove( mMaskingData->mAlphaMaskId );
+        textureManager.Remove( mMaskingData->mAlphaMaskId, this );
       }
     }
 
@@ -425,7 +418,6 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v
       if( value.Get( alphaUrl ) )
       {
         AllocateMaskData();
-        // Immediately trigger the alpha mask loading (it may just get a cached value)
         mMaskingData->mAlphaMaskUrl = alphaUrl;
       }
       break;
@@ -515,9 +507,12 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize )
     if( textureSet )
     {
       auto texture = textureSet.GetTexture(0);
-      naturalSize.x = texture.GetWidth();
-      naturalSize.y = texture.GetHeight();
-      return;
+      if( texture )
+      {
+        naturalSize.x = texture.GetWidth();
+        naturalSize.y = texture.GetHeight();
+        return;
+      }
     }
   }
 
@@ -553,7 +548,6 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize )
       return;
     }
   }
-
   naturalSize = Vector2::ZERO;
 }
 
@@ -568,7 +562,8 @@ void ImageVisual::CreateRenderer( TextureSet& textureSet )
 
     shader = mImageVisualShaderFactory.GetShader( mFactoryCache,
                              mImpl->mFlags & Impl::IS_ATLASING_APPLIED,
-                             mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE );
+                             mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE,
+                             IsRoundedCornerRequired() );
   }
   else
   {
@@ -663,11 +658,6 @@ void ImageVisual::CreateNativeImageRenderer( NativeImage& nativeImage )
   mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
 }
 
-bool ImageVisual::IsSynchronousResourceLoading() const
-{
-  return mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
-}
-
 void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& textures, bool orientationCorrection,
                                TextureManager::ReloadPolicy forceReload )
 {
@@ -688,7 +678,7 @@ void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& t
     : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
   textures = textureManager.LoadTexture( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode,
-                                         mMaskingData, IsSynchronousResourceLoading(), mTextureId,
+                                         mMaskingData, IsSynchronousLoadingRequired(), mTextureId,
                                          atlasRect, mAtlasRectSize, atlasing, mLoading, mWrapModeU,
                                          mWrapModeV, textureObserver, atlasUploadObserver, atlasManager,
                                          mOrientationCorrection, forceReload, preMultiplyOnLoad);
@@ -781,7 +771,7 @@ void ImageVisual::DoSetOnStage( Actor& actor )
   mPlacementActor = actor;
   // Search the Actor tree to find if Layer UI behaviour set.
   Layer layer = actor.GetLayer();
-  if( layer && layer.GetBehavior() == Layer::LAYER_3D )
+  if( layer && layer.GetProperty<Layer::Behavior>( Layer::Property::BEHAVIOR ) == Layer::LAYER_3D )
   {
      // Layer 3D set, do not align pixels
      mImpl->mRenderer.RegisterProperty( PIXEL_ALIGNED_UNIFORM_NAME, PIXEL_ALIGN_OFF );
@@ -829,7 +819,7 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const
   map.Clear();
   map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
 
-  bool sync = IsSynchronousResourceLoading();
+  bool sync = IsSynchronousLoadingRequired();
   map.Insert( SYNCHRONOUS_LOADING, sync );
   if( mImageUrl.IsValid() )
   {
@@ -1012,7 +1002,7 @@ void ImageVisual::RemoveTexture()
 {
   if( mTextureId != TextureManager::INVALID_TEXTURE_ID )
   {
-    mFactoryCache.GetTextureManager().Remove( mTextureId );
+    mFactoryCache.GetTextureManager().Remove( mTextureId, this );
     mTextureId = TextureManager::INVALID_TEXTURE_ID;
   }
   else