cellrendererduration: inline rounded rectangle

We can just embed this instead of relying on dazzle, and inline it at
the same time.
This commit is contained in:
Christian Hergert
2021-09-28 13:03:02 -07:00
parent fb16745723
commit 07d2de5d3a

View File

@ -55,6 +55,54 @@ G_DEFINE_TYPE_WITH_PRIVATE (SysprofCellRendererDuration, sysprof_cell_renderer_d
static GParamSpec *properties [N_PROPS];
static inline void
rounded_rectangle (cairo_t *cr,
const GdkRectangle *rect,
int x_radius,
int y_radius)
{
int x;
int y;
int width;
int height;
int x1, x2;
int y1, y2;
int xr1, xr2;
int yr1, yr2;
g_assert (cr);
g_assert (rect);
x = rect->x;
y = rect->y;
width = rect->width;
height = rect->height;
x1 = x;
x2 = x1 + width;
y1 = y;
y2 = y1 + height;
x_radius = MIN (x_radius, width / 2.0);
y_radius = MIN (y_radius, width / 2.0);
xr1 = x_radius;
xr2 = x_radius / 2.0;
yr1 = y_radius;
yr2 = y_radius / 2.0;
cairo_move_to (cr, x1 + xr1, y1);
cairo_line_to (cr, x2 - xr1, y1);
cairo_curve_to (cr, x2 - xr2, y1, x2, y1 + yr2, x2, y1 + yr1);
cairo_line_to (cr, x2, y2 - yr1);
cairo_curve_to (cr, x2, y2 - yr2, x2 - xr2, y2, x2 - xr1, y2);
cairo_line_to (cr, x1 + xr1, y2);
cairo_curve_to (cr, x1 + xr2, y2, x1, y2 - yr2, x1, y2 - yr1);
cairo_line_to (cr, x1, y1 + yr1);
cairo_curve_to (cr, x1, y1 + yr2, x1 + xr2, y1, x1 + xr1, y1);
cairo_close_path (cr);
}
static void
sysprof_cell_renderer_duration_render (GtkCellRenderer *renderer,
cairo_t *cr,
@ -108,7 +156,7 @@ sysprof_cell_renderer_duration_render (GtkCellRenderer *renderer,
if (r.width > 3)
{
dzl_cairo_rounded_rectangle (cr, &r, 2, 2);
rounded_rectangle (cr, &r, 2, 2);
cairo_fill (cr);
}
else if (r.width > 1)