[gtk] Move gtk_rounded_rect_scale_affine to the right place
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Move gtk_rounded_rect_scale_affine to the right place
- Date: Sun, 7 Mar 2021 20:17:43 +0000 (UTC)
commit c60a316e22470fd210cbbbaeb3bd2ccc43498f04
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 7 14:35:44 2021 -0500
Move gtk_rounded_rect_scale_affine to the right place
This function should live with the rest of the
GskRoundedRect code in gskroundedrect.c.
gsk/gskroundedrect.c | 25 +++++++++++++++++++++++++
gsk/gskroundedrectprivate.h | 7 +++++++
gtk/gtksnapshot.c | 32 +++++---------------------------
3 files changed, 37 insertions(+), 27 deletions(-)
---
diff --git a/gsk/gskroundedrect.c b/gsk/gskroundedrect.c
index 5090a91b1d..92a7bbb966 100644
--- a/gsk/gskroundedrect.c
+++ b/gsk/gskroundedrect.c
@@ -274,6 +274,31 @@ gsk_rounded_rect_shrink (GskRoundedRect *self,
return self;
}
+void
+gsk_rounded_rect_scale_affine (GskRoundedRect *dest,
+ const GskRoundedRect *src,
+ float scale_x,
+ float scale_y,
+ float dx,
+ float dy)
+{
+ guint flip = ((scale_x < 0) ? 1 : 0) + (scale_y < 0 ? 2 : 0);
+
+ g_assert (dest != src);
+
+ graphene_rect_scale (&src->bounds, scale_x, scale_y, &dest->bounds);
+ graphene_rect_offset (&dest->bounds, dx, dy);
+
+ scale_x = fabs (scale_x);
+ scale_y = fabs (scale_y);
+
+ for (guint i = 0; i < 4; i++)
+ {
+ dest->corner[i].width = src->corner[i ^ flip].width * scale_x;
+ dest->corner[i].height = src->corner[i ^ flip].height * scale_y;
+ }
+}
+
/* XXX: Find a better name */
gboolean
gsk_rounded_rect_is_circular (const GskRoundedRect *self)
diff --git a/gsk/gskroundedrectprivate.h b/gsk/gskroundedrectprivate.h
index bddd4ea18c..6dfe4b019d 100644
--- a/gsk/gskroundedrectprivate.h
+++ b/gsk/gskroundedrectprivate.h
@@ -17,6 +17,13 @@ G_BEGIN_DECLS
}}
+void gsk_rounded_rect_scale_affine (GskRoundedRect *dest,
+ const GskRoundedRect *src,
+ float scale_x,
+ float scale_y,
+ float dx,
+ float dy);
+
gboolean gsk_rounded_rect_is_circular (const GskRoundedRect *self);
void gsk_rounded_rect_path (const GskRoundedRect *self,
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 008dd108e4..8640a9decb 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -31,6 +31,7 @@
#include "gsktransformprivate.h"
#include "gsk/gskrendernodeprivate.h"
+#include "gsk/gskroundedrectprivate.h"
#include "gtk/gskpango.h"
@@ -708,29 +709,6 @@ gtk_graphene_rect_scale_affine (const graphene_rect_t *rect,
graphene_rect_normalize (res);
}
-static void
-gtk_rounded_rect_scale_affine (GskRoundedRect *dest,
- const GskRoundedRect *src,
- float scale_x,
- float scale_y,
- float dx,
- float dy)
-{
- guint flip;
- guint i;
-
- g_assert (dest != src);
-
- gtk_graphene_rect_scale_affine (&src->bounds, scale_x, scale_y, dx, dy, &dest->bounds);
- flip = ((scale_x < 0) ? 1 : 0) + (scale_y < 0 ? 2 : 0);
-
- for (i = 0; i < 4; i++)
- {
- dest->corner[i].width = src->corner[i ^ flip].width * fabsf (scale_x);
- dest->corner[i].height = src->corner[i ^ flip].height * fabsf (scale_y);
- }
-}
-
static void
gtk_snapshot_ensure_affine (GtkSnapshot *snapshot,
float *scale_x,
@@ -1099,7 +1077,7 @@ gtk_snapshot_push_rounded_clip (GtkSnapshot *snapshot,
gtk_snapshot_collect_rounded_clip,
NULL);
- gtk_rounded_rect_scale_affine (&state->data.rounded_clip.bounds, bounds, scale_x, scale_y, dx, dy);
+ gsk_rounded_rect_scale_affine (&state->data.rounded_clip.bounds, bounds, scale_x, scale_y, dx, dy);
}
static GskRenderNode *
@@ -2441,7 +2419,7 @@ gtk_snapshot_append_border (GtkSnapshot *snapshot,
g_return_if_fail (border_color != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
- gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, dx, dy);
+ gsk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, dx, dy);
node = gsk_border_node_new (&real_outline, border_width, border_color);
@@ -2478,7 +2456,7 @@ gtk_snapshot_append_inset_shadow (GtkSnapshot *snapshot,
g_return_if_fail (color != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &x, &y);
- gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
+ gsk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
node = gsk_inset_shadow_node_new (&real_outline,
color,
@@ -2520,7 +2498,7 @@ gtk_snapshot_append_outset_shadow (GtkSnapshot *snapshot,
g_return_if_fail (color != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &x, &y);
- gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
+ gsk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
node = gsk_outset_shadow_node_new (&real_outline,
color,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]