Add MaskingMode property in imageView to use Rendering Time Masking
authorseungho <sbsh.baek@samsung.com>
Thu, 7 Jul 2022 08:43:59 +0000 (17:43 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Mon, 25 Jul 2022 08:33:12 +0000 (17:33 +0900)
Signed-off-by: seungho <sbsh.baek@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs
src/Tizen.NUI/src/public/Visuals/VisualConstants.cs

index a5703df..27c15b1 100755 (executable)
@@ -236,6 +236,24 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Enumeration for MaskingMode of image.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public enum MaskingModeType
+        {
+            /// <summary>
+            /// Applies alpha masking on rendering time.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            MaskingOnRendering,
+            /// <summary>
+            /// Applies alpha masking on loading time.
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            MaskingOnLoading
+        }
+
+        /// <summary>
         /// ImageView ResourceUrl, type string.
         /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
         /// When it is set as null, it gives empty string ("") to be read.
@@ -510,6 +528,44 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Gets or sets whether to apply mask on GPU or not.<br />
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public MaskingModeType MaskingMode
+        {
+            get
+            {
+                return (MaskingModeType)GetValue(MaskingModeProperty);
+            }
+            set
+            {
+                SetValue(MaskingModeProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        private MaskingModeType InternalMaskingMode
+        {
+            get
+            {
+                int ret = (int)MaskingModeType.MaskingOnLoading;
+
+                PropertyValue maskingMode = GetCachedImageVisualProperty(ImageVisualProperty.MaskingMode);
+                maskingMode?.Get(out ret);
+                maskingMode?.Dispose();
+
+                return (MaskingModeType)ret;
+            }
+            set
+            {
+                MaskingModeType ret = value;
+                PropertyValue setValue = new PropertyValue((int)ret);
+                UpdateImage(ImageVisualProperty.MaskingMode, setValue);
+                setValue?.Dispose();
+            }
+        }
+
+        /// <summary>
         /// Gets the loading state of the visual resource.
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
@@ -839,8 +895,6 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-
-
         /// <summary>
         /// Gets or sets the desired image width.<br />
         /// If not specified, the actual image width is used.<br />
index bb1aa8f..3dc1024 100755 (executable)
@@ -325,6 +325,24 @@ namespace Tizen.NUI.BaseComponents
         }));
 
         /// <summary>
+        /// MaskingModeProperty
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty MaskingModeProperty = BindableProperty.Create(nameof(MaskingMode), typeof(MaskingModeType), typeof(ImageView), default(MaskingModeType), propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
+            if (newValue != null)
+            {
+                instance.InternalMaskingMode = (ImageView.MaskingModeType)newValue;
+            }
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
+            return instance.InternalMaskingMode;
+        });
+
+        /// <summary>
         /// ImageMapProperty
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index 11abf87..595fce7 100755 (executable)
@@ -945,6 +945,14 @@ namespace Tizen.NUI
         /// </remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly int RedrawInScalingDown = NDalic.ImageVisualOrientationCorrection + 11;
+
+        /// <summary>
+        /// @brief Whether to apply mask on the GPU or not.
+        /// @details Name "MaskingMode", type MaskingModeType (Property::INTEGER).
+        /// @note It is used in the ImageVisual, and AnimatedImageVisual.The default is MaskingOnLoading.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly int MaskingMode = NDalic.ImageVisualOrientationCorrection + 12;
     }
 
     /// <summary>