diff options
Diffstat (limited to 'src/cairo-gl-msaa-compositor.c')
-rw-r--r-- | src/cairo-gl-msaa-compositor.c | 101 |
1 files changed, 100 insertions, 1 deletions
diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c index 8e2c2ed5..ab5501db 100644 --- a/src/cairo-gl-msaa-compositor.c +++ b/src/cairo-gl-msaa-compositor.c @@ -48,6 +48,52 @@ #include "cairo-traps-private.h" static cairo_int_status_t +_draw_trap (cairo_gl_context_t *ctx, + cairo_gl_composite_t *setup, + cairo_trapezoid_t *trap) +{ + cairo_point_t quad[4]; + + quad[0].x = _cairo_edge_compute_intersection_x_for_y (&trap->left.p1, + &trap->left.p2, + trap->top); + quad[0].y = trap->top; + + quad[1].x = _cairo_edge_compute_intersection_x_for_y (&trap->left.p1, + &trap->left.p2, + trap->bottom); + quad[1].y = trap->bottom; + + quad[2].x = _cairo_edge_compute_intersection_x_for_y (&trap->right.p1, + &trap->right.p2, + trap->bottom); + quad[2].y = trap->bottom; + + quad[3].x = _cairo_edge_compute_intersection_x_for_y (&trap->right.p1, + &trap->right.p2, + trap->top); + quad[3].y = trap->top; + return _cairo_gl_composite_emit_quad_as_tristrip (ctx, setup, quad); +} + +static cairo_int_status_t +_draw_traps (cairo_gl_context_t *ctx, + cairo_gl_composite_t *setup, + cairo_traps_t *traps) +{ + int i; + cairo_int_status_t status = CAIRO_STATUS_SUCCESS; + + for (i = 0; i < traps->num_traps; i++) { + cairo_trapezoid_t *trap = traps->traps + i; + if (unlikely ((status = _draw_trap (ctx, setup, trap)))) + return status; + } + + return status; +} + +static cairo_int_status_t _cairo_gl_msaa_compositor_paint (const cairo_compositor_t *compositor, cairo_composite_rectangles_t *composite) { @@ -82,7 +128,60 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, double tolerance, cairo_antialias_t antialias) { - return CAIRO_INT_STATUS_UNSUPPORTED; + cairo_gl_composite_t setup; + cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; + cairo_gl_context_t *ctx = NULL; + cairo_int_status_t status; + cairo_traps_t traps; + + if (antialias != CAIRO_ANTIALIAS_NONE) + return CAIRO_INT_STATUS_UNSUPPORTED; + + if (! _cairo_composite_rectangles_can_reduce_clip (composite, + composite->clip)) + return CAIRO_INT_STATUS_UNSUPPORTED; + + _cairo_traps_init (&traps); + status = _cairo_path_fixed_fill_to_traps (path, fill_rule, tolerance, &traps); + if (unlikely (status)) + goto cleanup_traps; + + status = _cairo_gl_composite_init (&setup, + composite->op, + dst, + FALSE, /* assume_component_alpha */ + &composite->bounded); + if (unlikely (status)) + goto cleanup_traps; + + status = _cairo_gl_composite_set_source (&setup, + &composite->source_pattern.base, + composite->bounded.x, + composite->bounded.y, + composite->bounded.x, + composite->bounded.y, + composite->bounded.width, + composite->bounded.height); + if (unlikely (status)) + goto cleanup_setup; + + status = _cairo_gl_composite_begin_tristrip (&setup, &ctx); + if (unlikely (status)) + goto cleanup_setup; + + status = _draw_traps (ctx, &setup, &traps); + if (unlikely (status)) + goto cleanup_setup; + + _cairo_gl_composite_flush (ctx); +cleanup_setup: + _cairo_gl_composite_fini (&setup); + if (ctx) + status = _cairo_gl_context_release (ctx, status); +cleanup_traps: + _cairo_traps_fini (&traps); + + return status; } static void |