Move paint fallback from gstate to surface where it belongs.

Add clip pointer to surface.
This commit is contained in:
Carl Worth 2005-10-27 15:06:53 +00:00
parent e406f4b0f0
commit ce7b19fc34
4 changed files with 89 additions and 22 deletions

View file

@ -1,3 +1,14 @@
2005-10-27 Carl Worth <cworth@cworth.org>
* src/cairoint.h:
* src/cairo-gstate.c: (_cairo_gstate_paint):
* src/cairo-surface.c: (_fallback_paint), (_cairo_surface_paint):
Move paint fallback from gstate to surface where it belongs.
* src/cairoint.h:
* src/cairo-surface.c: (_cairo_surface_init), (_cairo_surface_set_clip):
Add clip pointer to surface.
2005-10-25 Carl Worth <cworth@cworth.org>
* src/cairo-xcb-surface.c: Add explicit NULLs for unimplmented

View file

@ -728,10 +728,8 @@ _cairo_gstate_copy_transformed_mask (cairo_gstate_t *gstate,
cairo_status_t
_cairo_gstate_paint (cairo_gstate_t *gstate)
{
cairo_rectangle_t rectangle;
cairo_status_t status;
cairo_box_t box;
cairo_traps_t traps;
cairo_pattern_union_t pattern;
if (gstate->source->status)
return gstate->source->status;
@ -740,26 +738,13 @@ _cairo_gstate_paint (cairo_gstate_t *gstate)
if (status)
return status;
status = _cairo_surface_get_extents (gstate->target, &rectangle);
if (status)
return status;
status = _cairo_clip_intersect_to_rectangle (&gstate->clip, &rectangle);
if (status)
return status;
_cairo_gstate_copy_transformed_source (gstate, &pattern.base);
box.p1.x = _cairo_fixed_from_int (rectangle.x);
box.p1.y = _cairo_fixed_from_int (rectangle.y);
box.p2.x = _cairo_fixed_from_int (rectangle.x + rectangle.width);
box.p2.y = _cairo_fixed_from_int (rectangle.y + rectangle.height);
status = _cairo_traps_init_box (&traps, &box);
if (status)
return status;
_cairo_gstate_clip_and_composite_trapezoids (gstate, &traps);
status = _cairo_surface_paint (gstate->operator,
&pattern.base,
gstate->target);
_cairo_traps_fini (&traps);
return CAIRO_STATUS_SUCCESS;
return status;
}
/**

View file

@ -152,6 +152,7 @@ _cairo_surface_init (cairo_surface_t *surface,
surface->device_x_scale = 1.0;
surface->device_y_scale = 1.0;
surface->clip = NULL;
surface->next_clip_serial = 0;
surface->current_clip_serial = 0;
@ -1141,6 +1142,66 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface,
return _fallback_fill_rectangles (surface, operator, color, rects, num_rects);
}
static cairo_status_t
_fallback_paint (cairo_operator_t operator,
cairo_pattern_t *pattern,
cairo_surface_t *dst)
{
cairo_status_t status;
cairo_rectangle_t rectangle;
cairo_box_t box;
cairo_traps_t traps;
status = _cairo_surface_get_extents (dst, &rectangle);
if (status)
return status;
status = _cairo_clip_intersect_to_rectangle (dst->clip, &rectangle);
if (status)
return status;
box.p1.x = _cairo_fixed_from_int (rectangle.x);
box.p1.y = _cairo_fixed_from_int (rectangle.y);
box.p2.x = _cairo_fixed_from_int (rectangle.x + rectangle.width);
box.p2.y = _cairo_fixed_from_int (rectangle.y + rectangle.height);
status = _cairo_traps_init_box (&traps, &box);
if (status)
return status;
_cairo_surface_clip_and_composite_trapezoids (pattern,
operator,
dst,
&traps,
dst->clip,
CAIRO_ANTIALIAS_NONE);
_cairo_traps_fini (&traps);
return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
_cairo_surface_paint (cairo_operator_t operator,
cairo_pattern_t *pattern,
cairo_surface_t *dst)
{
/* cairo_status_t status; */
assert (! dst->is_snapshot);
/* XXX: Need to add this to the backend.
if (dst->backend->paint) {
status = dst->backend->paint (operator, pattern, dst);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
return status;
}
*/
return _fallback_paint (operator, pattern, dst);
}
static cairo_status_t
_fallback_fill_path (cairo_operator_t operator,
@ -1554,9 +1615,12 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
{
if (!surface)
return CAIRO_STATUS_NULL_POINTER;
surface->clip = clip;
if (clip->serial == _cairo_surface_get_current_clip_serial (surface))
return CAIRO_STATUS_SUCCESS;
if (clip->path)
return _cairo_surface_set_clip_path (surface,
clip->path,

View file

@ -761,6 +761,8 @@ struct _cairo_surface {
double device_x_scale;
double device_y_scale;
cairo_clip_t *clip;
/*
* Each time a clip region is modified, it gets the next value in this
* sequence. This means that clip regions for this surface are uniquely
@ -1548,6 +1550,11 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface,
cairo_rectangle_t *rects,
int num_rects);
cairo_status_t
_cairo_surface_paint (cairo_operator_t operator,
cairo_pattern_t *pattern,
cairo_surface_t *dst);
cairo_private cairo_status_t
_cairo_surface_fill_path (cairo_operator_t operator,
cairo_pattern_t *pattern,