[cairo-commit] cairo/src cairo-glitz-surface.c, 1.69,
1.70 cairo-image-surface.c, 1.67, 1.68
Vladimir Vukicevic
commit at pdx.freedesktop.org
Tue Jan 3 09:23:50 PST 2006
Committed by: vladimir
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv16303/src
Modified Files:
cairo-glitz-surface.c cairo-image-surface.c
Log Message:
2006-01-03 Vladimir Vukicevic <vladimir at pobox.com>
* src/cairo-glitz-surface.c (_cairo_glitz_surface_create_similar):
Clamp surface dimensions to a minimum of 1.
(_cairo_glitz_surface_get_image): Set the glitz clip to NULL before
calling glitz_get_pixels, to return the full surface contents.
Restore clip afterwards.
(_cairo_glitz_surface_composite_trapezoid): Return UNSUPPORTED if
the antialias is anything other than DEFAULT/GRAY.
* src/cairo-image-surface.c (_cairo_image_surface_create_with_masks):
Try to recover a standard cairo_format_t from given pixman format
masks, so that various things that only work with a standard
format work correctly.
* test/cairo-test.c: Remove cairo_glitz_surface_write_to_png,
replace with generic cairo_surface_write_to_png (since it works with
image-surface create_with_masks fix)
Index: cairo-glitz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-glitz-surface.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- cairo-glitz-surface.c 5 Dec 2005 16:33:04 -0000 1.69
+++ cairo-glitz-surface.c 3 Jan 2006 17:23:48 -0000 1.70
@@ -92,7 +92,11 @@
return (cairo_surface_t*) &_cairo_surface_nil;
}
- surface = glitz_surface_create (drawable, gformat, width, height, 0, NULL);
+ surface = glitz_surface_create (drawable, gformat,
+ width <= 0 ? 1 : width,
+ height <= 0 ? 1 : height,
+ 0, NULL);
+
if (surface == NULL) {
_cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t*) &_cairo_surface_nil;
@@ -202,6 +206,10 @@
return CAIRO_STATUS_NO_MEMORY;
}
+ /* clear out the glitz clip; the clip affects glitz_get_pixels */
+ glitz_surface_set_clip_region (surface->surface,
+ 0, 0, NULL, 0);
+
glitz_get_pixels (surface->surface,
x1, y1,
width, height,
@@ -210,6 +218,10 @@
glitz_buffer_destroy (buffer);
+ /* restore the clip, if any */
+ surface->base.current_clip_serial = 0;
+ _cairo_surface_set_clip (&surface->base, surface->base.clip);
+
image = (cairo_image_surface_t *)
_cairo_image_surface_create_with_masks (pixels,
&format,
@@ -993,6 +1005,10 @@
cairo_int_status_t status;
unsigned short alpha;
+ if (antialias != CAIRO_ANTIALIAS_DEFAULT &&
+ antialias != CAIRO_ANTIALIAS_GRAY)
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
if (dst->base.status)
return dst->base.status;
@@ -2094,6 +2110,16 @@
return CAIRO_STATUS_SUCCESS;
}
+static cairo_status_t
+_cairo_glitz_surface_flush (void *abstract_surface)
+{
+ cairo_glitz_surface_t *surface = abstract_surface;
+
+ glitz_surface_flush (surface->surface);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
static const cairo_surface_backend_t cairo_glitz_surface_backend = {
_cairo_glitz_surface_create_similar,
_cairo_glitz_surface_finish,
@@ -2112,7 +2138,7 @@
_cairo_glitz_surface_get_extents,
_cairo_glitz_surface_old_show_glyphs,
NULL, /* get_font_options */
- NULL, /* flush */
+ _cairo_glitz_surface_flush,
NULL, /* mark_dirty_rectangle */
_cairo_glitz_surface_scaled_font_fini,
_cairo_glitz_surface_scaled_glyph_fini
Index: cairo-image-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-image-surface.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- cairo-image-surface.c 16 Dec 2005 19:21:24 -0000 1.67
+++ cairo-image-surface.c 3 Jan 2006 17:23:48 -0000 1.68
@@ -80,6 +80,46 @@
return &surface->base;
}
+/* Try to recover a cairo_format_t from a pixman_format
+ * by looking at the bpp and masks values. */
+static cairo_format_t
+_cairo_format_from_pixman_format (pixman_format_t *pixman_format)
+{
+ int bpp, am, rm, gm, bm;
+
+ pixman_format_get_masks (pixman_format, &bpp, &am, &rm, &gm, &bm);
+
+ if (bpp == 32 &&
+ am == 0xff000000 &&
+ rm == 0x00ff0000 &&
+ gm == 0x0000ff00 &&
+ bm == 0x000000ff)
+ return CAIRO_FORMAT_ARGB32;
+
+ if (bpp == 32 &&
+ am == 0x0 &&
+ rm == 0x00ff0000 &&
+ gm == 0x0000ff00 &&
+ bm == 0x000000ff)
+ return CAIRO_FORMAT_RGB24;
+
+ if (bpp == 8 &&
+ am == 0xff &&
+ rm == 0x0 &&
+ gm == 0x0 &&
+ bm == 0x0)
+ return CAIRO_FORMAT_A8;
+
+ if (bpp == 1 &&
+ am == 0x1 &&
+ rm == 0x0 &&
+ gm == 0x0 &&
+ bm == 0x0)
+ return CAIRO_FORMAT_A1;
+
+ return (cairo_format_t) -1;
+}
+
cairo_surface_t *
_cairo_image_surface_create_with_masks (unsigned char *data,
cairo_format_masks_t *format,
@@ -90,6 +130,7 @@
cairo_surface_t *surface;
pixman_format_t *pixman_format;
pixman_image_t *pixman_image;
+ cairo_format_t cairo_format;
pixman_format = pixman_format_create_masks (format->bpp,
format->alpha_mask,
@@ -102,6 +143,8 @@
return (cairo_surface_t*) &_cairo_surface_nil;
}
+ cairo_format = _cairo_format_from_pixman_format (pixman_format);
+
pixman_image = pixman_image_create_for_data ((pixman_bits_t *) data, pixman_format,
width, height, format->bpp, stride);
@@ -113,7 +156,7 @@
}
surface = _cairo_image_surface_create_for_pixman_image (pixman_image,
- (cairo_format_t)-1);
+ cairo_format);
return surface;
}
More information about the cairo-commit
mailing list