--- /dev/null
+# cube.obj
+#
+
+g cube
+
+v 0.0 0.0 0.0
+v 0.0 0.0 1.0
+v 0.0 1.0 0.0
+v 0.0 1.0 1.0
+v 1.0 0.0 0.0
+v 1.0 0.0 1.0
+v 1.0 1.0 0.0
+v 1.0 1.0 1.0
+
+vt 0.0 0.0
+vt 0.3 0.3
+vt 0.0 1.0
+vt 0.3 0.7
+vt 1.0 0.0
+vt 0.7 0.3
+vt 1.0 1.0
+vt 0.7 0.7
+
+vn 0.0 0.0 1.0
+vn 0.0 0.0 -1.0
+vn 0.0 1.0 0.0
+vn 0.0 -1.0 0.0
+vn 1.0 0.0 0.0
+vn -1.0 0.0 0.0
+
+f 1/1/2 7/7/2 5/5/2
+f 1/1/2 3/3/2 7/7/2
+f 1/1/6 4/4/6 3/3/6
+f 1/1/6 2/2/6 4/4/6
+f 3/3/3 8/8/3 7/7/3
+f 3/3/3 4/4/3 8/8/3
+f 5/5/5 7/7/5 8/8/5
+f 5/5/5 8/8/5 6/6/5
+f 1/1/4 5/5/4 6/6/4
+f 1/1/4 6/6/4 2/2/4
+f 2/2/1 6/6/1 8/8/1
+f 2/2/1 8/8/1 4/4/1
--- /dev/null
+newmtl lambert3SG
+illum 4
+Kd 0.00 0.00 0.00
+Ka 0.00 0.00 0.00
+Tf 1.00 1.00 1.00
+map_Kd tbcol.png
+Ni 1.00
+Ks 0.00 0.00 0.00
+Ns 3.66
--- /dev/null
+newmtl lambert3SG
+illum 4
+Kd 0.00 0.00 0.00
+Ka 0.00 0.00 0.00
+Tf 1.00 1.00 1.00
+map_Kd tbcol.png
+bump tb-norm.png -bm 0.05
+Ni 1.00
+Ks 0.00 0.00 0.00
+map_Ks TB-gloss.png
+Ns 3.66
0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 32.f, -2.f, 35.f, -11.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f,
};
struct LineRun line0 =
{
{ 38u, 12u },
{ 38u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
0.f, -9.f, 11.f, -9.f, 21.f, -9.f, 27.f, -13.f, 30.f, -13.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 30.f, -0.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
- 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f, 42.f, -12.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
+ 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f, 42.f, -11.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -8.f, 7.f, -6.f, 12.f, -7.f, 18.f, -7.f, 23.f, -11.f, 25.f, -0.f, 27.f, -7.f, 32.f, -11.f, 33.f, -11.f, 37.f, -8.f, 44.f, -11.f, 45.f, -11.f, 49.f, -8.f, 55.f, -0.f, 59.f, -10.f, 70.f, -13.f, 77.f, -10.f, 82.f, -10.f, 90.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 30.f, -0.f,
- 1.f, -12.f, 12.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 51.f, -9.f, 61.f, -9.f, 67.f, -13.f, 70.f, -13.f, 79.f, -0.f,
- 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
+ 1.f, -12.f, 12.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 41.f, -9.f, 52.f, -9.f, 62.f, -9.f, 68.f, -13.f, 71.f, -13.f, 80.f, -0.f,
+ 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 45.f, -10.f, 56.f, -13.f, 63.f, -10.f, 68.f, -10.f, 76.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 32.f, -2.f, 35.f, -11.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -8.f, 7.f, -6.f, 12.f, -7.f, 18.f, -7.f, 23.f, -11.f, 25.f, -0.f, 27.f, -7.f, 32.f, -11.f, 33.f, -11.f, 37.f, -8.f, 44.f, -11.f, 45.f, -11.f, 49.f, -8.f, 55.f, -0.f,
};
struct LineRun line01 =
92.f,
15.f,
-5.f,
- 4.f,
+ 5.f,
0.f,
false,
false
{
{ 74u, 12u },
{ 74u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
{
{ 92u, 12u },
{ 92u, 12u },
- 78.f,
+ 79.f,
15.f,
-5.f,
- 4.f,
+ 5.f,
0.f,
false,
false
{
{ 128u, 12u },
{ 128u, 12u },
- 81.f,
+ 82.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
{
{ 140u, 10u },
{ 140u, 10u },
- 76.f,
+ 77.f,
15.f,
-5.f,
4.f,
{
{ 166u, 12u },
{ 166u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
4.f,
0.f, -9.f, 11.f, -9.f, 21.f, -9.f, 27.f, -13.f, 30.f, -13.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 30.f, -0.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
- 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f, 42.f, -12.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
+ 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f, 42.f, -11.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -8.f, 7.f, -6.f, 12.f, -7.f, 18.f, -7.f, 23.f, -11.f, 25.f, -0.f, 27.f, -7.f, 32.f, -11.f, 33.f, -11.f, 37.f, -8.f, 44.f, -11.f, 45.f, -11.f, 49.f, -8.f, 55.f, -0.f, 59.f, -10.f, 70.f, -13.f, 77.f, -10.f, 82.f, -10.f, 90.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 30.f, -0.f,
- 1.f, -12.f, 12.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 51.f, -9.f, 61.f, -9.f, 67.f, -13.f, 70.f, -13.f, 79.f, -0.f,
- 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
+ 1.f, -12.f, 12.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 41.f, -9.f, 52.f, -9.f, 62.f, -9.f, 68.f, -13.f, 71.f, -13.f, 80.f, -0.f,
+ 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 45.f, -10.f, 56.f, -13.f, 63.f, -10.f, 68.f, -10.f, 76.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 32.f, -2.f, 35.f, -11.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -8.f, 7.f, -6.f, 12.f, -7.f, 18.f, -7.f, 23.f, -11.f, 25.f, -0.f, 27.f, -7.f, 32.f, -11.f, 33.f, -11.f, 37.f, -8.f, 44.f, -11.f, 45.f, -11.f, 49.f, -8.f, 55.f, -0.f,
};
struct LineRun line01 =
92.f,
15.f,
-5.f,
- 4.f,
+ 5.f,
0.f,
false,
false
{
{ 74u, 12u },
{ 74u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
{
{ 92u, 12u },
{ 92u, 12u },
- 78.f,
+ 79.f,
15.f,
-5.f,
- 4.f,
+ 5.f,
0.f,
false,
false
{
{ 128u, 12u },
{ 128u, 12u },
- 81.f,
+ 82.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
{
{ 140u, 10u },
{ 140u, 10u },
- 76.f,
+ 77.f,
15.f,
-5.f,
4.f,
{
{ 166u, 12u },
{ 166u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
4.f,
0.f, -9.f, 11.f, -9.f, 21.f, -9.f, 27.f, -13.f, 30.f, -13.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 30.f, -0.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
- 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f, 42.f, -12.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
+ 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -3.f, 42.f, -11.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -8.f, 7.f, -6.f, 12.f, -7.f, 18.f, -7.f, 23.f, -11.f, 25.f, -0.f, 27.f, -7.f, 32.f, -11.f, 33.f, -11.f, 37.f, -8.f, 44.f, -11.f, 45.f, -11.f, 49.f, -8.f, 55.f, -0.f, 59.f, -10.f, 70.f, -13.f, 77.f, -10.f, 82.f, -10.f, 90.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 30.f, -0.f,
- 1.f, -12.f, 12.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 40.f, -9.f, 51.f, -9.f, 61.f, -9.f, 67.f, -13.f, 70.f, -13.f, 79.f, -0.f,
- 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 44.f, -10.f, 55.f, -13.f, 62.f, -10.f, 67.f, -10.f, 75.f, -0.f,
+ 1.f, -12.f, 12.f, -9.f, 20.f, -13.f, 24.f, -13.f, 27.f, -9.f, 36.f, -0.f, 41.f, -9.f, 52.f, -9.f, 62.f, -9.f, 68.f, -13.f, 71.f, -13.f, 80.f, -0.f,
+ 0.f, -13.f, 10.f, -9.f, 18.f, -9.f, 30.f, -9.f, 39.f, -0.f, 45.f, -10.f, 56.f, -13.f, 63.f, -10.f, 68.f, -10.f, 76.f, -0.f,
1.f, -10.f, 9.f, -10.f, 14.f, -13.f, 22.f, -10.f, 32.f, -2.f, 35.f, -11.f,
1.f, -10.f, 12.f, -13.f, 19.f, -10.f, 24.f, -10.f, 32.f, -0.f, 37.f, -10.f, 45.f, -10.f, 50.f, -13.f, 58.f, -10.f, 66.f, -0.f,
- 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 38.f, -9.f, 49.f, -9.f, 59.f, -9.f, 65.f, -13.f, 68.f, -13.f, 77.f, -0.f,
+ 1.f, -13.f, 10.f, -9.f, 18.f, -13.f, 22.f, -13.f, 25.f, -9.f, 34.f, -0.f, 39.f, -9.f, 50.f, -9.f, 60.f, -9.f, 66.f, -13.f, 69.f, -13.f, 78.f, -0.f,
0.f, -8.f, 7.f, -6.f, 12.f, -7.f, 18.f, -7.f, 23.f, -11.f, 25.f, -0.f, 27.f, -7.f, 32.f, -11.f, 33.f, -11.f, 37.f, -8.f, 44.f, -11.f, 45.f, -11.f, 49.f, -8.f, 55.f, -0.f,
};
struct LineRun line01 =
92.f,
15.f,
-5.f,
- 4.f,
+ 5.f,
0.f,
false,
false
{
{ 74u, 12u },
{ 74u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
{
{ 92u, 12u },
{ 92u, 12u },
- 78.f,
+ 79.f,
15.f,
-5.f,
- 4.f,
+ 5.f,
0.f,
false,
false
{
{ 128u, 12u },
{ 128u, 12u },
- 81.f,
+ 82.f,
15.f,
-5.f,
- 3.f,
+ 4.f,
0.f,
false,
false
{
{ 140u, 10u },
{ 140u, 10u },
- 76.f,
+ 77.f,
15.f,
-5.f,
4.f,
{
{ 166u, 12u },
{ 166u, 12u },
- 79.f,
+ 80.f,
15.f,
-5.f,
4.f,
false,
false
};
+
Vector<LineRun> lines;
lines.PushBack( line01 );
lines.PushBack( line02 );
//
// void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
// Vector<FontId>& fontIds,
+// Vector<bool>& isDefaultFont,
// const TextAbstraction::FontDescription& defaultFontDescription,
// TextAbstraction::PointSize26Dot6 defaultPointSize,
// CharacterIndex startIndex,
unsigned int startIndex; ///< The start index.
unsigned int numberOfCharacters; ///< The number of characters.
Vector<FontId> expectedFontIds; ///< The expected font ids.
+ Vector<bool> expectedIsDefault; ///< The expected font ids.
};
struct ScriptsData
{
Vector<FontId> fontIds;
fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
+ Vector<bool> isDefaultFont;
+ isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
MergeFontDescriptions( data.fontDescriptionRuns,
fontIds,
+ isDefaultFont,
data.defaultFontDescription,
data.defaultPointSize,
data.startIndex,
std::cout << std::endl;
return false;
}
+
+ if( isDefaultFont[index] != data.expectedIsDefault[index] )
+ {
+ std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
+ return false;
+ }
}
return true;
TextAbstraction::FontDescription defaultFontDescription01;
Vector<FontDescriptionRun> fontDescriptionRuns01;
Vector<FontId> expectedFontIds01;
+ Vector<bool> expectedIsFontDefault01;
TextAbstraction::FontDescription defaultFontDescription02;
Vector<FontDescriptionRun> fontDescriptionRuns02;
Vector<FontId> expectedFontIds02;
expectedFontIds02.PushBack( 0u );
expectedFontIds02.PushBack( 0u );
+ Vector<bool> expectedIsFontDefault02;
+ expectedIsFontDefault02.PushBack( true );
+ expectedIsFontDefault02.PushBack( true );
TextAbstraction::FontDescription defaultFontDescription03;
defaultFontDescription03.family = "DejaVu Serif";
expectedFontIds03.PushBack( 3u );
expectedFontIds03.PushBack( 6u );
expectedFontIds03.PushBack( 6u );
+ Vector<bool> expectedIsFontDefault03;
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
+ expectedIsFontDefault03.PushBack( false );
const MergeFontDescriptionsData data[] =
{
TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
0u,
0u,
- expectedFontIds01
+ expectedFontIds01,
+ expectedIsFontDefault01
},
{
"No description runs.",
TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
0u,
2u,
- expectedFontIds02
+ expectedFontIds02,
+ expectedIsFontDefault02
},
{
"Some description runs.",
TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
0u,
10u,
- expectedFontIds03
+ expectedFontIds03,
+ expectedIsFontDefault03
}
};
const unsigned int numberOfTests = 3u;
#include <stdio.h>
#include <string.h>
-#include <dali-toolkit/internal/controls/flex-container/layout.h>
+#include <dali-toolkit/third-party/facebook-flexbox/layout.h>
void test(const char *name, css_node_t *style, css_node_t *expected_layout);
bool tests_finished(void);
# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
-# utc-Dali-Alignment.cpp
-# utc-Dali-BloomView.cpp
-# utc-Dali-BubbleEmitter.cpp
-# utc-Dali-Builder.cpp
-# utc-Dali-CheckBoxButton.cpp
-# utc-Dali-ConfirmationPopup.cpp
-# utc-Dali-CubeTransitionEffect.cpp
-# utc-Dali-EffectsView.cpp
-# utc-Dali-FlexContainer.cpp
-# utc-Dali-GaussianBlurView.cpp
-# utc-Dali-ImageView.cpp
-# utc-Dali-JsonParser.cpp
-# utc-Dali-KeyInputFocusManager.cpp
-# utc-Dali-PageTurnView.cpp
-# utc-Dali-Script.cpp
-# utc-Dali-ScrollBar.cpp
-# utc-Dali-ScrollView.cpp
-# utc-Dali-ShaderEffects.cpp
-# utc-Dali-ShadowView.cpp
-# utc-Dali-Slider.cpp
-# utc-Dali-TableView.cpp
-# utc-Dali-TextEditor.cpp
-# utc-Dali-TextField.cpp
-# utc-Dali-TextLabel.cpp
-# utc-Dali-TextSelectionPopup.cpp
-# utc-Dali-ToolBar.cpp
-# utc-Dali-Button.cpp
-# utc-Dali-Control.cpp
-# utc-Dali-ControlImpl.cpp
-# utc-Dali-AccessibilityManager.cpp
-# utc-Dali-ItemLayout.cpp
-# utc-Dali-ItemView.cpp
-# utc-Dali-KeyboardFocusManager.cpp
-# utc-Dali-Magnifier.cpp
-# utc-Dali-Popup.cpp
-# utc-Dali-PushButton.cpp
-# utc-Dali-RadioButton.cpp
-# utc-Dali-ScrollViewEffect.cpp
-# utc-Dali-SuperBlurView.cpp
-# utc-Dali-Toolkit.cpp
-# utc-Dali-Model3dView.cpp
-# utc-Dali-ControlRenderer.cpp
-# utc-Dali-RendererFactory.cpp
-# utc-Dali-DebugRenderer.cpp
-# utc-Dali-ImageAtlas.cpp
+ utc-Dali-Alignment.cpp
+ utc-Dali-BloomView.cpp
+ utc-Dali-BubbleEmitter.cpp
+ utc-Dali-Builder.cpp
+ utc-Dali-CheckBoxButton.cpp
+ utc-Dali-ConfirmationPopup.cpp
+ utc-Dali-CubeTransitionEffect.cpp
+ utc-Dali-EffectsView.cpp
+ utc-Dali-FlexContainer.cpp
+ utc-Dali-GaussianBlurView.cpp
+ utc-Dali-ImageView.cpp
+ utc-Dali-JsonParser.cpp
+ utc-Dali-KeyInputFocusManager.cpp
+ utc-Dali-PageTurnView.cpp
+ utc-Dali-Script.cpp
+ utc-Dali-ScrollBar.cpp
+ utc-Dali-ScrollView.cpp
+ utc-Dali-ShaderEffects.cpp
+ utc-Dali-ShadowView.cpp
+ utc-Dali-Slider.cpp
+ utc-Dali-TableView.cpp
+ utc-Dali-TextEditor.cpp
+ utc-Dali-TextField.cpp
+ utc-Dali-TextLabel.cpp
+ utc-Dali-TextSelectionPopup.cpp
+ utc-Dali-ToolBar.cpp
+ utc-Dali-Button.cpp
+ utc-Dali-Control.cpp
+ utc-Dali-ControlImpl.cpp
+ utc-Dali-AccessibilityManager.cpp
+ utc-Dali-ItemLayout.cpp
+ utc-Dali-ItemView.cpp
+ utc-Dali-KeyboardFocusManager.cpp
+ utc-Dali-Magnifier.cpp
+ utc-Dali-Popup.cpp
+ utc-Dali-PushButton.cpp
+ utc-Dali-RadioButton.cpp
+ utc-Dali-ScrollViewEffect.cpp
+ utc-Dali-SuperBlurView.cpp
+ utc-Dali-Toolkit.cpp
+ utc-Dali-Model3dView.cpp
+ utc-Dali-ControlRenderer.cpp
+ utc-Dali-RendererFactory.cpp
+ utc-Dali-DebugRenderer.cpp
+ utc-Dali-ImageAtlas.cpp
utc-Dali-VideoView.cpp
)
namespace
{
-const char * const TEXTURE_UNIFORM_NAME( "sTexture" );
-
const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
attribute mediump vec2 aPosition;\n
uniform mediump mat4 uMvpMatrix;\n
{
std::stringstream out;
out << program << ", " << shader;
- mShaderTrace.PushCall("AttachShader", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["program"] = ToString(program);
+ namedParams["shader"] = ToString(shader);
+ mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
}
inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
std::stringstream out;
out << target << ", " << texture;
- mTextureTrace.PushCall("BindTexture", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["texture"] = ToString(texture);
+
+ mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
}
inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
std::stringstream out;
out << shader;
- mShaderTrace.PushCall("CompileShader", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["shader"] = ToString(shader);
+
+ mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
}
inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
{
std::stringstream out;
out << type;
- mShaderTrace.PushCall("CreateShader", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["type"] = ToString(type);
+ mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
return ++mLastShaderIdUsed;
}
{
std::stringstream out;
out << mode;
- mCullFaceTrace.PushCall("CullFace", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["program"] = ToString(mode);
+
+ mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
}
inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
{
std::stringstream out;
out << program;
- mShaderTrace.PushCall("DeleteProgram", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["program"] = ToString(program);
+
+ mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
}
inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
{
std::stringstream out;
out << shader;
- mShaderTrace.PushCall("DeleteShader", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["shader"] = ToString(shader);
+
+ mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
}
inline void DeleteTextures(GLsizei n, const GLuint* textures)
std::stringstream out;
out << n << ", " << textures << " = [";
+ TraceCallStack::NamedParams namedParams;
+
for(GLsizei i=0; i<n; i++)
{
out << textures[i] << ", ";
+ std::stringstream paramName;
+ paramName<<"texture["<<i<<"]";
+ namedParams[paramName.str()] = ToString(textures[i]);
mDeletedTextureIds.push_back(textures[i]);
}
out << "]";
- mTextureTrace.PushCall("DeleteTextures", out.str());
+
+ mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
}
inline bool CheckNoTexturesDeleted()
inline void DepthFunc(GLenum func)
{
+ std::stringstream out;
+ out << func;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["func"] = ToString(func);
+
+ mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
}
inline void DepthMask(GLboolean flag)
{
std::stringstream out;
out << program << ", " << shader;
- mShaderTrace.PushCall("DetachShader", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["program"] = ToString(program);
+ namedParams["shader"] = ToString(shader);
+ mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
}
inline void Disable(GLenum cap)
{
std::stringstream out;
out << cap;
- mEnableDisableTrace.PushCall("Disable", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["cap"] = ToString(cap);
+ mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
}
inline void DisableVertexAttribArray(GLuint index)
{
std::stringstream out;
out << mode << ", " << first << ", " << count;
- mDrawTrace.PushCall("DrawArrays", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["mode"] = ToString(mode);
+ namedParams["first"] = ToString(first);
+ namedParams["count"] = ToString(count);
+ mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
}
inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
{
std::stringstream out;
out << mode << ", " << count << ", " << type << ", indices";
- mDrawTrace.PushCall("DrawElements", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["mode"] = ToString(mode);
+ namedParams["count"] = ToString(count);
+ namedParams["type"] = ToString(type);
+ // Skip void pointers - are they of any use?
+ mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
}
inline void Enable(GLenum cap)
{
std::stringstream out;
out << cap;
- mEnableDisableTrace.PushCall("Enable", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["cap"] = ToString(cap);
+ mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
}
inline void EnableVertexAttribArray(GLuint index)
inline void GenerateMipmap(GLenum target)
{
+ std::stringstream out;
+ out<<target;
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+
+ mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
}
inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
return mNextTextureIds;
}
- inline void GenTextures(GLsizei n, GLuint* textures)
+ inline void GenTextures(GLsizei count, GLuint* textures)
{
- for( int i=0; i<n; ++i )
+ for( int i=0; i<count; ++i )
{
if( !mNextTextureIds.empty() )
{
}
}
+ TraceCallStack::NamedParams namedParams;
+ namedParams["count"] = ToString(count);
+
std::stringstream out;
- for(int i=0; i<n; i++)
+ for(int i=0; i<count; i++)
{
out << textures[i];
- if(i<n-1)
+ if(i<count-1)
{
out << ", ";
}
+ std::ostringstream oss;
+ oss<<"indices["<<i<<"]";
+ namedParams[oss.str()] = ToString(textures[i]);
}
- mTextureTrace.PushCall("GenTextures", out.str());
+
+ mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
}
inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
{
std::stringstream out;
out << program;
- mShaderTrace.PushCall("LinkProgram", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["program"] = ToString(program);
+ mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
mNumberOfActiveUniforms=2;
GetUniformLocation(program, "sTexture");
inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
{
std::stringstream out;
- out << width << ", " << height;
- mTextureTrace.PushCall("TexImage2D", out.str());
+ out << target<<", "<<level<<", "<<width << ", " << height;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["level"] = ToString(level);
+ namedParams["internalformat"] = ToString(internalformat);
+ namedParams["width"] = ToString(width);
+ namedParams["height"] = ToString(height);
+ namedParams["border"] = ToString(border);
+ namedParams["format"] = ToString(format);
+ namedParams["type"] = ToString(type);
+
+ mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
}
inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
{
std::stringstream out;
out << target << ", " << pname << ", " << param;
- mTexParamaterTrace.PushCall("TexParameterf", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["pname"] = ToString(pname);
+ namedParams["param"] = ToString(param);
+
+ mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
}
inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
{
std::stringstream out;
out << target << ", " << pname << ", " << params[0];
- mTexParamaterTrace.PushCall("TexParameterfv", out.str());
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["pname"] = ToString(pname);
+ namedParams["params[0]"] = ToString(params[0]);
+
+ mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
}
inline void TexParameteri(GLenum target, GLenum pname, GLint param)
{
std::stringstream out;
out << target << ", " << pname << ", " << param;
- mTexParamaterTrace.PushCall("TexParameteri", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["pname"] = ToString(pname);
+ namedParams["param"] = ToString(param);
+ mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
}
inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
{
std::stringstream out;
out << target << ", " << pname << ", " << params[0];
- mTexParamaterTrace.PushCall("TexParameteriv", out.str());
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["pname"] = ToString(pname);
+ namedParams["params[0]"] = ToString(params[0]);
+ mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
}
inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
{
std::stringstream out;
- out << xoffset << ", " << yoffset << ", " << width << ", " << height;
- mTextureTrace.PushCall("TexSubImage2D", out.str());
+ out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["level"] = ToString(level);
+ namedParams["xoffset"] = ToString(xoffset);
+ namedParams["yoffset"] = ToString(yoffset);
+ namedParams["width"] = ToString(width);
+ namedParams["height"] = ToString(height);
+ mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
}
inline void Uniform1f(GLint location, GLfloat x)
inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
+ //Methods for Depth function verification
+ inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
+ inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
+ inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
+
template <typename T>
inline bool GetUniformValue( const char* name, T& value ) const
{
TraceCallStack mTextureTrace;
TraceCallStack mTexParamaterTrace;
TraceCallStack mDrawTrace;
+ TraceCallStack mDepthFunctionTrace;
// Shaders & Uniforms
GLuint mLastShaderIdUsed;
*/
#include "test-trace-call-stack.h"
+#include <sstream>
namespace Dali
{
+
+std::string ToString(int x)
+{
+ std::stringstream out;
+ out << x;
+ return out.str();
+}
+
+std::string ToString(unsigned int x)
+{
+ std::stringstream out;
+ out << x;
+ return out.str();
+}
+
+std::string ToString(float x)
+{
+ std::stringstream out;
+ out << x;
+ return out.str();
+}
+
/**
* Constructor
*/
{
if(mTraceActive)
{
- std::vector< std::string > functionCall;
- functionCall.push_back(method);
- functionCall.push_back(params);
- mCallStack.push_back( functionCall );
+ FunctionCall stackFrame(method, params);
+ mCallStack.push_back( stackFrame );
+ }
+}
+
+void TraceCallStack::PushCall(std::string method, std::string params, const TraceCallStack::NamedParams& altParams)
+{
+ if(mTraceActive)
+ {
+ FunctionCall stackFrame(method, params, altParams);
+ mCallStack.push_back( stackFrame );
}
}
bool found = false;
for( size_t i=0; i < mCallStack.size(); i++ )
{
- if( 0 == mCallStack[i][0].compare(method) )
+ if( 0 == mCallStack[i].method.compare(method) )
{
found = true;
break;
int numCalls = 0;
for( size_t i=0; i < mCallStack.size(); i++ )
{
- if( 0 == mCallStack[i][0].compare(method) )
+ if( 0 == mCallStack[i].method.compare(method) )
{
numCalls++;
}
return FindIndexFromMethodAndParams( method, params ) > -1;
}
+bool TraceCallStack::FindMethodAndParams(std::string method, const NamedParams& params) const
+{
+ return FindIndexFromMethodAndParams( method, params ) > -1;
+}
+
+
/**
* Search for a method in the stack with the given parameter list
* @param[in] method The name of the method
int index = -1;
for( size_t i=0; i < mCallStack.size(); i++ )
{
- if( 0 == mCallStack[i][0].compare(method) && 0 == mCallStack[i][1].compare(params) )
+ if( 0 == mCallStack[i].method.compare(method) && 0 == mCallStack[i].paramList.compare(params) )
{
index = i;
break;
return index;
}
+int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const TraceCallStack::NamedParams& params) const
+{
+ int index = -1;
+ for( size_t i=0; i < mCallStack.size(); i++ )
+ {
+ if( 0 == mCallStack[i].method.compare(method) )
+ {
+ // Test each of the passed in parameters:
+ bool match = true;
+ for( NamedParams::const_iterator iter = params.begin() ; iter != params.end() ; ++iter )
+ {
+ NamedParams::const_iterator paramIter = mCallStack[i].namedParams.find(iter->first);
+ if( paramIter == params.end() || paramIter->second.compare(iter->second) != 0 )
+ {
+ match = false;
+ break;
+ }
+ }
+ if( match == true )
+ {
+ index = i;
+ break;
+ }
+ }
+ }
+ return index;
+}
+
+
/**
* Test if the given method and parameters are at a given index in the stack
* @param[in] index Index in the call stack
*/
bool TraceCallStack::TestMethodAndParams(int index, std::string method, std::string params) const
{
- return ( 0 == mCallStack[index][0].compare(method) && 0 == mCallStack[index][1].compare(params) );
+ return ( 0 == mCallStack[index].method.compare(method) && 0 == mCallStack[index].paramList.compare(params) );
}
/**
#include <string>
#include <vector>
+#include <map>
namespace Dali
{
+std::string ToString(int x);
+std::string ToString(unsigned int x);
+std::string ToString(float x);
/**
* Helper class to track method calls in the abstraction and search for them in test cases
class TraceCallStack
{
public:
+ /// Typedef for passing and storing named parameters
+ typedef std::map< std::string, std::string > NamedParams;
+
/**
* Constructor
*/
*/
void PushCall(std::string method, std::string params);
+ /**
+ * Push a call onto the stack if the trace is active
+ * @param[in] method The name of the method
+ * @param[in] params A comma separated list of parameter values
+ * @param[in] altParams A map of named parameter values
+ */
+ void PushCall(std::string method, std::string params, const NamedParams& altParams);
/**
* Search for a method in the stack
/**
* Search for a method in the stack with the given parameter list
* @param[in] method The name of the method
+ * @param[in] params A map of named parameters to test for
+ * @return true if the method was in the stack
+ */
+ bool FindMethodAndParams(std::string method, const NamedParams& params) const;
+
+ /**
+ * Search for a method in the stack with the given parameter list
+ * @param[in] method The name of the method
* @param[in] params A comma separated list of parameter values
* @return index in the stack where the method was found or -1 otherwise
*/
int FindIndexFromMethodAndParams(std::string method, std::string params) const;
/**
+ * Search for a method in the stack with the given parameter list
+ * @param[in] method The name of the method
+ * @param[in] params A map of named parameter values to match
+ * @return index in the stack where the method was found or -1 otherwise
+ */
+ int FindIndexFromMethodAndParams(std::string method, const NamedParams& params) const;
+
+ /**
* Test if the given method and parameters are at a given index in the stack
* @param[in] index Index in the call stack
* @param[in] method Name of method to test
*/
void Reset();
- /**
- * Get the call stack
- * @return The call stack object (Vector of vector[2] of method/paramlist strings)
- */
- inline const std::vector< std::vector< std::string > >& GetCallStack() { return mCallStack; }
-
private:
bool mTraceActive; ///< True if the trace is active
- std::vector< std::vector< std::string > > mCallStack; ///< The call stack
+
+ struct FunctionCall
+ {
+ std::string method;
+ std::string paramList;
+ NamedParams namedParams;
+ FunctionCall( const std::string& aMethod, const std::string& aParamList )
+ : method( aMethod ), paramList( aParamList )
+ {
+ }
+ FunctionCall( const std::string& aMethod, const std::string& aParamList, const NamedParams& altParams )
+ : method( aMethod ), paramList( aParamList ), namedParams( altParams )
+ {
+ }
+ };
+
+ std::vector< FunctionCall > mCallStack; ///< The call stack
};
} // namespace dali
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
+const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
+const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
+const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
}
void dali_control_renderer_startup(void)
END_TEST;
}
+
+//Mesh renderer
+int UtcDaliControlRendererGetPropertyMap8(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliControlRendererGetPropertyMap8: MeshRenderer" );
+
+ //Request MeshRenderer using a property map.
+ RendererFactory factory = RendererFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
+ propertyMap.Insert( "texturesPath", TEST_RESOURCE_LOCATION );
+ propertyMap.Insert( "shaderType", "textureless" );
+ ControlRenderer meshRenderer = factory.GetControlRenderer( propertyMap );
+
+ Property::Map resultMap;
+ meshRenderer.CreatePropertyMap( resultMap );
+
+ //Check values in the result map are identical to the initial map's values.
+ Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "mesh" );
+
+ value = resultMap.Find( "objectUrl", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_OBJ_FILE_NAME );
+
+ value = resultMap.Find( "materialUrl", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_MTL_FILE_NAME );
+
+ value = resultMap.Find( "texturesPath", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_RESOURCE_LOCATION );
+
+ value = resultMap.Find( "shaderType", Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == "textureless" );
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliToolkitFlexContainerSetPropertyEnumP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyEnumP");
+ FlexContainer flexContainer = FlexContainer::New();
+ DALI_TEST_CHECK( flexContainer );
+
+ // Add flex container to the stage
+ Stage::GetCurrent().Add( flexContainer );
+
+ // Create two actors and add them to the container
+ Actor actor1 = Actor::New();
+ Actor actor2 = Actor::New();
+ DALI_TEST_CHECK( actor1 );
+ DALI_TEST_CHECK( actor2 );
+
+ flexContainer.Add(actor1);
+ flexContainer.Add(actor2);
+
+ // Check content direction property.
+ flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "RTL" );
+ DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::RTL, TEST_LOCATION );
+
+ // Check flex direction property.
+ flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, "columnReverse" );
+ DALI_TEST_EQUALS( (FlexContainer::FlexDirection)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ), FlexContainer::COLUMN_REVERSE, TEST_LOCATION );
+
+ // Check flex wrap property.
+ flexContainer.SetProperty( FlexContainer::Property::FLEX_WRAP, "wrap" );
+ DALI_TEST_EQUALS( (FlexContainer::WrapType)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_WRAP ), FlexContainer::WRAP, TEST_LOCATION );
+
+ // Check justify content property.
+ flexContainer.SetProperty( FlexContainer::Property::JUSTIFY_CONTENT, "spaceBetween" );
+ DALI_TEST_EQUALS( (FlexContainer::Justification)flexContainer.GetProperty<int>( FlexContainer::Property::JUSTIFY_CONTENT ), FlexContainer::JUSTIFY_SPACE_BETWEEN, TEST_LOCATION );
+
+ // Check align items property.
+ flexContainer.SetProperty( FlexContainer::Property::ALIGN_ITEMS, "flexStart" );
+ DALI_TEST_EQUALS( (FlexContainer::Alignment)flexContainer.GetProperty<int>( FlexContainer::Property::ALIGN_ITEMS ), FlexContainer::ALIGN_FLEX_START, TEST_LOCATION );
+
+ // Check align content property.
+ flexContainer.SetProperty( FlexContainer::Property::ALIGN_CONTENT, "stretch" );
+ DALI_TEST_EQUALS( (FlexContainer::Alignment)flexContainer.GetProperty<int>( FlexContainer::Property::ALIGN_CONTENT ), FlexContainer::ALIGN_STRETCH, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliToolkitFlexContainerSetChildPropertyP(void)
{
ToolkitTestApplication application;
DALI_TEST_EQUALS( actor.GetProperty<Vector4>( FlexContainer::ChildProperty::FLEX_MARGIN ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), TEST_LOCATION );
DALI_TEST_CHECK( actor.GetPropertyIndex( CHILD_PROPERTY_NAME_FLEX_MARGIN ) == FlexContainer::ChildProperty::FLEX_MARGIN );
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+
+
+//Functor to test whether RelayoutSignal is emitted
+class RelayoutSignalHandler : public Dali::ConnectionTracker
+{
+public:
+
+ RelayoutSignalHandler( FlexContainer& actor )
+ : mSignalVerified( false ),
+ mActor( actor )
+ {
+ }
+
+ // callback to be connected to RelayoutSignal
+ void RelayoutCallback( Actor actor )
+ {
+ if( mActor == actor )
+ {
+ mSignalVerified = true;
+ }
+ }
+
+ void Reset()
+ {
+ mSignalVerified = false;
+ }
+
+ bool mSignalVerified;
+ Actor& mActor;
+};
+
+int UtcDaliToolkitFlexContainerRemoveChildP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyP");
+ FlexContainer flexContainer = FlexContainer::New();
+ DALI_TEST_CHECK( flexContainer );
+
+ // Add flex container to the stage
+ Stage::GetCurrent().Add( flexContainer );
+
+ RelayoutSignalHandler relayoutSignal(flexContainer);
+ flexContainer.OnRelayoutSignal().Connect(&relayoutSignal, &RelayoutSignalHandler::RelayoutCallback );
+
+ // Create two actors and add them to the container
+ Actor actor1 = Actor::New();
+ Actor actor2 = Actor::New();
+ DALI_TEST_CHECK( actor1 );
+ DALI_TEST_CHECK( actor2 );
+
+ flexContainer.Add(actor1);
+ flexContainer.Add(actor2);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( relayoutSignal.mSignalVerified, true, TEST_LOCATION );
+ relayoutSignal.Reset();
+
+ DALI_TEST_CHECK( actor1 );
+ DALI_TEST_CHECK( actor2 );
+
+ flexContainer.Remove(actor1);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( relayoutSignal.mSignalVerified, true, TEST_LOCATION );
+ relayoutSignal.Reset();
+
+ flexContainer.Remove(actor2);
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( relayoutSignal.mSignalVerified, true, TEST_LOCATION );
+ relayoutSignal.Reset();
+
END_TEST;
}
+namespace
+{
+
+// Functors to test whether PreFocusChange signal is emitted when the keyboard focus is about to change
+class PreFocusChangeCallback : public Dali::ConnectionTracker
+{
+public:
+ PreFocusChangeCallback(bool& signalReceived, Actor firstFocusActor)
+ : mSignalVerified(signalReceived),
+ mFirstFocusActor(firstFocusActor),
+ mDirection(Control::KeyboardFocus::LEFT)
+ {
+ }
+
+ Actor Callback(Actor currentFocusedActor, Actor proposedActorToFocus, Control::KeyboardFocus::Direction direction)
+ {
+ tet_infoline("Verifying PreFocusChangeCallback()");
+
+ mSignalVerified = true;
+ mDirection = direction;
+ if( ! proposedActorToFocus )
+ {
+ return mFirstFocusActor;
+ }
+ else
+ {
+ return proposedActorToFocus;
+ }
+ }
+
+ void Reset()
+ {
+ mSignalVerified = false;
+ mDirection = Control::KeyboardFocus::LEFT;
+ }
+
+ bool& mSignalVerified;
+ Actor mFirstFocusActor;
+ Control::KeyboardFocus::Direction mDirection;
+};
+
+// Functors to test whether focus changed signal is emitted when the keyboard focus is changed
+class FocusChangedCallback : public Dali::ConnectionTracker
+{
+public:
+ FocusChangedCallback(bool& signalReceived)
+ : mSignalVerified(signalReceived),
+ mOriginalFocusedActor(),
+ mCurrentFocusedActor()
+ {
+ }
+
+ void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
+ {
+ tet_infoline("Verifying FocusChangedCallback()");
+
+ if(originalFocusedActor == mCurrentFocusedActor)
+ {
+ mSignalVerified = true;
+ }
+
+ mOriginalFocusedActor = originalFocusedActor;
+ mCurrentFocusedActor = currentFocusedActor;
+ }
+
+ void Reset()
+ {
+ mSignalVerified = false;
+ }
+
+ bool& mSignalVerified;
+ Actor mOriginalFocusedActor;
+ Actor mCurrentFocusedActor;
+};
+
+} // anonymous namespace
+
+
+int UtcDaliToolkitFlexContainerMoveFocus(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyP");
+ FlexContainer flexContainer = FlexContainer::New();
+ DALI_TEST_CHECK( flexContainer );
+
+ flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW );
+
+ // Add flex container to the stage
+ Stage::GetCurrent().Add( flexContainer );
+ Size stageSize = Stage::GetCurrent().GetSize();
+
+ RelayoutSignalHandler relayoutSignal(flexContainer);
+ flexContainer.OnRelayoutSignal().Connect(&relayoutSignal, &RelayoutSignalHandler::RelayoutCallback );
+ flexContainer.SetSize( stageSize );
+
+ // Create two actors and add them to the container
+ Actor actor1 = Actor::New();
+ Actor actor2 = Actor::New();
+ actor1.SetKeyboardFocusable(true);
+ actor2.SetKeyboardFocusable(true);
+ DALI_TEST_CHECK( actor1 );
+ DALI_TEST_CHECK( actor2 );
+
+ flexContainer.Add(actor1);
+ flexContainer.Add(actor2);
+
+ application.SendNotification();
+ application.Render();
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ bool preFocusChangeSignalVerified = false;
+ PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified, actor1);
+ manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
+
+ bool focusChangedSignalVerified = false;
+ FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
+ manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
+
+ // Move the focus to the right
+ DALI_TEST_EQUALS(manager.MoveFocus(Control::KeyboardFocus::RIGHT), true, TEST_LOCATION);
+ DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
+ DALI_TEST_EQUALS(manager.GetCurrentFocusActor(), actor1, TEST_LOCATION);
+ preFocusChangeCallback.Reset();
+ DALI_TEST_EQUALS(focusChangedCallback.mCurrentFocusedActor, actor1, TEST_LOCATION);
+ focusChangedCallback.Reset();
+
+ // Move the focus towards right
+ DALI_TEST_EQUALS(manager.MoveFocus(Control::KeyboardFocus::RIGHT), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(preFocusChangeCallback.mSignalVerified, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(manager.GetCurrentFocusActor(), actor2, TEST_LOCATION);
+ DALI_TEST_EQUALS(focusChangedCallback.mSignalVerified, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(focusChangedCallback.mCurrentFocusedActor, actor2, TEST_LOCATION);
+
+ preFocusChangeCallback.Reset();
+ focusChangedCallback.Reset();
+
+ // Move the focus towards left
+ DALI_TEST_EQUALS(manager.MoveFocus(Control::KeyboardFocus::LEFT), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(preFocusChangeCallback.mSignalVerified, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(manager.GetCurrentFocusActor(), actor1, TEST_LOCATION);
+ DALI_TEST_EQUALS(focusChangedCallback.mSignalVerified, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(focusChangedCallback.mCurrentFocusedActor, actor1, TEST_LOCATION);
+
+ END_TEST;
+}
&& rect2.y < rect1.y+rect1.height;
}
-}
+} // anonymous namespace
void dali_image_atlas_startup(void)
{
Rect<int> pixelArea1 = TextureCoordinateToPixelArea(textureRect1, size);
DALI_TEST_EQUALS( pixelArea1.width, 34, TEST_LOCATION );
DALI_TEST_EQUALS( pixelArea1.height, 34, TEST_LOCATION );
- std::stringstream out;
- out<<pixelArea1.x<<", "<<pixelArea1.y<<", "<<pixelArea1.width<<", "<<pixelArea1.height;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str()) );
+
+ TraceCallStack::NamedParams params;
+ params["width"] = ToString(pixelArea1.width);
+ params["height"] = ToString(pixelArea1.height);
+ params["xoffset"] = ToString(pixelArea1.x);
+ params["yoffset"] = ToString(pixelArea1.y);
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ));
Rect<int> pixelArea2 = TextureCoordinateToPixelArea(textureRect2, size);
DALI_TEST_EQUALS( pixelArea2.width, 50, TEST_LOCATION );
DALI_TEST_EQUALS( pixelArea2.height, 50, TEST_LOCATION );
- out.str("");
- out<<pixelArea2.x<<", "<<pixelArea2.y<<", "<<pixelArea2.width<<", "<<pixelArea2.height;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str()) );
+
+ params["width"] = ToString(pixelArea2.width);
+ params["height"] = ToString(pixelArea2.height);
+ params["xoffset"] = ToString(pixelArea2.x);
+ params["yoffset"] = ToString(pixelArea2.y);
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ) );
Rect<int> pixelArea3 = TextureCoordinateToPixelArea(textureRect3, size);
DALI_TEST_EQUALS( pixelArea3.width, 128, TEST_LOCATION );
DALI_TEST_EQUALS( pixelArea3.height, 128, TEST_LOCATION );
- out.str("");
- out<<pixelArea3.x<<", "<<pixelArea3.y<<", "<<pixelArea3.width<<", "<<pixelArea3.height;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str()) );
+
+ params["width"] = ToString(pixelArea3.width);
+ params["height"] = ToString(pixelArea3.height);
+ params["xoffset"] = ToString(pixelArea3.x);
+ params["yoffset"] = ToString(pixelArea3.y);
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ) );
DALI_TEST_CHECK( ! IsOverlap(pixelArea1, pixelArea2) );
DALI_TEST_CHECK( ! IsOverlap(pixelArea1, pixelArea3) );
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 34, 34" ) );
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 34, 50, 50" ) );
+ TraceCallStack::NamedParams params1;
+ params1["width"] = "34";
+ params1["height"] = "34";
+ params1["xoffset"] = "0";
+ params1["yoffset"] = "0";
+
+ TraceCallStack::NamedParams params2;
+ params2["width"] = "50";
+ params2["height"] = "50";
+ params2["xoffset"] = "0";
+ params2["yoffset"] = "34";
+
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams("TexSubImage2D", params1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams("TexSubImage2D", params2 ), true, TEST_LOCATION );
callStack.Reset();
callStack.Enable(true);
application.Render(RENDER_FRAME_INTERVAL);
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 34, 100, 100" ) );
+
+ TraceCallStack::NamedParams params3;
+ params3["width"] = "100";
+ params3["height"] = "100";
+ params3["xoffset"] = "0";
+ params3["yoffset"] = "34";
+
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams("TexSubImage2D", params3 ), true, TEST_LOCATION );
END_TEST;
}
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 34, 34" ) );
-
+ TraceCallStack::NamedParams params;
+ params["width"] = ToString(34);
+ params["height"] = ToString(34);
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
END_TEST;
}
Stage::GetCurrent().Add( imageView );
application.SendNotification();
application.Render(16);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 34, 34" ) );
- }
+ TraceCallStack::NamedParams params;
+ params["width"] = ToString(34);
+ params["height"] = ToString(34);
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
+ true, TEST_LOCATION );
+ }
END_TEST;
}
END_TEST;
}
-
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
-
const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
+const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
+const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
+const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl";
Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
{
END_TEST;
}
+//Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
+int UtcDaliRendererFactoryGetMeshRenderer1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer1: Request mesh renderer with a valid object file only" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ application.SendNotification();
+ application.Render( 0 );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+//Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
+int UtcDaliRendererFactoryGetMeshRenderer2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer2: Request mesh renderer with blank material file and images directory" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( "materialUrl", "" );
+ propertyMap.Insert( "texturesPath", "" );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ //Add renderer to an actor on stage.
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+//Test if mesh loads correctly when supplied with all parameters, an object file, a material file and a directory location.
+int UtcDaliRendererFactoryGetMeshRenderer3(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer3: Request mesh renderer with all parameters correct" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
+ propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ //Add renderer to an actor on stage.
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+//Test if mesh renderer can load a correctly supplied mesh without a normal map or gloss map in the material file.
+int UtcDaliRendererFactoryGetMeshRenderer4(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer4: Request mesh renderer with diffuse texture but not normal or gloss." );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( "materialUrl", TEST_SIMPLE_MTL_FILE_NAME );
+ propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ //Add renderer to an actor on stage.
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+//Test if mesh renderer handles the case of lacking an object file.
+int UtcDaliRendererFactoryGetMeshRendererN1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRendererN1: Request mesh renderer without object file" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
+ propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ //Add renderer to an actor on stage.
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ //Test to see if the object has not been loaded, as expected.
+ Matrix scaleMatrix;
+ DALI_TEST_CHECK( ! gl.GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+//Test if mesh renderer handles the case of being passed invalid material and images urls.
+int UtcDaliRendererFactoryGetMeshRendererN2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRendererN2: Request mesh renderer with invalid material and images urls" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( "materialUrl", "invalid" );
+ propertyMap.Insert( "texturesPath", "also invalid" );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ //Add renderer to an actor on stage.
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ //Test to see if the object has not been loaded, as expected.
+ Matrix scaleMatrix;
+ DALI_TEST_CHECK( ! gl.GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+//Test if mesh renderer handles the case of being passed an invalid object url
+int UtcDaliRendererFactoryGetMeshRendererN3(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetMeshRendererN3: Request mesh renderer with invalid object url" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Set up renderer properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( "rendererType", "mesh" );
+ propertyMap.Insert( "objectUrl", "invalid" );
+ propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
+ propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ //Add renderer to an actor on stage.
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ //Test to see if the object has not been loaded, as expected.
+ Matrix scaleMatrix;
+ DALI_TEST_CHECK( ! gl.GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+
+ controlRenderer.SetOffStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
int UtcDaliRendererFactoryResetRenderer1(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+//Test resetting mesh and primitive shape renderers
+int UtcDaliRendererFactoryResetRenderer4(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryResetRenderer4: Mesh and primitive renderers" );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map map;
+
+ //******
+
+ //Start with basic color renderer
+ ControlRenderer controlRenderer = factory.GetControlRenderer( Color::RED );
+ DALI_TEST_CHECK( controlRenderer );
+
+ TestControlRendererRender( application, actor, controlRenderer );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Ensure set correctly.
+ Vector4 actualValue( Vector4::ZERO );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
+
+ //******
+
+ //Reset to mesh renderer
+ map.Insert( "rendererType", "mesh" );
+ map.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
+ map.Insert( "materialUrl", TEST_MTL_FILE_NAME );
+ map.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+ factory.ResetRenderer( controlRenderer, actor, map );
+ application.SendNotification();
+ application.Render( 0 );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Tell the platform abstraction that the required resources have been loaded.
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetAllResourceRequestsAsLoaded();
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render( 0 );
+
+ //Ensure set correctly.
+ controlRenderer.CreatePropertyMap( map );
+ DALI_TEST_EQUALS( map.Find( "objectUrl", Property::STRING )->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ //******
+
+ //Reset back to color renderer
+ factory.ResetRenderer( controlRenderer, actor, Color::GREEN );
+ application.SendNotification();
+ application.Render( 0 );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ //Ensure set correctly.
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
+
+ //******
+
+ END_TEST;
+}
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/pan-gesture-event.h>
using namespace Dali;
using namespace Dali::Toolkit;
return true;
}
-int UtcDaliSliderSignals(void)
+int UtcDaliSliderSignals1(void)
{
ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
- tet_infoline(" UtcDaliSliderSignals");
+ tet_infoline(" UtcDaliSliderSignals1");
// Create the Popup actor
Slider slider = Slider::New();
DALI_TEST_CHECK(gSliderMarkCallBackCalled);
END_TEST;
}
+
+
+namespace
+{
+bool gSliderSignal=false;
+struct SliderSignalFunctor
+{
+ SliderSignalFunctor()
+ {
+ }
+
+ void operator()()
+ {
+ gSliderSignal = true;
+ }
+};
+} // anonymous
+
+
+
+int UtcDaliSliderSignals2(void)
+{
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ tet_infoline(" UtcDaliSliderSignals1");
+
+ // Create the Popup actor
+ Slider slider = Slider::New();
+ Stage::GetCurrent().Add( slider );
+ slider.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ slider.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ slider.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+ slider.SetPosition( 0.0f, 0.0f );
+
+ const float MIN_BOUND = 0.0f;
+ const float MAX_BOUND = 1.0f;
+ const int NUM_MARKS = 5;
+ Property::Array marks;
+ for( int i = 0; i < NUM_MARKS; ++i )
+ {
+ marks.PushBack( MIN_BOUND + ( static_cast<float>(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) );
+ }
+ slider.SetProperty( Slider::Property::MARKS, marks );
+ slider.SetProperty( Slider::Property::MARK_TOLERANCE, 0.1f );
+
+ gSliderSignal = false;
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ slider.ConnectSignal( testTracker, "valueChanged", SliderSignalFunctor() );
+
+ application.SendNotification();
+ application.Render();
+
+ gSliderValueChangedCallBackCalled = false;
+ gSliderMarkCallBackCalled = false;
+
+ Dali::Integration::TouchEvent event;
+
+ event = Dali::Integration::TouchEvent();
+
+ Integration::Point pointDown;
+ pointDown.SetState( PointState::DOWN );
+ pointDown.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
+ event.AddPoint( pointDown );
+
+ for( int i = 0; i < 5; ++i )
+ {
+ Integration::Point pointMotion;
+ pointMotion.SetState( PointState::MOTION );
+ pointMotion.SetScreenPosition( Vector2( 10.0f + i * 10.0f, 10.0f ) );
+ event.AddPoint( pointMotion );
+ }
+
+ Integration::Point pointUp;
+ pointUp.SetState( PointState::UP );
+ pointUp.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
+ event.AddPoint( pointUp );
+
+ application.ProcessEvent( event );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSliderSignal);
+ END_TEST;
+}
+
+int UtcDaliSetPropertyP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliSetPropertyP" );
+
+ Slider slider = Slider::New();
+ slider.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ slider.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ slider.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+ slider.SetPosition( 0.0f, 0.0f );
+
+ Stage::GetCurrent().Add(slider);
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ map["rendererType"] = "image";
+ map["url"] = "url";
+ slider.SetProperty(Slider::Property::LOWER_BOUND, 1.0f);
+ slider.SetProperty(Slider::Property::UPPER_BOUND, 5.0f);
+ slider.SetProperty(Slider::Property::VALUE, 3.0f);
+ slider.SetProperty(Slider::Property::DISABLED_COLOR, Color::BLACK);
+ slider.SetProperty(Slider::Property::VALUE_PRECISION, 4);
+ slider.SetProperty(Slider::Property::SHOW_POPUP, true);
+ slider.SetProperty(Slider::Property::SHOW_VALUE, true);
+ slider.SetProperty(Slider::Property::MARKS, false);
+ slider.SetProperty(Slider::Property::SNAP_TO_MARKS, false);
+ slider.SetProperty(Slider::Property::MARK_TOLERANCE, 0.5f);
+
+ float lb = slider.GetProperty<float>(Slider::Property::LOWER_BOUND);
+ DALI_TEST_EQUALS(lb, 1.0f, TEST_LOCATION);
+ float ub = slider.GetProperty<float>(Slider::Property::UPPER_BOUND);
+ DALI_TEST_EQUALS(ub, 5.0f, TEST_LOCATION);
+ float val = slider.GetProperty<float>(Slider::Property::VALUE);
+ DALI_TEST_EQUALS(val, 3.0f, TEST_LOCATION);
+ Vector4 color = slider.GetProperty<Vector4>(Slider::Property::DISABLED_COLOR);
+ DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
+ int precision = slider.GetProperty<int>(Slider::Property::VALUE_PRECISION);
+ DALI_TEST_EQUALS( precision, 4, TEST_LOCATION);
+ bool showPopup = slider.GetProperty<bool>(Slider::Property::SHOW_POPUP);
+ DALI_TEST_EQUALS( showPopup, true , TEST_LOCATION);
+ bool showValue = slider.GetProperty<bool>(Slider::Property::SHOW_VALUE);
+ DALI_TEST_EQUALS( showValue, true, TEST_LOCATION );
+ bool marks = slider.GetProperty<bool>(Slider::Property::MARKS);
+ DALI_TEST_EQUALS( marks, false, TEST_LOCATION );
+ bool snapToMarks = slider.GetProperty<bool>(Slider::Property::SNAP_TO_MARKS);
+ DALI_TEST_EQUALS( snapToMarks, false, TEST_LOCATION );
+ float tolerance = slider.GetProperty<float>(Slider::Property::MARK_TOLERANCE);
+ DALI_TEST_EQUALS( tolerance, 0.5f, TEST_LOCATION );
+
+ {
+ map["url"] = "track2.png";
+ slider.SetProperty(Slider::Property::TRACK_VISUAL, map);
+ map["url"] = "handle2.png";
+ slider.SetProperty(Slider::Property::HANDLE_VISUAL, map);
+ map["url"] = "progress2.png";
+ slider.SetProperty(Slider::Property::PROGRESS_VISUAL, map);
+ map["url"] = "popup2.png";
+ slider.SetProperty(Slider::Property::POPUP_VISUAL, map);
+ map["url"] = "popupArrow2.png";
+ slider.SetProperty(Slider::Property::POPUP_ARROW_VISUAL, map);
+
+ Property::Value value = slider.GetProperty(Slider::Property::TRACK_VISUAL);
+ Property::Map* resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ Property::Value* url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "track2.png", TEST_LOCATION );
+
+ value = slider.GetProperty(Slider::Property::HANDLE_VISUAL);
+ resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "handle2.png", TEST_LOCATION );
+
+ value = slider.GetProperty(Slider::Property::PROGRESS_VISUAL);
+ resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "progress2.png", TEST_LOCATION );
+
+ value = slider.GetProperty(Slider::Property::POPUP_VISUAL);
+ resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "popup2.png", TEST_LOCATION );
+
+ value = slider.GetProperty(Slider::Property::POPUP_ARROW_VISUAL);
+ resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "popupArrow2.png", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+
+// DestroyHandleVisualDisplay
+// CreateValueDisplay
+// SlidingFinishedSignal()
+// UpdateSkin disabled
+// AddPopup
+// RemovePopup
+// SnapToMark
+// HideValueView
+// GetDisabledColor
+// GetShowPopup
+// GetShowVisual
+// DisplayPopup (with set valueText label)
@for i in `find $(COVERAGE_DIR) -name "libdali_toolkit_la-*.gcda" -o -name "libdali_toolkit_la-*.gcno"` ;\
do mv $$i `echo $$i | sed s/libdali_toolkit_la-//` ; echo $$i ; done
@cd $(COVERAGE_DIR) ; lcov $(LCOV_OPTS) --base-directory . --directory . -c -o dali.info
- @cd $(COVERAGE_DIR) ; lcov $(LCOV_OPTS) --remove dali.info "/usr/include/*" "*/dali-env/*" -o dali.info
+ @cd $(COVERAGE_DIR) ; lcov $(LCOV_OPTS) --remove dali.info "/usr/include/*" "*/dali-env/*" "*solid-color-actor*" "*/dali-toolkit/third-party/*" -o dali.info
@test -z $(COVERAGE_OUTPUT_DIR) || mkdir -p $(COVERAGE_OUTPUT_DIR)
coverage: cov_data
# Build the Dali Toolkit library
-toolkit_images_dir = ../../../dali-toolkit/styles/images-common
-toolkit_sounds_dir = ../../../dali-toolkit/sounds
-toolkit_src_dir = ../../../dali-toolkit/internal
-public_api_src_dir = ../../../dali-toolkit/public-api
-devel_api_src_dir = ../../../dali-toolkit/devel-api
+toolkit_images_dir = ../../../dali-toolkit/styles/images-common
+toolkit_sounds_dir = ../../../dali-toolkit/sounds
+toolkit_src_dir = ../../../dali-toolkit/internal
+public_api_src_dir = ../../../dali-toolkit/public-api
+devel_api_src_dir = ../../../dali-toolkit/devel-api
+third_party_src_dir = ../../../dali-toolkit/third-party
toolkit_styles_dir = $(STYLE_DIR)
toolkit_style_images_dir = $(STYLE_DIR)/images
include ../../../dali-toolkit/internal/file.list
include ../../../dali-toolkit/public-api/file.list
include ../../../dali-toolkit/devel-api/file.list
+include ../../../dali-toolkit/third-party/file.list
vector_based_text_src_dir = ../../../dali-toolkit/internal/text/rendering/vector-based
include ../../../dali-toolkit/internal/text/rendering/vector-based/file.list
libdali_toolkit_la_SOURCES = \
$(toolkit_src_files) \
$(public_api_src_files) \
- $(devel_api_src_files)
+ $(devel_api_src_files) \
+ $(third_party_src_files)
dalistyledir = ${dataReadOnlyDir}/toolkit/styles/
dalistyle_DATA = ${dali_toolkit_style_files}
* else the renderer would be a handle to a newly created internal color renderer.
*
* @param[in] renderer The ControlRenderer to reset
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
+ * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
* @param[in] color The color to be rendered.
*/
void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color );
* else the renderer would be a handle to a newly created internal image renderer.
*
* @param[in] renderer The ControlRenderer to reset
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
+ * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
* @param[in] image The Image to be rendered.
*/
void ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image );
* else the renderer would be a handle to a newly created internal image renderer.
*
* @param[in] renderer The ControlRenderer to reset
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
+ * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
* @param[in] url The URL to the resource to be rendered.
* @param[in] size The width and height to fit the loaded image to.
*/
void ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url,
ImageDimensions size = ImageDimensions() );
-
/**
* @brief Request the current control renderer from the property map, merging the property map with the renderer
*
* else the renderer would be a handle to a newly created internal renderer.
*
* @param[in] renderer The ControlRenderer to reset
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
+ * @param[in] actor The Actor the renderer is applied to, empty if the renderer has not been applied to any Actor
* @param[in] propertyMap The map contains the properties required by the control renderer
* Depends on the content of the map, different kind of renderer would be returned.
*/
#include <dali-toolkit/public-api/controls/flex-container/flex-container.h>
extern "C"
{
-#include "layout.h"
+#include <dali-toolkit/third-party/facebook-flexbox/layout.h>
}
namespace Dali
if( mObjLoader.IsSceneLoaded() )
{
- mMesh = mObjLoader.CreateGeometry( mIlluminationType );
+ mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) );
CreateMaterial();
LoadTextures();
if (FileLoader::ReadFile(mObjUrl,fileSize,fileContent,FileLoader::TEXT))
{
mObjLoader.ClearArrays();
-
- std::string materialUrl;
- mObjLoader.Load(fileContent.Begin(), fileSize, materialUrl);
+ mObjLoader.LoadObject(fileContent.Begin(), fileSize);
//Get size information from the obj loaded
mSceneCenter = mObjLoader.GetCenter();
{
if( mObjLoader.IsSceneLoaded() )
{
- mMesh = mObjLoader.CreateGeometry( mIlluminationType );
+ mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) );
if( mRenderer )
{
}
}
+int Model3dView::GetShaderProperties( Toolkit::Model3dView::IlluminationType illuminationType )
+{
+ int objectProperties = 0;
+
+ if( illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_TEXTURE ||
+ illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
+ {
+ objectProperties |= ObjLoader::TEXTURE_COORDINATES;
+ }
+
+ if( illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
+ {
+ objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINOMIALS;
+ }
+
+ return objectProperties;
+}
+
} // namespace Internal
} // namespace Toolkit
} // namespace Dali
void UpdateShaderUniforms();
+ /*
+ * @brief Given a specific shader type, find out which properties are necessary for it.
+ *
+ * @param[in] illuminationType The type of shader we intend to use.
+ * @return A bitmask of the properties we require to be loaded to use the given shader.
+ */
+ int GetShaderProperties( Toolkit::Model3dView::IlluminationType illuminationType );
+
+
ObjLoader mObjLoader;
//Properties
#include "obj-loader.h"
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <string>
#include <sstream>
#include <string.h>
namespace Internal
{
+namespace
+{
+ const int MAX_POINT_INDICES = 4;
+}
using namespace Dali;
ObjLoader::ObjLoader()
mSceneLoaded = false;
mMaterialLoaded = false;
mHasTexturePoints = false;
- mHasNormalMap = false;
mHasDiffuseMap = false;
+ mHasNormalMap = false;
mHasSpecularMap = false;
mSceneAABB.Init();
}
Dali::Vector<Vector3>& normal,
Dali::Vector<Vector3>& tangent)
{
- normal.Clear();
- normal.Resize(vertex.Size());
-
Dali::Vector<Vector3> tangents;
tangents.Resize( vertex.Size() );
//we need to recalculate the normals too, because we need just one normal,tangent, bitangent per vertex
//In the case of a textureless object, we don't need tangents for our shader and so we skip this step
//TODO: Use a better function to calculate tangents
-
if( mTangents.Size() == 0 && mHasTexturePoints )
{
- mTangents.Resize( mNormals.Size() );
- mBiTangents.Resize( mNormals.Size() );
+ mNormals.Clear();
+
+ mNormals.Resize( mPoints.Size() );
+ mTangents.Resize( mPoints.Size() );
+ mBiTangents.Resize( mPoints.Size() );
+
CalculateTangentArray( mPoints, mTextures, mTriangles, mNormals, mTangents );
+
for ( unsigned int ui = 0 ; ui < mNormals.Size() ; ++ui )
{
mBiTangents[ui] = mNormals[ui].Cross(mTangents[ui]);
}
}
-bool ObjLoader::Load( char* objBuffer, std::streampos fileSize, std::string& materialFile )
+bool ObjLoader::LoadObject( char* objBuffer, std::streampos fileSize )
{
Vector3 point;
Vector2 texture;
- std::string vet[4], name;
- int ptIdx[4];
- int nrmIdx[4];
- int texIdx[4];
+ std::string vet[MAX_POINT_INDICES], name;
+ int ptIdx[MAX_POINT_INDICES];
+ int nrmIdx[MAX_POINT_INDICES];
+ int texIdx[MAX_POINT_INDICES];
TriIndex triangle,triangle2;
int pntAcum = 0, texAcum = 0, nrmAcum = 0;
bool iniObj = false;
}
int numIndices = 0;
- while( isline >> vet[numIndices] )
+ while( isline >> vet[numIndices] && numIndices < MAX_POINT_INDICES )
{
numIndices++;
}
{
isline >> name;
}
- else
- {
- }
}
if ( iniObj )
}
return false;
-
}
-void ObjLoader::LoadMaterial( char* objBuffer, std::streampos fileSize, std::string& texture0Url,
- std::string& texture1Url, std::string& texture2Url )
+void ObjLoader::LoadMaterial( char* objBuffer, std::streampos fileSize, std::string& diffuseTextureUrl,
+ std::string& normalTextureUrl, std::string& glossTextureUrl )
{
float fR,fG,fB;
{
isline >> info;
}
+ else if ( tag == "Ka" ) //ambient color
+ {
+ isline >> fR >> fG >> fB;
+ }
else if ( tag == "Kd" ) //diffuse color
{
isline >> fR >> fG >> fB;
}
- else if ( tag == "Kd" ) //Ambient color
+ else if ( tag == "Ks" ) //specular color
{
isline >> fR >> fG >> fB;
}
else if ( tag == "map_Kd" )
{
isline >> info;
- texture0Url = info;
+ diffuseTextureUrl = info;
mHasDiffuseMap = true;
}
else if ( tag == "bump" )
{
isline >> info;
- texture1Url = info;
+ normalTextureUrl = info;
mHasNormalMap = true;
}
else if ( tag == "map_Ks" )
{
isline >> info;
- texture2Url = info;
+ glossTextureUrl = info;
mHasSpecularMap = true;
}
}
mMaterialLoaded = true;
}
-Geometry ObjLoader::CreateGeometry( Toolkit::Model3dView::IlluminationType illuminationType )
+Geometry ObjLoader::CreateGeometry( int objectProperties )
{
Geometry surface = Geometry::New();
surface.AddVertexBuffer( surfaceVertices );
//Some need texture coordinates
- if( ( (illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP ) ||
- (illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_TEXTURE ) ) && mHasTexturePoints && mHasDiffuseMap )
+ if( ( objectProperties & TEXTURE_COORDINATES ) && mHasTexturePoints && mHasDiffuseMap )
{
Property::Map textureFormat;
textureFormat["aTexCoord"] = Property::VECTOR2;
}
//Some need tangent and bitangent
- if( illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP && mHasTexturePoints )
+ if( ( objectProperties & TANGENTS ) && ( objectProperties & BINOMIALS ) && mHasTexturePoints )
{
Property::Map vertexExtFormat;
vertexExtFormat["aTangent"] = Property::VECTOR3;
surface.AddVertexBuffer( extraVertices );
}
+ //If indices are required, we set them.
if ( indices.Size() )
{
surface.SetIndexBuffer ( &indices[0], indices.Size() );
}
- vertices.Clear();
- verticesExt.Clear();
- indices.Clear();
-
return surface;
}
// EXTERNAL INCLUDES
#include <dali/devel-api/rendering/renderer.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/model3d-view/model3d-view.h>
-
+#include <limits>
namespace Dali
{
{}
VertexExt( const Vector3& tangent, const Vector3& binormal )
- : tangent( tangent), bitangent (binormal)
+ : tangent( tangent), bitangent( binormal )
{}
Vector3 tangent;
{
void Init()
{
- pointMin = Vector3(999999.9,999999.9,999999.9);
- pointMax = Vector3(-999999.9,-999999.9,-999999.9);
+ pointMin = Vector3( std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max() );
+ pointMax = Vector3( std::numeric_limits<float>::min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::min() );
}
- void ConsiderNewPointInVolume(const Vector3& position)
+ void ConsiderNewPointInVolume( const Vector3& position )
{
- pointMin.x = std::min(position.x, pointMin.x);
- pointMin.y = std::min(position.y, pointMin.y);
- pointMin.z = std::min(position.z, pointMin.z);
+ pointMin.x = std::min( position.x, pointMin.x );
+ pointMin.y = std::min( position.y, pointMin.y );
+ pointMin.z = std::min( position.z, pointMin.z );
- pointMax.x = std::max(position.x, pointMax.x);
- pointMax.y = std::max(position.y, pointMax.y);
- pointMax.z = std::max(position.z, pointMax.z);
+ pointMax.x = std::max( position.x, pointMax.x );
+ pointMax.y = std::max( position.y, pointMax.y );
+ pointMax.z = std::max( position.z, pointMax.z );
}
Vector3 pointMin;
Vector3 pointMax;
};
+ //Defines bit masks to declare which properties are needed by anyone requesting a geometry.
+ enum ObjectProperties
+ {
+ TEXTURE_COORDINATES = 1 << 0,
+ TANGENTS = 1 << 1,
+ BINOMIALS = 1 << 2
+ };
+
ObjLoader();
virtual ~ObjLoader();
bool IsSceneLoaded();
bool IsMaterialLoaded();
- bool Load(char* objBuffer, std::streampos fileSize, std::string& materialFile);
+ bool LoadObject( char* objBuffer, std::streampos fileSize );
- void LoadMaterial(char* objBuffer, std::streampos fileSize, std::string& texture0Url, std::string& texture1Url, std::string& texture2Url);
+ void LoadMaterial( char* objBuffer, std::streampos fileSize, std::string& diffuseTextureUrl,
+ std::string& normalTextureUrl, std::string& glossTextureUrl );
- Geometry CreateGeometry(Toolkit::Model3dView::IlluminationType illuminationType);
+ Geometry CreateGeometry( int objectProperties );
Vector3 GetCenter();
Vector3 GetSize();
Dali::Vector<Vector3> mBiTangents;
Dali::Vector<TriIndex> mTriangles;
- void CalculateTangentArray(const Dali::Vector<Vector3>& vertex,
- const Dali::Vector<Vector2>& texcoord,
- Dali::Vector<TriIndex>& triangle,
- Dali::Vector<Vector3>& normal,
- Dali::Vector<Vector3>& tangent);
+ void CalculateTangentArray( const Dali::Vector<Vector3>& vertex,
+ const Dali::Vector<Vector2>& texcoord,
+ Dali::Vector<TriIndex>& triangle,
+ Dali::Vector<Vector3>& normal,
+ Dali::Vector<Vector3>& tangent );
- void CenterAndScale(bool center, Dali::Vector<Vector3>& points);
+ void CenterAndScale( bool center, Dali::Vector<Vector3>& points );
- void CreateGeometryArray(Dali::Vector<Vertex> & vertices,
- Dali::Vector<Vector2> & textures,
- Dali::Vector<VertexExt> & verticesExt,
- Dali::Vector<unsigned short> & indices);
+ void CreateGeometryArray( Dali::Vector<Vertex> & vertices,
+ Dali::Vector<Vector2> & textures,
+ Dali::Vector<VertexExt> & verticesExt,
+ Dali::Vector<unsigned short> & indices );
};
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "mesh-renderer.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/adaptor-framework/file-loader.h>
+#include <fstream>
+
+//INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+//Defines ordering of textures for shaders.
+//All shaders, if including certain texture types, must include them in the same order.
+//Within the texture set for the renderer, textures are ordered in the same manner.
+enum TextureIndex
+{
+ DIFFUSE_INDEX = 0u,
+ NORMAL_INDEX = 1u,
+ GLOSS_INDEX = 2u
+};
+
+const char * const RENDERER_TYPE_VALUE( "mesh" ); //String label for which type of control renderer this is.
+const char * const LIGHT_POSITION( "uLightPosition" ); //Shader property
+const char * const OBJECT_MATRIX( "uObjectMatrix" ); //Shader property
+
+//Shaders
+//If a shader requires certain textures, they must be listed in order,
+//as detailed in the TextureIndex enum documentation.
+
+//A basic shader that doesn't use textures at all.
+const char* SIMPLE_VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute highp vec3 aPosition;\n
+ attribute highp vec3 aNormal;\n
+ varying mediump vec3 vIllumination;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump mat4 uModelView;\n
+ uniform mediump mat3 uNormalMatrix;
+ uniform mediump mat4 uObjectMatrix;\n
+ uniform mediump vec3 uLightPosition;\n
+
+ void main()\n
+ {\n
+ vec4 vertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
+ vertexPosition = uObjectMatrix * vertexPosition;\n
+ vertexPosition = uMvpMatrix * vertexPosition;\n
+
+ //Illumination in Model-View space - Transform attributes and uniforms\n
+ vec4 vertPos = uModelView * vec4( aPosition.xyz, 1.0 );\n
+ vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
+ vec4 centre = uModelView * vec4( 0.0, 0.0, 0.0, 1.0 );\n
+ vec4 lightPos = vec4( centre.x, centre.y, uLightPosition.z, 1.0 );\n
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
+
+ float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );\n
+ vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
+
+ gl_Position = vertexPosition;\n
+ }\n
+);
+
+//Fragment shader corresponding to the texture-less shader.
+const char* SIMPLE_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ varying mediump vec3 vIllumination;\n
+ uniform lowp vec4 uColor;\n
+
+ void main()\n
+ {\n
+ gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a );\n
+ }\n
+);
+
+//Diffuse and specular illumination shader with albedo texture. Texture is index 0.
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute highp vec3 aPosition;\n
+ attribute highp vec2 aTexCoord;\n
+ attribute highp vec3 aNormal;\n
+ varying mediump vec2 vTexCoord;\n
+ varying mediump vec3 vIllumination;\n
+ varying mediump float vSpecular;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump mat4 uModelView;
+ uniform mediump mat3 uNormalMatrix;
+ uniform mediump mat4 uObjectMatrix;\n
+ uniform mediump vec3 uLightPosition;\n
+
+ void main()
+ {\n
+ vec4 vertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
+ vertexPosition = uObjectMatrix * vertexPosition;\n
+ vertexPosition = uMvpMatrix * vertexPosition;\n
+
+ //Illumination in Model-View space - Transform attributes and uniforms\n
+ vec4 vertPos = uModelView * vec4( aPosition.xyz, 1.0 );\n
+ vec4 centre = uModelView * vec4( 0.0, 0.0, 0.0, 1.0 );\n
+ vec4 lightPos = vec4( centre.x, centre.y, uLightPosition.z, 1.0 );\n
+ vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );\n
+
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
+ vec3 viewDir = normalize( -vertPos.xyz );
+
+ vec3 halfVector = normalize( viewDir + vecToLight );
+
+ float lightDiffuse = dot( vecToLight, normal );\n
+ lightDiffuse = max( 0.0,lightDiffuse );\n
+ vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
+
+ vec3 reflectDir = reflect( -vecToLight, normal );
+ vSpecular = pow( max( dot( reflectDir, viewDir ), 0.0 ), 4.0 );
+
+ vTexCoord = aTexCoord;\n
+ gl_Position = vertexPosition;\n
+ }\n
+);
+
+//Fragment shader corresponding to the diffuse and specular illumination shader with albedo texture
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ varying mediump vec2 vTexCoord;\n
+ varying mediump vec3 vIllumination;\n
+ varying mediump float vSpecular;\n
+ uniform sampler2D sDiffuse;\n
+ uniform lowp vec4 uColor;\n
+
+ void main()\n
+ {\n
+ vec4 texture = texture2D( sDiffuse, vTexCoord );\n
+ gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb + vSpecular * 0.3, texture.a * uColor.a );\n
+ }\n
+);
+
+//Diffuse and specular illumination shader with albedo texture, normal map and gloss map shader.
+//Diffuse (albedo) texture is index 0, normal is 1, gloss is 2. They must be declared in this order.
+const char* NORMAL_MAP_VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute highp vec3 aPosition;\n
+ attribute highp vec2 aTexCoord;\n
+ attribute highp vec3 aNormal;\n
+ attribute highp vec3 aTangent;\n
+ attribute highp vec3 aBiNormal;\n
+ varying mediump vec2 vTexCoord;\n
+ varying mediump vec3 vLightDirection;\n
+ varying mediump vec3 vHalfVector;\n
+ uniform mediump vec3 uSize;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump mat4 uModelView;
+ uniform mediump mat3 uNormalMatrix;
+ uniform mediump mat4 uObjectMatrix;\n
+ uniform mediump vec3 uLightPosition;\n
+
+ void main()
+ {\n
+ vec4 vertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
+ vertexPosition = uObjectMatrix * vertexPosition;\n
+ vertexPosition = uMvpMatrix * vertexPosition;\n
+
+ vec4 vertPos = uModelView * vec4( aPosition.xyz, 1.0 );\n
+ vec4 centre = uModelView * vec4( 0.0, 0.0, 0.0, 1.0 );\n
+ vec4 lightPos = vec4( centre.x, centre.y, uLightPosition.z, 1.0 );\n
+
+ vec3 tangent = normalize( uNormalMatrix * aTangent );
+ vec3 binormal = normalize( uNormalMatrix * aBiNormal );
+ vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
+
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
+ vLightDirection.x = dot( vecToLight, tangent );
+ vLightDirection.y = dot( vecToLight, binormal );
+ vLightDirection.z = dot( vecToLight, normal );
+
+ vec3 viewDir = normalize( -vertPos.xyz );
+ vec3 halfVector = normalize( viewDir + vecToLight );
+ vHalfVector.x = dot( halfVector, tangent );
+ vHalfVector.y = dot( halfVector, binormal );
+ vHalfVector.z = dot( halfVector, normal );
+
+ vTexCoord = aTexCoord;\n
+ gl_Position = vertexPosition;\n
+ }\n
+);
+
+//Fragment shader corresponding to the shader that uses all textures (diffuse, normal and gloss maps)
+const char* NORMAL_MAP_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ varying mediump vec2 vTexCoord;\n
+ varying mediump vec3 vLightDirection;\n
+ varying mediump vec3 vHalfVector;\n
+ uniform sampler2D sDiffuse;\n
+ uniform sampler2D sNormal;\n
+ uniform sampler2D sGloss;\n
+ uniform lowp vec4 uColor;\n
+
+ void main()\n
+ {\n
+ vec4 texture = texture2D( sDiffuse, vTexCoord );\n
+ vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n
+ vec4 glossMap = texture2D( sGloss, vTexCoord );\n
+
+ float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );\n
+ lightDiffuse = lightDiffuse * 0.5 + 0.5;\n
+
+ float shininess = pow ( max ( dot ( normalize( vHalfVector ), normal ), 0.0 ), 16.0 ) ;
+
+ gl_FragColor = vec4( texture.rgb * uColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a );\n
+ }\n
+);
+
+} // namespace
+
+MeshRenderer::MeshRenderer( RendererFactoryCache& factoryCache )
+: ControlRenderer( factoryCache ),
+ mShaderType( ALL_TEXTURES ),
+ mUseTexture( true )
+{
+}
+
+MeshRenderer::~MeshRenderer()
+{
+}
+
+void MeshRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+{
+ Property::Value* objectUrl = propertyMap.Find( OBJECT_URL );
+ if( !objectUrl || !objectUrl->Get( mObjectUrl ) )
+ {
+ DALI_LOG_ERROR( "Fail to provide object URL to the MeshRenderer object.\n" );
+ }
+
+ Property::Value* materialUrl = propertyMap.Find( MATERIAL_URL );
+
+ if( !materialUrl || !materialUrl->Get( mMaterialUrl ) || mMaterialUrl.empty() )
+ {
+ mUseTexture = false;
+ }
+
+ Property::Value* imagesUrl = propertyMap.Find( TEXTURES_PATH );
+ if( !imagesUrl || !imagesUrl->Get( mTexturesPath ) )
+ {
+ //Default behaviour is to assume files are in the same directory,
+ // or have their locations detailed in full when supplied.
+ mTexturesPath.clear();
+ }
+
+ Property::Value* shaderType = propertyMap.Find( SHADER_TYPE );
+ if( shaderType && shaderType->Get( mShaderTypeString ) )
+ {
+ if( mShaderTypeString == "textureless" )
+ {
+ mShaderType = TEXTURELESS;
+ }
+ else if( mShaderTypeString == "diffuseTexture" )
+ {
+ mShaderType = DIFFUSE_TEXTURE;
+ }
+ else if( mShaderTypeString == "allTextures" )
+ {
+ mShaderType = ALL_TEXTURES;
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Unknown shader type provided to the MeshRenderer object.\n");
+ }
+ }
+}
+
+void MeshRenderer::SetSize( const Vector2& size )
+{
+ ControlRenderer::SetSize( size );
+
+ // ToDo: renderer responds to the size change
+}
+
+void MeshRenderer::SetClipRect( const Rect<int>& clipRect )
+{
+ ControlRenderer::SetClipRect( clipRect );
+
+ //ToDo: renderer responds to the clipRect change
+}
+
+void MeshRenderer::SetOffset( const Vector2& offset )
+{
+ //ToDo: renderer applies the offset
+}
+
+void MeshRenderer::DoSetOnStage( Actor& actor )
+{
+ InitializeRenderer();
+}
+
+void MeshRenderer::DoCreatePropertyMap( Property::Map& map ) const
+{
+ map.Clear();
+ map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
+ map.Insert( OBJECT_URL, mObjectUrl );
+ map.Insert( MATERIAL_URL, mMaterialUrl );
+ map.Insert( TEXTURES_PATH, mTexturesPath );
+ map.Insert( SHADER_TYPE, mShaderTypeString );
+}
+
+void MeshRenderer::InitializeRenderer()
+{
+ //Try to load the geometry from the file.
+ if( !LoadGeometry() )
+ {
+ SupplyEmptyGeometry();
+ return;
+ }
+
+ //If a texture is used by the obj file, load the supplied material file.
+ if( mObjLoader.IsTexturePresent() && !mMaterialUrl.empty() )
+ {
+ if( !LoadMaterial() )
+ {
+ SupplyEmptyGeometry();
+ return;
+ }
+ }
+
+ //Now that the required parts are loaded, create the geometry for the object.
+ if( !CreateGeometry() )
+ {
+ SupplyEmptyGeometry();
+ return;
+ }
+
+ CreateShader();
+
+ //Load the various texture files supplied by the material file.
+ if( !LoadTextures() )
+ {
+ SupplyEmptyGeometry();
+ return;
+ }
+
+ mImpl->mRenderer = Renderer::New( mGeometry, mShader );
+ mImpl->mRenderer.SetTextures( mTextureSet );
+ mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
+}
+
+void MeshRenderer::SupplyEmptyGeometry()
+{
+ mGeometry = Geometry::New();
+ mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ mImpl->mRenderer = Renderer::New( mGeometry, mShader );
+
+ DALI_LOG_ERROR( "Initialisation error in mesh renderer.\n" );
+}
+
+void MeshRenderer::UpdateShaderUniforms()
+{
+ Stage stage = Stage::GetCurrent();
+
+ Vector3 lightPosition( 0, 0, stage.GetSize().width );
+ mShader.RegisterProperty( LIGHT_POSITION, lightPosition );
+
+ Matrix scaleMatrix;
+ scaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ mShader.RegisterProperty( OBJECT_MATRIX, scaleMatrix );
+}
+
+void MeshRenderer::CreateShader()
+{
+ if( mShaderType == ALL_TEXTURES )
+ {
+ mShader = Shader::New( NORMAL_MAP_VERTEX_SHADER, NORMAL_MAP_FRAGMENT_SHADER );
+ }
+ else if( mShaderType == DIFFUSE_TEXTURE )
+ {
+ mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ }
+ else //Textureless
+ {
+ mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ }
+
+ UpdateShaderUniforms();
+}
+
+bool MeshRenderer::CreateGeometry()
+{
+ //Determine if we need to use a simpler shader to handle the provided data
+ if( mShaderType == ALL_TEXTURES )
+ {
+ if( !mObjLoader.IsNormalMapPresent() || !mObjLoader.IsSpecularMapPresent() )
+ {
+ mShaderType = DIFFUSE_TEXTURE;
+ }
+ }
+ if( !mObjLoader.IsTexturePresent() || !mObjLoader.IsDiffuseMapPresent() || !mUseTexture )
+ {
+ mShaderType = TEXTURELESS;
+ }
+
+ int objectProperties = 0;
+
+ if( mShaderType == DIFFUSE_TEXTURE ||
+ mShaderType == ALL_TEXTURES )
+ {
+ objectProperties |= ObjLoader::TEXTURE_COORDINATES;
+ }
+
+ if( mShaderType == ALL_TEXTURES )
+ {
+ objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINOMIALS;
+ }
+
+ //Create geometry with attributes required by shader.
+ mGeometry = mObjLoader.CreateGeometry( objectProperties );
+
+ if( mGeometry )
+ {
+ return true;
+ }
+
+ DALI_LOG_ERROR( "Failed to load geometry in mesh renderer.\n" );
+ return false;
+}
+
+bool MeshRenderer::LoadGeometry()
+{
+ std::streampos fileSize;
+ Dali::Vector<char> fileContent;
+
+ if( FileLoader::ReadFile( mObjectUrl, fileSize, fileContent, FileLoader::TEXT ) )
+ {
+ mObjLoader.ClearArrays();
+ mObjLoader.LoadObject( fileContent.Begin(), fileSize );
+
+ //Get size information from the obj loaded
+ mSceneCenter = mObjLoader.GetCenter();
+ mSceneSize = mObjLoader.GetSize();
+
+ return true;
+ }
+
+ DALI_LOG_ERROR( "Failed to find object to load in mesh renderer.\n" );
+ return false;
+}
+
+bool MeshRenderer::LoadMaterial()
+{
+ std::streampos fileSize;
+ Dali::Vector<char> fileContent;
+
+ if( FileLoader::ReadFile( mMaterialUrl, fileSize, fileContent, FileLoader::TEXT ) )
+ {
+ //Load data into obj (usable) form
+ mObjLoader.LoadMaterial( fileContent.Begin(), fileSize, mDiffuseTextureUrl, mNormalTextureUrl, mGlossTextureUrl );
+ return true;
+ }
+
+ DALI_LOG_ERROR( "Failed to find texture set to load in mesh renderer.\n" );
+ mUseTexture = false;
+ return false;
+}
+
+bool MeshRenderer::LoadTextures()
+{
+ mTextureSet = TextureSet::New();
+
+ if( !mDiffuseTextureUrl.empty() )
+ {
+ std::string imageUrl = mTexturesPath + mDiffuseTextureUrl;
+
+ //Load textures
+ Image diffuseTexture = ResourceImage::New( imageUrl );
+ if( diffuseTexture )
+ {
+ mTextureSet.SetImage( DIFFUSE_INDEX, diffuseTexture );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Failed to load diffuse map texture in mesh renderer.\n");
+ return false;
+ }
+ }
+
+ if( !mNormalTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
+ {
+ std::string imageUrl = mTexturesPath + mNormalTextureUrl;
+
+ //Load textures
+ Image normalTexture = ResourceImage::New( imageUrl );
+ if( normalTexture )
+ {
+ mTextureSet.SetImage( NORMAL_INDEX, normalTexture );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Failed to load normal map texture in mesh renderer.\n");
+ return false;
+ }
+ }
+
+ if( !mGlossTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
+ {
+ std::string imageUrl = mTexturesPath + mGlossTextureUrl;
+
+ //Load textures
+ Image glossTexture = ResourceImage::New( imageUrl );
+ if( glossTexture )
+ {
+ mTextureSet.SetImage( GLOSS_INDEX, glossTexture );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Failed to load gloss map texture in mesh renderer.\n");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__
+#define __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <fstream>
+#include <string.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * The renderer which renders a 3D object to the control's quad
+ *
+ * The following Property::Map keys are required to create a MeshRender
+ *
+ * | %Property Name | Type | Representing |
+ * |-----------------|-------------|-----------------------------------------|
+ * | objectUrl | STRING | A URL to the .obj file |
+ * | materialUrl | STRING | A URL to the .mtl file |
+ * | texturesPath | STRING | A URL of the path to the texture images |
+ * | shaderType | STRING | An enum of shader types |
+ */
+class MeshRenderer: public ControlRenderer
+{
+public:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ */
+ MeshRenderer( RendererFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~MeshRenderer();
+
+public: // from ControlRenderer
+
+ /**
+ * @copydoc ControlRenderer::SetSize
+ */
+ virtual void SetSize( const Vector2& size );
+
+ /**
+ * @copydoc ControlRenderer::SetClipRect
+ */
+ virtual void SetClipRect( const Rect<int>& clipRect );
+
+ /**
+ * @copydoc ControlRenderer::SetOffset
+ */
+ virtual void SetOffset( const Vector2& offset );
+
+ /**
+ * @copydoc ControlRenderer::CreatePropertyMap
+ */
+ virtual void DoCreatePropertyMap( Property::Map& map ) const;
+
+protected:
+
+ /**
+ * @copydoc ControlRenderer::DoInitialize
+ */
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+
+ /**
+ * @copydoc ControlRenderer::DoSetOnStage
+ */
+ virtual void DoSetOnStage( Actor& actor );
+
+public:
+
+ /**
+ * Declare whether a texture map should be used for the object, if it's present. Defaults to true.
+ * @param[in] useTexture boolean declaration.
+ */
+ void SetUseTexture( bool useTexture );
+
+ /**
+ * Declare whether a normal map should be used for the object, if it's present. Defaults to true.
+ * @param[in] useNormalMap boolean declaration.
+ */
+ void SetUseNormalMap( bool useNormalMap );
+
+private:
+
+ //Corresponds to the shader that will be used by the mesh renderer.
+ enum ShaderType
+ {
+ TEXTURELESS,
+ DIFFUSE_TEXTURE,
+ ALL_TEXTURES
+ };
+
+ /**
+ * @brief Provide an empty geometry for the renderer to use.
+ * @details For use in error cases where the initialisation has failed for varying reasons.
+ */
+ void SupplyEmptyGeometry();
+
+ /**
+ * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ */
+ void InitializeRenderer();
+
+ /**
+ * @brief Create a shader for the object to use.
+ */
+ void CreateShader();
+
+ /**
+ * @brief Update shader related info, uniforms, etc. for the new shader.
+ */
+ void UpdateShaderUniforms();
+
+ /**
+ * @brief Use the object URL stored in the renderer to load and create the geometry of the object.
+ * @return Boolean of success of operation.
+ */
+ bool CreateGeometry();
+
+ /**
+ * @brief Use the object URL stored in the renderer to load the geometry of the object.
+ * @return Boolean of success of operation.
+ */
+ bool LoadGeometry();
+
+ /**
+ * @brief Use the material URL stored in the renderer to load the material of the object.
+ * @return Boolean of success of operation.
+ */
+ bool LoadMaterial();
+
+ /**
+ * @brief Use the image and texture URL components to load the different types of texture.
+ * @return Boolean of success of operation. Returns false if any texture fails to load from a url.
+ */
+ bool LoadTextures();
+
+private:
+
+ // Undefined
+ MeshRenderer( const MeshRenderer& meshRenderer );
+
+ // Undefined
+ MeshRenderer& operator=( const MeshRenderer& meshRenderer );
+
+private:
+
+ std::string mObjectUrl;
+ std::string mMaterialUrl;
+
+ std::string mDiffuseTextureUrl;
+ std::string mNormalTextureUrl;
+ std::string mGlossTextureUrl;
+ std::string mTexturesPath;
+
+ std::string mShaderTypeString;
+
+ Shader mShader;
+ Geometry mGeometry;
+ TextureSet mTextureSet;
+
+ ObjLoader mObjLoader;
+ Vector3 mSceneCenter;
+ Vector3 mSceneSize;
+ ShaderType mShaderType;
+
+ bool mUseTexture;
+};
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__ */
#include <dali-toolkit/internal/controls/renderers/npatch/npatch-renderer.h>
#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
#include <dali-toolkit/internal/controls/renderers/svg/svg-renderer.h>
+#include <dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h>
#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
#include <dali-toolkit/internal/controls/renderers/image-atlas-manager.h>
std::string typeValue ;
if( type && type->Get( typeValue ))
{
- if( typeValue == COLOR_RENDERER )
+ if( typeValue == COLOR_RENDERER )
{
rendererType = COLOR;
}
{
rendererType = BORDER;
}
- else if( typeValue == GRADIENT_RENDERER )
+ else if( typeValue == GRADIENT_RENDERER )
{
rendererType = GRADIENT;
}
- else if( typeValue == IMAGE_RENDERER )
+ else if( typeValue == IMAGE_RENDERER )
{
rendererType = IMAGE;
}
+ else if( typeValue == MESH_RENDERER )
+ {
+ rendererType = MESH;
+ }
}
// check the url if exist, to decide the renderer type
rendererPtr = new SvgRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
break;
}
+ case MESH:
+ {
+ rendererPtr = new MeshRenderer( *( mFactoryCache.Get() ) );
+ break;
+ }
case UNDEFINED:
default:
{
//If there's no renderer type specified or if there hasn't been a renderer type change then we can reuse the renderer
if( type == UNDEFINED ||
- ( type == IMAGE && typeid( controlRenderer ) == typeid( ImageRenderer ) ) ||
- ( type == N_PATCH && typeid( controlRenderer ) == typeid( NPatchRenderer ) ) ||
- ( type == COLOR && typeid( controlRenderer ) == typeid( ColorRenderer ) )||
- ( type == GRADIENT && typeid( controlRenderer ) == typeid( GradientRenderer ) ) ||
- ( type == BORDER && typeid( controlRenderer ) == typeid( BorderRenderer ) ) ||
- ( type == SVG && typeid( controlRenderer ) == typeid( SvgRenderer ) ) )
+ ( type == IMAGE && typeid( controlRenderer ) == typeid( ImageRenderer ) ) ||
+ ( type == N_PATCH && typeid( controlRenderer ) == typeid( NPatchRenderer ) ) ||
+ ( type == COLOR && typeid( controlRenderer ) == typeid( ColorRenderer ) ) ||
+ ( type == GRADIENT && typeid( controlRenderer ) == typeid( GradientRenderer ) ) ||
+ ( type == BORDER && typeid( controlRenderer ) == typeid( BorderRenderer ) ) ||
+ ( type == SVG && typeid( controlRenderer ) == typeid( SvgRenderer ) ) ||
+ ( type == MESH && typeid( controlRenderer ) == typeid( MeshRenderer ) ) )
{
controlRenderer.Initialize( actor, propertyMap );
return;
} // namespace Toolkit
} // namespace Dali
-
IMAGE,
N_PATCH,
SVG,
+ MESH,
UNDEFINED
};
const char * const BORDER_RENDERER("border");
const char * const GRADIENT_RENDERER("gradient");
const char * const IMAGE_RENDERER("image");
+const char * const MESH_RENDERER("mesh");
const char * const IMAGE_URL_NAME("url");
const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
+const char * const COLOR( "color" );
+
+//Mesh properties
+const char * const OBJECT_URL( "objectUrl" );
+const char * const MATERIAL_URL( "materialUrl" );
+const char * const TEXTURES_PATH( "texturesPath" );
+const char * const SHADER_TYPE( "shaderType" );
} // namespace Internal
extern const char * const BORDER_RENDERER;
extern const char * const GRADIENT_RENDERER;
extern const char * const IMAGE_RENDERER;
+extern const char * const MESH_RENDERER;
extern const char * const IMAGE_URL_NAME;
extern const char * const ATLAS_RECT_UNIFORM_NAME;
+extern const char * const COLOR;
+
+//Mesh properties
+extern const char * const OBJECT_URL;
+extern const char * const MATERIAL_URL;
+extern const char * const TEXTURES_PATH;
+extern const char * const SHADER_TYPE;
} // namespace Internal
#include "svg-rasterize-thread.h"
// INTERNAL INCLUDES
-#include "nanosvg/nanosvgrast.h"
-#include "svg-renderer.h"
+#include <dali-toolkit/third-party/nanosvg/nanosvgrast.h>
+#include <dali-toolkit/internal/controls/renderers/svg/svg-renderer.h>
namespace Dali
{
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include "nanosvg/nanosvg.h"
-#include "svg-rasterize-thread.h"
+#include <dali-toolkit/third-party/nanosvg/nanosvg.h>
+#include <dali-toolkit/internal/controls/renderers/svg/svg-rasterize-thread.h>
#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
$(toolkit_src_dir)/controls/renderers/gradient/linear-gradient.cpp \
$(toolkit_src_dir)/controls/renderers/gradient/radial-gradient.cpp \
$(toolkit_src_dir)/controls/renderers/gradient/gradient-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/svg/nanosvg/nanosvg.cc \
- $(toolkit_src_dir)/controls/renderers/svg/nanosvg/nanosvgrast.cc \
$(toolkit_src_dir)/controls/renderers/svg/svg-rasterize-thread.cpp \
$(toolkit_src_dir)/controls/renderers/svg/svg-renderer.cpp \
+ $(toolkit_src_dir)/controls/renderers/mesh/mesh-renderer.cpp \
$(toolkit_src_dir)/controls/alignment/alignment-impl.cpp \
$(toolkit_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
$(toolkit_src_dir)/controls/bubble-effect/bubble-emitter-impl.cpp \
$(toolkit_src_dir)/controls/buttons/push-button-impl.cpp \
$(toolkit_src_dir)/controls/buttons/radio-button-impl.cpp \
$(toolkit_src_dir)/controls/effects-view/effects-view-impl.cpp \
- $(toolkit_src_dir)/controls/flex-container/layout.c \
$(toolkit_src_dir)/controls/flex-container/flex-container-impl.cpp \
$(toolkit_src_dir)/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp \
$(toolkit_src_dir)/controls/image-view/image-view-impl.cpp \
{
const HandleImpl& primaryHandle = mHandle[LEFT_SELECTION_HANDLE];
const HandleImpl& secondaryHandle = mHandle[RIGHT_SELECTION_HANDLE];
- const HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
if( primaryHandle.active || secondaryHandle.active )
else
{
// Calculates the popup's position if the grab handle is active.
- mCopyPastePopup.position = Vector3( cursor.position.x, -0.5f * popupSize.height - grabHandle.size.height + cursor.position.y, 0.0f );
+ const HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
+ if( grabHandle.verticallyFlipped )
+ {
+ mCopyPastePopup.position = Vector3( cursor.position.x, -0.5f * popupSize.height - grabHandle.size.height + cursor.position.y, 0.0f );
+ }
+ else
+ {
+ mCopyPastePopup.position = Vector3( cursor.position.x, -0.5f * popupSize.height + cursor.position.y, 0.0f );
+ }
}
}
{
// If this operation is too slow, consider a binary search.
+ const ScriptRun* const scriptRunBuffer = mScriptRuns.Begin();
for( Length index = 0u, length = mScriptRuns.Count(); index < length; ++index )
{
- const ScriptRun* const scriptRun = mScriptRuns.Begin() + index;
+ const ScriptRun* const scriptRun = scriptRunBuffer + index;
if( ( scriptRun->characterRun.characterIndex <= characterIndex ) &&
( characterIndex < scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters ) )
void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
Vector<FontId>& fontIds,
+ Vector<bool>& isDefaultFont,
const TextAbstraction::FontDescription& defaultFontDescription,
TextAbstraction::PointSize26Dot6 defaultPointSize,
CharacterIndex startIndex,
// Pointer to the font id buffer.
FontId* fontIdsBuffer = fontIds.Begin();
+ // Pointer to the 'is default' font buffer.
+ bool* isDefaultFontBuffer = isDefaultFont.Begin();
+
// Used to temporarily store the style per character.
TextAbstraction::FontDescription fontDescription;
TextAbstraction::PointSize26Dot6 fontSize;
const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
for( CharacterIndex index = startIndex; index < lastCharacterPlusOne; ++index )
{
- bool defaultFont = true;
+ bool& defaultFont = *(isDefaultFontBuffer + index - startIndex );
Length runIndex = 0u;
*
* @param[in] fontDescriptions The font descriptions.
* @param[out] fontIds The font id for each character.
+ * @param[out] isDefaultFont Whether the font is a default one.
* @param[in] defaultFontDescription The default font description.
* @param[in] defaultPointSize The default font size.
* @param[in] startIndex The character from where the fonts are merged.
*/
void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
Vector<FontId>& fontIds,
+ Vector<bool>& isDefaultFont,
const TextAbstraction::FontDescription& defaultFontDescription,
TextAbstraction::PointSize26Dot6 defaultPointSize,
CharacterIndex startIndex,
namespace Internal
{
-bool ValidateFontsPerScript::FindValidFont( FontId fontId ) const
+bool ValidateFontsPerScript::IsValidFont( FontId fontId ) const
{
for( Vector<FontId>::ConstIterator it = mValidFonts.Begin(),
endIt = mValidFonts.End();
// Count the number of characters which are valid for all scripts. i.e. white spaces or '\n'.
Length numberOfAllScriptCharacters = 0u;
- // Pointers to the text and break info buffers.
+ // Pointers to the text buffer.
const Character* const textBuffer = text.Begin();
// Traverse all characters and set the scripts.
currentScriptRun.characterRun.numberOfCharacters = 0u;
currentScriptRun.script = TextAbstraction::UNKNOWN;
numberOfAllScriptCharacters = 0u;
- }
+ }
// Get the next character.
++index;
// Merge font descriptions
Vector<FontId> fontIds;
fontIds.Resize( numberOfCharacters, defaultFontId );
+ Vector<bool> isDefaultFont;
+ isDefaultFont.Resize( numberOfCharacters, true );
MergeFontDescriptions( fontDescriptions,
fontIds,
+ isDefaultFont,
defaultFontDescription,
defaultPointSize,
startIndex,
const Character* const textBuffer = text.Begin();
const FontId* const fontIdsBuffer = fontIds.Begin();
+ const bool* const isDefaultFontBuffer = isDefaultFont.Begin();
Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
Vector<ScriptRun>::ConstIterator scriptRunEndIt = scripts.End();
bool isNewParagraphCharacter = false;
PointSize26Dot6 currentPointSize = defaultPointSize;
FontId currentFontId = 0u;
+ FontId previousFontId = 0u;
+
+ // Whether it's the first set of characters to be validated.
+ // Used in case the paragraph starts with characters common to all scripts.
+ bool isFirstSetToBeValidated = true;
CharacterIndex lastCharacter = startIndex + numberOfCharacters;
for( Length index = startIndex; index < lastCharacter; ++index )
{
- // Get the character.
+ // Get the current character.
const Character character = *( textBuffer + index );
- // Get the font for the character.
+ // Get the font for the current character.
FontId fontId = *( fontIdsBuffer + index - startIndex );
- // Get the script for the character.
- Script script = GetScript( index,
- scriptRunIt,
- scriptRunEndIt );
+ // Whether the font being validated for the current character is a default one not set by the user.
+ const bool isDefault = *( isDefaultFontBuffer + index - startIndex );
+
+ // Get the script for the current character.
+ const Script script = GetScript( index,
+ scriptRunIt,
+ scriptRunEndIt );
// Get the current point size.
if( currentFontId != fontId )
}
#endif
- // Whether the font being validated is a default one not set by the user.
- FontId preferredFont = fontId;
-
- // Validate if the font set by the user supports the character.
+ // Validate whether the current character is supported by the given font.
+ bool isValidFont = false;
- // Check first in the caches.
+ // Check first in the cache of default fonts per script and size.
DefaultFonts* defaultFonts = *( defaultFontPerScriptCacheBuffer + script );
FontId cachedDefaultFontId = 0u;
cachedDefaultFontId = defaultFonts->FindFont( fontClient, currentPointSize );
}
- // The user may have set the default font. Check it. Otherwise check in the valid fonts cache.
- if( fontId != cachedDefaultFontId )
- {
- // Check in the valid fonts cache.
- ValidateFontsPerScript* validateFontsPerScript = *( validFontsPerScriptCacheBuffer + script );
+ // Whether the cached default font is valid.
+ const bool isValidCachedDefaultFont = 0u != cachedDefaultFontId;
- if( NULL == validateFontsPerScript )
- {
- validateFontsPerScript = new ValidateFontsPerScript();
+ // The font is valid if it matches with the default one for the current script and size and it's different than zero.
+ isValidFont = isValidCachedDefaultFont && ( fontId == cachedDefaultFontId );
- *( validFontsPerScriptCacheBuffer + script ) = validateFontsPerScript;
- }
+ bool isCommonScript = false;
+
+ // If the given font is not valid, it means either:
+ // - there is no cached font for the current script yet or,
+ // - the user has set a different font than the default one for the current script or,
+ // - the platform default font is different than the default font for the current script.
- if( NULL != validateFontsPerScript )
+ // Need to check if the given font supports the current character.
+ if( !isValidFont ) // (1)
+ {
+ // Whether the current character is common for all scripts (i.e. white spaces, ...)
+
+ // Is not desirable to cache fonts for the common script.
+ //
+ // i.e. Consider the text " हिंदी", the 'white space' has assigned the DEVANAGARI script.
+ // The user may have set a font or the platform's default is used.
+ //
+ // As the 'white space' is the first character, no font is cached so the font validation
+ // retrieves a glyph from the given font.
+ //
+ // Many fonts support 'white spaces' so probably the font set by the user or the platform's default
+ // supports the 'white space'. However, that font may not support the DEVANAGARI script.
+ isCommonScript = TextAbstraction::IsCommonScript( character );
+
+ if( isCommonScript )
+ {
+ if( isValidCachedDefaultFont &&
+ ( isDefault || ( currentFontId == previousFontId ) ) )
+ {
+ // At this point the character common for all scripts has no font assigned.
+ // If there is a valid previously cached default font for it, use that one.
+ fontId = cachedDefaultFontId;
+ isValidFont = true;
+ }
+ }
+ else
{
- if( !validateFontsPerScript->FindValidFont( fontId ) )
+ // Check in the valid fonts cache.
+ ValidateFontsPerScript* validateFontsPerScript = *( validFontsPerScriptCacheBuffer + script );
+
+ if( NULL != validateFontsPerScript )
+ {
+ isValidFont = validateFontsPerScript->IsValidFont( fontId );
+ }
+
+ if( !isValidFont ) // (2)
{
// Use the font client to validate the font.
- GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
+ const GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
+
+ // The font is valid if there is a glyph for that character.
+ isValidFont = 0u != glyphIndex;
// Emojis are present in many monochrome fonts; prefer color by default.
- if( ( TextAbstraction::EMOJI == script ) &&
- ( 0u != glyphIndex ) )
+ if( isValidFont &&
+ ( TextAbstraction::EMOJI == script ) )
{
- BufferImage bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
- if( bitmap &&
- ( Pixel::BGRA8888 != bitmap.GetPixelFormat() ) )
- {
- glyphIndex = 0u;
- }
- }
+ const BufferImage bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
- if( 0u == glyphIndex )
- {
- // The font is not valid. Set to zero and a default one will be set.
- fontId = 0u;
+ // For color emojis, the font is valid if the bitmap is RGBA.
+ isValidFont = bitmap && ( Pixel::BGRA8888 == bitmap.GetPixelFormat() );
}
- else
+
+ // If there is a valid font, cache it.
+ if( isValidFont )
{
- // Add the font to the valid font cache.
-
- // At this point the validated font supports the given character. However, characters
- // common for all scripts, like white spaces or new paragraph characters, need to be
- // processed differently.
- //
- // i.e. A white space can have assigned a DEVANAGARI script but the font assigned may not
- // support none of the DEVANAGARI glyphs. This font can't be added to the cache as a valid
- // font for the DEVANAGARI script but the COMMON one.
- if( TextAbstraction::IsCommonScript( character ) )
+ if( NULL == validateFontsPerScript )
{
- validateFontsPerScript = *( validFontsPerScriptCacheBuffer + TextAbstraction::COMMON );
+ validateFontsPerScript = new ValidateFontsPerScript();
- if( NULL == validateFontsPerScript )
- {
- validateFontsPerScript = new ValidateFontsPerScript();
-
- *( validFontsPerScriptCacheBuffer + TextAbstraction::COMMON ) = validateFontsPerScript;
- }
+ *( validFontsPerScriptCacheBuffer + script ) = validateFontsPerScript;
}
validateFontsPerScript->mValidFonts.PushBack( fontId );
}
- }
- }
- }
- // The font has not been validated. Find a default one.
- if( 0u == fontId )
- {
- // The character has no font assigned. Get a default one from the cache
- fontId = cachedDefaultFontId;
+ if( !isValidFont ) // (3)
+ {
+ // The given font has not been validated.
- // If the cache has not a default font, get one from the font client.
- if( 0u == fontId )
- {
- // Emojis are present in many monochrome fonts; prefer color by default.
- bool preferColor = ( TextAbstraction::EMOJI == script );
+ if( isValidCachedDefaultFont )
+ {
+ // Use the cached default font for the script if there is one.
+ fontId = cachedDefaultFontId;
+ }
+ else
+ {
+ // There is no valid cached default font for the script.
- // Find a fallback-font.
- fontId = fontClient.FindFallbackFont( preferredFont, character, currentPointSize, preferColor );
+ DefaultFonts* defaultFontsPerScript = NULL;
- // If the system does not support a suitable font, fallback to Latin
- DefaultFonts* latinDefaults = NULL;
- if( 0u == fontId )
- {
- latinDefaults = *( defaultFontPerScriptCacheBuffer + TextAbstraction::LATIN );
- if( NULL != latinDefaults )
- {
- fontId = latinDefaults->FindFont( fontClient, currentPointSize );
- }
- }
+ // Emojis are present in many monochrome fonts; prefer color by default.
+ const bool preferColor = ( TextAbstraction::EMOJI == script );
- if( 0u == fontId )
- {
- fontId = fontClient.FindDefaultFont( UTF32_A, currentPointSize );
- }
+ // Find a fallback-font.
+ fontId = fontClient.FindFallbackFont( currentFontId, character, currentPointSize, preferColor );
- // Cache the font.
- if( NULL == latinDefaults )
- {
- latinDefaults = new DefaultFonts();
- *( defaultFontPerScriptCacheBuffer + script ) = latinDefaults;
- }
- latinDefaults->mFonts.PushBack( fontId );
- }
- }
+ if( 0u == fontId )
+ {
+ // If the system does not support a suitable font, fallback to Latin
+ defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + TextAbstraction::LATIN );
+ if( NULL != defaultFontsPerScript )
+ {
+ fontId = defaultFontsPerScript->FindFont( fontClient, currentPointSize );
+ }
+ }
+
+ if( 0u == fontId )
+ {
+ fontId = fontClient.FindDefaultFont( UTF32_A, currentPointSize );
+ }
+
+ // Cache the font.
+ if( NULL == defaultFontsPerScript )
+ {
+ defaultFontsPerScript = new DefaultFonts();
+ *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+ }
+ defaultFontsPerScript->mFonts.PushBack( fontId );
+ }
+ } // !isValidFont (3)
+ } // !isValidFont (2)
+ } // !isCommonScript
+ } // !isValidFont (1)
#ifdef DEBUG_ENABLED
{
}
#endif
+ if( isFirstSetToBeValidated && !isCommonScript )
+ {
+ currentFontRun.fontId = fontId;
+ isFirstSetToBeValidated = false;
+ }
+
// The font is now validated.
if( ( fontId != currentFontRun.fontId ) ||
isNewParagraphCharacter )
currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
currentFontRun.characterRun.numberOfCharacters = 0u;
currentFontRun.fontId = fontId;
+
+ if( isNewParagraphCharacter )
+ {
+ isFirstSetToBeValidated = true;
+ }
}
// Add one more character to the run.
// Whether the current character is a new paragraph character.
isNewParagraphCharacter = TextAbstraction::IsNewParagraph( character );
- }
+ previousFontId = currentFontId;
+ } // end traverse characters.
if( 0u != currentFontRun.characterRun.numberOfCharacters )
{
*
* @return @e true if the font is in the vector of valid fonts.
*/
- bool FindValidFont( FontId fontId ) const;
+ bool IsValidFont( FontId fontId ) const;
Vector<FontId> mValidFonts;
};
}
}
+ if( mEventData->mUpdateCursorPosition ||
+ mEventData->mUpdateLeftSelectionPosition ||
+ mEventData->mUpdateRightSelectionPosition )
+ {
+ NotifyImfManager();
+ }
+
// The cursor must also be repositioned after inserts into the model
if( mEventData->mUpdateCursorPosition )
{
return decoratorUpdated;
}
+void Controller::Impl::NotifyImfManager()
+{
+ if( mEventData && mEventData->mImfManager )
+ {
+ CharacterIndex cursorPosition = GetLogicalCursorPosition();
+
+ const Length numberOfWhiteSpaces = GetNumberOfWhiteSpaces( 0u );
+
+ // Update the cursor position by removing the initial white spaces.
+ if( cursorPosition < numberOfWhiteSpaces )
+ {
+ cursorPosition = 0u;
+ }
+ else
+ {
+ cursorPosition -= numberOfWhiteSpaces;
+ }
+
+ mEventData->mImfManager.SetCursorPosition( cursorPosition );
+ mEventData->mImfManager.NotifyCursorPosition();
+ }
+}
+
+CharacterIndex Controller::Impl::GetLogicalCursorPosition() const
+{
+ CharacterIndex cursorPosition = 0u;
+
+ if( mEventData )
+ {
+ if( ( EventData::SELECTING == mEventData->mState ) ||
+ ( EventData::SELECTION_HANDLE_PANNING == mEventData->mState ) )
+ {
+ cursorPosition = std::min( mEventData->mRightSelectionPosition, mEventData->mLeftSelectionPosition );
+ }
+ else
+ {
+ cursorPosition = mEventData->mPrimaryCursorPosition;
+ }
+ }
+
+ return cursorPosition;
+}
+
+Length Controller::Impl::GetNumberOfWhiteSpaces( CharacterIndex index ) const
+{
+ Length numberOfWhiteSpaces = 0u;
+
+ // Get the buffer to the text.
+ Character* utf32CharacterBuffer = mLogicalModel->mText.Begin();
+
+ const Length totalNumberOfCharacters = mLogicalModel->mText.Count();
+ for( ; index < totalNumberOfCharacters; ++index, ++numberOfWhiteSpaces )
+ {
+ if( !TextAbstraction::IsWhiteSpace( *( utf32CharacterBuffer + index ) ) )
+ {
+ break;
+ }
+ }
+
+ return numberOfWhiteSpaces;
+}
+
+void Controller::Impl::GetText( CharacterIndex index, std::string& text ) const
+{
+ // Get the total number of characters.
+ Length numberOfCharacters = mLogicalModel->mText.Count();
+
+ // Retrieve the text.
+ if( 0u != numberOfCharacters )
+ {
+ Utf32ToUtf8( mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text );
+ }
+}
+
void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters )
{
mTextUpdateInfo.mParagraphCharacterIndex = 0u;
}
}
+ /**
+ * @brief Helper to notify IMF manager with surrounding text & cursor changes.
+ */
+ void NotifyImfManager();
+
+ /**
+ * @brief Retrieve the current cursor position.
+ *
+ * @return The cursor position.
+ */
+ CharacterIndex GetLogicalCursorPosition() const;
+
+ /**
+ * @brief Retrieves the number of consecutive white spaces starting from the given @p index.
+ *
+ * @param[in] index The character index from where to count the number of consecutive white spaces.
+ *
+ * @return The number of consecutive white spaces.
+ */
+ Length GetNumberOfWhiteSpaces( CharacterIndex index ) const;
+
+ /**
+ * @brief Retrieve any text previously set starting from the given @p index.
+ *
+ * @param[in] index The character index from where to retrieve the text.
+ * @param[out] text A string of UTF-8 characters.
+ *
+ * @see Dali::Toolkit::Text::Controller::GetText()
+ */
+ void GetText( CharacterIndex index, std::string& text ) const;
+
bool IsClipboardEmpty()
{
bool result( mClipboard && mClipboard.NumberOfItems() );
mImpl->mEventData->mEventQueue.clear();
}
- // Notify IMF as text changed
- NotifyImfManager();
-
// Do this last since it provides callbacks into application code
mImpl->mControlInterface.TextChanged();
}
{
if( !mImpl->IsShowingPlaceholderText() )
{
- Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
-
- if( 0u != utf32Characters.Count() )
- {
- Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), text );
- }
+ // Retrieves the text string.
+ mImpl->GetText( 0u, text );
}
else
{
}
}
-unsigned int Controller::GetLogicalCursorPosition() const
-{
- if( NULL != mImpl->mEventData )
- {
- return mImpl->mEventData->mPrimaryCursorPosition;
- }
-
- return 0u;
-}
-
void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
{
if( NULL != mImpl->mEventData )
textChanged = true;
}
- if( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
- ( mImpl->mEventData->mState != EventData::INACTIVE ) )
+ if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
+ ( mImpl->mEventData->mState != EventData::INACTIVE ) &&
+ ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) )
{
+ // Should not change the state if the key is the shift send by the imf manager.
+ // Otherwise, when the state is SELECTING the text controller can't send the right
+ // surrounding info to the imf.
mImpl->ChangeState( EventData::EDITING );
}
mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
mImpl->mOperationsPending = ALL_OPERATIONS;
- // This is to reset the virtual keyboard to Upper-case
- if( 0u == mImpl->mLogicalModel->mText.Count() )
- {
- NotifyImfManager();
- }
-
if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
!mImpl->IsPlaceholderAvailable() )
{
ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
{
- bool update = false;
+ // Whether the text needs to be relaid-out.
bool requestRelayout = false;
- std::string text;
- unsigned int cursorPosition = 0u;
+ // Whether to retrieve the text and cursor position to be sent to the IMF manager.
+ bool retrieveText = false;
+ bool retrieveCursor = false;
switch( imfEvent.eventName )
{
case ImfManager::COMMIT:
{
InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
- update = true;
requestRelayout = true;
+ retrieveCursor = true;
break;
}
case ImfManager::PREEDIT:
{
InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
- update = true;
requestRelayout = true;
+ retrieveCursor = true;
break;
}
case ImfManager::DELETESURROUNDING:
{
- update = RemoveText( imfEvent.cursorOffset,
- imfEvent.numberOfChars,
- DONT_UPDATE_INPUT_STYLE );
+ const bool textDeleted = RemoveText( imfEvent.cursorOffset,
+ imfEvent.numberOfChars,
+ DONT_UPDATE_INPUT_STYLE );
- if( update )
+ if( textDeleted )
{
if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
!mImpl->IsPlaceholderAvailable() )
}
mImpl->mEventData->mUpdateCursorPosition = true;
mImpl->mEventData->mScrollAfterDelete = true;
+
+ requestRelayout = true;
+ retrieveCursor = true;
}
- requestRelayout = true;
break;
}
case ImfManager::GETSURROUNDING:
{
- GetText( text );
- cursorPosition = GetLogicalCursorPosition();
-
- imfManager.SetSurroundingText( text );
- imfManager.SetCursorPosition( cursorPosition );
+ retrieveText = true;
+ retrieveCursor = true;
break;
}
case ImfManager::VOID:
}
} // end switch
- if( ImfManager::GETSURROUNDING != imfEvent.eventName )
- {
- GetText( text );
- cursorPosition = GetLogicalCursorPosition();
- }
-
if( requestRelayout )
{
mImpl->mOperationsPending = ALL_OPERATIONS;
mImpl->mControlInterface.TextChanged();
}
- ImfManager::ImfCallbackData callbackData( update, cursorPosition, text, false );
+ std::string text;
+ CharacterIndex cursorPosition = 0u;
+ Length numberOfWhiteSpaces = 0u;
+
+ if( retrieveCursor )
+ {
+ numberOfWhiteSpaces = mImpl->GetNumberOfWhiteSpaces( 0u );
+
+ cursorPosition = mImpl->GetLogicalCursorPosition();
+
+ if( cursorPosition < numberOfWhiteSpaces )
+ {
+ cursorPosition = 0u;
+ }
+ else
+ {
+ cursorPosition -= numberOfWhiteSpaces;
+ }
+ }
+
+ if( retrieveText )
+ {
+ mImpl->GetText( numberOfWhiteSpaces, text );
+ }
+
+ ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
return callbackData;
}
if( removed )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE RemovedText\n", this );
- // Notifiy the IMF manager after text changed
- // Automatic Upper-case and restarting prediction on an existing word require this.
- NotifyImfManager();
-
if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
!mImpl->IsPlaceholderAvailable() )
{
return removed;
}
-void Controller::NotifyImfManager()
-{
- if( NULL != mImpl->mEventData )
- {
- if( mImpl->mEventData->mImfManager )
- {
- // Notifying IMF of a cursor change triggers a surrounding text request so updating it now.
- std::string text;
- GetText( text );
- mImpl->mEventData->mImfManager.SetSurroundingText( text );
-
- mImpl->mEventData->mImfManager.SetCursorPosition( GetLogicalCursorPosition() );
- mImpl->mEventData->mImfManager.NotifyCursorPosition();
- }
- }
-}
-
void Controller::ShowPlaceholderText()
{
if( mImpl->IsPlaceholderAvailable() )
/**
* @brief Retrieve any text previously set.
*
- * @return A string of UTF-8 characters.
+ * @param[out] text A string of UTF-8 characters.
*/
void GetText( std::string& text ) const;
UpdateInputStyleType type );
/**
- * @brief Retrieve the current cursor position.
- *
- * @return The cursor position.
- */
- unsigned int GetLogicalCursorPosition() const;
-
- /**
* @brief Replaces any placeholder text previously set.
*
* @param[in] type Different placeholder-text can be shown when the control is active/inactive.
bool BackspaceKeyEvent();
/**
- * @brief Helper to notify IMF manager with surrounding text & cursor changes.
- */
- void NotifyImfManager();
-
- /**
* @brief Helper to clear font-specific data.
*/
void ShowPlaceholderText();
DIFFUSE_WITH_NORMAL_MAP
};
-
/**
* @brief Create a new instance of a Model3dView control.
*
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 39;
+const unsigned int TOOLKIT_MICRO_VERSION = 40;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
--- /dev/null
+third_party_src_files = \
+ $(third_party_src_dir)/nanosvg/nanosvg.cc \
+ $(third_party_src_dir)/nanosvg/nanosvgrast.cc \
+ $(third_party_src_dir)/facebook-flexbox/layout.c
+ [Gradient](@ref gradient-renderer)
+ [Image](@ref image-renderers)
+ [Border](@ref border-renderer)
+ + [Mesh](@ref mesh-renderer)
Controls can provide properties that allow users to specify the renderer type.
Setting renderer properties are done via a property map.
};
~~~
+___________________________________________________________________________________________________
+
+## Mesh Renderer {#mesh-renderer}
+
+Renders a mesh using a .obj file, optionally with textures provided by a mtl file. Scaled to fit the control.
+
+![ ](../assets/img/renderers/mesh-renderer.png)
+![ ](renderers/mesh-renderer.png)
+
+### Properties Supported
+
+**RendererType** "mesh"
+
+| Property Name | Type | Required | Description |
+|---------------|:-------:|:------------------:|----------------------------------------------------------------------|
+| objectUrl | STRING | Yes | The location of the .obj file. |
+| materialUrl | STRING | No | The location of the .mtl file. Leave blank for a textureless object. |
+| texturesPath | STRING | If using material | Path to the directory textures (including gloss and normal) are stored in. |
+| shaderType | STRING | No | Sets the type of shader to be used with the mesh. Note that if anything the shader requires is missing, it will use a simpler one that it can handle with what has been supplied.\n Possible values: "textureless", "diffuseTexture", "allTextures". |
+
+### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ "rendererType" ] = "mesh";
+map[ "objectUrl" ] = "home/models/Dino.obj";
+map[ "materialUrl" ] = "home/models/Dino.mtl";
+map[ "texturesPath" ] = "home/images/";
+
+control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+~~~
+
@class _Guide_Control_Renderers
*/
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.39
+Version: 1.1.40
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
%define dali_toolkit_profile MOBILE
%endif
+%if 0%{?enable_coverage}
+CXXFLAGS+=" -fprofile-arcs -ftest-coverage --coverage "
+LDFLAGS+=" -fprofile-arcs -ftest-coverage --coverage -lgcov "
+%endif
+
+
%description
The OpenGLES Canvas Core Library Toolkit - a set of controls that provide
user interface functionality.
%defattr(-,root,root,-)
%{dev_include_path}/%{name}/*
%{_libdir}/pkgconfig/*.pc
-