cogl/matrix-stack: Use graphene types on entries

This will help moving to graphene_matrix_t, since the convertions
between nodes and graphene types won't be necessary anymore.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
This commit is contained in:
Georges Basile Stavracas Neto 2019-02-21 09:56:51 -03:00
parent bdf5e3f357
commit 8cfa8dc0c1
2 changed files with 25 additions and 36 deletions

View File

@ -68,9 +68,7 @@ typedef struct _CoglMatrixEntryTranslate
{ {
CoglMatrixEntry _parent_data; CoglMatrixEntry _parent_data;
float x; graphene_point3d_t translate;
float y;
float z;
} CoglMatrixEntryTranslate; } CoglMatrixEntryTranslate;
@ -79,9 +77,7 @@ typedef struct _CoglMatrixEntryRotate
CoglMatrixEntry _parent_data; CoglMatrixEntry _parent_data;
float angle; float angle;
float x; graphene_vec3_t axis;
float y;
float z;
} CoglMatrixEntryRotate; } CoglMatrixEntryRotate;

View File

@ -158,9 +158,7 @@ cogl_matrix_stack_translate (CoglMatrixStack *stack,
entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_TRANSLATE); entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_TRANSLATE);
entry->x = x; graphene_point3d_init (&entry->translate, x, y, z);
entry->y = y;
entry->z = z;
} }
void void
@ -175,9 +173,7 @@ cogl_matrix_stack_rotate (CoglMatrixStack *stack,
entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_ROTATE); entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_ROTATE);
entry->angle = angle; entry->angle = angle;
entry->x = x; graphene_vec3_init (&entry->axis, x, y, z);
entry->y = y;
entry->z = z;
} }
void void
@ -540,9 +536,9 @@ initialized:
CoglMatrixEntryTranslate *translate = CoglMatrixEntryTranslate *translate =
(CoglMatrixEntryTranslate *)children[i]; (CoglMatrixEntryTranslate *)children[i];
cogl_matrix_translate (matrix, cogl_matrix_translate (matrix,
translate->x, translate->translate.x,
translate->y, translate->translate.y,
translate->z); translate->translate.z);
continue; continue;
} }
case COGL_MATRIX_OP_ROTATE: case COGL_MATRIX_OP_ROTATE:
@ -551,9 +547,9 @@ initialized:
(CoglMatrixEntryRotate *)children[i]; (CoglMatrixEntryRotate *)children[i];
cogl_matrix_rotate (matrix, cogl_matrix_rotate (matrix,
rotate->angle, rotate->angle,
rotate->x, graphene_vec3_get_x (&rotate->axis),
rotate->y, graphene_vec3_get_y (&rotate->axis),
rotate->z); graphene_vec3_get_z (&rotate->axis));
continue; continue;
} }
case COGL_MATRIX_OP_ROTATE_EULER: case COGL_MATRIX_OP_ROTATE_EULER:
@ -756,9 +752,9 @@ cogl_matrix_entry_calculate_translation (CoglMatrixEntry *entry0,
translate = (CoglMatrixEntryTranslate *)node0; translate = (CoglMatrixEntryTranslate *)node0;
*x = *x - translate->x; *x = *x - translate->translate.x;
*y = *y - translate->y; *y = *y - translate->translate.y;
*z = *z - translate->z; *z = *z - translate->translate.z;
} }
for (head1 = common_ancestor1->next; head1; head1 = head1->next) for (head1 = common_ancestor1->next; head1; head1 = head1->next)
{ {
@ -771,9 +767,9 @@ cogl_matrix_entry_calculate_translation (CoglMatrixEntry *entry0,
translate = (CoglMatrixEntryTranslate *)node1; translate = (CoglMatrixEntryTranslate *)node1;
*x = *x + translate->x; *x = *x + translate->translate.x;
*y = *y + translate->y; *y = *y + translate->translate.y;
*z = *z + translate->z; *z = *z + translate->translate.z;
} }
return TRUE; return TRUE;
@ -936,9 +932,8 @@ cogl_matrix_entry_equal (CoglMatrixEntry *entry0,
/* We could perhaps use an epsilon to compare here? /* We could perhaps use an epsilon to compare here?
* I expect the false negatives are probaly never going to * I expect the false negatives are probaly never going to
* be a problem and this is a bit cheaper. */ * be a problem and this is a bit cheaper. */
if (translate0->x != translate1->x || if (!graphene_point3d_equal (&translate0->translate,
translate0->y != translate1->y || &translate1->translate))
translate0->z != translate1->z)
return FALSE; return FALSE;
} }
break; break;
@ -949,9 +944,7 @@ cogl_matrix_entry_equal (CoglMatrixEntry *entry0,
CoglMatrixEntryRotate *rotate1 = CoglMatrixEntryRotate *rotate1 =
(CoglMatrixEntryRotate *)entry1; (CoglMatrixEntryRotate *)entry1;
if (rotate0->angle != rotate1->angle || if (rotate0->angle != rotate1->angle ||
rotate0->x != rotate1->x || !graphene_vec3_equal (&rotate0->axis, &rotate1->axis))
rotate0->y != rotate1->y ||
rotate0->z != rotate1->z)
return FALSE; return FALSE;
} }
break; break;
@ -1038,9 +1031,9 @@ cogl_debug_matrix_entry_print (CoglMatrixEntry *entry)
CoglMatrixEntryTranslate *translate = CoglMatrixEntryTranslate *translate =
(CoglMatrixEntryTranslate *)entry; (CoglMatrixEntryTranslate *)entry;
g_print (" TRANSLATE X=%f Y=%f Z=%f\n", g_print (" TRANSLATE X=%f Y=%f Z=%f\n",
translate->x, translate->translate.x,
translate->y, translate->translate.y,
translate->z); translate->translate.z);
continue; continue;
} }
case COGL_MATRIX_OP_ROTATE: case COGL_MATRIX_OP_ROTATE:
@ -1049,9 +1042,9 @@ cogl_debug_matrix_entry_print (CoglMatrixEntry *entry)
(CoglMatrixEntryRotate *)entry; (CoglMatrixEntryRotate *)entry;
g_print (" ROTATE ANGLE=%f X=%f Y=%f Z=%f\n", g_print (" ROTATE ANGLE=%f X=%f Y=%f Z=%f\n",
rotate->angle, rotate->angle,
rotate->x, graphene_vec3_get_x (&rotate->axis),
rotate->y, graphene_vec3_get_y (&rotate->axis),
rotate->z); graphene_vec3_get_z (&rotate->axis));
continue; continue;
} }
case COGL_MATRIX_OP_ROTATE_EULER: case COGL_MATRIX_OP_ROTATE_EULER: