[cairo-commit] cairo/src cairo_glitz_surface.c,1.5,1.6
David Reveman
commit at pdx.freedesktop.org
Wed Sep 15 09:55:42 PDT 2004
Committed by: davidr
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv15709/src
Modified Files:
cairo_glitz_surface.c
Log Message:
Improved format handling, pixel transfers and gradients
Index: cairo_glitz_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_glitz_surface.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** cairo_glitz_surface.c 12 Sep 2004 22:34:00 -0000 1.5
--- cairo_glitz_surface.c 15 Sep 2004 16:55:40 -0000 1.6
***************
*** 193,197 ****
glitz_pixel_format_t pf;
pixman_format_t *format;
! int am, rm, gm, bm;
format = pixman_image_get_format (image->pixman_image);
--- 193,198 ----
glitz_pixel_format_t pf;
pixman_format_t *format;
! int am, rm, gm, bm, y;
! unsigned char *data;
format = pixman_image_get_format (image->pixman_image);
***************
*** 208,215 ****
pf.skip_lines = 0;
pf.bytes_per_line = (((image->width * pf.masks.bpp) / 8) + 3) & -4;
! pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
buffer = glitz_pixel_buffer_create (surface->surface,
! image->data,
pf.bytes_per_line * image->height,
GLITZ_BUFFER_HINT_STREAM_DRAW);
--- 209,216 ----
pf.skip_lines = 0;
pf.bytes_per_line = (((image->width * pf.masks.bpp) / 8) + 3) & -4;
! pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
buffer = glitz_pixel_buffer_create (surface->surface,
! NULL,
pf.bytes_per_line * image->height,
GLITZ_BUFFER_HINT_STREAM_DRAW);
***************
*** 217,220 ****
--- 218,230 ----
return CAIRO_STATUS_NO_MEMORY;
+ data = glitz_buffer_map (buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
+
+ for (y = 0; y < image->height; y++)
+ memcpy (&data[pf.bytes_per_line * (image->height - 1 - y)],
+ &image->data[pf.bytes_per_line * y],
+ pf.bytes_per_line);
+
+ glitz_buffer_unmap (buffer);
+
glitz_set_pixels (surface->surface,
0, 0,
***************
*** 324,343 ****
}
- static glitz_format_name_t
- _glitz_format (cairo_format_t format)
- {
- switch (format) {
- case CAIRO_FORMAT_A1:
- return GLITZ_STANDARD_A1;
- case CAIRO_FORMAT_A8:
- return GLITZ_STANDARD_A8;
- case CAIRO_FORMAT_RGB24:
- return GLITZ_STANDARD_RGB24;
- case CAIRO_FORMAT_ARGB32:
- default:
- return GLITZ_STANDARD_ARGB32;
- }
- }
-
static glitz_surface_t *
_glitz_surface_create_solid (glitz_surface_t *other,
--- 334,337 ----
***************
*** 374,381 ****
cairo_surface_t *crsurface;
glitz_format_t *glitz_format;
!
glitz_format =
! glitz_surface_find_similar_standard_format (src->surface,
! _glitz_format (format));
if (glitz_format == NULL)
return NULL;
--- 368,402 ----
cairo_surface_t *crsurface;
glitz_format_t *glitz_format;
! glitz_format_t templ;
! unsigned long mask;
!
! mask = GLITZ_FORMAT_DRAW_OFFSCREEN_MASK;
! if (drawable) {
! templ.draw.offscreen = 1;
! templ.multisample.samples = src->format->multisample.samples;
! mask |= GLITZ_FORMAT_MULTISAMPLE_SAMPLES_MASK;
! } else
! templ.draw.offscreen = 0;
!
! switch (format) {
! case CAIRO_FORMAT_A1:
! case CAIRO_FORMAT_A8:
! templ.alpha_size = 8;
! mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
! break;
! case CAIRO_FORMAT_RGB24:
! templ.red_size = 8;
! mask |= GLITZ_FORMAT_RED_SIZE_MASK;
! break;
! case CAIRO_FORMAT_ARGB32:
! default:
! templ.alpha_size = templ.red_size = 8;
! mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
! mask |= GLITZ_FORMAT_RED_SIZE_MASK;
! break;
! }
!
glitz_format =
! glitz_surface_find_similar_format (src->surface, mask, &templ, 0);
if (glitz_format == NULL)
return NULL;
***************
*** 770,777 ****
glitz_color_t color;
! color.red = pattern->stops[i].color_char[0] * 256;
! color.green = pattern->stops[i].color_char[1] * 256;
! color.blue = pattern->stops[i].color_char[2] * 256;
! color.alpha = pattern->stops[i].color_char[3] * 256;
glitz_set_rectangle (src->surface, &color, i, 0, 1, 1);
--- 791,799 ----
glitz_color_t color;
! color.alpha = pattern->stops[i].color_char[3];
! color.red = pattern->stops[i].color_char[0] * color.alpha;
! color.green = pattern->stops[i].color_char[1] * color.alpha;
! color.blue = pattern->stops[i].color_char[2] * color.alpha;
! color.alpha *= 256;
glitz_set_rectangle (src->surface, &color, i, 0, 1, 1);
More information about the cairo-commit
mailing list