Merge "Fix text AutoScroll ellipsis issue" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / graphics / shaders / npatch-visual-shader.vert
1 attribute mediump vec2 aPosition;
2 varying mediump vec2 vTexCoord;
3 varying mediump vec2 vMaskTexCoord;
4 uniform highp mat4 uMvpMatrix;
5 uniform highp vec3 uSize;
6 uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];
7 uniform mediump vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];
8
9 // Visual size and offset
10 uniform mediump vec2 offset;
11 uniform highp vec2 size;
12 uniform mediump vec4 offsetSizeMode;
13 uniform mediump vec2 origin;
14 uniform mediump vec2 anchorPoint;
15 uniform mediump vec2 extraSize;
16
17 void main()
18 {
19   mediump vec2 fixedFactor= vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );
20   mediump vec2 stretch= vec2( uNinePatchFactorsX[ int( ( aPosition.x ) * 0.5 ) ].y, uNinePatchFactorsY[ int( ( aPosition.y ) * 0.5 ) ].y );
21
22   mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );
23   mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );
24
25   vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
26   vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
27
28   // Scale down if fixedTotal is bigger than visualSize
29   mediump float fixedScaleDownRate = min(1.0, min(visualSize.x / fixedTotal.x, visualSize.y / fixedTotal.y));
30
31   mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( visualSize.xy - fixedTotal * fixedScaleDownRate ) * stretch / stretchTotal, 0.0, 1.0 );
32   mediump vec4 vertexPosition = gridPosition;
33   vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
34   vertexPosition.xy += anchorPoint*visualSize + visualOffset + origin * uSize.xy;
35   vertexPosition = uMvpMatrix * vertexPosition;
36
37   vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );
38   vMaskTexCoord = gridPosition.xy / visualSize;
39
40   gl_Position = vertexPosition;
41 }