[cairo-commit] cairo/src cairo_gstate.c, 1.89,
1.90 cairo_image_surface.c, 1.25, 1.26 cairo_pattern.c, 1.22,
1.23 cairo_pdf_surface.c, 1.14, 1.15 cairo_ps_surface.c, 1.22,
1.23 cairo_xlib_surface.c, 1.44, 1.45 cairoint.h, 1.99, 1.100
David Reveman
commit at pdx.freedesktop.org
Thu Mar 3 17:40:08 PST 2005
Committed by: davidr
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv27097/src
Modified Files:
cairo_gstate.c cairo_image_surface.c cairo_pattern.c
cairo_pdf_surface.c cairo_ps_surface.c cairo_xlib_surface.c
cairoint.h
Log Message:
Change to cairo_surface_t like structure of of cairo_pattern_t
Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- cairo_gstate.c 1 Mar 2005 22:50:57 -0000 1.89
+++ cairo_gstate.c 4 Mar 2005 01:40:05 -0000 1.90
@@ -1313,13 +1313,13 @@
* does, it may make sense for this function to just disappear.
*/
static void
-_cairo_gstate_pattern_init_copy (cairo_gstate_t *gstate,
- cairo_pattern_t *pattern,
- cairo_pattern_t *src)
+_cairo_gstate_pattern_init_copy (cairo_gstate_t *gstate,
+ cairo_pattern_union_t *pattern,
+ cairo_pattern_t *src)
{
- _cairo_pattern_init_copy (pattern, src);
- _cairo_pattern_transform (pattern, &gstate->ctm_inverse);
- _cairo_pattern_set_alpha (pattern, gstate->alpha);
+ _cairo_pattern_init_copy (&pattern->base, src);
+ _cairo_pattern_transform (&pattern->base, &gstate->ctm_inverse);
+ _cairo_pattern_set_alpha (&pattern->base, gstate->alpha);
}
cairo_status_t
@@ -1472,7 +1472,7 @@
cairo_traps_t *traps)
{
cairo_status_t status;
- cairo_pattern_t pattern;
+ cairo_pattern_union_t pattern;
cairo_rectangle_t extents;
cairo_box_t trap_extents;
@@ -1510,26 +1510,28 @@
goto BAIL1;
}
- _cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
+ _cairo_pattern_init_solid (&pattern.solid, 1.0, 1.0, 1.0);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,
- &pattern, intermediate,
+ &pattern.base,
+ intermediate,
extents.x, extents.y,
0, 0,
extents.width,
extents.height,
traps->traps,
traps->num_traps);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
if (status)
goto BAIL2;
- _cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
+ _cairo_pattern_init_for_surface (&pattern.surface,
+ gstate->clip.surface);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
- &pattern,
+ &pattern.base,
NULL,
intermediate,
extents.x - gstate->clip.rect.x,
@@ -1537,7 +1539,7 @@
0, 0,
0, 0,
extents.width, extents.height);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
if (status)
goto BAIL2;
@@ -1545,13 +1547,13 @@
_cairo_gstate_pattern_init_copy (gstate, &pattern, src);
status = _cairo_surface_composite (operator,
- &pattern, intermediate, dst,
+ &pattern.base, intermediate, dst,
extents.x, extents.y,
0, 0,
extents.x, extents.y,
extents.width, extents.height);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
BAIL2:
cairo_surface_destroy (intermediate);
@@ -1598,7 +1600,7 @@
_cairo_gstate_pattern_init_copy (gstate, &pattern, src);
status = _cairo_surface_composite_trapezoids (gstate->operator,
- &pattern, dst,
+ &pattern.base, dst,
extents.x, extents.y,
extents.x, extents.y,
extents.width,
@@ -1606,7 +1608,7 @@
traps->traps,
traps->num_traps);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
if (status)
return status;
@@ -1825,7 +1827,7 @@
_cairo_gstate_clip (cairo_gstate_t *gstate)
{
cairo_status_t status;
- cairo_pattern_t pattern;
+ cairo_pattern_union_t pattern;
cairo_traps_t traps;
cairo_color_t white_color;
cairo_box_t extents;
@@ -1903,10 +1905,10 @@
}
translate_traps (&traps, -gstate->clip.rect.x, -gstate->clip.rect.y);
- _cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
+ _cairo_pattern_init_solid (&pattern.solid, 1.0, 1.0, 1.0);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
- &pattern,
+ &pattern.base,
gstate->clip.surface,
0, 0,
0, 0,
@@ -1915,7 +1917,7 @@
traps.traps,
traps.num_traps);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
_cairo_traps_fini (&traps);
@@ -2000,7 +2002,7 @@
cairo_matrix_t image_to_user, image_to_device;
double device_x, device_y;
double device_width, device_height;
- cairo_pattern_t pattern;
+ cairo_surface_pattern_t pattern;
cairo_box_t pattern_extents;
cairo_rectangle_t extents;
@@ -2016,8 +2018,18 @@
&device_width, &device_height);
_cairo_pattern_init_for_surface (&pattern, surface);
- _cairo_pattern_transform (&pattern, &gstate->ctm_inverse);
- _cairo_pattern_set_alpha (&pattern, gstate->alpha);
+
+ /* inherit surface attributes while surface attribute functions still
+ exist */
+ pattern.base.matrix = surface->matrix;
+ pattern.base.filter = surface->filter;
+ if (surface->repeat)
+ pattern.base.extend = CAIRO_EXTEND_REPEAT;
+ else
+ pattern.base.extend = CAIRO_EXTEND_NONE;
+
+ _cairo_pattern_transform (&pattern.base, &gstate->ctm_inverse);
+ _cairo_pattern_set_alpha (&pattern.base, gstate->alpha);
pattern_extents.p1.x = _cairo_fixed_from_double (device_x);
pattern_extents.p1.y = _cairo_fixed_from_double (device_y);
@@ -2032,7 +2044,7 @@
/* We only need to composite if the rectangle is not empty. */
if (!_cairo_rectangle_empty (&extents)) {
status = _cairo_surface_composite (gstate->operator,
- &pattern,
+ &pattern.base,
gstate->clip.surface,
gstate->surface,
extents.x, extents.y,
@@ -2051,7 +2063,7 @@
* rounded. Is this still the case?
*/
status = _cairo_surface_composite (gstate->operator,
- &pattern,
+ &pattern.base,
NULL,
gstate->surface,
extents.x, extents.y,
@@ -2061,7 +2073,7 @@
}
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
return status;
}
@@ -2378,7 +2390,7 @@
cairo_status_t status;
int i;
cairo_glyph_t *transformed_glyphs = NULL;
- cairo_pattern_t pattern;
+ cairo_pattern_union_t pattern;
cairo_box_t bbox;
cairo_rectangle_t extents;
@@ -2438,25 +2450,26 @@
transformed_glyphs[i].y -= extents.y;
}
- _cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
+ _cairo_pattern_init_solid (&pattern.solid, 1.0, 1.0, 1.0);
status = _cairo_font_show_glyphs (gstate->font,
CAIRO_OPERATOR_ADD,
- &pattern, intermediate,
+ &pattern.base, intermediate,
extents.x, extents.y,
0, 0,
extents.width, extents.height,
transformed_glyphs, num_glyphs);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
if (status)
goto BAIL2;
- _cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
+ _cairo_pattern_init_for_surface (&pattern.surface,
+ gstate->clip.surface);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
- &pattern,
+ &pattern.base,
NULL,
intermediate,
extents.x - gstate->clip.rect.x,
@@ -2465,7 +2478,7 @@
0, 0,
extents.width, extents.height);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
if (status)
goto BAIL2;
@@ -2473,14 +2486,14 @@
_cairo_gstate_pattern_init_copy (gstate, &pattern, gstate->pattern);
status = _cairo_surface_composite (gstate->operator,
- &pattern,
+ &pattern.base,
intermediate,
gstate->surface,
extents.x, extents.y,
0, 0,
extents.x, extents.y,
extents.width, extents.height);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
BAIL2:
cairo_surface_destroy (intermediate);
@@ -2492,14 +2505,14 @@
_cairo_gstate_pattern_init_copy (gstate, &pattern, gstate->pattern);
status = _cairo_font_show_glyphs (gstate->font,
- gstate->operator, &pattern,
+ gstate->operator, &pattern.base,
gstate->surface,
extents.x, extents.y,
extents.x, extents.y,
extents.width, extents.height,
transformed_glyphs, num_glyphs);
- _cairo_pattern_fini (&pattern);
+ _cairo_pattern_fini (&pattern.base);
}
CLEANUP_GLYPHS:
Index: cairo_image_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_image_surface.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cairo_image_surface.c 27 Feb 2005 19:02:49 -0000 1.25
+++ cairo_image_surface.c 4 Mar 2005 01:40:05 -0000 1.26
@@ -409,6 +409,34 @@
return CAIRO_STATUS_SUCCESS;
}
+static cairo_int_status_t
+_cairo_image_surface_set_attributes (cairo_image_surface_t *surface,
+ cairo_surface_attributes_t *attributes)
+{
+ cairo_int_status_t status;
+
+ status = _cairo_image_surface_set_matrix (surface, &attributes->matrix);
+ if (status)
+ return status;
+
+ switch (attributes->extend) {
+ case CAIRO_EXTEND_NONE:
+ _cairo_image_surface_set_repeat (surface, 0);
+ break;
+ case CAIRO_EXTEND_REPEAT:
+ _cairo_image_surface_set_repeat (surface, 1);
+ break;
+ case CAIRO_EXTEND_REFLECT:
+ /* XXX: Obviously wrong. */
+ _cairo_image_surface_set_repeat (surface, 1);
+ break;
+ }
+
+ status = _cairo_image_surface_set_filter (surface, attributes->filter);
+
+ return status;
+}
+
static pixman_operator_t
_pixman_operator (cairo_operator_t operator)
{
@@ -460,43 +488,51 @@
unsigned int width,
unsigned int height)
{
- cairo_image_surface_t *dst = abstract_dst;
- cairo_image_surface_t *src;
- cairo_image_surface_t *mask = NULL;
- void *mask_extra;
- cairo_pattern_info_t pattern_info;
- cairo_status_t status;
-
- status = _cairo_pattern_begin_draw (pattern, &pattern_info,
- &dst->base,
- src_x, src_y, width, height);
- if (!CAIRO_OK (status))
- return status;
-
- src = (cairo_image_surface_t *)pattern_info.src;
+ cairo_surface_attributes_t attributes;
+ cairo_image_surface_t *dst = abstract_dst;
+ cairo_image_surface_t *src;
+ cairo_image_surface_t *mask = NULL;
+ void *extra;
+ cairo_int_status_t status;
/* XXX This stuff can go when we change the mask to be a pattern also. */
- if (generic_mask) {
- status = _cairo_surface_acquire_source_image (generic_mask, &mask, &mask_extra);
- if (!CAIRO_OK (status))
- goto FAIL;
+ if (generic_mask)
+ {
+ status = _cairo_surface_acquire_source_image (generic_mask,
+ &mask, &extra);
+ if (status)
+ return status;
}
+
+ status = _cairo_pattern_acquire_surface (pattern, &dst->base,
+ src_x, src_y, width, height,
+ (cairo_surface_t **) &src,
+ &attributes);
+ if (status)
+ {
+ if (mask)
+ _cairo_surface_release_source_image (&dst->base, mask, extra);
+
+ return status;
+ }
+
+ status = _cairo_image_surface_set_attributes (src, &attributes);
+ if (CAIRO_OK (status))
+ pixman_composite (_pixman_operator (operator),
+ src->pixman_image,
+ mask ? mask->pixman_image : NULL,
+ dst->pixman_image,
+ src_x + attributes.x_offset,
+ src_y + attributes.y_offset,
+ mask_x, mask_y,
+ dst_x, dst_y,
+ width, height);
- pixman_composite (_pixman_operator (operator),
- src->pixman_image,
- mask ? mask->pixman_image : NULL,
- dst->pixman_image,
- src_x - pattern_info.x_offset, src_y - pattern_info.y_offset,
- mask_x, mask_y,
- dst_x, dst_y,
- width, height);
-
+ _cairo_pattern_release_surface (&dst->base, &src->base, &attributes);
if (mask)
- _cairo_surface_release_source_image (generic_mask, mask, mask_extra);
- FAIL:
- _cairo_pattern_end_draw (pattern, &pattern_info);
-
- return CAIRO_STATUS_SUCCESS;
+ _cairo_surface_release_source_image (&dst->base, mask, extra);
+
+ return status;
}
static cairo_int_status_t
@@ -535,21 +571,20 @@
cairo_trapezoid_t *traps,
int num_traps)
{
- cairo_image_surface_t *dst = abstract_dst;
- cairo_image_surface_t *src;
- cairo_pattern_info_t pattern_info;
- int render_reference_x, render_reference_y;
- int render_src_x, render_src_y;
- cairo_status_t status;
+ cairo_surface_attributes_t attributes;
+ cairo_image_surface_t *dst = abstract_dst;
+ cairo_image_surface_t *src;
+ cairo_int_status_t status;
+ int render_reference_x, render_reference_y;
+ int render_src_x, render_src_y;
- status = _cairo_pattern_begin_draw (pattern, &pattern_info,
- &dst->base,
- src_x, src_y, width, height);
- if (!CAIRO_OK (status))
+ status = _cairo_pattern_acquire_surface (pattern, &dst->base,
+ src_x, src_y, width, height,
+ (cairo_surface_t **) &src,
+ &attributes);
+ if (status)
return status;
- src = (cairo_image_surface_t *)pattern_info.src;
-
if (traps[0].left.p1.y < traps[0].left.p2.y) {
render_reference_x = _cairo_fixed_integer_floor (traps[0].left.p1.x);
render_reference_y = _cairo_fixed_integer_floor (traps[0].left.p1.y);
@@ -563,16 +598,18 @@
/* XXX: The pixman_trapezoid_t cast is evil and needs to go away
* somehow. */
- pixman_composite_trapezoids (operator,
- src->pixman_image,
- dst->pixman_image,
- render_src_x - pattern_info.x_offset,
- render_src_y - pattern_info.y_offset,
- (pixman_trapezoid_t *) traps, num_traps);
+ status = _cairo_image_surface_set_attributes (src, &attributes);
+ if (CAIRO_OK (status))
+ pixman_composite_trapezoids (operator,
+ src->pixman_image,
+ dst->pixman_image,
+ render_src_x + attributes.x_offset,
+ render_src_y + attributes.y_offset,
+ (pixman_trapezoid_t *) traps, num_traps);
- _cairo_pattern_end_draw (pattern, &pattern_info);
+ _cairo_pattern_release_surface (&dst->base, &src->base, &attributes);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
static cairo_int_status_t
Index: cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pattern.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cairo_pattern.c 25 Feb 2005 20:52:47 -0000 1.22
+++ cairo_pattern.c 4 Mar 2005 01:40:05 -0000 1.23
@@ -21,155 +21,254 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * Author: David Reveman <c99drn at cs.umu.se>
+ * Author: David Reveman <davidr at novell.com>
*/
#include "cairoint.h"
+typedef void (*cairo_shader_function_t) (unsigned char *color0,
+ unsigned char *color1,
[...1238 lines suppressed...]
-_cairo_pattern_end_draw (cairo_pattern_t *pattern,
- cairo_pattern_info_t *info)
+_cairo_pattern_release_surface (cairo_surface_t *dst,
+ cairo_surface_t *surface,
+ cairo_surface_attributes_t *attributes)
{
- _cairo_pattern_restore_surface (pattern, info->src);
-
- if (info->acquired)
- _cairo_surface_release_source_image (pattern->u.surface.surface,
- (cairo_image_surface_t *)info->src,
- info->extra);
+ if (attributes->acquired)
+ _cairo_surface_release_source_image (dst,
+ (cairo_image_surface_t *) surface,
+ attributes->extra);
else
- cairo_surface_destroy (info->src);
+ cairo_surface_destroy (surface);
}
Index: cairo_pdf_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pdf_surface.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cairo_pdf_surface.c 14 Feb 2005 04:36:28 -0000 1.14
+++ cairo_pdf_surface.c 4 Mar 2005 01:40:05 -0000 1.15
@@ -1234,7 +1234,7 @@
static cairo_int_status_t
_cairo_pdf_surface_composite_image (cairo_pdf_surface_t *dst,
- cairo_pattern_t *pattern)
+ cairo_surface_pattern_t *pattern)
{
cairo_pdf_document_t *document = dst->document;
FILE *file = document->file;
@@ -1245,7 +1245,7 @@
cairo_surface_t *src;
void *image_extra;
- src = pattern->u.surface.surface;
+ src = pattern->surface;
status = _cairo_surface_acquire_source_image (src, &image, &image_extra);
if (!CAIRO_OK (status))
return status;
@@ -1260,7 +1260,7 @@
_cairo_pdf_surface_ensure_stream (dst);
- cairo_matrix_copy (&i2u, &pattern->matrix);
+ cairo_matrix_copy (&i2u, &pattern->base.matrix);
cairo_matrix_invert (&i2u);
cairo_matrix_translate (&i2u, 0, image->height);
cairo_matrix_scale (&i2u, image->width, -image->height);
@@ -1290,7 +1290,7 @@
static cairo_int_status_t
_cairo_pdf_surface_composite_pdf (cairo_pdf_surface_t *dst,
- cairo_pattern_t *pattern)
+ cairo_surface_pattern_t *pattern)
{
cairo_pdf_document_t *document = dst->document;
FILE *file = document->file;
@@ -1301,7 +1301,7 @@
_cairo_pdf_surface_ensure_stream (dst);
- src = (cairo_pdf_surface_t *) pattern->u.surface.surface;
+ src = (cairo_pdf_surface_t *) pattern->surface;
cairo_matrix_copy (&i2u, &src->base.matrix);
cairo_matrix_invert (&i2u);
@@ -1346,14 +1346,15 @@
unsigned int height)
{
cairo_pdf_surface_t *dst = abstract_dst;
+ cairo_surface_pattern_t *src = (cairo_surface_pattern_t *) pattern;
if (pattern->type != CAIRO_PATTERN_SURFACE)
return CAIRO_STATUS_SUCCESS;
- if (pattern->u.surface.surface->backend == &cairo_pdf_surface_backend)
- return _cairo_pdf_surface_composite_pdf (dst, pattern);
+ if (src->surface->backend == &cairo_pdf_surface_backend)
+ return _cairo_pdf_surface_composite_pdf (dst, src);
else
- return _cairo_pdf_surface_composite_image (dst, pattern);
+ return _cairo_pdf_surface_composite_image (dst, src);
}
static cairo_int_status_t
@@ -1385,25 +1386,26 @@
}
static void
-emit_solid_pattern (cairo_pdf_surface_t *surface, cairo_pattern_t *pattern)
+emit_solid_pattern (cairo_pdf_surface_t *surface,
+ cairo_solid_pattern_t *pattern)
{
cairo_pdf_document_t *document = surface->document;
FILE *file = document->file;
unsigned int alpha;
- alpha = _cairo_pdf_surface_add_alpha (surface, pattern->color.alpha);
+ alpha = _cairo_pdf_surface_add_alpha (surface, pattern->base.alpha);
_cairo_pdf_surface_ensure_stream (surface);
fprintf (file,
"%f %f %f rg /a%d gs\r\n",
- pattern->color.red,
- pattern->color.green,
- pattern->color.blue,
+ pattern->red,
+ pattern->green,
+ pattern->blue,
alpha);
}
static void
emit_surface_pattern (cairo_pdf_surface_t *dst,
- cairo_pattern_t *pattern)
+ cairo_surface_pattern_t *pattern)
{
cairo_pdf_document_t *document = dst->document;
FILE *file = document->file;
@@ -1415,11 +1417,11 @@
unsigned int id, alpha;
cairo_matrix_t pm;
- if (pattern->u.surface.surface->backend == &cairo_pdf_surface_backend) {
+ if (pattern->surface->backend == &cairo_pdf_surface_backend) {
return;
}
- status = _cairo_surface_acquire_source_image (pattern->u.surface.surface, &image, &image_extra);
+ status = _cairo_surface_acquire_source_image (pattern->surface, &image, &image_extra);
if (!CAIRO_OK (status))
return;
@@ -1432,7 +1434,7 @@
cairo_matrix_set_identity (&pm);
cairo_matrix_scale (&pm, image->width, image->height);
- cairo_matrix_copy (&pm, &pattern->matrix);
+ cairo_matrix_copy (&pm, &pattern->base.matrix);
cairo_matrix_invert (&pm);
snprintf (entries, sizeof entries,
@@ -1461,11 +1463,11 @@
"/Pattern cs /res%d scn /a%d gs\r\n",
stream->id, alpha);
- _cairo_surface_release_source_image (pattern->u.surface.surface, image, image_extra);
+ _cairo_surface_release_source_image (pattern->surface, image, image_extra);
}
static unsigned int
-emit_pattern_stops (cairo_pdf_surface_t *surface, cairo_pattern_t *pattern)
+emit_pattern_stops (cairo_pdf_surface_t *surface, cairo_gradient_pattern_t *pattern)
{
cairo_pdf_document_t *document = surface->document;
FILE *file = document->file;
@@ -1484,12 +1486,12 @@
"stream\r\n",
function_id);
- fputc (pattern->stops[0].color_char[0], file);
- fputc (pattern->stops[0].color_char[1], file);
- fputc (pattern->stops[0].color_char[2], file);
- fputc (pattern->stops[1].color_char[0], file);
- fputc (pattern->stops[1].color_char[1], file);
- fputc (pattern->stops[1].color_char[2], file);
+ fputc (pattern->stops[0].color.red * 0xff, file);
+ fputc (pattern->stops[0].color.green * 0xff, file);
+ fputc (pattern->stops[0].color.blue * 0xff, file);
+ fputc (pattern->stops[1].color.red * 0xff, file);
+ fputc (pattern->stops[1].color.green * 0xff, file);
+ fputc (pattern->stops[1].color.blue * 0xff, file);
fprintf (file,
"\r\n"
@@ -1500,7 +1502,7 @@
}
static void
-emit_linear_pattern (cairo_pdf_surface_t *surface, cairo_pattern_t *pattern)
+emit_linear_pattern (cairo_pdf_surface_t *surface, cairo_linear_pattern_t *pattern)
{
cairo_pdf_document_t *document = surface->document;
FILE *file = document->file;
@@ -1510,16 +1512,16 @@
_cairo_pdf_document_close_stream (document);
- function_id = emit_pattern_stops (surface, pattern);
+ function_id = emit_pattern_stops (surface, &pattern->base);
- cairo_matrix_copy (&p2u, &pattern->matrix);
+ cairo_matrix_copy (&p2u, &pattern->base.base.matrix);
cairo_matrix_invert (&p2u);
- x0 = pattern->u.linear.point0.x;
- y0 = pattern->u.linear.point0.y;
+ x0 = pattern->point0.x;
+ y0 = pattern->point0.y;
cairo_matrix_transform_point (&p2u, &x0, &y0);
- x1 = pattern->u.linear.point1.x;
- y1 = pattern->u.linear.point1.y;
+ x1 = pattern->point1.x;
+ y1 = pattern->point1.y;
cairo_matrix_transform_point (&p2u, &x1, &y1);
pattern_id = _cairo_pdf_document_new_object (document);
@@ -1554,7 +1556,7 @@
}
static void
-emit_radial_pattern (cairo_pdf_surface_t *surface, cairo_pattern_t *pattern)
+emit_radial_pattern (cairo_pdf_surface_t *surface, cairo_radial_pattern_t *pattern)
{
cairo_pdf_document_t *document = surface->document;
FILE *file = document->file;
@@ -1564,18 +1566,18 @@
_cairo_pdf_document_close_stream (document);
- function_id = emit_pattern_stops (surface, pattern);
+ function_id = emit_pattern_stops (surface, &pattern->base);
- cairo_matrix_copy (&p2u, &pattern->matrix);
+ cairo_matrix_copy (&p2u, &pattern->base.base.matrix);
cairo_matrix_invert (&p2u);
- x0 = pattern->u.radial.center0.x;
- y0 = pattern->u.radial.center0.y;
- r0 = pattern->u.radial.radius0;
+ x0 = pattern->center0.x;
+ y0 = pattern->center0.y;
+ r0 = pattern->radius0;
cairo_matrix_transform_point (&p2u, &x0, &y0);
- x1 = pattern->u.radial.center1.x;
- y1 = pattern->u.radial.center1.y;
- r1 = pattern->u.radial.radius1;
+ x1 = pattern->center1.x;
+ y1 = pattern->center1.y;
+ r1 = pattern->radius1;
cairo_matrix_transform_point (&p2u, &x1, &y1);
/* FIXME: This is surely crack, but how should you scale a radius
@@ -1625,19 +1627,19 @@
{
switch (pattern->type) {
case CAIRO_PATTERN_SOLID:
- emit_solid_pattern (surface, pattern);
+ emit_solid_pattern (surface, (cairo_solid_pattern_t *) pattern);
break;
case CAIRO_PATTERN_SURFACE:
- emit_surface_pattern (surface, pattern);
+ emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern);
break;
case CAIRO_PATTERN_LINEAR:
- emit_linear_pattern (surface, pattern);
+ emit_linear_pattern (surface, (cairo_linear_pattern_t *) pattern);
break;
case CAIRO_PATTERN_RADIAL:
- emit_radial_pattern (surface, pattern);
+ emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern);
break;
}
}
Index: cairo_ps_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_ps_surface.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cairo_ps_surface.c 22 Feb 2005 19:35:03 -0000 1.22
+++ cairo_ps_surface.c 4 Mar 2005 01:40:06 -0000 1.23
@@ -344,7 +344,7 @@
int i, x, y;
- cairo_pattern_t white_pattern;
+ cairo_solid_pattern_t white_pattern;
char *rgb, *compressed;
long rgb_size, compressed_size;
@@ -368,7 +368,7 @@
_cairo_pattern_init_solid (&white_pattern, 1.0, 1.0, 1.0);
_cairo_surface_composite (CAIRO_OPERATOR_OVER_REVERSE,
- &white_pattern,
+ &white_pattern.base,
NULL,
&surface->image->base,
0, 0,
@@ -376,7 +376,7 @@
0, 0,
width, height);
- _cairo_pattern_fini (&white_pattern);
+ _cairo_pattern_fini (&white_pattern.base);
i = 0;
for (y = 0; y < height; y++) {
Index: cairo_xlib_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_xlib_surface.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cairo_xlib_surface.c 22 Feb 2005 19:35:03 -0000 1.44
+++ cairo_xlib_surface.c 4 Mar 2005 01:40:06 -0000 1.45
@@ -541,6 +541,34 @@
return CAIRO_STATUS_SUCCESS;
}
+static cairo_int_status_t
+_cairo_xlib_surface_set_attributes (cairo_xlib_surface_t *surface,
+ cairo_surface_attributes_t *attributes)
+{
+ cairo_int_status_t status;
+
+ status = _cairo_xlib_surface_set_matrix (surface, &attributes->matrix);
+ if (status)
+ return status;
+
+ switch (attributes->extend) {
+ case CAIRO_EXTEND_NONE:
+ _cairo_xlib_surface_set_repeat (surface, 0);
+ break;
+ case CAIRO_EXTEND_REPEAT:
+ _cairo_xlib_surface_set_repeat (surface, 1);
+ break;
+ case CAIRO_EXTEND_REFLECT:
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+ }
+
+ status = _cairo_xlib_surface_set_filter (surface, attributes->filter);
+ if (status)
+ return status;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
static int
_render_operator (cairo_operator_t operator)
{
@@ -592,75 +620,58 @@
unsigned int width,
unsigned int height)
{
- cairo_xlib_surface_t *dst = abstract_dst;
- cairo_xlib_surface_t *src;
- cairo_xlib_surface_t *mask = (cairo_xlib_surface_t *) generic_mask;
- cairo_surface_t *mask_clone = NULL;
- XGCValues gc_values;
- int src_x_off, src_y_off, dst_x_off, dst_y_off;
- cairo_pattern_info_t pattern_info;
- cairo_status_t status;
+ cairo_surface_attributes_t attributes;
+ cairo_xlib_surface_t *dst = abstract_dst;
+ cairo_xlib_surface_t *src;
+ cairo_xlib_surface_t *mask = (cairo_xlib_surface_t *) generic_mask;
+ cairo_surface_t *mask_clone = NULL;
+ cairo_int_status_t status;
if (!CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst))
return CAIRO_INT_STATUS_UNSUPPORTED;
- status = _cairo_pattern_begin_draw (pattern, &pattern_info,
- &dst->base,
- src_x, src_y, width, height);
- if (!CAIRO_OK (status))
- return status;
-
- src = (cairo_xlib_surface_t *)pattern_info.src;
-
/* XXX This stuff can go when we change the mask to be a pattern also. */
- if (generic_mask && (generic_mask->backend != dst->base.backend || mask->dpy != dst->dpy)) {
- status = _cairo_surface_clone_similar (abstract_dst, generic_mask, &mask_clone);
- if (!CAIRO_OK (status))
- goto FAIL;
- mask = (cairo_xlib_surface_t *)mask_clone;
+ if (generic_mask && (generic_mask->backend != dst->base.backend ||
+ mask->dpy != dst->dpy)) {
+ status = _cairo_surface_clone_similar (abstract_dst, generic_mask,
+ &mask_clone);
+ if (status)
+ return status;
+
+ mask = (cairo_xlib_surface_t *) mask_clone;
}
-
- if (operator == CAIRO_OPERATOR_SRC
- && !mask
- && _cairo_matrix_is_integer_translation(&(src->base.matrix),
- &src_x_off, &src_y_off)
- && _cairo_matrix_is_integer_translation(&(dst->base.matrix),
- &dst_x_off, &dst_y_off)) {
- /* Fast path for copying "raw" areas. */
- _cairo_xlib_surface_ensure_gc (dst);
- XGetGCValues(dst->dpy, dst->gc, GCGraphicsExposures, &gc_values);
- XSetGraphicsExposures(dst->dpy, dst->gc, False);
- XCopyArea(dst->dpy,
- src->drawable,
- dst->drawable,
- dst->gc,
- src_x + src_x_off - pattern_info.x_offset,
- src_y + src_y_off - pattern_info.y_offset,
- width, height,
- dst_x + dst_x_off,
- dst_y + dst_y_off);
- XSetGraphicsExposures(dst->dpy, dst->gc, gc_values.graphics_exposures);
-
- } else {
+
+ status = _cairo_pattern_acquire_surface (pattern, &dst->base,
+ src_x, src_y, width, height,
+ (cairo_surface_t **) &src,
+ &attributes);
+ if (status)
+ {
+ if (mask_clone)
+ cairo_surface_destroy (mask_clone);
+
+ return status;
+ }
+
+ status = _cairo_xlib_surface_set_attributes (src, &attributes);
+ if (CAIRO_OK (status))
XRenderComposite (dst->dpy,
_render_operator (operator),
src->picture,
mask ? mask->picture : 0,
dst->picture,
- src_x - pattern_info.x_offset,
- src_y - pattern_info.y_offset,
+ src_x + attributes.x_offset,
+ src_y + attributes.y_offset,
mask_x, mask_y,
dst_x, dst_y,
width, height);
- }
if (mask_clone)
cairo_surface_destroy (mask_clone);
+
+ _cairo_pattern_release_surface (&dst->base, &src->base, &attributes);
- FAIL:
- _cairo_pattern_end_draw (pattern, &pattern_info);
-
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
static cairo_int_status_t
@@ -703,24 +714,23 @@
cairo_trapezoid_t *traps,
int num_traps)
{
- cairo_xlib_surface_t *dst = abstract_dst;
- cairo_xlib_surface_t *src;
- cairo_pattern_info_t pattern_info;
- int render_reference_x, render_reference_y;
- int render_src_x, render_src_y;
- cairo_status_t status;
+ cairo_surface_attributes_t attributes;
+ cairo_xlib_surface_t *dst = abstract_dst;
+ cairo_xlib_surface_t *src;
+ cairo_int_status_t status;
+ int render_reference_x, render_reference_y;
+ int render_src_x, render_src_y;
if (!CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS (dst))
return CAIRO_INT_STATUS_UNSUPPORTED;
-
- status = _cairo_pattern_begin_draw (pattern, &pattern_info,
- &dst->base,
- src_x, src_y, width, height);
- if (!CAIRO_OK (status))
+
+ status = _cairo_pattern_acquire_surface (pattern, &dst->base,
+ src_x, src_y, width, height,
+ (cairo_surface_t **) &src,
+ &attributes);
+ if (status)
return status;
-
- src = (cairo_xlib_surface_t *)pattern_info.src;
-
+
if (traps[0].left.p1.y < traps[0].left.p2.y) {
render_reference_x = _cairo_fixed_integer_floor (traps[0].left.p1.x);
render_reference_y = _cairo_fixed_integer_floor (traps[0].left.p1.y);
@@ -733,17 +743,19 @@
render_src_y = src_y + render_reference_y - dst_y;
/* XXX: The XTrapezoid cast is evil and needs to go away somehow. */
- XRenderCompositeTrapezoids (dst->dpy,
- _render_operator (operator),
- src->picture, dst->picture,
- XRenderFindStandardFormat (dst->dpy, PictStandardA8),
- render_src_x - pattern_info.x_offset,
- render_src_y - pattern_info.y_offset,
- (XTrapezoid *) traps, num_traps);
+ status = _cairo_xlib_surface_set_attributes (src, &attributes);
+ if (CAIRO_OK (status))
+ XRenderCompositeTrapezoids (dst->dpy,
+ _render_operator (operator),
+ src->picture, dst->picture,
+ XRenderFindStandardFormat (dst->dpy, PictStandardA8),
+ render_src_x + attributes.x_offset,
+ render_src_y + attributes.y_offset,
+ (XTrapezoid *) traps, num_traps);
- _cairo_pattern_end_draw (pattern, &pattern_info);
+ _cairo_pattern_release_surface (&dst->base, &src->base, &attributes);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
static cairo_int_status_t
@@ -1402,12 +1414,12 @@
const cairo_glyph_t *glyphs,
int num_glyphs)
{
+ cairo_surface_attributes_t attributes;
+ cairo_int_status_t status;
unsigned int elt_size;
cairo_xlib_surface_t *self = abstract_surface;
- cairo_pattern_info_t pattern_info;
cairo_xlib_surface_t *src;
glyphset_cache_t *g;
- cairo_status_t status = CAIRO_STATUS_NO_MEMORY;
cairo_glyph_cache_key_t key;
glyphset_cache_entry_t **entries;
glyphset_cache_entry_t *stack_entries [N_STACK_BUF];
@@ -1415,6 +1427,17 @@
if (!CAIRO_SURFACE_RENDER_HAS_COMPOSITE_TEXT (self))
return CAIRO_INT_STATUS_UNSUPPORTED;
+
+ status = _cairo_pattern_acquire_surface (pattern, &self->base,
+ source_x, source_y, width, height,
+ (cairo_surface_t **) &src,
+ &attributes);
+ if (status)
+ return status;
+
+ status = _cairo_xlib_surface_set_attributes (src, &attributes);
+ if (status)
+ goto FAIL;
/* Acquire an entry array of suitable size. */
if (num_glyphs < N_STACK_BUF) {
@@ -1426,14 +1449,6 @@
goto FAIL;
}
- status = _cairo_pattern_begin_draw (pattern, &pattern_info,
- &self->base,
- source_x, source_y, width, height);
- if (!CAIRO_OK (status))
- goto FREE_ENTRIES;
-
- src = (cairo_xlib_surface_t *)pattern_info.src;
-
_lock_xlib_glyphset_caches ();
g = _get_glyphset_cache (self->dpy);
if (g == NULL)
@@ -1470,18 +1485,18 @@
if (elt_size == 8)
status = _cairo_xlib_surface_show_glyphs8 (font, operator, g, &key, src, self,
- source_x - pattern_info.x_offset,
- source_y - pattern_info.y_offset,
+ source_x + attributes.x_offset,
+ source_y + attributes.y_offset,
glyphs, entries, num_glyphs);
else if (elt_size == 16)
status = _cairo_xlib_surface_show_glyphs16 (font, operator, g, &key, src, self,
- source_x - pattern_info.x_offset,
- source_y - pattern_info.y_offset,
+ source_x + attributes.x_offset,
+ source_y + attributes.y_offset,
glyphs, entries, num_glyphs);
else
status = _cairo_xlib_surface_show_glyphs32 (font, operator, g, &key, src, self,
- source_x - pattern_info.x_offset,
- source_y - pattern_info.y_offset,
+ source_x + attributes.x_offset,
+ source_y + attributes.y_offset,
glyphs, entries, num_glyphs);
for (i = 0; i < num_glyphs; ++i)
@@ -1489,12 +1504,12 @@
UNLOCK:
_unlock_xlib_glyphset_caches ();
- _cairo_pattern_end_draw (pattern, &pattern_info);
- FREE_ENTRIES:
if (num_glyphs >= N_STACK_BUF)
free (entries);
FAIL:
+ _cairo_pattern_release_surface (&self->base, &src->base, &attributes);
+
return status;
}
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- cairoint.h 25 Feb 2005 21:31:00 -0000 1.99
+++ cairoint.h 4 Mar 2005 01:40:06 -0000 1.100
@@ -730,64 +730,77 @@
typedef struct _cairo_color_stop {
cairo_fixed_t offset;
- cairo_fixed_48_16_t scale;
- int id;
- unsigned char color_char[4];
+ cairo_color_t color;
} cairo_color_stop_t;
-typedef void (*cairo_shader_function_t) (unsigned char *color0,
- unsigned char *color1,
- cairo_fixed_t factor,
- int *pixel);
+struct _cairo_pattern {
+ cairo_pattern_type_t type;
+ unsigned int ref_count;
+ cairo_matrix_t matrix;
+ cairo_filter_t filter;
+ cairo_extend_t extend;
+ double alpha;
+};
-typedef struct _cairo_shader_op {
- cairo_color_stop_t *stops;
- int n_stops;
- cairo_extend_t extend;
- cairo_shader_function_t shader_function;
-} cairo_shader_op_t;
+typedef struct _cairo_solid_pattern {
+ cairo_pattern_t base;
+
+ double red, green, blue;
+} cairo_solid_pattern_t;
-struct _cairo_pattern {
- unsigned int ref_count;
-
- cairo_extend_t extend;
- cairo_filter_t filter;
- cairo_matrix_t matrix;
-
+typedef struct _cairo_surface_pattern {
+ cairo_pattern_t base;
+
+ cairo_surface_t *surface;
+} cairo_surface_pattern_t;
+
+typedef struct _cairo_gradient_pattern {
+ cairo_pattern_t base;
+
cairo_color_stop_t *stops;
- int n_stops;
+ int n_stops;
+} cairo_gradient_pattern_t;
- cairo_color_t color;
-
- cairo_pattern_type_t type;
- union {
- struct {
- cairo_surface_t *surface;
- cairo_matrix_t save_matrix;
- int save_repeat;
- cairo_filter_t save_filter;
- } surface;
- struct {
- cairo_point_double_t point0;
- cairo_point_double_t point1;
- } linear;
- struct {
- cairo_point_double_t center0;
- cairo_point_double_t center1;
- double radius0;
- double radius1;
- } radial;
- } u;
-};
+typedef struct _cairo_linear_pattern {
+ cairo_gradient_pattern_t base;
-typedef struct {
- cairo_surface_t *src;
- int x_offset;
- int y_offset;
+ cairo_point_double_t point0;
+ cairo_point_double_t point1;
+} cairo_linear_pattern_t;
- int acquired; /* If we used _cairo_surface_acquire_source_image */
- void *extra;
-} cairo_pattern_info_t;
+typedef struct _cairo_radial_pattern {
+ cairo_gradient_pattern_t base;
+
+ cairo_point_double_t center0;
+ cairo_point_double_t center1;
+ double radius0;
+ double radius1;
+} cairo_radial_pattern_t;
+
+typedef union {
+ cairo_gradient_pattern_t base;
+
+ cairo_linear_pattern_t linear;
+ cairo_radial_pattern_t radial;
+} cairo_gradient_pattern_union_t;
+
+typedef union {
+ cairo_pattern_t base;
+
+ cairo_solid_pattern_t solid;
+ cairo_surface_pattern_t surface;
+ cairo_gradient_pattern_union_t gradient;
+} cairo_pattern_union_t;
+
+typedef struct _cairo_surface_attributes {
+ cairo_matrix_t matrix;
+ cairo_extend_t extend;
+ cairo_filter_t filter;
+ int x_offset;
+ int y_offset;
+ cairo_bool_t acquired;
+ void *extra;
+} cairo_surface_attributes_t;
typedef struct _cairo_traps {
cairo_trapezoid_t *traps;
@@ -1676,23 +1689,30 @@
_cairo_slope_counter_clockwise (cairo_slope_t *a, cairo_slope_t *b);
/* cairo_pattern.c */
-cairo_private void
-_cairo_pattern_init (cairo_pattern_t *pattern);
cairo_private cairo_status_t
_cairo_pattern_init_copy (cairo_pattern_t *pattern, cairo_pattern_t *other);
cairo_private void
-_cairo_pattern_fini (cairo_pattern_t *pattern);
-
-cairo_private void
-_cairo_pattern_init_solid (cairo_pattern_t *pattern,
+_cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
double red, double green, double blue);
-void
-_cairo_pattern_init_for_surface (cairo_pattern_t *pattern,
+cairo_private void
+_cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern,
cairo_surface_t *surface);
+cairo_private void
+_cairo_pattern_init_linear (cairo_linear_pattern_t *pattern,
+ double x0, double y0, double x1, double y1);
+
+cairo_private void
+_cairo_pattern_init_radial (cairo_radial_pattern_t *pattern,
+ double cx0, double cy0, double radius0,
+ double cx1, double cy1, double radius1);
+
+cairo_private void
+_cairo_pattern_fini (cairo_pattern_t *pattern);
+
cairo_private cairo_pattern_t *
_cairo_pattern_create_solid (double red, double green, double blue);
@@ -1707,35 +1727,21 @@
_cairo_pattern_transform (cairo_pattern_t *pattern,
cairo_matrix_t *ctm_inverse);
-cairo_private void
-_cairo_pattern_prepare_surface (cairo_pattern_t *pattern,
- cairo_surface_t *surface);
-
-cairo_private void
-_cairo_pattern_restore_surface (cairo_pattern_t *pattern,
- cairo_surface_t *surface);
-
-cairo_private void
-_cairo_pattern_shader_init (cairo_pattern_t *pattern,
- cairo_shader_op_t *op);
+cairo_private cairo_int_status_t
+_cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
+ cairo_surface_t *dst,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height,
+ cairo_surface_t **surface_out,
+ cairo_surface_attributes_t *attributes);
cairo_private void
-_cairo_pattern_calc_color_at_pixel (cairo_shader_op_t *op,
- cairo_fixed_t factor,
- int *pixel);
-
-cairo_private cairo_status_t
-_cairo_pattern_begin_draw (cairo_pattern_t *pattern,
- cairo_pattern_info_t *info,
- cairo_surface_t *dst,
- int x,
- int y,
- unsigned int width,
- unsigned int height);
+_cairo_pattern_release_surface (cairo_surface_t *dst,
+ cairo_surface_t *surface,
+ cairo_surface_attributes_t *attributes);
-cairo_private void
-_cairo_pattern_end_draw (cairo_pattern_t *pattern,
- cairo_pattern_info_t *info);
/* cairo_unicode.c */
More information about the cairo-commit
mailing list