From: Victor Cebollada Date: Fri, 24 Jun 2016 07:51:18 +0000 (+0100) Subject: [dali_1.1.40] Merge branch 'devel/master' X-Git-Tag: dali_1.9.8~5^2~193 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=0111b4a410b1c8243617a66fd5d5517b7e37b047;hp=9a36e256c115e4c7e63e6ded1e1a69b06963ccff [dali_1.1.40] Merge branch 'devel/master' Change-Id: I8597bf4b7fda1590b350a530d7f91fcd9a72faee --- diff --git a/automated-tests/resources/Cube.obj b/automated-tests/resources/Cube.obj new file mode 100644 index 0000000..e9bc9b4 --- /dev/null +++ b/automated-tests/resources/Cube.obj @@ -0,0 +1,42 @@ +# 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 diff --git a/automated-tests/resources/TB-gloss.png b/automated-tests/resources/TB-gloss.png new file mode 100644 index 0000000..9ed4b6c Binary files /dev/null and b/automated-tests/resources/TB-gloss.png differ diff --git a/automated-tests/resources/ToyRobot-Metal-Simple.mtl b/automated-tests/resources/ToyRobot-Metal-Simple.mtl new file mode 100644 index 0000000..f699daf --- /dev/null +++ b/automated-tests/resources/ToyRobot-Metal-Simple.mtl @@ -0,0 +1,9 @@ +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 diff --git a/automated-tests/resources/ToyRobot-Metal.mtl b/automated-tests/resources/ToyRobot-Metal.mtl new file mode 100644 index 0000000..cab3ae2 --- /dev/null +++ b/automated-tests/resources/ToyRobot-Metal.mtl @@ -0,0 +1,11 @@ +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 diff --git a/automated-tests/resources/tb-norm.png b/automated-tests/resources/tb-norm.png new file mode 100644 index 0000000..884cc90 Binary files /dev/null and b/automated-tests/resources/tb-norm.png differ diff --git a/automated-tests/resources/tbcol.png b/automated-tests/resources/tbcol.png new file mode 100644 index 0000000..93d98cd Binary files /dev/null and b/automated-tests/resources/tbcol.png differ diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp index 219fba1..7164972 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp @@ -1014,7 +1014,7 @@ int UtcDaliTextLayoutMultilineText02(void) 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 = @@ -1069,10 +1069,10 @@ int UtcDaliTextLayoutMultilineText02(void) { { 38u, 12u }, { 38u, 12u }, - 79.f, + 80.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -1660,16 +1660,16 @@ int UtcDaliTextUpdateLayout01(void) 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 = @@ -1715,7 +1715,7 @@ int UtcDaliTextUpdateLayout01(void) 92.f, 15.f, -5.f, - 4.f, + 5.f, 0.f, false, false @@ -1760,10 +1760,10 @@ int UtcDaliTextUpdateLayout01(void) { { 74u, 12u }, { 74u, 12u }, - 79.f, + 80.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -1784,10 +1784,10 @@ int UtcDaliTextUpdateLayout01(void) { { 92u, 12u }, { 92u, 12u }, - 78.f, + 79.f, 15.f, -5.f, - 4.f, + 5.f, 0.f, false, false @@ -1820,10 +1820,10 @@ int UtcDaliTextUpdateLayout01(void) { { 128u, 12u }, { 128u, 12u }, - 81.f, + 82.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -1832,7 +1832,7 @@ int UtcDaliTextUpdateLayout01(void) { { 140u, 10u }, { 140u, 10u }, - 76.f, + 77.f, 15.f, -5.f, 4.f, @@ -1868,7 +1868,7 @@ int UtcDaliTextUpdateLayout01(void) { { 166u, 12u }, { 166u, 12u }, - 79.f, + 80.f, 15.f, -5.f, 4.f, @@ -2187,16 +2187,16 @@ int UtcDaliTextUpdateLayout02(void) 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 = @@ -2242,7 +2242,7 @@ int UtcDaliTextUpdateLayout02(void) 92.f, 15.f, -5.f, - 4.f, + 5.f, 0.f, false, false @@ -2287,10 +2287,10 @@ int UtcDaliTextUpdateLayout02(void) { { 74u, 12u }, { 74u, 12u }, - 79.f, + 80.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -2311,10 +2311,10 @@ int UtcDaliTextUpdateLayout02(void) { { 92u, 12u }, { 92u, 12u }, - 78.f, + 79.f, 15.f, -5.f, - 4.f, + 5.f, 0.f, false, false @@ -2347,10 +2347,10 @@ int UtcDaliTextUpdateLayout02(void) { { 128u, 12u }, { 128u, 12u }, - 81.f, + 82.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -2359,7 +2359,7 @@ int UtcDaliTextUpdateLayout02(void) { { 140u, 10u }, { 140u, 10u }, - 76.f, + 77.f, 15.f, -5.f, 4.f, @@ -2395,7 +2395,7 @@ int UtcDaliTextUpdateLayout02(void) { { 166u, 12u }, { 166u, 12u }, - 79.f, + 80.f, 15.f, -5.f, 4.f, @@ -2714,16 +2714,16 @@ int UtcDaliTextUpdateLayout03(void) 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 = @@ -2769,7 +2769,7 @@ int UtcDaliTextUpdateLayout03(void) 92.f, 15.f, -5.f, - 4.f, + 5.f, 0.f, false, false @@ -2814,10 +2814,10 @@ int UtcDaliTextUpdateLayout03(void) { { 74u, 12u }, { 74u, 12u }, - 79.f, + 80.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -2838,10 +2838,10 @@ int UtcDaliTextUpdateLayout03(void) { { 92u, 12u }, { 92u, 12u }, - 78.f, + 79.f, 15.f, -5.f, - 4.f, + 5.f, 0.f, false, false @@ -2874,10 +2874,10 @@ int UtcDaliTextUpdateLayout03(void) { { 128u, 12u }, { 128u, 12u }, - 81.f, + 82.f, 15.f, -5.f, - 3.f, + 4.f, 0.f, false, false @@ -2886,7 +2886,7 @@ int UtcDaliTextUpdateLayout03(void) { { 140u, 10u }, { 140u, 10u }, - 76.f, + 77.f, 15.f, -5.f, 4.f, @@ -2922,7 +2922,7 @@ int UtcDaliTextUpdateLayout03(void) { { 166u, 12u }, { 166u, 12u }, - 79.f, + 80.f, 15.f, -5.f, 4.f, @@ -2954,6 +2954,7 @@ int UtcDaliTextUpdateLayout03(void) false, false }; + Vector lines; lines.PushBack( line01 ); lines.PushBack( line02 ); diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp index eea51a6..db59db3 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp @@ -37,6 +37,7 @@ using namespace Text; // // void MergeFontDescriptions( const Vector& fontDescriptions, // Vector& fontIds, +// Vector& isDefaultFont, // const TextAbstraction::FontDescription& defaultFontDescription, // TextAbstraction::PointSize26Dot6 defaultPointSize, // CharacterIndex startIndex, @@ -79,6 +80,7 @@ struct MergeFontDescriptionsData unsigned int startIndex; ///< The start index. unsigned int numberOfCharacters; ///< The number of characters. Vector expectedFontIds; ///< The expected font ids. + Vector expectedIsDefault; ///< The expected font ids. }; struct ScriptsData @@ -108,9 +110,12 @@ bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data ) { Vector fontIds; fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u ); + Vector isDefaultFont; + isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true ); MergeFontDescriptions( data.fontDescriptionRuns, fontIds, + isDefaultFont, data.defaultFontDescription, data.defaultPointSize, data.startIndex, @@ -141,6 +146,12 @@ bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data ) 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; @@ -413,12 +424,16 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontDescription defaultFontDescription01; Vector fontDescriptionRuns01; Vector expectedFontIds01; + Vector expectedIsFontDefault01; TextAbstraction::FontDescription defaultFontDescription02; Vector fontDescriptionRuns02; Vector expectedFontIds02; expectedFontIds02.PushBack( 0u ); expectedFontIds02.PushBack( 0u ); + Vector expectedIsFontDefault02; + expectedIsFontDefault02.PushBack( true ); + expectedIsFontDefault02.PushBack( true ); TextAbstraction::FontDescription defaultFontDescription03; defaultFontDescription03.family = "DejaVu Serif"; @@ -532,6 +547,17 @@ int UtcDaliTextMergeFontDescriptions(void) expectedFontIds03.PushBack( 3u ); expectedFontIds03.PushBack( 6u ); expectedFontIds03.PushBack( 6u ); + Vector 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[] = { @@ -542,7 +568,8 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontClient::DEFAULT_POINT_SIZE, 0u, 0u, - expectedFontIds01 + expectedFontIds01, + expectedIsFontDefault01 }, { "No description runs.", @@ -551,7 +578,8 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontClient::DEFAULT_POINT_SIZE, 0u, 2u, - expectedFontIds02 + expectedFontIds02, + expectedIsFontDefault02 }, { "Some description runs.", @@ -560,7 +588,8 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontClient::DEFAULT_POINT_SIZE, 0u, 10u, - expectedFontIds03 + expectedFontIds03, + expectedIsFontDefault03 } }; const unsigned int numberOfTests = 3u; diff --git a/automated-tests/src/dali-toolkit-third-party/facebook-flexbox/layout-test-utils.h b/automated-tests/src/dali-toolkit-third-party/facebook-flexbox/layout-test-utils.h index 9c8a903..7513141 100644 --- a/automated-tests/src/dali-toolkit-third-party/facebook-flexbox/layout-test-utils.h +++ b/automated-tests/src/dali-toolkit-third-party/facebook-flexbox/layout-test-utils.h @@ -10,7 +10,7 @@ #include #include -#include +#include void test(const char *name, css_node_t *style, css_node_t *expected_layout); bool tests_finished(void); diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 77b2c96..d6aa2fb 100644 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -7,51 +7,51 @@ SET(CAPI_LIB "dali-toolkit") # 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 ) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp index fb50bf5..9be97bc 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp @@ -28,8 +28,6 @@ namespace Dali 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 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h index 1fe97c1..9a93c8e 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h @@ -73,7 +73,11 @@ public: { 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 ) @@ -141,7 +145,12 @@ public: 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) @@ -278,7 +287,10 @@ public: { 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) @@ -310,7 +322,10 @@ public: { 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; } @@ -319,7 +334,11 @@ public: { 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) @@ -334,7 +353,11 @@ public: { 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) @@ -345,7 +368,11 @@ public: { 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) @@ -353,13 +380,19 @@ public: std::stringstream out; out << n << ", " << textures << " = ["; + TraceCallStack::NamedParams namedParams; + for(GLsizei i=0; i inline bool GetUniformValue( const char* name, T& value ) const { @@ -1850,6 +1967,7 @@ private: TraceCallStack mTextureTrace; TraceCallStack mTexParamaterTrace; TraceCallStack mDrawTrace; + TraceCallStack mDepthFunctionTrace; // Shaders & Uniforms GLuint mLastShaderIdUsed; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp index bda38d3..3f2e6e5 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp @@ -16,9 +16,32 @@ */ #include "test-trace-call-stack.h" +#include 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 */ @@ -45,10 +68,17 @@ void TraceCallStack::PushCall(std::string method, std::string params) { 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 ); } } @@ -62,7 +92,7 @@ bool TraceCallStack::FindMethod(std::string method) const 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; @@ -76,7 +106,7 @@ int TraceCallStack::CountMethod(std::string method) const 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++; } @@ -95,6 +125,12 @@ bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) 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 @@ -106,7 +142,7 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string 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; @@ -115,6 +151,35 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string 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 @@ -123,7 +188,7 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string */ 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) ); } /** diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h index d319487..32375a6 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h @@ -20,9 +20,13 @@ #include #include +#include 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 @@ -30,6 +34,9 @@ namespace Dali class TraceCallStack { public: + /// Typedef for passing and storing named parameters + typedef std::map< std::string, std::string > NamedParams; + /** * Constructor */ @@ -54,6 +61,13 @@ public: */ 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 @@ -80,12 +94,28 @@ public: /** * 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 @@ -98,15 +128,25 @@ public: */ 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 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp index d524b81..0983366 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp @@ -30,6 +30,9 @@ namespace 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) @@ -625,3 +628,46 @@ int UtcDaliControlRendererGetPropertyMap7(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() == "mesh" ); + + value = resultMap.Find( "objectUrl", Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == TEST_OBJ_FILE_NAME ); + + value = resultMap.Find( "materialUrl", Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == TEST_MTL_FILE_NAME ); + + value = resultMap.Find( "texturesPath", Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == TEST_RESOURCE_LOCATION ); + + value = resultMap.Find( "shaderType", Property::STRING ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == "textureless" ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-FlexContainer.cpp b/automated-tests/src/dali-toolkit/utc-Dali-FlexContainer.cpp index b92e8e7..f602079 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-FlexContainer.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-FlexContainer.cpp @@ -186,6 +186,53 @@ int UtcDaliToolkitFlexContainerSetPropertyP(void) 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( 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( 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( 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( 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( 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( FlexContainer::Property::ALIGN_CONTENT ), FlexContainer::ALIGN_STRETCH, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliToolkitFlexContainerSetChildPropertyP(void) { ToolkitTestApplication application; @@ -217,6 +264,233 @@ int UtcDaliToolkitFlexContainerSetChildPropertyP(void) DALI_TEST_EQUALS( actor.GetProperty( 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; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp index 0f56e92..a8fa8cc 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp @@ -61,7 +61,7 @@ bool IsOverlap( Rect rect1, Rect rect2 ) && rect2.y < rect1.y+rect1.height; } -} +} // anonymous namespace void dali_image_atlas_startup(void) { @@ -191,23 +191,33 @@ int UtcDaliImageAtlasUploadP(void) Rect pixelArea1 = TextureCoordinateToPixelArea(textureRect1, size); DALI_TEST_EQUALS( pixelArea1.width, 34, TEST_LOCATION ); DALI_TEST_EQUALS( pixelArea1.height, 34, TEST_LOCATION ); - std::stringstream out; - out< pixelArea2 = TextureCoordinateToPixelArea(textureRect2, size); DALI_TEST_EQUALS( pixelArea2.width, 50, TEST_LOCATION ); DALI_TEST_EQUALS( pixelArea2.height, 50, TEST_LOCATION ); - out.str(""); - out< pixelArea3 = TextureCoordinateToPixelArea(textureRect3, size); DALI_TEST_EQUALS( pixelArea3.width, 128, TEST_LOCATION ); DALI_TEST_EQUALS( pixelArea3.height, 128, TEST_LOCATION ); - out.str(""); - out<( "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( "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( "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( "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( "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( "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( "uObjectMatrix", scaleMatrix ) ); + + controlRenderer.SetOffStage( actor ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + + END_TEST; +} + int UtcDaliRendererFactoryResetRenderer1(void) { ToolkitTestApplication application; @@ -1052,3 +1429,84 @@ int UtcDaliRendererFactoryResetRenderer3(void) 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( "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(), 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( "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( "mixColor", actualValue ) ); + DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION ); + + //****** + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp index 7ec6acf..e96556b 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -114,10 +115,10 @@ static bool OnSliderMark( Slider slider, int value ) 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(); @@ -178,3 +179,202 @@ int UtcDaliSliderSignals(void) 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(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(Slider::Property::LOWER_BOUND); + DALI_TEST_EQUALS(lb, 1.0f, TEST_LOCATION); + float ub = slider.GetProperty(Slider::Property::UPPER_BOUND); + DALI_TEST_EQUALS(ub, 5.0f, TEST_LOCATION); + float val = slider.GetProperty(Slider::Property::VALUE); + DALI_TEST_EQUALS(val, 3.0f, TEST_LOCATION); + Vector4 color = slider.GetProperty(Slider::Property::DISABLED_COLOR); + DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION ); + int precision = slider.GetProperty(Slider::Property::VALUE_PRECISION); + DALI_TEST_EQUALS( precision, 4, TEST_LOCATION); + bool showPopup = slider.GetProperty(Slider::Property::SHOW_POPUP); + DALI_TEST_EQUALS( showPopup, true , TEST_LOCATION); + bool showValue = slider.GetProperty(Slider::Property::SHOW_VALUE); + DALI_TEST_EQUALS( showValue, true, TEST_LOCATION ); + bool marks = slider.GetProperty(Slider::Property::MARKS); + DALI_TEST_EQUALS( marks, false, TEST_LOCATION ); + bool snapToMarks = slider.GetProperty(Slider::Property::SNAP_TO_MARKS); + DALI_TEST_EQUALS( snapToMarks, false, TEST_LOCATION ); + float tolerance = slider.GetProperty(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) diff --git a/build/tizen/Makefile.am b/build/tizen/Makefile.am index e116401..a672053 100644 --- a/build/tizen/Makefile.am +++ b/build/tizen/Makefile.am @@ -55,7 +55,7 @@ cov_data: @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 diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am index 2cc6de7..7383ebe 100644 --- a/build/tizen/dali-toolkit/Makefile.am +++ b/build/tizen/dali-toolkit/Makefile.am @@ -16,11 +16,12 @@ # 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 @@ -31,6 +32,7 @@ include ../../../dali-toolkit/styles/images-common/file.list 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 @@ -56,7 +58,8 @@ lib_LTLIBRARIES = libdali-toolkit.la 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} diff --git a/dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h b/dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h index c6fc451..fb52bf3 100644 --- a/dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h +++ b/dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h @@ -112,7 +112,7 @@ public: * 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 ); @@ -151,7 +151,7 @@ public: * 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 ); @@ -173,14 +173,13 @@ public: * 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 * @@ -188,7 +187,7 @@ public: * 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. */ diff --git a/dali-toolkit/internal/controls/flex-container/flex-container-impl.h b/dali-toolkit/internal/controls/flex-container/flex-container-impl.h index 2005f9c..f89c1f4 100644 --- a/dali-toolkit/internal/controls/flex-container/flex-container-impl.h +++ b/dali-toolkit/internal/controls/flex-container/flex-container-impl.h @@ -26,7 +26,7 @@ #include extern "C" { -#include "layout.h" +#include } namespace Dali diff --git a/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp b/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp index d395fb2..eac2d89 100644 --- a/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp +++ b/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp @@ -423,7 +423,7 @@ void Model3dView::OnStageConnection( int depth ) if( mObjLoader.IsSceneLoaded() ) { - mMesh = mObjLoader.CreateGeometry( mIlluminationType ); + mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) ); CreateMaterial(); LoadTextures(); @@ -462,9 +462,7 @@ void Model3dView::LoadGeometry() 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(); @@ -520,7 +518,7 @@ void Model3dView::CreateGeometry() { if( mObjLoader.IsSceneLoaded() ) { - mMesh = mObjLoader.CreateGeometry( mIlluminationType ); + mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) ); if( mRenderer ) { @@ -629,6 +627,24 @@ void Model3dView::LoadTextures() } } +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 diff --git a/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.h b/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.h index 8e44911..9c24faa 100644 --- a/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.h +++ b/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.h @@ -146,6 +146,15 @@ private: 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 diff --git a/dali-toolkit/internal/controls/model3d-view/obj-loader.cpp b/dali-toolkit/internal/controls/model3d-view/obj-loader.cpp index bc4e174..aaf7c60 100644 --- a/dali-toolkit/internal/controls/model3d-view/obj-loader.cpp +++ b/dali-toolkit/internal/controls/model3d-view/obj-loader.cpp @@ -19,6 +19,7 @@ #include "obj-loader.h" // EXTERNAL INCLUDES +#include #include #include #include @@ -32,6 +33,10 @@ namespace Toolkit namespace Internal { +namespace +{ + const int MAX_POINT_INDICES = 4; +} using namespace Dali; ObjLoader::ObjLoader() @@ -39,8 +44,8 @@ ObjLoader::ObjLoader() mSceneLoaded = false; mMaterialLoaded = false; mHasTexturePoints = false; - mHasNormalMap = false; mHasDiffuseMap = false; + mHasNormalMap = false; mHasSpecularMap = false; mSceneAABB.Init(); } @@ -67,9 +72,6 @@ void ObjLoader::CalculateTangentArray(const Dali::Vector& vertex, Dali::Vector& normal, Dali::Vector& tangent) { - normal.Clear(); - normal.Resize(vertex.Size()); - Dali::Vector tangents; tangents.Resize( vertex.Size() ); @@ -172,12 +174,16 @@ void ObjLoader::CreateGeometryArray(Dali::Vector & vertices, //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]); @@ -275,14 +281,14 @@ void ObjLoader::CreateGeometryArray(Dali::Vector & vertices, } } -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; @@ -372,7 +378,7 @@ bool ObjLoader::Load( char* objBuffer, std::streampos fileSize, std::string& mat } int numIndices = 0; - while( isline >> vet[numIndices] ) + while( isline >> vet[numIndices] && numIndices < MAX_POINT_INDICES ) { numIndices++; } @@ -476,9 +482,6 @@ bool ObjLoader::Load( char* objBuffer, std::streampos fileSize, std::string& mat { isline >> name; } - else - { - } } if ( iniObj ) @@ -490,11 +493,10 @@ bool ObjLoader::Load( char* objBuffer, std::streampos fileSize, std::string& mat } 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; @@ -518,11 +520,15 @@ void ObjLoader::LoadMaterial( char* objBuffer, std::streampos fileSize, std::str { 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; } @@ -535,19 +541,19 @@ void ObjLoader::LoadMaterial( char* objBuffer, std::streampos fileSize, std::str 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; } } @@ -555,7 +561,7 @@ void ObjLoader::LoadMaterial( char* objBuffer, std::streampos fileSize, std::str mMaterialLoaded = true; } -Geometry ObjLoader::CreateGeometry( Toolkit::Model3dView::IlluminationType illuminationType ) +Geometry ObjLoader::CreateGeometry( int objectProperties ) { Geometry surface = Geometry::New(); @@ -575,8 +581,7 @@ Geometry ObjLoader::CreateGeometry( Toolkit::Model3dView::IlluminationType illum 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; @@ -587,7 +592,7 @@ Geometry ObjLoader::CreateGeometry( Toolkit::Model3dView::IlluminationType illum } //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; @@ -598,15 +603,12 @@ Geometry ObjLoader::CreateGeometry( Toolkit::Model3dView::IlluminationType illum 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; } diff --git a/dali-toolkit/internal/controls/model3d-view/obj-loader.h b/dali-toolkit/internal/controls/model3d-view/obj-loader.h index 0a9ea25..0336323 100644 --- a/dali-toolkit/internal/controls/model3d-view/obj-loader.h +++ b/dali-toolkit/internal/controls/model3d-view/obj-loader.h @@ -20,10 +20,7 @@ // EXTERNAL INCLUDES #include - -// INTERNAL INCLUDES -#include - +#include namespace Dali { @@ -65,7 +62,7 @@ public: {} VertexExt( const Vector3& tangent, const Vector3& binormal ) - : tangent( tangent), bitangent (binormal) + : tangent( tangent), bitangent( binormal ) {} Vector3 tangent; @@ -76,36 +73,45 @@ public: { void Init() { - pointMin = Vector3(999999.9,999999.9,999999.9); - pointMax = Vector3(-999999.9,-999999.9,-999999.9); + pointMin = Vector3( std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max() ); + pointMax = Vector3( std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::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(); @@ -138,19 +144,19 @@ private: Dali::Vector mBiTangents; Dali::Vector mTriangles; - void CalculateTangentArray(const Dali::Vector& vertex, - const Dali::Vector& texcoord, - Dali::Vector& triangle, - Dali::Vector& normal, - Dali::Vector& tangent); + void CalculateTangentArray( const Dali::Vector& vertex, + const Dali::Vector& texcoord, + Dali::Vector& triangle, + Dali::Vector& normal, + Dali::Vector& tangent ); - void CenterAndScale(bool center, Dali::Vector& points); + void CenterAndScale( bool center, Dali::Vector& points ); - void CreateGeometryArray(Dali::Vector & vertices, - Dali::Vector & textures, - Dali::Vector & verticesExt, - Dali::Vector & indices); + void CreateGeometryArray( Dali::Vector & vertices, + Dali::Vector & textures, + Dali::Vector & verticesExt, + Dali::Vector & indices ); }; diff --git a/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp new file mode 100644 index 0000000..8b3256d --- /dev/null +++ b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp @@ -0,0 +1,553 @@ +/* + * 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 +#include +#include +#include +#include + +//INTERNAL INCLUDES +#include +#include +#include +#include + +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& 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 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 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 diff --git a/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h new file mode 100644 index 0000000..ede12fb --- /dev/null +++ b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h @@ -0,0 +1,207 @@ +#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 +#include + +// INTERNAL INCLUDES +#include +#include + +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& 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__ */ diff --git a/dali-toolkit/internal/controls/renderers/renderer-factory-impl.cpp b/dali-toolkit/internal/controls/renderers/renderer-factory-impl.cpp index fb62e8c..fe00209 100644 --- a/dali-toolkit/internal/controls/renderers/renderer-factory-impl.cpp +++ b/dali-toolkit/internal/controls/renderers/renderer-factory-impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -82,7 +83,7 @@ RendererFactory::RendererType RendererFactory::GetRendererType( const Property:: std::string typeValue ; if( type && type->Get( typeValue )) { - if( typeValue == COLOR_RENDERER ) + if( typeValue == COLOR_RENDERER ) { rendererType = COLOR; } @@ -90,14 +91,18 @@ RendererFactory::RendererType RendererFactory::GetRendererType( const Property:: { 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 @@ -177,6 +182,11 @@ Toolkit::ControlRenderer RendererFactory::GetControlRenderer( const Property::Ma rendererPtr = new SvgRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) ); break; } + case MESH: + { + rendererPtr = new MeshRenderer( *( mFactoryCache.Get() ) ); + break; + } case UNDEFINED: default: { @@ -444,12 +454,13 @@ void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& //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; @@ -485,4 +496,3 @@ void RendererFactory::CreateAtlasManager() } // namespace Toolkit } // namespace Dali - diff --git a/dali-toolkit/internal/controls/renderers/renderer-factory-impl.h b/dali-toolkit/internal/controls/renderers/renderer-factory-impl.h index b9d5cf1..87e321f 100644 --- a/dali-toolkit/internal/controls/renderers/renderer-factory-impl.h +++ b/dali-toolkit/internal/controls/renderers/renderer-factory-impl.h @@ -54,6 +54,7 @@ public: IMAGE, N_PATCH, SVG, + MESH, UNDEFINED }; diff --git a/dali-toolkit/internal/controls/renderers/renderer-string-constants.cpp b/dali-toolkit/internal/controls/renderers/renderer-string-constants.cpp index ef01bd1..a5eb87a 100644 --- a/dali-toolkit/internal/controls/renderers/renderer-string-constants.cpp +++ b/dali-toolkit/internal/controls/renderers/renderer-string-constants.cpp @@ -32,9 +32,17 @@ const char * const COLOR_RENDERER("color"); 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 diff --git a/dali-toolkit/internal/controls/renderers/renderer-string-constants.h b/dali-toolkit/internal/controls/renderers/renderer-string-constants.h index ebaf29f..51e13f0 100644 --- a/dali-toolkit/internal/controls/renderers/renderer-string-constants.h +++ b/dali-toolkit/internal/controls/renderers/renderer-string-constants.h @@ -32,9 +32,17 @@ extern const char * const COLOR_RENDERER; 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 diff --git a/dali-toolkit/internal/controls/renderers/svg/svg-rasterize-thread.cpp b/dali-toolkit/internal/controls/renderers/svg/svg-rasterize-thread.cpp index a2c1ad7..9e2e707 100644 --- a/dali-toolkit/internal/controls/renderers/svg/svg-rasterize-thread.cpp +++ b/dali-toolkit/internal/controls/renderers/svg/svg-rasterize-thread.cpp @@ -19,8 +19,8 @@ #include "svg-rasterize-thread.h" // INTERNAL INCLUDES -#include "nanosvg/nanosvgrast.h" -#include "svg-renderer.h" +#include +#include namespace Dali { diff --git a/dali-toolkit/internal/controls/renderers/svg/svg-renderer.cpp b/dali-toolkit/internal/controls/renderers/svg/svg-renderer.cpp index ce3dbc0..8fbf70a 100644 --- a/dali-toolkit/internal/controls/renderers/svg/svg-renderer.cpp +++ b/dali-toolkit/internal/controls/renderers/svg/svg-renderer.cpp @@ -26,8 +26,8 @@ #include // INTERNAL INCLUDES -#include "nanosvg/nanosvg.h" -#include "svg-rasterize-thread.h" +#include +#include #include #include #include diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index f9edbdd..a33845e 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -25,10 +25,9 @@ toolkit_src_files = \ $(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 \ @@ -38,7 +37,6 @@ toolkit_src_files = \ $(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 \ diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index cf47cb3..ff03ac9 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -486,7 +486,6 @@ struct Decorator::Impl : public ConnectionTracker { 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 ) @@ -502,7 +501,15 @@ struct Decorator::Impl : public ConnectionTracker 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 ); + } } } diff --git a/dali-toolkit/internal/text/logical-model-impl.cpp b/dali-toolkit/internal/text/logical-model-impl.cpp index b9921c2..dcfb3e4 100644 --- a/dali-toolkit/internal/text/logical-model-impl.cpp +++ b/dali-toolkit/internal/text/logical-model-impl.cpp @@ -53,9 +53,10 @@ Script LogicalModel::GetScript( CharacterIndex characterIndex ) const { // 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 ) ) diff --git a/dali-toolkit/internal/text/multi-language-helper-functions.cpp b/dali-toolkit/internal/text/multi-language-helper-functions.cpp index 06b0f10..731b89d 100644 --- a/dali-toolkit/internal/text/multi-language-helper-functions.cpp +++ b/dali-toolkit/internal/text/multi-language-helper-functions.cpp @@ -32,6 +32,7 @@ namespace Text void MergeFontDescriptions( const Vector& fontDescriptions, Vector& fontIds, + Vector& isDefaultFont, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultPointSize, CharacterIndex startIndex, @@ -43,6 +44,9 @@ void MergeFontDescriptions( const Vector& fontDescriptions, // 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; @@ -57,7 +61,7 @@ void MergeFontDescriptions( const Vector& fontDescriptions, const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters; for( CharacterIndex index = startIndex; index < lastCharacterPlusOne; ++index ) { - bool defaultFont = true; + bool& defaultFont = *(isDefaultFontBuffer + index - startIndex ); Length runIndex = 0u; diff --git a/dali-toolkit/internal/text/multi-language-helper-functions.h b/dali-toolkit/internal/text/multi-language-helper-functions.h index b73da2f..8052638 100644 --- a/dali-toolkit/internal/text/multi-language-helper-functions.h +++ b/dali-toolkit/internal/text/multi-language-helper-functions.h @@ -39,6 +39,7 @@ namespace Text * * @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. @@ -46,6 +47,7 @@ namespace Text */ void MergeFontDescriptions( const Vector& fontDescriptions, Vector& fontIds, + Vector& isDefaultFont, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultPointSize, CharacterIndex startIndex, diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index ec9167b..1e8abf2 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -47,7 +47,7 @@ namespace Text namespace Internal { -bool ValidateFontsPerScript::FindValidFont( FontId fontId ) const +bool ValidateFontsPerScript::IsValidFont( FontId fontId ) const { for( Vector::ConstIterator it = mValidFonts.Begin(), endIt = mValidFonts.End(); @@ -186,7 +186,7 @@ void MultilanguageSupport::SetScripts( const Vector& text, // 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. @@ -238,7 +238,7 @@ void MultilanguageSupport::SetScripts( const Vector& text, currentScriptRun.characterRun.numberOfCharacters = 0u; currentScriptRun.script = TextAbstraction::UNKNOWN; numberOfAllScriptCharacters = 0u; - } + } // Get the next character. ++index; @@ -415,8 +415,11 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, // Merge font descriptions Vector fontIds; fontIds.Resize( numberOfCharacters, defaultFontId ); + Vector isDefaultFont; + isDefaultFont.Resize( numberOfCharacters, true ); MergeFontDescriptions( fontDescriptions, fontIds, + isDefaultFont, defaultFontDescription, defaultPointSize, startIndex, @@ -424,26 +427,35 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, const Character* const textBuffer = text.Begin(); const FontId* const fontIdsBuffer = fontIds.Begin(); + const bool* const isDefaultFontBuffer = isDefaultFont.Begin(); Vector::ConstIterator scriptRunIt = scripts.Begin(); Vector::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 ) @@ -466,12 +478,10 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, } #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; @@ -480,112 +490,136 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, 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 { @@ -600,6 +634,12 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, } #endif + if( isFirstSetToBeValidated && !isCommonScript ) + { + currentFontRun.fontId = fontId; + isFirstSetToBeValidated = false; + } + // The font is now validated. if( ( fontId != currentFontRun.fontId ) || isNewParagraphCharacter ) @@ -617,6 +657,11 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, 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. @@ -624,7 +669,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, // Whether the current character is a new paragraph character. isNewParagraphCharacter = TextAbstraction::IsNewParagraph( character ); - } + previousFontId = currentFontId; + } // end traverse characters. if( 0u != currentFontRun.characterRun.numberOfCharacters ) { diff --git a/dali-toolkit/internal/text/multi-language-support-impl.h b/dali-toolkit/internal/text/multi-language-support-impl.h index 283b021..ff5e94d 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.h +++ b/dali-toolkit/internal/text/multi-language-support-impl.h @@ -67,7 +67,7 @@ struct ValidateFontsPerScript * * @return @e true if the font is in the vector of valid fonts. */ - bool FindValidFont( FontId fontId ) const; + bool IsValidFont( FontId fontId ) const; Vector mValidFonts; }; diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index e248c25..aad550c 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -161,6 +161,13 @@ bool Controller::Impl::ProcessInputEvents() } } + if( mEventData->mUpdateCursorPosition || + mEventData->mUpdateLeftSelectionPosition || + mEventData->mUpdateRightSelectionPosition ) + { + NotifyImfManager(); + } + // The cursor must also be repositioned after inserts into the model if( mEventData->mUpdateCursorPosition ) { @@ -276,6 +283,80 @@ bool Controller::Impl::ProcessInputEvents() 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; diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index cefc5aa..003aec5 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -429,6 +429,37 @@ struct Controller::Impl } } + /** + * @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() ); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 2891953..96a2dc3 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -292,9 +292,6 @@ void Controller::SetText( const std::string& text ) mImpl->mEventData->mEventQueue.clear(); } - // Notify IMF as text changed - NotifyImfManager(); - // Do this last since it provides callbacks into application code mImpl->mControlInterface.TextChanged(); } @@ -303,12 +300,8 @@ void Controller::GetText( std::string& text ) const { if( !mImpl->IsShowingPlaceholderText() ) { - Vector& utf32Characters = mImpl->mLogicalModel->mText; - - if( 0u != utf32Characters.Count() ) - { - Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), text ); - } + // Retrieves the text string. + mImpl->GetText( 0u, text ); } else { @@ -316,16 +309,6 @@ void Controller::GetText( std::string& text ) const } } -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 ) @@ -2018,9 +2001,13 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) 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 ); } @@ -2564,12 +2551,6 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt 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() ) { @@ -2632,35 +2613,36 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt 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() ) @@ -2673,17 +2655,16 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons } 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: @@ -2693,12 +2674,6 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons } } // end switch - if( ImfManager::GETSURROUNDING != imfEvent.eventName ) - { - GetText( text ); - cursorPosition = GetLogicalCursorPosition(); - } - if( requestRelayout ) { mImpl->mOperationsPending = ALL_OPERATIONS; @@ -2708,7 +2683,32 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons 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; } @@ -2746,11 +2746,6 @@ bool Controller::BackspaceKeyEvent() 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() ) { @@ -2767,23 +2762,6 @@ bool Controller::BackspaceKeyEvent() 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() ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 7badd1e..e559fad 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -191,7 +191,7 @@ public: /** * @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; @@ -212,13 +212,6 @@ public: 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. @@ -963,11 +956,6 @@ private: bool BackspaceKeyEvent(); /** - * @brief Helper to notify IMF manager with surrounding text & cursor changes. - */ - void NotifyImfManager(); - - /** * @brief Helper to clear font-specific data. */ void ShowPlaceholderText(); diff --git a/dali-toolkit/public-api/controls/model3d-view/model3d-view.h b/dali-toolkit/public-api/controls/model3d-view/model3d-view.h index 536df51..85b8aa8 100644 --- a/dali-toolkit/public-api/controls/model3d-view/model3d-view.h +++ b/dali-toolkit/public-api/controls/model3d-view/model3d-view.h @@ -83,7 +83,6 @@ public: DIFFUSE_WITH_NORMAL_MAP }; - /** * @brief Create a new instance of a Model3dView control. * diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index ef55c84..a4e1d30 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit 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 diff --git a/dali-toolkit/internal/controls/flex-container/layout.c b/dali-toolkit/third-party/facebook-flexbox/layout.c similarity index 100% rename from dali-toolkit/internal/controls/flex-container/layout.c rename to dali-toolkit/third-party/facebook-flexbox/layout.c diff --git a/dali-toolkit/internal/controls/flex-container/layout.h b/dali-toolkit/third-party/facebook-flexbox/layout.h similarity index 100% rename from dali-toolkit/internal/controls/flex-container/layout.h rename to dali-toolkit/third-party/facebook-flexbox/layout.h diff --git a/dali-toolkit/third-party/file.list b/dali-toolkit/third-party/file.list new file mode 100644 index 0000000..53e027f --- /dev/null +++ b/dali-toolkit/third-party/file.list @@ -0,0 +1,4 @@ +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 diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc b/dali-toolkit/third-party/nanosvg/nanosvg.cc similarity index 100% rename from dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc rename to dali-toolkit/third-party/nanosvg/nanosvg.cc diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h b/dali-toolkit/third-party/nanosvg/nanosvg.h similarity index 100% rename from dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h rename to dali-toolkit/third-party/nanosvg/nanosvg.h diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc b/dali-toolkit/third-party/nanosvg/nanosvgrast.cc similarity index 100% rename from dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc rename to dali-toolkit/third-party/nanosvg/nanosvgrast.cc diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.h b/dali-toolkit/third-party/nanosvg/nanosvgrast.h similarity index 100% rename from dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.h rename to dali-toolkit/third-party/nanosvg/nanosvgrast.h diff --git a/docs/content/images/renderers/mesh-renderer.png b/docs/content/images/renderers/mesh-renderer.png new file mode 100644 index 0000000..d5e8ca0 Binary files /dev/null and b/docs/content/images/renderers/mesh-renderer.png differ diff --git a/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md b/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md index b19b5dd..6930b03 100644 --- a/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md +++ b/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md @@ -14,6 +14,7 @@ DALi provides the following renderers: + [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. @@ -423,6 +424,42 @@ control.background = }; ~~~ +___________________________________________________________________________________________________ + +## 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 */ diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 7ec107a..80ce145 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ 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 @@ -37,6 +37,12 @@ BuildRequires: dali-adaptor-devel %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. @@ -155,4 +161,3 @@ exit 0 %defattr(-,root,root,-) %{dev_include_path}/%{name}/* %{_libdir}/pkgconfig/*.pc -