Adding ImageVisual ReleasePolicy & LoadPolicy 21/153021/2
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Wed, 27 Sep 2017 14:28:14 +0000 (15:28 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Wed, 18 Oct 2017 14:34:14 +0000 (14:34 +0000)
Change-Id: I9c434fb9336426556142c1a3fad8d73797d22f24

Tizen.NUI/src/internal/NDalic.cs
Tizen.NUI/src/internal/NDalicPINVOKE.cs
Tizen.NUI/src/public/NUIConstants.cs
Tizen.NUI/src/public/VisualMaps.cs

index 13697ac..62c3f1c 100755 (executable)
@@ -885,6 +885,8 @@ namespace Tizen.NUI
         internal static readonly int IMAGE_VISUAL_FRAME_DELAY = NDalicPINVOKE.IMAGE_VISUAL_FRAME_DELAY_get();
         internal static readonly int IMAGE_VISUAL_MASK_CONTENT_SCALE = NDalicPINVOKE.IMAGE_VISUAL_MASK_CONTENT_SCALE_get();
         internal static readonly int IMAGE_VISUAL_CROP_TO_MASK = NDalicPINVOKE.IMAGE_VISUAL_CROP_TO_MASK_get();
+        internal static readonly int IMAGE_VISUAL_RELEASE_POLICY = NDalicPINVOKE.IMAGE_VISUAL_RELEASE_POLICY_get();
+        internal static readonly int IMAGE_VISUAL_LOAD_POLICY = NDalicPINVOKE.IMAGE_VISUAL_LOAD_POLICY_get();
 
         internal static readonly int MESH_VISUAL_OBJECT_URL = NDalicPINVOKE.MESH_VISUAL_OBJECT_URL_get();
         internal static readonly int MESH_VISUAL_MATERIAL_URL = NDalicPINVOKE.MESH_VISUAL_MATERIAL_URL_get();
index 728cea5..73ce6d8 100755 (executable)
@@ -6564,6 +6564,12 @@ class NDalicPINVOKE {
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_IMAGE_VISUAL_CROP_TO_MASK_get")]
   public static extern int IMAGE_VISUAL_CROP_TO_MASK_get();
 
+  [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_IMAGE_VISUAL_RELEASE_POLICY_get")]
+  public static extern int IMAGE_VISUAL_RELEASE_POLICY_get();
+
+  [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_IMAGE_VISUAL_LOAD_POLICY_get")]
+  public static extern int IMAGE_VISUAL_LOAD_POLICY_get();
+
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_MESH_VISUAL_OBJECT_URL_get")]
   public static extern int MESH_VISUAL_OBJECT_URL_get();
 
index b89e0cd..6b8e184 100755 (executable)
@@ -481,6 +481,42 @@ namespace Tizen.NUI
     }
 
     /// <summary>
+    /// Specifies the Release Policy types <br>
+    /// Decides if the image should be cached in different conditions
+    /// </summary>
+    public enum ReleasePolicyType
+    {
+      /// <summary>
+      /// Image is released when visual detached from scene
+      /// </summary>
+      Detached = 0,
+      /// <summary>
+      /// Image is only released when visual is destroyed
+      /// </summary>
+      Destroyed,
+      /// <summary>
+      /// Image is not released.
+      /// </summary>
+      Never
+    }
+
+    /// <summary>
+    /// Specifies the Load Policy types <br>
+    /// Decides when the image texture should be loaded
+    /// </summary>
+    public enum LoadPolicyType
+    {
+       /// <summary>
+       /// Load texture once the image source has been provided. Even if not being used yet.
+       /// </summary>
+       Immediate = 0,
+       /// <summary>
+       /// Only load texture once the visual is attached, when the image needs to be shown.
+       /// </summary>
+       Attached
+    }
+
+    /// <summary>
     /// The type of coordinate system for certain attributes of the points in a gradient.
     /// </summary>
     public enum GradientVisualUnitsType
@@ -833,7 +869,8 @@ namespace Tizen.NUI
         public static readonly int BatchSize = NDalic.IMAGE_VISUAL_BATCH_SIZE;
         public static readonly int CacheSize = NDalic.IMAGE_VISUAL_CACHE_SIZE;
         public static readonly int FrameDelay = NDalic.IMAGE_VISUAL_FRAME_DELAY;
-
+        public static readonly int ReleasePolicy = NDalic.IMAGE_VISUAL_RELEASE_POLICY;
+        public static readonly int LoadPolicy = NDalic.IMAGE_VISUAL_LOAD_POLICY;
     }
 
     /// <summary>
index 6dc815d..da6550e 100755 (executable)
@@ -570,6 +570,8 @@ namespace Tizen.NUI
         private WrapModeType? _wrapModeV = null;
         private float? _maskContentScale = null;
         private bool? _cropToMask = null;
+        private ReleasePolicyType? _releasePolicy = null;
+        private LoadPolicyType? _loadPolicy = null;
 
         /// <summary>
         /// Get or set the URL of the image.<br>
@@ -809,6 +811,41 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// Get or set the Image Visual release policy<br>
+        /// It decides if a texture should be released from the cache or kept to reduce loading time <br>
+        /// </summary>
+        public ReleasePolicyType ReleasePolicy
+        {
+            get
+            {
+                return _releasePolicy ?? (ReleasePolicyType.Destroyed );
+            }
+            set
+            {
+                _releasePolicy = value;
+                UpdateVisual();
+            }
+        }
+
+
+        /// <summary>
+        /// Get or set the Image Visual image loading policy<br>
+        /// It decides if a texture should be loaded immediately after source set or only after visual is added to window <br>
+        /// </summary>
+        public LoadPolicyType LoadPolicy
+        {
+            get
+            {
+                return _loadPolicy ?? (LoadPolicyType.Attached);
+            }
+            set
+            {
+                _loadPolicy = value;
+                UpdateVisual();
+            }
+        }
+
         protected override void ComposingPropertyMap()
         {
             if (_url != null)
@@ -832,6 +869,8 @@ namespace Tizen.NUI
                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
                 if (_maskContentScale != null) { _outputVisualMap.Add((int)ImageVisualProperty.MaskContentScale, new PropertyValue((float)_maskContentScale)); }
                 if (_cropToMask != null) { _outputVisualMap.Add((int)ImageVisualProperty.CropToMask, new PropertyValue((bool)_cropToMask)); }
+                if (_releasePolicy != null) { _outputVisualMap.Add( ImageVisualProperty.ReleasePolicy , new PropertyValue((int)_releasePolicy)); }
+                if (_loadPolicy != null) { _outputVisualMap.Add( ImageVisualProperty.LoadPolicy, new PropertyValue((int)_loadPolicy)); }
             }
         }
     }