summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2013-10-14 04:54:24 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2013-10-14 04:54:24 -0400
commit0dbd82323c1be19603536bce9a78b8e8efa23215 (patch)
tree2d52184bc299f95eb7ab363c9b25864c5ed81369
parent49df8f400daa27eb50197b14a0ebaff576b42872 (diff)
path
-rw-r--r--test/path.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/test/path.c b/test/path.c
index fb948244..b4b1418e 100644
--- a/test/path.c
+++ b/test/path.c
@@ -60,7 +60,6 @@ path_realloc (path_t *path, int n_elements)
path_t *result;
int n_bytes =
sizeof (path_t) + (n_elements - 1) * sizeof (path_element_t);
-
result = realloc (path, n_bytes);
if (!result)
free (path);
@@ -79,7 +78,8 @@ static path_t *
path_new (void)
{
path_t *path = path_realloc (NULL, 0);
-
+
+ path->n_elements = 0;
path_add_move_to (path, 0.0, 0.0);
return path;
@@ -305,10 +305,10 @@ path_new_stroke (path_t *path, double line_width)
}
static pixman_image_t *
-path_to_polygon (path_t *path)
+path_to_polygon (path_t *path, double tolerance_squared)
{
polygon_builder_t builder;
- path_t *flattened = path_new_flatten (path, 0.1);
+ path_t *flattened = path_new_flatten (path, tolerance_squared);
int i;
polygon_builder_init (&builder);
@@ -329,9 +329,6 @@ path_to_polygon (path_t *path)
break;
case CLOSE_PATH:
- printf ("closing to %f %f\n",
- element->close_path.end_x,
- element->close_path.end_y);
polygon_builder_line_to (
&builder, element->close_path.end_x, element->close_path.end_y);
break;
@@ -345,7 +342,7 @@ path_to_polygon (path_t *path)
path_free (flattened);
return polygon_builder_get_polygon (
- &builder, PIXMAN_FILL_RULE_WINDING, TRUE);
+ &builder, PIXMAN_FILL_RULE_WINDING, FALSE);
}
int
@@ -355,25 +352,57 @@ main (void)
pixman_image_create_bits (PIXMAN_a8r8g8b8, 400, 400, NULL, -1);
pixman_image_t *polygon;
path_t *path = path_new();
- pixman_color_t color = { 0x0000, 0x0000, 0x7777, 0xffff };
+ pixman_color_t color = { 0x0000, 0x0000, 0x0000, 0x8888 };
+ pixman_color_t color2 = { 0xcccc, 0xaaaa, 0x0000, 0xffff };
pixman_image_t *solid;
+ pixman_image_t *tmp;
+ pixman_fixed_t *params;
+ int n_params;
+ pixman_transform_t xform;
+
+ draw_checkerboard (dest, 16, 0xffdddddd, 0xffcccccc);
solid = pixman_image_create_solid_fill (&color);
- path = path_add_move_to (path, 100, 100);
- path = path_add_curve_to (path, 200, 200, 300, 0, 400, 100);
+ path = path_add_move_to (path, 103.5, 104.5);
+ path = path_add_curve_to (path, 200, 700, 300, -500, 400, 70);
path = path_add_close_path (path);
- polygon = path_to_polygon (path);
+ polygon = path_to_polygon (path, 0.5);
pixman_image_set_antialias (polygon, PIXMAN_ANTIALIAS_BOX_17_15);
+ tmp = pixman_image_create_bits (PIXMAN_a8r8g8b8, 400, 400, NULL, -1);
pixman_image_composite (
- PIXMAN_OP_OVER, solid, polygon, dest,
+ PIXMAN_OP_OVER, solid, polygon, tmp,
150, 150, 50, -100, 0, 0, 400, 400);
+ params = pixman_filter_create_separable_convolution (
+ &n_params, (3 << 16), (3 << 16),
+ PIXMAN_KERNEL_IMPULSE, PIXMAN_KERNEL_IMPULSE,
+ PIXMAN_KERNEL_GAUSSIAN, PIXMAN_KERNEL_GAUSSIAN,
+ 0, 0);
+
+ pixman_image_set_filter (
+ tmp, PIXMAN_FILTER_SEPARABLE_CONVOLUTION, params, n_params);
+
+ pixman_transform_init_scale (
+ &xform,
+ pixman_double_to_fixed (1.001),
+ pixman_double_to_fixed (1.001));
+
+ pixman_image_set_transform (tmp, &xform);
+ pixman_image_composite (
+ PIXMAN_OP_OVER, tmp, NULL, dest, 0, 0, 0, 0, 0, 0, 400, 400);
+
+ solid = pixman_image_create_solid_fill (&color2);
+
+#define OFFSET 5
+
+ pixman_image_composite (
+ PIXMAN_OP_OVER, solid, polygon, dest,
+ 0, 0, 50 + OFFSET, -100 + OFFSET, 0, 0, 400, 400);
+
write_png (dest, "polygon.png");
-
- printf ("asdf\n");
return 0;
}