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.

Change surface backend create_similar call to accept a cairo_content_t rather than a cairo_format_t.
Fix all calls into create_similar to pass a cairo_content_t rather than a cairo_format_t.
This commit is contained in:
Carl Worth 2005-07-08 10:12:28 +00:00
parent 9fd2f0a25c
commit 9a2ba48b29
18 changed files with 256 additions and 106 deletions

View file

@ -1,3 +1,47 @@
2005-07-08 Carl Worth <cworth@cworth.org>
* 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.
2005-07-07 Carl Worth <cworth@cworth.org>
* CODING_STYLE: Add a missing word.

View file

@ -52,26 +52,26 @@ _cairo_glitz_surface_finish (void *abstract_surface)
}
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 @@ _cairo_glitz_surface_create_similar (void *abstract_src,
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 @@ _cairo_glitz_surface_clone_similar (void *abstract_surface,
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 @@ _cairo_glitz_pattern_acquire_surface (cairo_pattern_t *pattern,
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 @@ _cairo_glitz_surface_fill_rectangles (void *abstract_dst,
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 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
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 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
mask = (cairo_glitz_surface_t *)
_cairo_surface_create_similar_scratch (&dst->base,
CAIRO_FORMAT_A8,
CAIRO_CONTENT_ALPHA,
width, height);
if (!mask)
{

View file

@ -903,7 +903,7 @@ _cairo_gstate_mask (cairo_gstate_t *gstate,
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 @@ _composite_traps_intermediate_surface (cairo_gstate_t *gstate,
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_gstate_intersect_clip_mask (cairo_gstate_t *gstate,
_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 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
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);

View file

@ -156,6 +156,10 @@ cairo_image_surface_create (cairo_format_t format,
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 @@ cairo_image_surface_create_for_data (unsigned char *data,
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 @@ cairo_image_surface_get_height (cairo_surface_t *surface)
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

View file

@ -65,8 +65,8 @@ _cairo_meta_surface_create (double width, double height)
}
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)
{

View file

@ -1225,7 +1225,7 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t *pattern,
cairo_surface_attributes_t *attribs)
{
*out = _cairo_surface_create_similar_solid (dst,
CAIRO_FORMAT_ARGB32,
CAIRO_CONTENT_COLOR_ALPHA,
1, 1,
&pattern->color);

View file

@ -389,8 +389,8 @@ _cairo_pdf_surface_clear (cairo_pdf_surface_t *surface)
}
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)
{

View file

@ -153,10 +153,10 @@ cairo_ps_surface_create_for_stream (cairo_write_func_t write_func,
}
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 @@ emit_image (cairo_ps_surface_t *surface,
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);

View file

@ -58,12 +58,11 @@ ImageDataReleaseFunc(void *info, const void *data, size_t size)
}
}
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;
}

View file

@ -59,42 +59,62 @@ _cairo_surface_init (cairo_surface_t *surface,
}
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)

View file

@ -290,11 +290,12 @@ _cairo_win32_surface_create_for_dc (HDC original_dc,
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_get_subimage (cairo_win32_surface_t *surface,
{
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;

View file

@ -228,7 +228,7 @@ _CAIRO_FORMAT_DEPTH (cairo_format_t format)
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 @@ _cairo_xcb_surface_create_similar (void *abstract_src,
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 @@ _cairo_xcb_surface_clone_similar (void *abstract_surface,
}
} 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;

View file

@ -179,8 +179,8 @@ _CAIRO_FORMAT_XRENDER_FORMAT(Display *dpy, cairo_format_t format)
}
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 @@ _cairo_xlib_surface_create_similar (void *abstract_src,
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 @@ _cairo_xlib_surface_clone_similar (void *abstract_surface,
}
} 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;

View file

@ -147,7 +147,7 @@ typedef struct _cairo_user_data_key {
* 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 @@ cairo_pop_group (cairo_t *cr);
/* Modify state */
typedef enum cairo_operator {
typedef enum _cairo_operator {
CAIRO_OPERATOR_CLEAR,
CAIRO_OPERATOR_SOURCE,
@ -285,7 +285,7 @@ cairo_set_tolerance (cairo_t *cr, double tolerance);
* (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 @@ cairo_set_line_width (cairo_t *cr, double width);
*
* 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 @@ typedef enum cairo_line_cap {
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 @@ typedef struct {
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_get_target (cairo_t *cr);
* 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 @@ cairo_status_to_string (cairo_status_t status);
/* 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 @@ cairo_surface_set_device_offset (cairo_surface_t *surface,
/* 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 @@ void
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_pattern_set_extend (cairo_pattern_t *pattern, cairo_extend_t extend);
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,

View file

@ -586,7 +586,7 @@ extern const cairo_private struct _cairo_scaled_font_backend cairo_atsui_scaled_
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_path_fixed_stroke_to_traps (cairo_path_fixed_t *path,
/* 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_surface_show_glyphs (cairo_scaled_font_t *scaled_font,
/* 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,

View file

@ -74,7 +74,7 @@ mask_polygon (cairo_t *cr, int x, int y)
cairo_t *cr2;
mask_surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_A8,
CAIRO_CONTENT_ALPHA,
WIDTH, HEIGHT);
cr2 = cairo_create (mask_surface);
@ -196,7 +196,7 @@ draw (cairo_t *cr, int width, int height)
* a temporary surface and copy over.
*/
tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_ARGB32,
CAIRO_CONTENT_COLOR_ALPHA,
IMAGE_WIDTH, IMAGE_HEIGHT);
cr2 = cairo_create (tmp_surface);

View file

@ -28,7 +28,7 @@ draw (cairo_t *cr, int width, int height)
cairo_t *cr2;
stamp = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_ARGB32,
CAIRO_CONTENT_COLOR_ALPHA,
WIDTH, HEIGHT);
cr2 = cairo_create (stamp);
{

View file

@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
cairo_t *cr2;
source_surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_ARGB32,
CAIRO_CONTENT_COLOR_ALPHA,
SIZE, SIZE);
cr2 = cairo_create (source_surface);