[Tizen] CornerRadius valid to clip children 01/274301/1 accepted/tizen/6.0/unified/20220513.142023 submit/tizen_6.0/20220512.140928
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 26 Apr 2022 05:03:06 +0000 (14:03 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 26 Apr 2022 05:04:59 +0000 (14:04 +0900)
Make able to use CornerRadius clip children.
Note : It use stencil buffer. So Edge of rounded corner
will show some alias.

Change-Id: Id077a6a4226547e8ead3b953a8d8650ec5a4e733
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/devel-api/visuals/visual-properties-devel.h
dali-toolkit/internal/visuals/color/color-visual.cpp
dali-toolkit/internal/visuals/gradient/gradient-visual.cpp
dali-toolkit/internal/visuals/image-visual-shader-factory.cpp

index 99e3837..b449034 100644 (file)
@@ -74,6 +74,7 @@ enum Type
   /**
    * @brief The radius for the rounded corners of the visual
    * @details Name "cornerRadius", type Property::FLOAT.
+   * @note Their may exist some alias when you use it as ClippingMode::CLIP_CHILDREN.
    * @note Optional.
    */
   CORNER_RADIUS = OPACITY + 2,
index 4fae268..3a67c29 100644 (file)
@@ -126,9 +126,16 @@ const char* FRAGMENT_SHADER_ROUNDED_CORNER = DALI_COMPOSE_SHADER(
   \n
   void main()\n
   {\n
-      mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
+    mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
+    if(dist > 1.0)\n
+    {\n
+      discard;\n
+    }\n
+    else\n
+    {\n
       gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
       gl_FragColor.a *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
+    }\n
   }\n
 );
 
index 462a6c0..497dccd 100644 (file)
@@ -274,8 +274,15 @@ DALI_COMPOSE_SHADER(
   void main()\n
   {\n
     mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
-    gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
-    gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
+    if(dist > 1.0)\n
+    {\n
+      discard;\n
+    }\n
+    else\n
+    {\n
+      gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
+      gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
+    }\n
   }\n
 ),
 
@@ -292,8 +299,15 @@ DALI_COMPOSE_SHADER(
   void main()\n
   {\n
     mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
-    gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
-    gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
+    if(dist > 1.0)\n
+    {\n
+      discard;\n
+    }\n
+    else\n
+    {\n
+      gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
+      gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
+    }\n
   }\n
 )
 };
index 45d0e3f..49d1b5c 100644 (file)
@@ -174,10 +174,17 @@ const char* FRAGMENT_SHADER_ROUNDED_CORNER = DALI_COMPOSE_SHADER(
   void main()\n
   {\n
       mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
-      mediump float opacity = 1.0 - smoothstep( -1.0, 1.0, dist );\n
-      gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
-      gl_FragColor.a *= opacity;\n
-      gl_FragColor.rgb *= mix( 1.0, opacity, preMultipliedAlpha );\n
+      if(dist > 1.0)\n
+      {\n
+        discard;\n
+      }\n
+      else\n
+      {\n
+        mediump float opacity = 1.0 - smoothstep( -1.0, 1.0, dist );\n
+        gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
+        gl_FragColor.a *= opacity;\n
+        gl_FragColor.rgb *= mix( 1.0, opacity, preMultipliedAlpha );\n
+      }\n
   }\n
 );