Scaledown image when visual is bigger than n-patch fixed length 26/267326/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 1 Dec 2021 12:02:20 +0000 (21:02 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 3 Dec 2021 10:31:31 +0000 (19:31 +0900)
When n-patch image's fixed length is bigger than visual size,
the visual's geometry breakdown.

This patch calculate good scales in vertex shader.

NOTE : We scaledown same rates both width and height. This action follow up CSS current action.

Change-Id: Ief2c6e6e2deb04dac36a1b9575e7bd620697d81d
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/graphics/shaders/npatch-visual-3x3-shader.vert
dali-toolkit/internal/graphics/shaders/npatch-visual-shader.vert

index 1586312..c7b8a9f 100644 (file)
@@ -25,7 +25,10 @@ void main()
   mediump vec2 stretch  = floor( aPosition * 0.5 );
   mediump vec2 fixedTotal   = uFixed[ 2 ];
 
-  mediump vec4 gridPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );
+  // Scale down if fixedTotal is bigger than visualSize
+  mediump float fixedScaleDownRate = min(1.0, min(size.x / fixedTotal.x, size.y / fixedTotal.y));
+
+  mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( size - fixedTotal * fixedScaleDownRate ) * stretch, 0.0, 1.0 );
   mediump vec4 vertexPosition = gridPosition;
   vertexPosition.xy -= size * vec2( 0.5, 0.5 );
   vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;
index 07f645b..4cd84bc 100644 (file)
@@ -25,7 +25,10 @@ void main()
   vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
   vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
 
-  mediump vec4 gridPosition = vec4( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal, 0.0, 1.0 );
+  // Scale down if fixedTotal is bigger than visualSize
+  mediump float fixedScaleDownRate = min(1.0, min(visualSize.x / fixedTotal.x, visualSize.y / fixedTotal.y));
+
+  mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( visualSize.xy - fixedTotal * fixedScaleDownRate ) * stretch / stretchTotal, 0.0, 1.0 );
   mediump vec4 vertexPosition = gridPosition;
   vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
   vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;