Update prototype to eliminate warning.

Remember to reference surfaces when copying patterns.
Don't call _gstate_create_pattern for internally created patterns. (_cairo_gstate_show_surface): Don't change the surface matrix here, it's done later when we set it up as a pattern.
Correct clip_twice-ref.png filename.
Add these.
Fix broken intersection code.
This commit is contained in:
Kristian Høgsberg 2005-01-28 12:27:23 +00:00
parent 4c329eecb9
commit a24f2f909e
8 changed files with 57 additions and 82 deletions

View file

@ -1,3 +1,25 @@
2005-01-28 Kristian Høgsberg <krh@redhat.com>
* src/cairo_png_surface.c (_cairo_png_surface_composite): Update
prototype to eliminate warning.
* src/cairo_pattern.c (_cairo_pattern_init_copy): Remember to
reference surfaces when copying patterns.
* src/cairo_gstate.c: (_cairo_rectangle_intersect),
(_cairo_gstate_clip_and_composite_trapezoids),
(_cairo_gstate_clip), (_cairo_gstate_show_glyphs): Don't call
_gstate_create_pattern for internally created patterns.
(_cairo_gstate_show_surface): Don't change the surface matrix
here, it's done later when we set it up as a pattern.
* test/Makefile.am: Correct clip_twice-ref.png filename.
* src/cairoint.h (MIN, MAX): Add these.
* src/cairo_gstate.c (_cairo_rectangle_intersect): Fix broken
intersection code.
2005-01-27 Kristian Høgsberg <krh@redhat.com>
* src/cairo_pattern.c (_cairo_pattern_get_surface): Make sure we

View file

@ -1413,27 +1413,20 @@ _cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_t *rectangle)
static void
_cairo_rectangle_intersect (cairo_rectangle_t *dest, cairo_rectangle_t *src)
{
if (dest->x < src->x)
dest->x = src->x;
cairo_rectangle_t out;
if (dest->y < src->y)
dest->y = src->y;
out.x = MAX (dest->x, src->x);
out.y = MAX (dest->y, src->y);
out.width = MIN (dest->x + dest->width, src->x + src->width) - out.x;
out.height = MIN (dest->y + dest->height, src->y + src->height) - out.y;
if (dest->x + dest->width < src->x + src->width)
dest->width = dest->x + dest->width - dest->x;
else
dest->width = src->x + src->width - dest->x;
if (dest->y + dest->height < src->y + src->height)
dest->height = dest->y + dest->height - dest->y;
else
dest->height = src->y + src->height - dest->y;
if (dest->width <= 0 || dest->height == 0) {
if (out.width <= 0 || out.height <= 0) {
dest->x = 0;
dest->y = 0;
dest->width = 0;
dest->height = 0;
} else {
*dest = out;
}
}
@ -1521,9 +1514,6 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
}
_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
_cairo_gstate_create_pattern (gstate, &pattern);
/* Override the alpha set from gstate. */
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,
&pattern, intermediate,
@ -1540,8 +1530,6 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
_cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
&pattern,
@ -1887,8 +1875,6 @@ _cairo_gstate_clip (cairo_gstate_t *gstate)
translate_traps (&traps, -gstate->clip.rect.x, -gstate->clip.rect.y);
_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
&pattern,
@ -1982,19 +1968,14 @@ _cairo_gstate_show_surface (cairo_gstate_t *gstate,
*/
cairo_status_t status;
cairo_matrix_t user_to_image, image_to_user;
cairo_matrix_t image_to_device, device_to_image;
cairo_matrix_t image_to_user, image_to_device;
double device_x, device_y;
double device_width, device_height;
cairo_pattern_t pattern;
cairo_box_t pattern_extents;
cairo_rectangle_t extents;
cairo_surface_get_matrix (surface, &user_to_image);
cairo_matrix_multiply (&device_to_image, &gstate->ctm_inverse, &user_to_image);
cairo_surface_set_matrix (surface, &device_to_image);
image_to_user = user_to_image;
cairo_surface_get_matrix (surface, &image_to_user);
cairo_matrix_invert (&image_to_user);
cairo_matrix_multiply (&image_to_device, &image_to_user, &gstate->ctm);
@ -2058,13 +2039,7 @@ _cairo_gstate_show_surface (cairo_gstate_t *gstate,
_cairo_pattern_fini (&pattern);
/* restore the matrix originally in the surface */
cairo_surface_set_matrix (surface, &user_to_image);
if (status)
return status;
return CAIRO_STATUS_SUCCESS;
return status;
}
static void
@ -2455,8 +2430,6 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
}
_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_font_show_glyphs (gstate->font,
CAIRO_OPERATOR_ADD,
@ -2472,8 +2445,6 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
goto BAIL2;
_cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
&pattern,

View file

@ -64,6 +64,9 @@ _cairo_pattern_init_copy (cairo_pattern_t *pattern, cairo_pattern_t *other)
sizeof (cairo_color_stop_t) * other->n_stops);
}
if (pattern->type == CAIRO_PATTERN_SURFACE)
cairo_surface_reference (pattern->u.surface.surface);
return CAIRO_STATUS_SUCCESS;
}
@ -820,6 +823,7 @@ _cairo_pattern_get_surface (cairo_pattern_t *pattern,
cairo_surface_set_filter (surface, cairo_surface_get_filter(src));
_cairo_surface_set_image (surface, image);
cairo_surface_set_matrix (surface, &(image->base.matrix));
cairo_surface_set_repeat (surface, image->base.repeat);
cairo_surface_destroy (&image->base);
return surface;

View file

@ -1413,27 +1413,20 @@ _cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_t *rectangle)
static void
_cairo_rectangle_intersect (cairo_rectangle_t *dest, cairo_rectangle_t *src)
{
if (dest->x < src->x)
dest->x = src->x;
cairo_rectangle_t out;
if (dest->y < src->y)
dest->y = src->y;
out.x = MAX (dest->x, src->x);
out.y = MAX (dest->y, src->y);
out.width = MIN (dest->x + dest->width, src->x + src->width) - out.x;
out.height = MIN (dest->y + dest->height, src->y + src->height) - out.y;
if (dest->x + dest->width < src->x + src->width)
dest->width = dest->x + dest->width - dest->x;
else
dest->width = src->x + src->width - dest->x;
if (dest->y + dest->height < src->y + src->height)
dest->height = dest->y + dest->height - dest->y;
else
dest->height = src->y + src->height - dest->y;
if (dest->width <= 0 || dest->height == 0) {
if (out.width <= 0 || out.height <= 0) {
dest->x = 0;
dest->y = 0;
dest->width = 0;
dest->height = 0;
} else {
*dest = out;
}
}
@ -1521,9 +1514,6 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
}
_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
_cairo_gstate_create_pattern (gstate, &pattern);
/* Override the alpha set from gstate. */
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,
&pattern, intermediate,
@ -1540,8 +1530,6 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
_cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
&pattern,
@ -1887,8 +1875,6 @@ _cairo_gstate_clip (cairo_gstate_t *gstate)
translate_traps (&traps, -gstate->clip.rect.x, -gstate->clip.rect.y);
_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
&pattern,
@ -1982,19 +1968,14 @@ _cairo_gstate_show_surface (cairo_gstate_t *gstate,
*/
cairo_status_t status;
cairo_matrix_t user_to_image, image_to_user;
cairo_matrix_t image_to_device, device_to_image;
cairo_matrix_t image_to_user, image_to_device;
double device_x, device_y;
double device_width, device_height;
cairo_pattern_t pattern;
cairo_box_t pattern_extents;
cairo_rectangle_t extents;
cairo_surface_get_matrix (surface, &user_to_image);
cairo_matrix_multiply (&device_to_image, &gstate->ctm_inverse, &user_to_image);
cairo_surface_set_matrix (surface, &device_to_image);
image_to_user = user_to_image;
cairo_surface_get_matrix (surface, &image_to_user);
cairo_matrix_invert (&image_to_user);
cairo_matrix_multiply (&image_to_device, &image_to_user, &gstate->ctm);
@ -2058,13 +2039,7 @@ _cairo_gstate_show_surface (cairo_gstate_t *gstate,
_cairo_pattern_fini (&pattern);
/* restore the matrix originally in the surface */
cairo_surface_set_matrix (surface, &user_to_image);
if (status)
return status;
return CAIRO_STATUS_SUCCESS;
return status;
}
static void
@ -2455,8 +2430,6 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
}
_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_font_show_glyphs (gstate->font,
CAIRO_OPERATOR_ADD,
@ -2472,8 +2445,6 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
goto BAIL2;
_cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
_cairo_gstate_create_pattern (gstate, &pattern);
_cairo_pattern_set_alpha (&pattern, 1.0);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
&pattern,

View file

@ -64,6 +64,9 @@ _cairo_pattern_init_copy (cairo_pattern_t *pattern, cairo_pattern_t *other)
sizeof (cairo_color_stop_t) * other->n_stops);
}
if (pattern->type == CAIRO_PATTERN_SURFACE)
cairo_surface_reference (pattern->u.surface.surface);
return CAIRO_STATUS_SUCCESS;
}
@ -820,6 +823,7 @@ _cairo_pattern_get_surface (cairo_pattern_t *pattern,
cairo_surface_set_filter (surface, cairo_surface_get_filter(src));
_cairo_surface_set_image (surface, image);
cairo_surface_set_matrix (surface, &(image->base.matrix));
cairo_surface_set_repeat (surface, image->base.repeat);
cairo_surface_destroy (&image->base);
return surface;

View file

@ -239,7 +239,7 @@ _cairo_png_surface_set_repeat (void *abstract_surface,
static cairo_int_status_t
_cairo_png_surface_composite (cairo_operator_t operator,
cairo_surface_t *generic_src,
cairo_pattern_t *pattern,
cairo_surface_t *generic_mask,
void *abstract_dst,
int src_x,

View file

@ -108,6 +108,9 @@
#define __attribute__(x)
#endif
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#include "cairo-wideint.h"
typedef int32_t cairo_fixed_16_16_t;

View file

@ -18,7 +18,7 @@ leaky_polygon-ref.png \
line_width-ref.png \
move_to_show_surface-ref.png \
coverage-ref.png \
clip_twice.png
clip_twice-ref.png
# Once we can draw the text_rotate.c test case correctly, we should
# create and add text_rotate-ref.png to the list of reference PNGs.