From 959a418cc345a74945fdb33ee4f08fc719ec44f8 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 16 Feb 2019 09:41:43 -0200 Subject: [PATCH] Replace CoglEuler by graphene_euler_t As the first step into removing Cogl types that are covered by Graphene, remove CoglEuler and replace it by graphene_euler_t. This is a mostly straightforward replacement, except that the naming conventions changed a bit. Cogl uses "heading" for the Y axis, "pitch" for the X axis, and "roll" for the Z axis, and graphene uses the axis themselves. That means the 1st and 2nd arguments need to be swapped. Also adapt the matrix stack to store a graphene_euler_t in the rotation node -- that simplifies the code a bit as well. https://gitlab.gnome.org/GNOME/mutter/merge_requests/458 --- cogl/cogl/cogl-euler.c | 196 --------------- cogl/cogl/cogl-euler.h | 265 --------------------- cogl/cogl/cogl-framebuffer.c | 2 +- cogl/cogl/cogl-framebuffer.h | 7 +- cogl/cogl/cogl-matrix-stack-private.h | 6 +- cogl/cogl/cogl-matrix-stack.c | 26 +- cogl/cogl/cogl-matrix-stack.h | 5 +- cogl/cogl/cogl-matrix.c | 10 +- cogl/cogl/cogl-matrix.h | 12 +- cogl/cogl/cogl-quaternion.c | 15 +- cogl/cogl/cogl-quaternion.h | 7 +- cogl/cogl/cogl-types.h | 6 +- cogl/cogl/cogl.h | 3 +- cogl/cogl/cogl.symbols | 13 - cogl/cogl/meson.build | 2 - cogl/tests/conform/test-euler-quaternion.c | 4 +- src/compositor/meta-shaped-texture.c | 23 +- 17 files changed, 60 insertions(+), 542 deletions(-) delete mode 100644 cogl/cogl/cogl-euler.c delete mode 100644 cogl/cogl/cogl-euler.h diff --git a/cogl/cogl/cogl-euler.c b/cogl/cogl/cogl-euler.c deleted file mode 100644 index 016aaa6c5..000000000 --- a/cogl/cogl/cogl-euler.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#include "cogl-config.h" - -#include -#include -#include -#include "cogl-gtype-private.h" - -#include -#include - -COGL_GTYPE_DEFINE_BOXED (Euler, euler, - cogl_euler_copy, - cogl_euler_free); - -void -cogl_euler_init (CoglEuler *euler, - float heading, - float pitch, - float roll) -{ - euler->heading = heading; - euler->pitch = pitch; - euler->roll = roll; -} - -void -cogl_euler_init_from_matrix (CoglEuler *euler, - const CoglMatrix *matrix) -{ - /* - * Extracting a canonical Euler angle from a matrix: - * (where it is assumed the matrix contains no scaling, mirroring or - * skewing) - * - * A Euler angle is a combination of three rotations around mutually - * perpendicular axis. For this algorithm they are: - * - * Heading: A rotation about the Y axis by an angle H: - * | cosH 0 sinH| - * | 0 1 0| - * |-sinH 0 cosH| - * - * Pitch: A rotation around the X axis by an angle P: - * |1 0 0| - * |0 cosP -sinP| - * |0 sinP cosP| - * - * Roll: A rotation about the Z axis by an angle R: - * |cosR -sinR 0| - * |sinR cosR 0| - * | 0 0 1| - * - * When multiplied as matrices this gives: - * | cosHcosR+sinHsinPsinR sinRcosP -sinHcosR+cosHsinPsinR| - * M = |-cosHsinR+sinHsinPcosR cosRcosP sinRsinH+cosHsinPcosB| - * | sinHcosP -sinP cosHcosP | - * - * Given that there are an infinite number of ways to represent - * a given orientation, the "canonical" Euler angle is any such that: - * -180 < H < 180, - * -180 < R < 180 and - * -90 < P < 90 - * - * M[3][2] = -sinP lets us immediately solve for P = asin(-M[3][2]) - * (Note: asin has a range of +-90) - * This gives cosP - * This means we can use M[3][1] to calculate sinH: - * sinH = M[3][1]/cosP - * And use M[3][3] to calculate cosH: - * cosH = M[3][3]/cosP - * This lets us calculate H = atan2(sinH,cosH), but we optimise this: - * 1st note: atan2(x, y) does: atan(x/y) and uses the sign of x and y to - * determine the quadrant of the final angle. - * 2nd note: we know cosP is > 0 (ignoring cosP == 0) - * Therefore H = atan2((M[3][1]/cosP) / (M[3][3]/cosP)) can be simplified - * by skipping the division by cosP since it won't change the x/y ratio - * nor will it change their sign. This gives: - * H = atan2(M[3][1], M[3][3]) - * R is computed in the same way as H from M[1][2] and M[2][2] so: - * R = atan2(M[1][2], M[2][2]) - * Note: If cosP were == 0 then H and R could not be calculated as above - * because all the necessary matrix values would == 0. In other words we are - * pitched vertically and so H and R would now effectively rotate around the - * same axis - known as "Gimbal lock". In this situation we will set all the - * rotation on H and set R = 0. - * So with P = R = 0 we have cosP = 0, sinR = 0 and cosR = 1 - * We can substitute those into the above equation for M giving: - * | cosH 0 -sinH| - * |sinHsinP 0 cosHsinP| - * | 0 -sinP 0| - * And calculate H as atan2 (-M[3][2], M[1][1]) - */ - - float sinP; - float H; /* heading */ - float P; /* pitch */ - float R; /* roll */ - - /* NB: CoglMatrix provides struct members named according to the - * [row][column] indexed. So matrix->zx is row 3 column 1. */ - sinP = -matrix->zy; - - /* Determine the Pitch, avoiding domain errors with asin () which - * might occur due to previous imprecision in manipulating the - * matrix. */ - if (sinP <= -1.0f) - P = -G_PI_2; - else if (sinP >= 1.0f) - P = G_PI_2; - else - P = asinf (sinP); - - /* If P is too close to 0 then we have hit Gimbal lock */ - if (sinP > 0.999f) - { - H = atan2f (-matrix->zy, matrix->xx); - R = 0; - } - else - { - H = atan2f (matrix->zx, matrix->zz); - R = atan2f (matrix->xy, matrix->yy); - } - - euler->heading = H; - euler->pitch = P; - euler->roll = R; -} - -gboolean -cogl_euler_equal (const void *v1, const void *v2) -{ - const CoglEuler *a = v1; - const CoglEuler *b = v2; - - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); - - if (v1 == v2) - return TRUE; - - return (a->heading == b->heading && - a->pitch == b->pitch && - a->roll == b->roll); -} - -CoglEuler * -cogl_euler_copy (const CoglEuler *src) -{ - if (G_LIKELY (src)) - { - CoglEuler *new = g_slice_new (CoglEuler); - memcpy (new, src, sizeof (float) * 3); - return new; - } - else - return NULL; -} - -void -cogl_euler_free (CoglEuler *euler) -{ - g_slice_free (CoglEuler, euler); -} - diff --git a/cogl/cogl/cogl-euler.h b/cogl/cogl/cogl-euler.h deleted file mode 100644 index 9b5f53aeb..000000000 --- a/cogl/cogl/cogl-euler.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __COGL_EULER_H -#define __COGL_EULER_H - -#include - -#include - -G_BEGIN_DECLS - -/** - * SECTION:cogl-euler - * @short_description: Functions for initializing and manipulating - * euler angles. - * - * Euler angles are a simple representation of a 3 dimensional - * rotation; comprised of 3 ordered heading, pitch and roll rotations. - * An important thing to understand is that the axis of rotation - * belong to the object being rotated and so they also rotate as each - * of the heading, pitch and roll rotations are applied. - * - * One way to consider euler angles is to imagine controlling an - * aeroplane, where you first choose a heading (Such as flying south - * east), then you set the pitch (such as 30 degrees to take off) and - * then you might set a roll, by dipping the left, wing as you prepare - * to turn. - * - * They have some advantages and limitations that it helps to be - * aware of: - * - * Advantages: - * - * - * Easy to understand and use, compared to quaternions and matrices, - * so may be a good choice for a user interface. - * - * - * Efficient storage, needing only 3 components any rotation can be - * represented. - * Actually the #CoglEuler type isn't optimized for size because - * we may cache the equivalent #CoglQuaternion along with a euler - * rotation, but it would be trivial for an application to track the - * components of euler rotations in a packed float array if optimizing - * for size was important. The values could be passed to Cogl only when - * manipulation is necessary. - * - * - * - * Disadvantages: - * - * - * Aliasing: it's possible to represent some rotations with multiple - * different heading, pitch and roll rotations. - * - * - * They can suffer from a problem called Gimbal Lock. A good - * explanation of this can be seen on wikipedia here: - * http://en.wikipedia.org/wiki/Gimbal_lock but basically two - * of the axis of rotation may become aligned and so you loose a - * degree of freedom. For example a pitch of +-90° would mean that - * heading and bank rotate around the same axis. - * - * - * If you use euler angles to orient something in 3D space and try to - * transition between orientations by interpolating the component - * angles you probably wont get the transitions you expect as they may - * not follow the shortest path between the two orientations. - * - * - * There's no standard to what order the component axis rotations are - * applied. The most common convention seems to be what we do in Cogl - * with heading (y-axis), pitch (x-axis) and then roll (z-axis), but - * other software might apply x-axis, y-axis then z-axis or any other - * order so you need to consider this if you are accepting euler - * rotations from some other software. Other software may also use - * slightly different aeronautical terms, such as "yaw" instead of - * "heading" or "bank" instead of "roll". - * - * - * - * To minimize the aliasing issue we may refer to "Canonical Euler" - * angles where heading and roll are restricted to +- 180° and pitch is - * restricted to +- 90°. If pitch is +- 90° bank is set to 0°. - * - * Quaternions don't suffer from Gimbal Lock and they can be nicely - * interpolated between, their disadvantage is that they don't have an - * intuitive representation. - * - * A common practice is to accept angles in the intuitive Euler form - * and convert them to quaternions internally to avoid Gimbal Lock and - * handle interpolations. See cogl_quaternion_init_from_euler(). - */ - -/** - * CoglEuler: - * @heading: Angle to rotate around an object's y axis - * @pitch: Angle to rotate around an object's x axis - * @roll: Angle to rotate around an object's z axis - * - * Represents an ordered rotation first of @heading degrees around an - * object's y axis, then @pitch degrees around an object's x axis and - * finally @roll degrees around an object's z axis. - * - * It's important to understand the that axis are associated - * with the object being rotated, so the axis also rotate in sequence - * with the rotations being applied. - * - * The members of a #CoglEuler can be initialized, for example, with - * cogl_euler_init() and cogl_euler_init_from_quaternion (). - * - * You may also want to look at cogl_quaternion_init_from_euler() if - * you want to do interpolation between 3d rotations. - * - * Since: 2.0 - */ -struct _CoglEuler -{ - /*< public > */ - float heading; - float pitch; - float roll; - - /*< private > */ - /* May cached a quaternion here in the future */ - float padding0; - float padding1; - float padding2; - float padding3; - float padding4; -}; -COGL_STRUCT_SIZE_ASSERT (CoglEuler, 32); - -/** - * cogl_euler_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ -GType cogl_euler_get_gtype (void); - -/** - * cogl_euler_init: - * @euler: The #CoglEuler angle to initialize - * @heading: Angle to rotate around an object's y axis - * @pitch: Angle to rotate around an object's x axis - * @roll: Angle to rotate around an object's z axis - * - * Initializes @euler to represent a rotation of @x_angle degrees - * around the x axis, then @y_angle degrees around the y_axis and - * @z_angle degrees around the z axis. - * - * Since: 2.0 - */ -void -cogl_euler_init (CoglEuler *euler, - float heading, - float pitch, - float roll); - -/** - * cogl_euler_init_from_matrix: - * @euler: The #CoglEuler angle to initialize - * @matrix: A #CoglMatrix containing a rotation, but no scaling, - * mirroring or skewing. - * - * Extracts a euler rotation from the given @matrix and - * initializses @euler with the component x, y and z rotation angles. - */ -void -cogl_euler_init_from_matrix (CoglEuler *euler, - const CoglMatrix *matrix); - -/** - * cogl_euler_init_from_quaternion: - * @euler: The #CoglEuler angle to initialize - * @quaternion: A #CoglEuler with the rotation to initialize with - * - * Initializes a @euler rotation with the equivalent rotation - * represented by the given @quaternion. - */ -void -cogl_euler_init_from_quaternion (CoglEuler *euler, - const CoglQuaternion *quaternion); - -/** - * cogl_euler_equal: - * @v1: The first euler angle to compare - * @v2: The second euler angle to compare - * - * Compares the two given euler angles @v1 and @v1 and it they are - * equal returns %TRUE else %FALSE. - * - * This function only checks that all three components rotations - * are numerically equal, it does not consider that some rotations - * can be represented with different component rotations - * - * Returns: %TRUE if @v1 and @v2 are equal else %FALSE. - * Since: 2.0 - */ -gboolean -cogl_euler_equal (const void *v1, const void *v2); - -/** - * cogl_euler_copy: - * @src: A #CoglEuler to copy - * - * Allocates a new #CoglEuler and initilizes it with the component - * angles of @src. The newly allocated euler should be freed using - * cogl_euler_free(). - * - * Returns: A newly allocated #CoglEuler - * Since: 2.0 - */ -CoglEuler * -cogl_euler_copy (const CoglEuler *src); - -/** - * cogl_euler_free: - * @euler: A #CoglEuler allocated via cogl_euler_copy() - * - * Frees a #CoglEuler that was previously allocated using - * cogl_euler_copy(). - * - * Since: 2.0 - */ -void -cogl_euler_free (CoglEuler *euler); - -G_END_DECLS - -#endif /* __COGL_EULER_H */ - diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 1114ce197..a032feb8c 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -1560,7 +1560,7 @@ cogl_framebuffer_rotate_quaternion (CoglFramebuffer *framebuffer, void cogl_framebuffer_rotate_euler (CoglFramebuffer *framebuffer, - const CoglEuler *euler) + const graphene_euler_t *euler) { CoglMatrixStack *modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer); diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index 08ed3354b..c3fc28d9b 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -53,10 +53,11 @@ typedef struct _CoglFramebuffer CoglFramebuffer; #include #include #include -#include #include #include +#include + G_BEGIN_DECLS /** @@ -380,7 +381,7 @@ cogl_framebuffer_rotate_quaternion (CoglFramebuffer *framebuffer, /** * cogl_framebuffer_rotate_euler: * @framebuffer: A #CoglFramebuffer pointer - * @euler: A #CoglEuler + * @euler: A #graphene_euler_t * * Multiplies the current model-view matrix by one that rotates * according to the rotation described by @euler. @@ -390,7 +391,7 @@ cogl_framebuffer_rotate_quaternion (CoglFramebuffer *framebuffer, */ void cogl_framebuffer_rotate_euler (CoglFramebuffer *framebuffer, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_framebuffer_transform: diff --git a/cogl/cogl/cogl-matrix-stack-private.h b/cogl/cogl/cogl-matrix-stack-private.h index dec789b8a..f510d97d7 100644 --- a/cogl/cogl/cogl-matrix-stack-private.h +++ b/cogl/cogl/cogl-matrix-stack-private.h @@ -90,11 +90,7 @@ typedef struct _CoglMatrixEntryRotateEuler { CoglMatrixEntry _parent_data; - /* This doesn't store an actual CoglEuler in order to avoid the - * padding */ - float heading; - float pitch; - float roll; + graphene_euler_t euler; } CoglMatrixEntryRotateEuler; typedef struct _CoglMatrixEntryRotateQuaternion diff --git a/cogl/cogl/cogl-matrix-stack.c b/cogl/cogl/cogl-matrix-stack.c index 2d2aeba2a..5bacb7e51 100644 --- a/cogl/cogl/cogl-matrix-stack.c +++ b/cogl/cogl/cogl-matrix-stack.c @@ -196,17 +196,14 @@ cogl_matrix_stack_rotate_quaternion (CoglMatrixStack *stack, } void -cogl_matrix_stack_rotate_euler (CoglMatrixStack *stack, - const CoglEuler *euler) +cogl_matrix_stack_rotate_euler (CoglMatrixStack *stack, + const graphene_euler_t *euler) { CoglMatrixEntryRotateEuler *entry; entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_ROTATE_EULER); - - entry->heading = euler->heading; - entry->pitch = euler->pitch; - entry->roll = euler->roll; + graphene_euler_init_from_euler (&entry->euler, euler); } void @@ -580,13 +577,8 @@ initialized: { CoglMatrixEntryRotateEuler *rotate = (CoglMatrixEntryRotateEuler *)children[i]; - CoglEuler euler; - cogl_euler_init (&euler, - rotate->heading, - rotate->pitch, - rotate->roll); cogl_matrix_rotate_euler (matrix, - &euler); + &rotate->euler); continue; } case COGL_MATRIX_OP_ROTATE_QUATERNION: @@ -1008,9 +1000,7 @@ cogl_matrix_entry_equal (CoglMatrixEntry *entry0, CoglMatrixEntryRotateEuler *rotate1 = (CoglMatrixEntryRotateEuler *)entry1; - if (rotate0->heading != rotate1->heading || - rotate0->pitch != rotate1->pitch || - rotate0->roll != rotate1->roll) + if (!graphene_euler_equal (&rotate0->euler, &rotate1->euler)) return FALSE; } break; @@ -1118,9 +1108,9 @@ cogl_debug_matrix_entry_print (CoglMatrixEntry *entry) CoglMatrixEntryRotateEuler *rotate = (CoglMatrixEntryRotateEuler *)entry; g_print (" ROTATE EULER heading=%f pitch=%f roll=%f\n", - rotate->heading, - rotate->pitch, - rotate->roll); + graphene_euler_get_y (&rotate->euler), + graphene_euler_get_x (&rotate->euler), + graphene_euler_get_z (&rotate->euler)); continue; } case COGL_MATRIX_OP_SCALE: diff --git a/cogl/cogl/cogl-matrix-stack.h b/cogl/cogl/cogl-matrix-stack.h index 4be9f59c2..9ab4aa733 100644 --- a/cogl/cogl/cogl-matrix-stack.h +++ b/cogl/cogl/cogl-matrix-stack.h @@ -42,6 +42,7 @@ #include "cogl-matrix.h" #include "cogl-context.h" +#include /** * SECTION:cogl-matrix-stack @@ -321,14 +322,14 @@ cogl_matrix_stack_rotate_quaternion (CoglMatrixStack *stack, /** * cogl_matrix_stack_rotate_euler: * @stack: A #CoglMatrixStack - * @euler: A #CoglEuler + * @euler: A #graphene_euler_t * * Multiplies the current matrix by one that rotates according to the * rotation described by @euler. */ void cogl_matrix_stack_rotate_euler (CoglMatrixStack *stack, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_matrix_stack_multiply: diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c index af5591357..21fffe42f 100644 --- a/cogl/cogl/cogl-matrix.c +++ b/cogl/cogl/cogl-matrix.c @@ -1370,7 +1370,7 @@ cogl_matrix_rotate_quaternion (CoglMatrix *matrix, void cogl_matrix_rotate_euler (CoglMatrix *matrix, - const CoglEuler *euler) + const graphene_euler_t *euler) { CoglMatrix rotation_transform; @@ -1779,12 +1779,12 @@ cogl_matrix_init_from_quaternion (CoglMatrix *matrix, void cogl_matrix_init_from_euler (CoglMatrix *matrix, - const CoglEuler *euler) + const graphene_euler_t *euler) { /* Convert angles to radians */ - float heading_rad = euler->heading / 180.0f * G_PI; - float pitch_rad = euler->pitch / 180.0f * G_PI; - float roll_rad = euler->roll / 180.0f * G_PI; + float heading_rad = graphene_euler_get_y (euler) / 180.0f * G_PI; + float pitch_rad = graphene_euler_get_x (euler) / 180.0f * G_PI; + float roll_rad = graphene_euler_get_z (euler) / 180.0f * G_PI; /* Pre-calculate the sin and cos */ float sin_heading = sinf (heading_rad); float cos_heading = cosf (heading_rad); diff --git a/cogl/cogl/cogl-matrix.h b/cogl/cogl/cogl-matrix.h index 6d8ddb433..30af4ac7d 100644 --- a/cogl/cogl/cogl-matrix.h +++ b/cogl/cogl/cogl-matrix.h @@ -44,6 +44,8 @@ #include #include +#include + G_BEGIN_DECLS /** @@ -216,13 +218,13 @@ cogl_matrix_rotate_quaternion (CoglMatrix *matrix, * @euler: A euler describing a rotation * * Multiplies @matrix with a rotation transformation described by the - * given #CoglEuler. + * given #graphene_euler_t. * * Since: 2.0 */ void cogl_matrix_rotate_euler (CoglMatrix *matrix, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_matrix_translate: @@ -529,13 +531,13 @@ cogl_matrix_init_from_quaternion (CoglMatrix *matrix, /** * cogl_matrix_init_from_euler: * @matrix: A 4x4 transformation matrix - * @euler: A #CoglEuler + * @euler: A #graphene_euler_t * - * Initializes @matrix from a #CoglEuler rotation. + * Initializes @matrix from a #graphene_euler_t rotation. */ void cogl_matrix_init_from_euler (CoglMatrix *matrix, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_matrix_equal: diff --git a/cogl/cogl/cogl-quaternion.c b/cogl/cogl/cogl-quaternion.c index 20bd2ad6c..a8f43a7d4 100644 --- a/cogl/cogl/cogl-quaternion.c +++ b/cogl/cogl/cogl-quaternion.c @@ -46,7 +46,6 @@ #include #include #include -#include #include "cogl-gtype-private.h" #include @@ -200,24 +199,24 @@ cogl_quaternion_init_from_z_rotation (CoglQuaternion *quaternion, void cogl_quaternion_init_from_euler (CoglQuaternion *quaternion, - const CoglEuler *euler) + const graphene_euler_t *euler) { /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair * in this form: * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] */ float sin_heading = - sinf (euler->heading * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); + sinf (graphene_euler_get_y (euler) * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); float sin_pitch = - sinf (euler->pitch * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); + sinf (graphene_euler_get_x (euler) * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); float sin_roll = - sinf (euler->roll * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); + sinf (graphene_euler_get_z (euler) * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); float cos_heading = - cosf (euler->heading * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); + cosf (graphene_euler_get_y (euler) * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); float cos_pitch = - cosf (euler->pitch * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); + cosf (graphene_euler_get_x (euler) * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); float cos_roll = - cosf (euler->roll * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); + cosf (graphene_euler_get_z (euler) * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); quaternion->w = cos_heading * cos_pitch * cos_roll + diff --git a/cogl/cogl/cogl-quaternion.h b/cogl/cogl/cogl-quaternion.h index 6e8db6bf8..c6c6d504e 100644 --- a/cogl/cogl/cogl-quaternion.h +++ b/cogl/cogl/cogl-quaternion.h @@ -36,6 +36,8 @@ #ifndef __COGL_QUATERNION_H__ #define __COGL_QUATERNION_H__ +#include + #include #include @@ -57,7 +59,6 @@ G_BEGIN_DECLS * . */ #include -#include #include @@ -269,13 +270,13 @@ cogl_quaternion_init_from_z_rotation (CoglQuaternion *quaternion, /** * cogl_quaternion_init_from_euler: * @quaternion: A #CoglQuaternion - * @euler: A #CoglEuler with which to initialize the quaternion + * @euler: A #graphene_euler_t with which to initialize the quaternion * * Since: 2.0 */ void cogl_quaternion_init_from_euler (CoglQuaternion *quaternion, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_quaternion_init_from_quaternion: diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h index 62771d66e..f7b9b38ba 100644 --- a/cogl/cogl/cogl-types.h +++ b/cogl/cogl/cogl-types.h @@ -85,17 +85,13 @@ GType cogl_handle_get_type (void) G_GNUC_CONST; /* We forward declare this in cogl-types to avoid circular dependencies - * between cogl-matrix.h, cogl-euler.h and cogl-quaterion.h */ + * between cogl-matrix.h and cogl-quaterion.h */ typedef struct _CoglMatrix CoglMatrix; /* Same as above we forward declared CoglQuaternion to avoid * circular dependencies. */ typedef struct _CoglQuaternion CoglQuaternion; -/* Same as above we forward declared CoglEuler to avoid - * circular dependencies. */ -typedef struct _CoglEuler CoglEuler; - /** * CoglAngle: * diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index 1c251cc88..aeda0d3b4 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -42,6 +42,8 @@ #define __COGL_MUST_UNDEF_COGL_H_INSIDE__ #endif +#include + /* We currently keep gtype integration delimited in case we eventually * want to split it out into a separate utility library when Cogl * becomes a standalone project. (like cairo-gobject.so) @@ -100,7 +102,6 @@ #include #include #include -#include #include #include #include diff --git a/cogl/cogl/cogl.symbols b/cogl/cogl/cogl.symbols index 38c205ff3..996fd775b 100644 --- a/cogl/cogl/cogl.symbols +++ b/cogl/cogl/cogl.symbols @@ -194,19 +194,6 @@ cogl_display_set_onscreen_template cogl_double_to_fixed -cogl_euler_copy -cogl_euler_equal -cogl_euler_free -#ifdef COGL_HAS_GTYPE_SUPPORT -cogl_euler_get_gtype -#endif -cogl_euler_init -cogl_euler_init_from_matrix -#if 0 -/* not yet implemented */ -cogl_euler_init_from_quaternion -#endif - cogl_features_available cogl_feature_flags_get_type cogl_fence_closure_get_user_data diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 0be388637..6da28e254 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -113,7 +113,6 @@ cogl_nonintrospected_headers = [ 'cogl-primitive.h', 'cogl-frame-info.h', 'cogl-vector.h', - 'cogl-euler.h', 'cogl-output.h', 'cogl-quaternion.h', 'cogl-matrix-stack.h', @@ -267,7 +266,6 @@ cogl_sources = [ 'cogl-primitive.c', 'cogl-matrix.c', 'cogl-vector.c', - 'cogl-euler.c', 'cogl-quaternion-private.h', 'cogl-quaternion.c', 'cogl-matrix-private.h', diff --git a/cogl/tests/conform/test-euler-quaternion.c b/cogl/tests/conform/test-euler-quaternion.c index 312667162..8aa413a19 100644 --- a/cogl/tests/conform/test-euler-quaternion.c +++ b/cogl/tests/conform/test-euler-quaternion.c @@ -38,7 +38,7 @@ void test_euler_quaternion (void) { - CoglEuler euler; + graphene_euler_t euler; CoglQuaternion quaternion; CoglMatrix matrix_a, matrix_b; @@ -49,7 +49,7 @@ test_euler_quaternion (void) cogl_matrix_rotate (&matrix_a, 50.0f, 0.0f, 0.0f, 1.0f); /* And try the same rotation with a euler */ - cogl_euler_init (&euler, -30, 40, 50); + graphene_euler_init_with_order (&euler, 40, -30, 50, GRAPHENE_EULER_ORDER_YXZ); cogl_matrix_init_from_euler (&matrix_b, &euler); /* Verify that the matrices are approximately the same */ diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 4b9e7864f..6f4fced8c 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -279,31 +279,38 @@ get_base_pipeline (MetaShapedTexture *stex, if (stex->transform != META_MONITOR_TRANSFORM_NORMAL) { - CoglEuler euler; + graphene_euler_t euler; cogl_matrix_translate (&matrix, 0.5, 0.5, 0.0); switch (stex->transform) { case META_MONITOR_TRANSFORM_90: - cogl_euler_init (&euler, 0.0, 0.0, 90.0); + graphene_euler_init_with_order (&euler, 0.0, 0.0, 90.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_180: - cogl_euler_init (&euler, 0.0, 0.0, 180.0); + graphene_euler_init_with_order (&euler, 0.0, 0.0, 180.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_270: - cogl_euler_init (&euler, 0.0, 0.0, 270.0); + graphene_euler_init_with_order (&euler, 0.0, 0.0, 270.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED: - cogl_euler_init (&euler, 180.0, 0.0, 0.0); + graphene_euler_init_with_order (&euler, 0.0, 180.0, 0.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED_90: - cogl_euler_init (&euler, 0.0, 180.0, 90.0); + graphene_euler_init_with_order (&euler, 180.0, 0.0, 90.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED_180: - cogl_euler_init (&euler, 180.0, 0.0, 180.0); + graphene_euler_init_with_order (&euler, 0.0, 180.0, 180.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED_270: - cogl_euler_init (&euler, 0.0, 180.0, 270.0); + graphene_euler_init_with_order (&euler, 180.0, 0.0, 270.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_NORMAL: g_assert_not_reached ();