[test] Draw spline bbox

Add the stroked extents to the spline-decomposition test.
This commit is contained in:
Chris Wilson 2008-12-29 12:16:53 +00:00
parent efb1716090
commit 84b81388be
10 changed files with 65 additions and 4 deletions

View file

@ -902,11 +902,9 @@ REFERENCE_IMAGES = \
source-surface-scale-paint.ref.png \
source-surface-scale-paint.rgb24.ref.png \
spline-decomposition.ref.png \
spline-decomposition.ps2.ref.png \
spline-decomposition.ps3.ref.png \
spline-decomposition.ps.ref.png \
spline-decomposition.pdf.ref.png \
spline-decomposition.svg11.ref.png \
spline-decomposition.svg12.ref.png \
spline-decomposition.svg.ref.png \
stroke-ctm-caps.ps2.ref.png \
stroke-ctm-caps.ps3.ref.png \
surface-pattern-big-scale-down.ref.png \

View file

@ -309,9 +309,21 @@ thin_splines (cairo_t *cr)
}
#endif
static void
draw_bbox (cairo_t *cr, double x0, double y0, double x1, double y1)
{
cairo_rectangle (cr,
floor (x0) + .5, floor (y0) + .5,
ceil (x1) - floor (x0), ceil (y1) - floor (y0));
cairo_stroke (cr);
}
static void
stroke_splines (cairo_t *cr)
{
double stroke_x0, stroke_x1, stroke_y0, stroke_y1;
double path_x0, path_x1, path_y0, path_y1;
cairo_save (cr);
cairo_translate (cr, 15, 15);
@ -322,8 +334,18 @@ stroke_splines (cairo_t *cr)
knots[0].b.x, knots[0].b.y,
knots[0].c.x, knots[0].c.y,
knots[0].d.x, knots[0].d.y);
cairo_stroke_extents (cr, &stroke_x0, &stroke_y0, &stroke_x1, &stroke_y1);
cairo_path_extents (cr, &path_x0, &path_y0, &path_x1, &path_y1);
cairo_stroke (cr);
cairo_save (cr); {
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1, 0, 0);
draw_bbox (cr, stroke_x0, stroke_y0, stroke_x1, stroke_y1);
cairo_set_source_rgb (cr, 0, 0, 1);
draw_bbox (cr, path_x0, path_y0, path_x1, path_y1);
} cairo_restore (cr);
cairo_translate (cr, 130, 0);
cairo_new_path (cr);
@ -333,8 +355,18 @@ stroke_splines (cairo_t *cr)
knots[1].b.x, knots[1].b.y,
knots[1].c.x, knots[1].c.y,
knots[1].d.x, knots[1].d.y);
cairo_stroke_extents (cr, &stroke_x0, &stroke_y0, &stroke_x1, &stroke_y1);
cairo_path_extents (cr, &path_x0, &path_y0, &path_x1, &path_y1);
cairo_stroke (cr);
cairo_save (cr); {
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1, 0, 0);
draw_bbox (cr, stroke_x0, stroke_y0, stroke_x1, stroke_y1);
cairo_set_source_rgb (cr, 0, 0, 1);
draw_bbox (cr, path_x0, path_y0, path_x1, path_y1);
} cairo_restore (cr);
cairo_translate (cr, 130, 0);
cairo_new_path (cr);
@ -344,8 +376,18 @@ stroke_splines (cairo_t *cr)
knots[2].b.x, knots[2].b.y,
knots[2].c.x, knots[2].c.y,
knots[2].d.x, knots[2].d.y);
cairo_stroke_extents (cr, &stroke_x0, &stroke_y0, &stroke_x1, &stroke_y1);
cairo_path_extents (cr, &path_x0, &path_y0, &path_x1, &path_y1);
cairo_stroke (cr);
cairo_save (cr); {
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1, 0, 0);
draw_bbox (cr, stroke_x0, stroke_y0, stroke_x1, stroke_y1);
cairo_set_source_rgb (cr, 0, 0, 1);
draw_bbox (cr, path_x0, path_y0, path_x1, path_y1);
} cairo_restore (cr);
cairo_translate (cr, -130 - 65, 130);
cairo_new_path (cr);
@ -355,8 +397,18 @@ stroke_splines (cairo_t *cr)
knots[3].b.x, knots[3].b.y,
knots[3].c.x, knots[3].c.y,
knots[3].d.x, knots[3].d.y);
cairo_stroke_extents (cr, &stroke_x0, &stroke_y0, &stroke_x1, &stroke_y1);
cairo_path_extents (cr, &path_x0, &path_y0, &path_x1, &path_y1);
cairo_stroke (cr);
cairo_save (cr); {
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1, 0, 0);
draw_bbox (cr, stroke_x0, stroke_y0, stroke_x1, stroke_y1);
cairo_set_source_rgb (cr, 0, 0, 1);
draw_bbox (cr, path_x0, path_y0, path_x1, path_y1);
} cairo_restore (cr);
cairo_translate (cr, 130, 0);
cairo_new_path (cr);
@ -366,7 +418,18 @@ stroke_splines (cairo_t *cr)
knots[4].b.x, knots[4].b.y,
knots[4].c.x, knots[4].c.y,
knots[4].d.x, knots[4].d.y);
cairo_stroke_extents (cr, &stroke_x0, &stroke_y0, &stroke_x1, &stroke_y1);
cairo_path_extents (cr, &path_x0, &path_y0, &path_x1, &path_y1);
cairo_stroke (cr);
cairo_save (cr); {
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1, 0, 0);
draw_bbox (cr, stroke_x0, stroke_y0, stroke_x1, stroke_y1);
cairo_set_source_rgb (cr, 0, 0, 1);
draw_bbox (cr, path_x0, path_y0, path_x1, path_y1);
} cairo_restore (cr);
cairo_restore (cr);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB