diff --git a/src/backends/meta-monitor-transform.c b/src/backends/meta-monitor-transform.c index 5706ad5de..8acf8290e 100644 --- a/src/backends/meta-monitor-transform.c +++ b/src/backends/meta-monitor-transform.c @@ -153,3 +153,52 @@ meta_monitor_transform_transform_point (MetaMonitorTransform transform, break; } } + +void +meta_monitor_transform_transform_matrix (MetaMonitorTransform transform, + graphene_matrix_t *matrix) +{ + graphene_euler_t euler; + + if (transform == META_MONITOR_TRANSFORM_NORMAL) + return; + + graphene_matrix_translate (matrix, + &GRAPHENE_POINT3D_INIT (-0.5, -0.5, 0.0)); + switch (transform) + { + case META_MONITOR_TRANSFORM_90: + graphene_euler_init_with_order (&euler, 0.0, 0.0, 270.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_180: + graphene_euler_init_with_order (&euler, 0.0, 0.0, 180.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_270: + graphene_euler_init_with_order (&euler, 0.0, 0.0, 90.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_FLIPPED: + graphene_euler_init_with_order (&euler, 0.0, 180.0, 0.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_FLIPPED_90: + graphene_euler_init_with_order (&euler, 0.0, 180.0, 90.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_FLIPPED_180: + graphene_euler_init_with_order (&euler, 0.0, 180.0, 180.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_FLIPPED_270: + graphene_euler_init_with_order (&euler, 0.0, 180.0, 270.0, + GRAPHENE_EULER_ORDER_SYXZ); + break; + case META_MONITOR_TRANSFORM_NORMAL: + g_assert_not_reached (); + } + graphene_matrix_rotate_euler (matrix, &euler); + graphene_matrix_translate (matrix, + &GRAPHENE_POINT3D_INIT (0.5, 0.5, 0.0)); +} diff --git a/src/backends/meta-monitor-transform.h b/src/backends/meta-monitor-transform.h index 3449c14d7..79677e8e2 100644 --- a/src/backends/meta-monitor-transform.h +++ b/src/backends/meta-monitor-transform.h @@ -72,4 +72,7 @@ void meta_monitor_transform_transform_point (MetaMonitorTransform transform, int *out_x, int *out_y); +void meta_monitor_transform_transform_matrix (MetaMonitorTransform transform, + graphene_matrix_t *matrix); + #endif /* META_MONITOR_TRANSFORM_H */ diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 679b6a18b..bea77c1a1 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -310,49 +310,8 @@ get_base_pipeline (MetaShapedTexture *stex, } } - if (stex->transform != META_MONITOR_TRANSFORM_NORMAL) - { - graphene_euler_t euler; - - graphene_matrix_translate (&matrix, - &GRAPHENE_POINT3D_INIT (-0.5, -0.5, 0.0)); - switch (stex->transform) - { - case META_MONITOR_TRANSFORM_90: - graphene_euler_init_with_order (&euler, 0.0, 0.0, 270.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_180: - graphene_euler_init_with_order (&euler, 0.0, 0.0, 180.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_270: - graphene_euler_init_with_order (&euler, 0.0, 0.0, 90.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_FLIPPED: - graphene_euler_init_with_order (&euler, 0.0, 180.0, 0.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_FLIPPED_90: - graphene_euler_init_with_order (&euler, 0.0, 180.0, 90.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_FLIPPED_180: - graphene_euler_init_with_order (&euler, 0.0, 180.0, 180.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_FLIPPED_270: - graphene_euler_init_with_order (&euler, 0.0, 180.0, 270.0, - GRAPHENE_EULER_ORDER_SYXZ); - break; - case META_MONITOR_TRANSFORM_NORMAL: - g_assert_not_reached (); - } - graphene_matrix_rotate_euler (&matrix, &euler); - graphene_matrix_translate (&matrix, - &GRAPHENE_POINT3D_INIT (0.5, 0.5, 0.0)); - } + meta_monitor_transform_transform_matrix (stex->transform, + &matrix); cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);