matrix: check DIRTY_TYPE flag in _cogl_matrix_print

when printing a matrix we aim to print out the matrix type but we
weren't checking the flags first to see if the type is valid. We now
check for the DIRTY_TYPE flag and if not set we also validate the matrix
type isn't out of range.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2011-10-17 10:19:10 +01:00
parent a054b53891
commit fd67ddd56e

View File

@ -107,7 +107,8 @@ enum CoglMatrixType {
COGL_MATRIX_TYPE_PERSPECTIVE, /**< perspective projection matrix */ COGL_MATRIX_TYPE_PERSPECTIVE, /**< perspective projection matrix */
COGL_MATRIX_TYPE_2D, /**< 2-D transformation */ COGL_MATRIX_TYPE_2D, /**< 2-D transformation */
COGL_MATRIX_TYPE_2D_NO_ROT, /**< 2-D scale & translate only */ COGL_MATRIX_TYPE_2D_NO_ROT, /**< 2-D scale & translate only */
COGL_MATRIX_TYPE_3D /**< 3-D transformation */ COGL_MATRIX_TYPE_3D, /**< 3-D transformation */
COGL_MATRIX_N_TYPES
} ; } ;
#define DEG2RAD (G_PI/180.0) #define DEG2RAD (G_PI/180.0)
@ -372,8 +373,15 @@ print_matrix_floats (const float m[16])
void void
_cogl_matrix_print (const CoglMatrix *matrix) _cogl_matrix_print (const CoglMatrix *matrix)
{ {
g_print ("Matrix type: %s, flags: %x\n", if (!(matrix->flags & MAT_DIRTY_TYPE))
types[matrix->type], (int)matrix->flags); {
g_return_if_fail (matrix->type < COGL_MATRIX_N_TYPES);
g_print ("Matrix type: %s, flags: %x\n",
types[matrix->type], (int)matrix->flags);
}
else
g_print ("Matrix type: DIRTY, flags: %x\n", (int)matrix->flags);
print_matrix_floats ((float *)matrix); print_matrix_floats ((float *)matrix);
g_print ("Inverse: \n"); g_print ("Inverse: \n");
if (!(matrix->flags & MAT_DIRTY_INVERSE)) if (!(matrix->flags & MAT_DIRTY_INVERSE))