[cairo-commit] cairo/src cairo-glitz-surface.c, 1.48,
1.49 cairo-gstate.c, 1.144, 1.145 cairo-image-surface.c, 1.47,
1.48 cairo-meta-surface.c, 1.2, 1.3 cairo-pattern.c, 1.47,
1.48 cairo-pdf-surface.c, 1.48, 1.49 cairo-ps-surface.c, 1.39,
1.40 cairo-quartz-surface.c, 1.12, 1.13 cairo-surface.c, 1.77,
1.78 cairo-win32-surface.c, 1.27, 1.28 cairo-xcb-surface.c,
1.38, 1.39 cairo-xlib-surface.c, 1.85, 1.86 cairo.h, 1.133,
1.134 cairoint.h, 1.160, 1.161
Carl Worth
commit at pdx.freedesktop.org
Fri Jul 8 10:12:31 PDT 2005
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv8893/src
Modified Files:
cairo-glitz-surface.c cairo-gstate.c cairo-image-surface.c
cairo-meta-surface.c cairo-pattern.c cairo-pdf-surface.c
cairo-ps-surface.c cairo-quartz-surface.c cairo-surface.c
cairo-win32-surface.c cairo-xcb-surface.c cairo-xlib-surface.c
cairo.h cairoint.h
Log Message:
* src/cairo.h: Give enum tags an underscore prefix to match the
style of the struct tags. Add new cairo_content_t and change
cairo_surface_create_similar to accept a cairo_content_t rather
than a cairo_format_t.
* src/cairoint.h:
* src/cairo-glitz-surface.c: (_cairo_glitz_surface_create_similar):
* src/cairo-image-surface.c: (_cairo_image_surface_create_similar):
* src/cairo-meta-surface.c: (_cairo_meta_surface_create_similar):
* src/cairo-pdf-surface.c: (_cairo_pdf_surface_create_similar):
* src/cairo-ps-surface.c: (_cairo_ps_surface_create_similar):
* src/cairo-quartz-surface.c: (_cairo_quartz_surface_create_similar):
* src/cairo-surface.c: (_cairo_surface_create_similar_scratch),
(cairo_surface_create_similar),
(_cairo_surface_create_similar_solid):
* src/cairo-win32-surface.c: (_cairo_win32_surface_create_similar),
(_cairo_win32_surface_get_subimage):
* src/cairo-xcb-surface.c: (_cairo_xcb_surface_create_similar),
(_cairo_xcb_surface_clone_similar):
* src/cairo-xlib-surface.c: (_cairo_xlib_surface_create_similar),
(_cairo_xlib_surface_clone_similar): Change surface backend
create_similar call to accept a cairo_content_t rather than a
cairo_format_t.
* src/cairo-glitz-surface.c: (_glitz_format_from_content),
(_cairo_glitz_surface_clone_similar),
(_cairo_glitz_pattern_acquire_surface),
(_cairo_glitz_surface_fill_rectangles),
(_cairo_glitz_surface_composite_trapezoids):
* src/cairo-gstate.c: (_cairo_gstate_mask),
(_composite_traps_intermediate_surface),
(_cairo_gstate_intersect_clip_mask), (_cairo_gstate_show_glyphs):
* src/cairo-image-surface.c: (cairo_image_surface_create),
(cairo_image_surface_create_for_data),
(_cairo_format_from_content), (_cairo_content_from_format):
* src/cairo-pattern.c: (_cairo_pattern_acquire_surface_for_solid):
* src/cairo-ps-surface.c: (emit_image):
* test/mask.c: (mask_polygon), (draw):
* test/pixman-rotate.c: (draw):
* test/source-clip.c: (draw): Fix all calls into create_similar to
pass a cairo_content_t rather than a cairo_format_t.
Index: cairo-glitz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-glitz-surface.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cairo-glitz-surface.c 4 Jul 2005 10:58:44 -0000 1.48
+++ cairo-glitz-surface.c 8 Jul 2005 17:12:29 -0000 1.49
@@ -52,26 +52,26 @@
}
static glitz_format_name_t
-_glitz_format (cairo_format_t format)
+_glitz_format_from_content (cairo_content_t content)
{
- switch (format) {
- default:
- case CAIRO_FORMAT_ARGB32:
- return GLITZ_STANDARD_ARGB32;
- case CAIRO_FORMAT_RGB24:
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
return GLITZ_STANDARD_RGB24;
- case CAIRO_FORMAT_A8:
+ case CAIRO_CONTENT_ALPHA:
return GLITZ_STANDARD_A8;
- case CAIRO_FORMAT_A1:
- return GLITZ_STANDARD_A1;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ return GLITZ_STANDARD_ARGB32;
}
+
+ ASSERT_NOT_REACHED;
+ return GLITZ_STANDARD_ARGB32;
}
static cairo_surface_t *
_cairo_glitz_surface_create_similar (void *abstract_src,
- cairo_format_t format,
- int width,
- int height)
+ cairo_content_t content,
+ int width,
+ int height)
{
cairo_glitz_surface_t *src = abstract_src;
cairo_surface_t *crsurface;
@@ -81,7 +81,8 @@
drawable = glitz_surface_get_drawable (src->surface);
- gformat = glitz_find_standard_format (drawable, _glitz_format (format));
+ gformat = glitz_find_standard_format (drawable,
+ _glitz_format_from_content (content));
if (!gformat)
return NULL;
@@ -350,9 +351,10 @@
else if (_cairo_surface_is_image (src))
{
cairo_image_surface_t *image_src = (cairo_image_surface_t *) src;
+ cairo_content_t content = _cairo_content_from_format (image_src->format);
clone = (cairo_glitz_surface_t *)
- _cairo_glitz_surface_create_similar (surface, image_src->format,
+ _cairo_glitz_surface_create_similar (surface, content,
image_src->width,
image_src->height);
if (!clone)
@@ -563,10 +565,10 @@
free (data);
return CAIRO_STATUS_NO_MEMORY;
}
-
+
src = (cairo_glitz_surface_t *)
_cairo_surface_create_similar_scratch (&dst->base,
- CAIRO_FORMAT_ARGB32,
+ CAIRO_CONTENT_COLOR_ALPHA,
gradient->n_stops, 1);
if (!src)
{
@@ -897,7 +899,8 @@
src = (cairo_glitz_surface_t *)
_cairo_surface_create_similar_solid (&dst->base,
- CAIRO_FORMAT_ARGB32, 1, 1,
+ CAIRO_CONTENT_COLOR_ALPHA,
+ 1, 1,
(cairo_color_t *) color);
if (!src)
return CAIRO_STATUS_NO_MEMORY;
@@ -999,7 +1002,7 @@
mask = (cairo_glitz_surface_t *)
_cairo_glitz_surface_create_similar (&dst->base,
- CAIRO_FORMAT_A8,
+ CAIRO_CONTENT_ALPHA,
2, 1);
if (!mask)
{
@@ -1099,7 +1102,7 @@
mask = (cairo_glitz_surface_t *)
_cairo_surface_create_similar_scratch (&dst->base,
- CAIRO_FORMAT_A8,
+ CAIRO_CONTENT_ALPHA,
width, height);
if (!mask)
{
Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- cairo-gstate.c 6 Jul 2005 21:52:01 -0000 1.144
+++ cairo-gstate.c 8 Jul 2005 17:12:29 -0000 1.145
@@ -903,7 +903,7 @@
cairo_surface_t *intermediate;
intermediate = cairo_surface_create_similar (gstate->clip.surface,
- CAIRO_FORMAT_A8,
+ CAIRO_CONTENT_ALPHA,
extents.width,
extents.height);
if (intermediate == NULL)
@@ -1242,7 +1242,7 @@
translate_traps (traps, -extents->x, -extents->y);
intermediate = _cairo_surface_create_similar_solid (gstate->clip.surface,
- CAIRO_FORMAT_A8,
+ CAIRO_CONTENT_ALPHA,
extents->width,
extents->height,
CAIRO_COLOR_TRANSPARENT);
@@ -1718,7 +1718,7 @@
_cairo_rectangle_intersect (&surface_rect, &gstate->clip.surface_rect);
surface = _cairo_surface_create_similar_solid (gstate->target,
- CAIRO_FORMAT_A8,
+ CAIRO_CONTENT_ALPHA,
surface_rect.width,
surface_rect.height,
CAIRO_COLOR_WHITE);
@@ -2129,9 +2129,9 @@
status = CAIRO_STATUS_SUCCESS;
goto BAIL1;
}
-
+
intermediate = _cairo_surface_create_similar_solid (gstate->clip.surface,
- CAIRO_FORMAT_A8,
+ CAIRO_CONTENT_ALPHA,
extents.width,
extents.height,
CAIRO_COLOR_TRANSPARENT);
Index: cairo-image-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-image-surface.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- cairo-image-surface.c 17 Jun 2005 20:25:19 -0000 1.47
+++ cairo-image-surface.c 8 Jul 2005 17:12:29 -0000 1.48
@@ -156,6 +156,10 @@
pixman_format_t *pixman_format;
pixman_image_t *pixman_image;
+ /* XXX: Really need to make this kind of thing pass through _cairo_error. */
+ if (! CAIRO_FORMAT_VALID (format))
+ return NULL;
+
pixman_format = _create_pixman_format (format);
if (pixman_format == NULL)
return NULL;
@@ -205,6 +209,10 @@
pixman_format_t *pixman_format;
pixman_image_t *pixman_image;
+ /* XXX: Really need to make this kind of thing pass through _cairo_error. */
+ if (! CAIRO_FORMAT_VALID (format))
+ return NULL;
+
pixman_format = _create_pixman_format (format);
if (pixman_format == NULL)
return NULL;
@@ -256,13 +264,51 @@
return image_surface->height;
}
+cairo_format_t
+_cairo_format_from_content (cairo_content_t content)
+{
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
+ return CAIRO_FORMAT_RGB24;
+ case CAIRO_CONTENT_ALPHA:
+ return CAIRO_FORMAT_A8;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ return CAIRO_FORMAT_ARGB32;
+ }
+
+ ASSERT_NOT_REACHED;
+ return CAIRO_FORMAT_ARGB32;
+}
+
+cairo_content_t
+_cairo_content_from_format (cairo_format_t format)
+{
+ switch (format) {
+ case CAIRO_FORMAT_ARGB32:
+ return CAIRO_CONTENT_COLOR_ALPHA;
+ case CAIRO_FORMAT_RGB24:
+ return CAIRO_CONTENT_COLOR;
+ case CAIRO_FORMAT_A8:
+ case CAIRO_FORMAT_A1:
+ return CAIRO_CONTENT_ALPHA;
+ }
+
+ ASSERT_NOT_REACHED;
+ return CAIRO_CONTENT_COLOR_ALPHA;
+}
+
static cairo_surface_t *
-_cairo_image_surface_create_similar (void *abstract_src,
- cairo_format_t format,
+_cairo_image_surface_create_similar (void *abstract_src,
+ cairo_content_t content,
int width,
int height)
{
- return cairo_image_surface_create (format, width, height);
+ /* XXX: Really need to make this kind of thing pass through _cairo_error. */
+ if (! CAIRO_CONTENT_VALID (content))
+ return NULL;
+
+ return cairo_image_surface_create (_cairo_format_from_content (content),
+ width, height);
}
static cairo_status_t
Index: cairo-meta-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-meta-surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo-meta-surface.c 1 Jul 2005 19:45:35 -0000 1.2
+++ cairo-meta-surface.c 8 Jul 2005 17:12:29 -0000 1.3
@@ -65,8 +65,8 @@
}
static cairo_surface_t *
-_cairo_meta_surface_create_similar (void *abstract_surface,
- cairo_format_t format,
+_cairo_meta_surface_create_similar (void *abstract_surface,
+ cairo_content_t content,
int width,
int height)
{
Index: cairo-pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pattern.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- cairo-pattern.c 28 Jun 2005 22:58:42 -0000 1.47
+++ cairo-pattern.c 8 Jul 2005 17:12:29 -0000 1.48
@@ -1225,7 +1225,7 @@
cairo_surface_attributes_t *attribs)
{
*out = _cairo_surface_create_similar_solid (dst,
- CAIRO_FORMAT_ARGB32,
+ CAIRO_CONTENT_COLOR_ALPHA,
1, 1,
&pattern->color);
Index: cairo-pdf-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf-surface.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cairo-pdf-surface.c 21 Jun 2005 22:38:51 -0000 1.48
+++ cairo-pdf-surface.c 8 Jul 2005 17:12:29 -0000 1.49
@@ -389,8 +389,8 @@
}
static cairo_surface_t *
-_cairo_pdf_surface_create_similar (void *abstract_src,
- cairo_format_t format,
+_cairo_pdf_surface_create_similar (void *abstract_src,
+ cairo_content_t content,
int width,
int height)
{
Index: cairo-ps-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ps-surface.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- cairo-ps-surface.c 6 Jul 2005 05:30:59 -0000 1.39
+++ cairo-ps-surface.c 8 Jul 2005 17:12:29 -0000 1.40
@@ -153,10 +153,10 @@
}
static cairo_surface_t *
-_cairo_ps_surface_create_similar (void *abstract_src,
- cairo_format_t format,
- int width,
- int height)
+_cairo_ps_surface_create_similar (void *abstract_src,
+ cairo_content_t content,
+ int width,
+ int height)
{
return NULL;
}
@@ -593,7 +593,7 @@
current image over a white RGB surface to eliminate it. */
opaque = _cairo_surface_create_similar_solid (&image->base,
- CAIRO_FORMAT_RGB24,
+ CAIRO_CONTENT_COLOR,
image->width,
image->height,
CAIRO_COLOR_WHITE);
Index: cairo-quartz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-quartz-surface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo-quartz-surface.c 15 Jun 2005 02:45:23 -0000 1.12
+++ cairo-quartz-surface.c 8 Jul 2005 17:12:29 -0000 1.13
@@ -58,12 +58,11 @@
}
}
-static cairo_surface_t *_cairo_quartz_surface_create_similar(void
- *abstract_src,
- cairo_format_t
- format,
- int width,
- int height)
+static cairo_surface_t *
+_cairo_quartz_surface_create_similar (void *abstract_src,
+ cairo_content_t content,
+ int width,
+ int height)
{
return NULL;
}
Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cairo-surface.c 1 Jul 2005 19:45:35 -0000 1.77
+++ cairo-surface.c 8 Jul 2005 17:12:29 -0000 1.78
@@ -59,42 +59,62 @@
}
cairo_surface_t *
-_cairo_surface_create_similar_scratch (cairo_surface_t *other,
- cairo_format_t format,
+_cairo_surface_create_similar_scratch (cairo_surface_t *other,
+ cairo_content_t content,
int width,
int height)
{
if (other == NULL)
return NULL;
- return other->backend->create_similar (other, format, width, height);
+ return other->backend->create_similar (other, content, width, height);
}
+/**
+ * cairo_surface_create_similar:
+ * @other: an existing surface used to select the backend of the new surface
+ * @content: the content for the new surface
+ * @width: width of the new surface, (in device-space units)
+ * @height: height of the new surface (in device-space units)
+ *
+ * Create a new surface that is as compatible as possible with an
+ * existing surface. The new surface will use the same backend as
+ * @other unless that is not possible for some reason.
+ *
+ * Return value: a pointer to the newly allocated surface, or NULL in
+ * the case of errors. The caller owns the surface and should call
+ * cairo_surface_destroy when done with it.
+ **/
cairo_surface_t *
-cairo_surface_create_similar (cairo_surface_t *other,
- cairo_format_t format,
+cairo_surface_create_similar (cairo_surface_t *other,
+ cairo_content_t content,
int width,
int height)
{
if (other == NULL)
return NULL;
- return _cairo_surface_create_similar_solid (other, format,
+ /* XXX: Really need to make this kind of thing pass through _cairo_error. */
+ if (! CAIRO_CONTENT_VALID (content))
+ return NULL;
+
+ return _cairo_surface_create_similar_solid (other, content,
width, height,
CAIRO_COLOR_TRANSPARENT);
}
cairo_surface_t *
_cairo_surface_create_similar_solid (cairo_surface_t *other,
- cairo_format_t format,
+ cairo_content_t content,
int width,
int height,
const cairo_color_t *color)
{
cairo_status_t status;
cairo_surface_t *surface;
+ cairo_format_t format = _cairo_format_from_content (content);
- surface = _cairo_surface_create_similar_scratch (other, format,
+ surface = _cairo_surface_create_similar_scratch (other, content,
width, height);
if (surface == NULL)
Index: cairo-win32-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32-surface.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cairo-win32-surface.c 25 Jun 2005 09:00:17 -0000 1.27
+++ cairo-win32-surface.c 8 Jul 2005 17:12:29 -0000 1.28
@@ -290,11 +290,12 @@
static cairo_surface_t *
_cairo_win32_surface_create_similar (void *abstract_src,
- cairo_format_t format,
+ cairo_content_t content,
int width,
int height)
{
cairo_win32_surface_t *src = abstract_src;
+ cairo_format_t format = _cairo_format_from_content (content);
return _cairo_win32_surface_create_for_dc (src->dc, format, width, height);
}
@@ -351,11 +352,13 @@
{
cairo_win32_surface_t *local;
cairo_status_t status;
+ cairo_content_t content = _cairo_content_from_format (surface->format);
local =
(cairo_win32_surface_t *) _cairo_win32_surface_create_similar (surface,
- surface->format,
- width, height);
+ content,
+ width,
+ height);
if (!local)
return CAIRO_STATUS_NO_MEMORY;
Index: cairo-xcb-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xcb-surface.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- cairo-xcb-surface.c 18 Jun 2005 06:22:21 -0000 1.38
+++ cairo-xcb-surface.c 8 Jul 2005 17:12:29 -0000 1.39
@@ -228,7 +228,7 @@
static cairo_surface_t *
_cairo_xcb_surface_create_similar (void *abstract_src,
- cairo_format_t format,
+ cairo_content_t content,
int width,
int height)
{
@@ -236,6 +236,7 @@
XCBConnection *dpy = src->dpy;
XCBDRAWABLE d;
cairo_xcb_surface_t *surface;
+ cairo_format_t format = _cairo_format_from_content (content);
XCBRenderPICTFORMINFO xrender_format = _format_from_cairo (dpy, format);
/* As a good first approximation, if the display doesn't have COMPOSITE,
@@ -635,9 +636,10 @@
}
} else if (_cairo_surface_is_image (src)) {
cairo_image_surface_t *image_src = (cairo_image_surface_t *)src;
+ cairo_content_t content = _cairo_content_from_format (image_src->format);
clone = (cairo_xcb_surface_t *)
- _cairo_xcb_surface_create_similar (surface, image_src->format,
+ _cairo_xcb_surface_create_similar (surface, content,
image_src->width, image_src->height);
if (clone == NULL)
return CAIRO_STATUS_NO_MEMORY;
Index: cairo-xlib-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib-surface.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- cairo-xlib-surface.c 28 Jun 2005 20:28:56 -0000 1.85
+++ cairo-xlib-surface.c 8 Jul 2005 17:12:29 -0000 1.86
@@ -179,8 +179,8 @@
}
static cairo_surface_t *
-_cairo_xlib_surface_create_similar (void *abstract_src,
- cairo_format_t format,
+_cairo_xlib_surface_create_similar (void *abstract_src,
+ cairo_content_t content,
int width,
int height)
{
@@ -189,6 +189,7 @@
int scr;
Pixmap pix;
cairo_xlib_surface_t *surface;
+ cairo_format_t format = _cairo_format_from_content (content);
int depth = _CAIRO_FORMAT_DEPTH (format);
XRenderPictFormat *xrender_format = _CAIRO_FORMAT_XRENDER_FORMAT (dpy,
format);
@@ -639,9 +640,10 @@
}
} else if (_cairo_surface_is_image (src)) {
cairo_image_surface_t *image_src = (cairo_image_surface_t *)src;
+ cairo_content_t content = _cairo_content_from_format (image_src->format);
clone = (cairo_xlib_surface_t *)
- _cairo_xlib_surface_create_similar (surface, image_src->format,
+ _cairo_xlib_surface_create_similar (surface, content,
image_src->width, image_src->height);
if (clone == NULL)
return CAIRO_STATUS_NO_MEMORY;
Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- cairo.h 6 Jul 2005 21:52:01 -0000 1.133
+++ cairo.h 8 Jul 2005 17:12:29 -0000 1.134
@@ -147,7 +147,7 @@
* but when using #cairo_t, the last error, if any, is stored in
* the context and can be retrieved with cairo_status().
**/
-typedef enum cairo_status {
+typedef enum _cairo_status {
CAIRO_STATUS_SUCCESS = 0,
CAIRO_STATUS_NO_MEMORY,
CAIRO_STATUS_INVALID_RESTORE,
@@ -221,7 +221,7 @@
/* Modify state */
-typedef enum cairo_operator {
+typedef enum _cairo_operator {
CAIRO_OPERATOR_CLEAR,
CAIRO_OPERATOR_SOURCE,
@@ -285,7 +285,7 @@
* (Note that filling is not actually implemented in this way. This
* is just a description of the rule that is applied.)
**/
-typedef enum cairo_fill_rule {
+typedef enum _cairo_fill_rule {
CAIRO_FILL_RULE_WINDING,
CAIRO_FILL_RULE_EVEN_ODD
} cairo_fill_rule_t;
@@ -305,7 +305,7 @@
*
* enumeration for style of line-endings
**/
-typedef enum cairo_line_cap {
+typedef enum _cairo_line_cap {
CAIRO_LINE_CAP_BUTT,
CAIRO_LINE_CAP_ROUND,
CAIRO_LINE_CAP_SQUARE
@@ -314,7 +314,7 @@
void
cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap);
-typedef enum cairo_line_join {
+typedef enum _cairo_line_join {
CAIRO_LINE_JOIN_MITER,
CAIRO_LINE_JOIN_ROUND,
CAIRO_LINE_JOIN_BEVEL
@@ -625,13 +625,13 @@
double max_y_advance;
} cairo_font_extents_t;
-typedef enum cairo_font_slant {
+typedef enum _cairo_font_slant {
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_SLANT_ITALIC,
CAIRO_FONT_SLANT_OBLIQUE
} cairo_font_slant_t;
-typedef enum cairo_font_weight {
+typedef enum _cairo_font_weight {
CAIRO_FONT_WEIGHT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD
} cairo_font_weight_t;
@@ -825,7 +825,7 @@
* cairo_path_destroy (path);
* </programlisting></informalexample>
*/
-typedef enum cairo_path_data_type {
+typedef enum _cairo_path_data_type {
CAIRO_PATH_MOVE_TO,
CAIRO_PATH_LINE_TO,
CAIRO_PATH_CURVE_TO,
@@ -888,39 +888,32 @@
/* Surface manipulation */
/**
- * cairo_format_t
- * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
- * alpha in the upper 8 bits, then red, then green, then blue.
- * The 32-bit quantities are stored native-endian. Pre-multiplied
- * alpha is used. (That is, 50% transparent red is 0x80800000,
- * not 0x80ff0000.)
- * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
- * the upper 8 bits unused. Red, Green, and Blue are stored
- * in the remaining 24 bits in that order.
- * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
- * an alpha value.
- * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
- * an alpha value. Pixels are packed together into 32-bit
- * quantities. The ordering of the bits matches the
- * endianess of the platform. On a big-endian machine, the
- * first pixel is in the uppermost bit, on a little-endian
- * machine the first pixel is in the least-significant bit.
+ * cairo_content_t
+ * @CAIRO_CONTENT_COLOR: The surface will hold color content only.
+ * @CAIRO_CONTENT_ALPHA: The surface will hold alpha content only.
+ * @CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha content.
*
- * #cairo_format_t is used to identify the memory format of
- * image data.
+ * @cairo_content_t is used to describe the content that a surface will
+ * contain, whether color information, alpha information (translucence
+ * vs. opacity), or both.
+ *
+ * Note: The large values here are designed to keep cairo_content_t
+ * values distinct from cairo_format_t values so that the
+ * implementation can detect the error if users confuse the two types.
*/
-typedef enum cairo_format {
- CAIRO_FORMAT_ARGB32,
- CAIRO_FORMAT_RGB24,
- CAIRO_FORMAT_A8,
- CAIRO_FORMAT_A1
-} cairo_format_t;
+typedef enum _cairo_content {
+ CAIRO_CONTENT_COLOR = 0x1000,
+ CAIRO_CONTENT_ALPHA = 0x2000,
+ CAIRO_CONTENT_COLOR_ALPHA = 0x3000
+} cairo_content_t;
+
+#define CAIRO_CONTENT_VALID(content) (((content) & ~(CAIRO_CONTENT_COLOR | \
+ CAIRO_CONTENT_ALPHA | \
+ CAIRO_CONTENT_COLOR_ALPHA)) == 0)
-/* XXX: I want to remove this function, (replace with
- cairo_begin_group and friends). */
cairo_surface_t *
-cairo_surface_create_similar (cairo_surface_t *other,
- cairo_format_t format,
+cairo_surface_create_similar (cairo_surface_t *other,
+ cairo_content_t content,
int width,
int height);
@@ -963,6 +956,38 @@
/* Image-surface functions */
+/**
+ * cairo_format_t
+ * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
+ * alpha in the upper 8 bits, then red, then green, then blue.
+ * The 32-bit quantities are stored native-endian. Pre-multiplied
+ * alpha is used. (That is, 50% transparent red is 0x80800000,
+ * not 0x80ff0000.)
+ * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
+ * the upper 8 bits unused. Red, Green, and Blue are stored
+ * in the remaining 24 bits in that order.
+ * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
+ * an alpha value.
+ * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
+ * an alpha value. Pixels are packed together into 32-bit
+ * quantities. The ordering of the bits matches the
+ * endianess of the platform. On a big-endian machine, the
+ * first pixel is in the uppermost bit, on a little-endian
+ * machine the first pixel is in the least-significant bit.
+ *
+ * #cairo_format_t is used to identify the memory format of
+ * image data.
+ */
+typedef enum _cairo_format {
+ CAIRO_FORMAT_ARGB32,
+ CAIRO_FORMAT_RGB24,
+ CAIRO_FORMAT_A8,
+ CAIRO_FORMAT_A1
+} cairo_format_t;
+
+#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 && \
+ (format) <= CAIRO_FORMAT_A1)
+
cairo_surface_t *
cairo_image_surface_create (cairo_format_t format,
int width,
@@ -1040,7 +1065,7 @@
cairo_pattern_get_matrix (cairo_pattern_t *pattern,
cairo_matrix_t *matrix);
-typedef enum {
+typedef enum _cairo_extend {
CAIRO_EXTEND_NONE,
CAIRO_EXTEND_REPEAT,
CAIRO_EXTEND_REFLECT
@@ -1052,7 +1077,7 @@
cairo_extend_t
cairo_pattern_get_extend (cairo_pattern_t *pattern);
-typedef enum {
+typedef enum _cairo_filter {
CAIRO_FILTER_FAST,
CAIRO_FILTER_GOOD,
CAIRO_FILTER_BEST,
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- cairoint.h 1 Jul 2005 19:45:35 -0000 1.160
+++ cairoint.h 8 Jul 2005 17:12:29 -0000 1.161
@@ -586,7 +586,7 @@
typedef struct _cairo_surface_backend {
cairo_surface_t *
(*create_similar) (void *surface,
- cairo_format_t format,
+ cairo_content_t content,
int width,
int height);
@@ -1424,14 +1424,14 @@
/* cairo-surface.c */
cairo_private cairo_surface_t *
-_cairo_surface_create_similar_scratch (cairo_surface_t *other,
- cairo_format_t format,
+_cairo_surface_create_similar_scratch (cairo_surface_t *other,
+ cairo_content_t content,
int width,
int height);
cairo_private cairo_surface_t *
_cairo_surface_create_similar_solid (cairo_surface_t *other,
- cairo_format_t format,
+ cairo_content_t content,
int width,
int height,
const cairo_color_t *color);
@@ -1576,6 +1576,12 @@
/* cairo_image_surface.c */
+cairo_private cairo_format_t
+_cairo_format_from_content (cairo_content_t content);
+
+cairo_private cairo_content_t
+_cairo_content_from_format (cairo_format_t format);
+
cairo_private cairo_image_surface_t *
_cairo_image_surface_create_with_masks (unsigned char *data,
cairo_format_masks_t *format,
More information about the cairo-commit
mailing list