[gtk/wip/baedert/gl-rework: 39/41] GskTransform: Compute sin/deg of 90deg rotations manually
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/gl-rework: 39/41] GskTransform: Compute sin/deg of 90deg rotations manually
- Date: Fri, 20 Dec 2019 09:55:56 +0000 (UTC)
commit cdadaf541fc692260cdff75c007a1b2eda80a67a
Author: Timm Bäder <mail baedert org>
Date: Thu Dec 19 12:30:08 2019 +0100
GskTransform: Compute sin/deg of 90deg rotations manually
Otherwise we might end up with inaccuracies, e.g. when
gsk_transform_transform_bounds()'ing bounds.
gsk/gsktransform.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c
index 330342b5e7..aaea880335 100644
--- a/gsk/gsktransform.c
+++ b/gsk/gsktransform.c
@@ -690,11 +690,35 @@ gsk_rotate_transform_to_matrix (GskTransform *transform,
graphene_matrix_t *out_matrix)
{
GskRotateTransform *self = (GskRotateTransform *) transform;
- float rad, c, s;
+ float c, s;
+
+ if (self->angle == 90.0 || self->angle == -270)
+ {
+ c = 0.0;
+ s = 1.0;
+ }
+ else if (self->angle == 180.0 || self->angle == -180)
+ {
+ c = -1.0;
+ s = 0.0;
+ }
+ else if (self->angle == 270.0 || self->angle == -90)
+ {
+ c = 0.0;
+ s = -1.0;
+ }
+ else if (self->angle == 0.0 || self->angle == 360.0)
+ {
+ c = 1.0;
+ s = 0.0;
+ }
+ else
+ {
+ const float rad = self->angle * M_PI / 180.f;
+ c = cosf (rad);
+ s = sinf (rad);
+ }
- rad = self->angle * M_PI / 180.f;
- c = cosf (rad);
- s = sinf (rad);
graphene_matrix_init_from_2d (out_matrix,
c, s,
-s, c,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]