summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorse.osadchy <se.osadchy@samsung.com>2015-12-02 14:14:17 -0800
committerChris Michael <cp.michael@samsung.com>2015-12-03 11:31:07 -0500
commitf8e7f0d2accb7dfbb785e0ae8514cbe31160e16b (patch)
tree3962bda153b1faf82b965867347ec3cc8e8ef982
parent77b3975640b9ead17743c36d4d1116dd29f4667d (diff)
evas: fix bug with logic with eina_matrix in evas_3d_utils
Summary: Also need to fix logically dead code in coverity. Reviewers: raster, Hermet, cedric Subscribers: jpeg Maniphest Tasks: T2832 Differential Revision: https://phab.enlightenment.org/D3346 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/Makefile_Evas.am1
-rw-r--r--src/lib/eina/eina_matrix.c32
-rw-r--r--src/lib/evas/include/evas_3d_utils.h32
-rw-r--r--src/tests/evas/evas_suite.c1
-rw-r--r--src/tests/evas/evas_suite.h1
-rw-r--r--src/tests/evas/evas_test_matrix.c41
6 files changed, 76 insertions, 32 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 0c9a21438d..3c1f491393 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -2132,6 +2132,7 @@ tests/evas/evas_test_image.c \
2132tests/evas/evas_test_mesh.c \ 2132tests/evas/evas_test_mesh.c \
2133tests/evas/evas_test_mask.c \ 2133tests/evas/evas_test_mask.c \
2134tests/evas/evas_test_evasgl.c \ 2134tests/evas/evas_test_evasgl.c \
2135tests/evas/evas_test_matrix.c \
2135tests/evas/evas_tests_helpers.h \ 2136tests/evas/evas_tests_helpers.h \
2136tests/evas/evas_suite.h 2137tests/evas/evas_suite.h
2137 2138
diff --git a/src/lib/eina/eina_matrix.c b/src/lib/eina/eina_matrix.c
index 7a1469c1b0..13362f95ee 100644
--- a/src/lib/eina/eina_matrix.c
+++ b/src/lib/eina/eina_matrix.c
@@ -1004,40 +1004,40 @@ eina_matrix4_multiply(Eina_Matrix4 *out, const Eina_Matrix4 *mat_a,
1004 } 1004 }
1005 1005
1006 MATRIX_XX(out) = MATRIX_XX(mat_a) * MATRIX_XX(mat_b) + MATRIX_YX(mat_a) * MATRIX_XY(mat_b) + 1006 MATRIX_XX(out) = MATRIX_XX(mat_a) * MATRIX_XX(mat_b) + MATRIX_YX(mat_a) * MATRIX_XY(mat_b) +
1007 MATRIX_ZX(mat_a) * MATRIX_XZ(mat_b) + mat_a->wx * MATRIX_XW(mat_b); 1007 MATRIX_ZX(mat_a) * MATRIX_XZ(mat_b) + MATRIX_WX(mat_a) * MATRIX_XW(mat_b);
1008 MATRIX_YX(out) = MATRIX_XX(mat_a) * MATRIX_YX(mat_b) + MATRIX_YX(mat_a) * MATRIX_YY(mat_b) + 1008 MATRIX_YX(out) = MATRIX_XX(mat_a) * MATRIX_YX(mat_b) + MATRIX_YX(mat_a) * MATRIX_YY(mat_b) +
1009 MATRIX_ZX(mat_a) * MATRIX_YZ(mat_b) + mat_a->wx * MATRIX_YW(mat_b); 1009 MATRIX_ZX(mat_a) * MATRIX_YZ(mat_b) + MATRIX_WX(mat_a) * MATRIX_YW(mat_b);
1010 MATRIX_ZX(out) = MATRIX_XX(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YX(mat_a) * MATRIX_ZY(mat_b) + 1010 MATRIX_ZX(out) = MATRIX_XX(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YX(mat_a) * MATRIX_ZY(mat_b) +
1011 MATRIX_ZX(mat_a) * MATRIX_ZZ(mat_b) + mat_a->wx * MATRIX_ZW(mat_b); 1011 MATRIX_ZX(mat_a) * MATRIX_ZZ(mat_b) + MATRIX_WX(mat_a) * MATRIX_ZW(mat_b);
1012 MATRIX_WX(out) = MATRIX_XX(mat_a) * MATRIX_WX(mat_b) + MATRIX_YX(mat_a) * MATRIX_WY(mat_b) + 1012 MATRIX_WX(out) = MATRIX_XX(mat_a) * MATRIX_WX(mat_b) + MATRIX_YX(mat_a) * MATRIX_WY(mat_b) +
1013 MATRIX_ZX(mat_a) * MATRIX_WZ(mat_b) + mat_a->wx * MATRIX_WW(mat_b); 1013 MATRIX_ZX(mat_a) * MATRIX_WZ(mat_b) + MATRIX_WX(mat_a) * MATRIX_WW(mat_b);
1014 1014
1015 MATRIX_XY(out) = MATRIX_XY(mat_a) * MATRIX_XX(mat_b) + MATRIX_YY(mat_a) * MATRIX_XY(mat_b) + 1015 MATRIX_XY(out) = MATRIX_XY(mat_a) * MATRIX_XX(mat_b) + MATRIX_YY(mat_a) * MATRIX_XY(mat_b) +
1016 MATRIX_ZY(mat_a) * MATRIX_XZ(mat_b) + mat_a->wy * MATRIX_XW(mat_b); 1016 MATRIX_ZY(mat_a) * MATRIX_XZ(mat_b) + MATRIX_WY(mat_a) * MATRIX_XW(mat_b);
1017 MATRIX_YY(out) = MATRIX_XY(mat_a) * MATRIX_YX(mat_b) + MATRIX_YY(mat_a) * MATRIX_YY(mat_b) + 1017 MATRIX_YY(out) = MATRIX_XY(mat_a) * MATRIX_YX(mat_b) + MATRIX_YY(mat_a) * MATRIX_YY(mat_b) +
1018 MATRIX_ZY(mat_a) * MATRIX_YZ(mat_b) + mat_a->wy * MATRIX_YW(mat_b); 1018 MATRIX_ZY(mat_a) * MATRIX_YZ(mat_b) + MATRIX_WY(mat_a) * MATRIX_YW(mat_b);
1019 MATRIX_ZY(out) = MATRIX_XY(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YY(mat_a) * MATRIX_ZY(mat_b) + 1019 MATRIX_ZY(out) = MATRIX_XY(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YY(mat_a) * MATRIX_ZY(mat_b) +
1020 MATRIX_ZY(mat_a) * MATRIX_ZZ(mat_b) + mat_a->wy * MATRIX_ZW(mat_b); 1020 MATRIX_ZY(mat_a) * MATRIX_ZZ(mat_b) + MATRIX_WY(mat_a) * MATRIX_ZW(mat_b);
1021 MATRIX_WY(out) = MATRIX_XY(mat_a) * MATRIX_WX(mat_b) + MATRIX_YY(mat_a) * MATRIX_WY(mat_b) + 1021 MATRIX_WY(out) = MATRIX_XY(mat_a) * MATRIX_WX(mat_b) + MATRIX_YY(mat_a) * MATRIX_WY(mat_b) +
1022 MATRIX_ZY(mat_a) * MATRIX_WZ(mat_b) + mat_a->wy * MATRIX_WW(mat_b); 1022 MATRIX_ZY(mat_a) * MATRIX_WZ(mat_b) + MATRIX_WY(mat_a) * MATRIX_WW(mat_b);
1023 1023
1024 MATRIX_XZ(out) = MATRIX_XZ(mat_a) * MATRIX_XX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_XY(mat_b) + 1024 MATRIX_XZ(out) = MATRIX_XZ(mat_a) * MATRIX_XX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_XY(mat_b) +
1025 MATRIX_ZZ(mat_a) * MATRIX_XZ(mat_b) + mat_a->wz * MATRIX_XW(mat_b); 1025 MATRIX_ZZ(mat_a) * MATRIX_XZ(mat_b) + MATRIX_WZ(mat_a) * MATRIX_XW(mat_b);
1026 MATRIX_YZ(out) = MATRIX_XZ(mat_a) * MATRIX_YX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_YY(mat_b) + 1026 MATRIX_YZ(out) = MATRIX_XZ(mat_a) * MATRIX_YX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_YY(mat_b) +
1027 MATRIX_ZZ(mat_a) * MATRIX_YZ(mat_b) + mat_a->wz * MATRIX_YW(mat_b); 1027 MATRIX_ZZ(mat_a) * MATRIX_YZ(mat_b) + MATRIX_WZ(mat_a) * MATRIX_YW(mat_b);
1028 MATRIX_ZZ(out) = MATRIX_XZ(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_ZY(mat_b) + 1028 MATRIX_ZZ(out) = MATRIX_XZ(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_ZY(mat_b) +
1029 MATRIX_ZZ(mat_a) * MATRIX_ZZ(mat_b) + mat_a->wz * MATRIX_ZW(mat_b); 1029 MATRIX_ZZ(mat_a) * MATRIX_ZZ(mat_b) + MATRIX_WZ(mat_a) * MATRIX_ZW(mat_b);
1030 MATRIX_WZ(out) = MATRIX_XZ(mat_a) * MATRIX_WX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_WY(mat_b) + 1030 MATRIX_WZ(out) = MATRIX_XZ(mat_a) * MATRIX_WX(mat_b) + MATRIX_YZ(mat_a) * MATRIX_WY(mat_b) +
1031 MATRIX_ZZ(mat_a) * MATRIX_WZ(mat_b) + mat_a->wz * MATRIX_WW(mat_b); 1031 MATRIX_ZZ(mat_a) * MATRIX_WZ(mat_b) + MATRIX_WZ(mat_a) * MATRIX_WW(mat_b);
1032 1032
1033 MATRIX_XW(out) = MATRIX_XW(mat_a) * MATRIX_XX(mat_b) + MATRIX_YW(mat_a) * MATRIX_XY(mat_b) + 1033 MATRIX_XW(out) = MATRIX_XW(mat_a) * MATRIX_XX(mat_b) + MATRIX_YW(mat_a) * MATRIX_XY(mat_b) +
1034 MATRIX_ZW(mat_a) * MATRIX_XZ(mat_b) + mat_a->ww * MATRIX_XW(mat_b); 1034 MATRIX_ZW(mat_a) * MATRIX_XZ(mat_b) + MATRIX_WW(mat_a) * MATRIX_XW(mat_b);
1035 MATRIX_YW(out) = MATRIX_XW(mat_a) * MATRIX_YX(mat_b) + MATRIX_YW(mat_a) * MATRIX_YY(mat_b) + 1035 MATRIX_YW(out) = MATRIX_XW(mat_a) * MATRIX_YX(mat_b) + MATRIX_YW(mat_a) * MATRIX_YY(mat_b) +
1036 MATRIX_ZW(mat_a) * MATRIX_YZ(mat_b) + mat_a->ww * MATRIX_YW(mat_b); 1036 MATRIX_ZW(mat_a) * MATRIX_YZ(mat_b) + MATRIX_WW(mat_a) * MATRIX_YW(mat_b);
1037 MATRIX_ZW(out) = MATRIX_XW(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YW(mat_a) * MATRIX_ZY(mat_b) + 1037 MATRIX_ZW(out) = MATRIX_XW(mat_a) * MATRIX_ZX(mat_b) + MATRIX_YW(mat_a) * MATRIX_ZY(mat_b) +
1038 MATRIX_ZW(mat_a) * MATRIX_ZZ(mat_b) + mat_a->ww * MATRIX_ZW(mat_b); 1038 MATRIX_ZW(mat_a) * MATRIX_ZZ(mat_b) + MATRIX_WW(mat_a) * MATRIX_ZW(mat_b);
1039 MATRIX_WW(out) = MATRIX_XW(mat_a) * MATRIX_WX(mat_b) + MATRIX_YW(mat_a) * MATRIX_WY(mat_b) + 1039 MATRIX_WW(out) = MATRIX_XW(mat_a) * MATRIX_WX(mat_b) + MATRIX_YW(mat_a) * MATRIX_WY(mat_b) +
1040 MATRIX_ZW(mat_a) * MATRIX_WZ(mat_b) + mat_a->ww * MATRIX_WW(mat_b); 1040 MATRIX_ZW(mat_a) * MATRIX_WZ(mat_b) + MATRIX_WW(mat_a) * MATRIX_WW(mat_b);
1041} 1041}
1042 1042
1043EAPI void 1043EAPI void
diff --git a/src/lib/evas/include/evas_3d_utils.h b/src/lib/evas/include/evas_3d_utils.h
index 52a95116bd..f3d4ed07ff 100644
--- a/src/lib/evas/include/evas_3d_utils.h
+++ b/src/lib/evas/include/evas_3d_utils.h
@@ -373,8 +373,8 @@ evas_vec3_homogeneous_position_transform(Evas_Vec3 *out, const Evas_Vec3 *v, con
373 return; 373 return;
374 } 374 }
375 375
376 tmp.x = (m->xx * v->x) + (m->zw * v->y) + (m->zx * v->z) + m->wx; 376 tmp.x = (m->xx * v->x) + (m->yx * v->y) + (m->zx * v->z) + m->wx;
377 tmp.y = (m->xy * v->x) + (m->yx * v->y) + (m->zy * v->z) + m->wy; 377 tmp.y = (m->xy * v->x) + (m->yy * v->y) + (m->zy * v->z) + m->wy;
378 tmp.z = (m->xz * v->x) + (m->yz * v->y) + (m->zz * v->z) + m->wz; 378 tmp.z = (m->xz * v->x) + (m->yz * v->y) + (m->zz * v->z) + m->wz;
379 379
380 evas_vec3_scale(out, &tmp, 380 evas_vec3_scale(out, &tmp,
@@ -392,8 +392,8 @@ evas_vec3_homogeneous_direction_transform(Evas_Vec3 *out, const Evas_Vec3 *v, co
392 return; 392 return;
393 } 393 }
394 394
395 tmp.x = (m->xx * v->x) + (m->zw * v->y) + (m->zx * v->z); 395 tmp.x = (m->xx * v->x) + (m->yx * v->y) + (m->zx * v->z);
396 tmp.y = (m->xy * v->x) + (m->yx * v->y) + (m->zy * v->z); 396 tmp.y = (m->xy * v->x) + (m->yy * v->y) + (m->zy * v->z);
397 tmp.z = (m->xz * v->x) + (m->yz * v->y) + (m->zz * v->z); 397 tmp.z = (m->xz * v->x) + (m->yz * v->y) + (m->zz * v->z);
398 398
399 evas_vec3_copy(out, &tmp); 399 evas_vec3_copy(out, &tmp);
@@ -953,17 +953,17 @@ evas_mat4_build(Eina_Matrix4 *out,
953 evas_vec4_quaternion_rotation_matrix_get(orientation, &rot); 953 evas_vec4_quaternion_rotation_matrix_get(orientation, &rot);
954 954
955 out->xx = scale->x * rot.xx; 955 out->xx = scale->x * rot.xx;
956 out->xy = scale->y * rot.xy; 956 out->xy = scale->x * rot.xy;
957 out->xz = scale->z * rot.xz; 957 out->xz = scale->x * rot.xz;
958 out->xw = 0.0; 958 out->xw = 0.0;
959 959
960 out->yx = scale->x * rot.yx; 960 out->yx = scale->y * rot.yx;
961 out->yy = scale->y * rot.yy; 961 out->yy = scale->y * rot.yy;
962 out->yz = scale->z * rot.yz; 962 out->yz = scale->y * rot.yz;
963 out->yw = 0.0; 963 out->yw = 0.0;
964 964
965 out->zx = scale->x * rot.zx; 965 out->zx = scale->z * rot.zx;
966 out->zy = scale->y * rot.zy; 966 out->zy = scale->z * rot.zy;
967 out->zz = scale->z * rot.zz; 967 out->zz = scale->z * rot.zz;
968 out->zw = 0.0; 968 out->zw = 0.0;
969 969
@@ -998,17 +998,17 @@ evas_mat4_inverse_build(Eina_Matrix4 *out, const Evas_Vec3 *position,
998 evas_vec4_quaternion_rotation_matrix_get(&inv_rotation, &rot); 998 evas_vec4_quaternion_rotation_matrix_get(&inv_rotation, &rot);
999 999
1000 out->xx = inv_scale.x * rot.xx; 1000 out->xx = inv_scale.x * rot.xx;
1001 out->xy = inv_scale.y * rot.xy; 1001 out->xy = inv_scale.x * rot.xy;
1002 out->xz = inv_scale.z * rot.xz; 1002 out->xz = inv_scale.x * rot.xz;
1003 out->xw = 0.0; 1003 out->xw = 0.0;
1004 1004
1005 out->yx = inv_scale.x * rot.yx; 1005 out->yx = inv_scale.y * rot.yx;
1006 out->yy = inv_scale.y * rot.yy; 1006 out->yy = inv_scale.y * rot.yy;
1007 out->yz = inv_scale.z * rot.yz; 1007 out->yz = inv_scale.y * rot.yz;
1008 out->yw = 0.0; 1008 out->yw = 0.0;
1009 1009
1010 out->zx = inv_scale.x * rot.zx; 1010 out->zx = inv_scale.z * rot.zx;
1011 out->zy = inv_scale.y * rot.zy; 1011 out->zy = inv_scale.z * rot.zy;
1012 out->zz = inv_scale.z * rot.zz; 1012 out->zz = inv_scale.z * rot.zz;
1013 out->zw = 0.0; 1013 out->zw = 0.0;
1014 1014
diff --git a/src/tests/evas/evas_suite.c b/src/tests/evas/evas_suite.c
index 10a8d2732c..3654ab60dc 100644
--- a/src/tests/evas/evas_suite.c
+++ b/src/tests/evas/evas_suite.c
@@ -30,6 +30,7 @@ static const Evas_Test_Case etc[] = {
30 { "Masking", evas_test_mask }, 30 { "Masking", evas_test_mask },
31 { "Evas GL", evas_test_evasgl }, 31 { "Evas GL", evas_test_evasgl },
32 { "Object Smart", evas_test_object_smart }, 32 { "Object Smart", evas_test_object_smart },
33 { "Matrix", evas_test_matrix },
33 { NULL, NULL } 34 { NULL, NULL }
34}; 35};
35 36
diff --git a/src/tests/evas/evas_suite.h b/src/tests/evas/evas_suite.h
index bf77aee056..cb22dd4762 100644
--- a/src/tests/evas/evas_suite.h
+++ b/src/tests/evas/evas_suite.h
@@ -15,5 +15,6 @@ void evas_test_mesh(TCase *tc);
15void evas_test_mask(TCase *tc); 15void evas_test_mask(TCase *tc);
16void evas_test_evasgl(TCase *tc); 16void evas_test_evasgl(TCase *tc);
17void evas_test_object_smart(TCase *tc); 17void evas_test_object_smart(TCase *tc);
18void evas_test_matrix(TCase *tc);
18 19
19#endif /* _EVAS_SUITE_H */ 20#endif /* _EVAS_SUITE_H */
diff --git a/src/tests/evas/evas_test_matrix.c b/src/tests/evas/evas_test_matrix.c
new file mode 100644
index 0000000000..26e8b02f60
--- /dev/null
+++ b/src/tests/evas/evas_test_matrix.c
@@ -0,0 +1,41 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <sys/types.h>
6#include <sys/stat.h>
7#include <unistd.h>
8#include <stdio.h>
9
10#include "../../lib/evas/include/evas_common_private.h"
11#include "../../lib/evas/include/evas_private.h"
12#include "evas_suite.h"
13#include "Evas.h"
14#include "evas_tests_helpers.h"
15
16START_TEST(evas_matrix)
17{
18 Evas_Vec3 position;
19 Evas_Vec4 orientation;
20 Evas_Vec3 scale;
21 Eina_Matrix4 mat;
22
23 evas_vec3_set(&position, 5.0, 3.0, 2.0);
24 evas_vec4_set(&orientation, 30.0, 1.0, 0.0, 0.0);
25 evas_vec3_set(&scale, 1.0, 2.0, 1.0);
26
27 evas_mat4_build(&mat, &position, &orientation, &scale);
28 fail_if((mat.xx != -1) || (mat.xy != 60) ||
29 (mat.wx != 5) || (mat.wy != 3) ||
30 (mat.wz != 2) || (mat.ww != 1));
31
32 evas_mat4_inverse_build(&mat, &position, &orientation, &scale);
33 fail_if((mat.xx - 0.99 < DBL_EPSILON) || (mat.xy - 0.0 < DBL_EPSILON) ||
34 (mat.yx -0.0 < DBL_EPSILON) || (mat.yy -0.49 < DBL_EPSILON));
35}
36END_TEST
37
38void evas_test_matrix(TCase *tc)
39{
40 tcase_add_test(tc, evas_matrix);
41}