Merge branch 'matthiasc/for-main' into 'main'

gtk-demo: Update some ifdefed code

See merge request GNOME/gtk!6416
This commit is contained in:
Matthias Clasen 2023-09-21 02:53:33 +00:00
commit 72d832a4f3
2 changed files with 23 additions and 5 deletions

View File

@ -9,6 +9,8 @@
#include "paintable.h"
#undef SHOW_CONTROLS
#define GTK_TYPE_SPINNER_PAINTABLE (gtk_spinner_paintable_get_type ())
G_DECLARE_FINAL_TYPE (GtkSpinnerPaintable, gtk_spinner_paintable, GTK, SPINNER_PAINTABLE, GObject)
@ -150,6 +152,7 @@ static gboolean
add_controls (GskPathOperation op,
const graphene_point_t *pts,
gsize n_pts,
float weight,
gpointer data)
{
GskPathBuilder *builder = data;
@ -166,7 +169,7 @@ add_controls (GskPathOperation op,
break;
case GSK_PATH_QUAD:
case GSK_PATH_ARC:
case GSK_PATH_CONIC:
gsk_path_builder_line_to (builder, pts[1].x, pts[1].y);
gsk_path_builder_line_to (builder, pts[2].x, pts[2].y);
break;

View File

@ -104,6 +104,19 @@ struct _GskContourClass
#define DEG_TO_RAD(x) ((x) * (G_PI / 180.f))
#define RAD_TO_DEG(x) ((x) / (G_PI / 180.f))
static inline void
_sincosf (float angle,
float *out_s,
float *out_c)
{
#ifdef HAVE_SINCOSF
sincosf (angle, out_s, out_c);
#else
*out_s = sinf (angle);
*out_c = cosf (angle);
#endif
}
static void
_g_string_append_float (GString *string,
const char *prefix,
@ -1498,7 +1511,7 @@ gsk_circle_contour_get_closest_point (const GskContour *contour,
angle = atan2f (point->y - self->center.y, point->x - self->center.x);
if (angle < 0)
angle = M_PI - angle;
angle = 2 * M_PI + angle;
t = CLAMP (angle / (2 * M_PI), 0, 1);
@ -1554,9 +1567,11 @@ gsk_circle_contour_get_position (const GskContour *contour,
}
else
{
float angle = M_PI_2 * ((idx - 1) + t);
*position = GRAPHENE_POINT_INIT (self->center.x + cosf (angle) * self->radius,
self->center.y + sinf (angle) * self->radius);
float s, c;
_sincosf (M_PI_2 * ((idx - 1) + t), &s, &c);
*position = GRAPHENE_POINT_INIT (self->center.x + c * self->radius,
self->center.y + s * self->radius);
}
}