Check that lvalue of BITSWAP8() is a uint8_t.

The bit-swapping macro uses the full register for intermediate storage so
we need to be careful to only read the low byte when using the result.

[Only the use in ps-surface.c was incorrect, I just converted the other
unsigned chars to uint8_t for consistency.]
This commit is contained in:
Chris Wilson 2008-09-01 15:33:05 +01:00
parent d756a4d632
commit e955b7399e
5 changed files with 16 additions and 17 deletions

View file

@ -1095,7 +1095,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
#ifndef WORDS_BIGENDIAN
{
unsigned char *d = data;
uint8_t *d = data;
int count = stride * height;
while (count--) {

View file

@ -3444,7 +3444,7 @@ static cairo_status_t
_cairo_pdf_emit_imagemask (cairo_image_surface_t *image,
cairo_output_stream_t *stream)
{
unsigned char *byte, output_byte;
uint8_t *byte, output_byte;
int row, col, num_cols;
/* The only image type supported by Type 3 fonts are 1-bit image

View file

@ -388,7 +388,7 @@ static cairo_status_t
_cairo_ps_emit_imagemask (cairo_image_surface_t *image,
cairo_output_stream_t *stream)
{
unsigned char *row, *byte;
uint8_t *row, *byte;
int rows, cols;
/* The only image type supported by Type 3 fonts are 1-bit image
@ -410,18 +410,15 @@ _cairo_ps_emit_imagemask (cairo_image_surface_t *image,
image->height);
_cairo_output_stream_printf (stream,
" /DataSource {<");
" /DataSource {<\n ");
for (row = image->data, rows = image->height; rows; row += image->stride, rows--) {
for (byte = row, cols = (image->width + 7) / 8; cols; byte++, cols--) {
unsigned int output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
uint8_t output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
_cairo_output_stream_printf (stream, "%02x ", output_byte);
}
_cairo_output_stream_printf (stream, "\n ");
}
_cairo_output_stream_printf (stream,
" >}\n");
_cairo_output_stream_printf (stream,
">>\n");
_cairo_output_stream_printf (stream, ">}\n>>\n");
_cairo_output_stream_printf (stream,
"imagemask\n");
@ -2238,11 +2235,13 @@ _cairo_ps_surface_paint_surface (cairo_ps_surface_t *surface,
cairo_matrix_translate (&ps_p2d, 0.0, height);
cairo_matrix_scale (&ps_p2d, 1.0, -1.0);
_cairo_output_stream_printf (surface->stream,
"[ %f %f %f %f %f %f ] concat\n",
ps_p2d.xx, ps_p2d.yx,
ps_p2d.xy, ps_p2d.yy,
ps_p2d.x0, ps_p2d.y0);
if (! _cairo_matrix_is_identity (&ps_p2d)) {
_cairo_output_stream_printf (surface->stream,
"[ %f %f %f %f %f %f ] concat\n",
ps_p2d.xx, ps_p2d.yx,
ps_p2d.xy, ps_p2d.yy,
ps_p2d.x0, ps_p2d.y0);
}
status = _cairo_ps_surface_emit_surface (surface, pattern, op);
_cairo_ps_surface_release_surface (surface, pattern);

View file

@ -2023,7 +2023,7 @@ _trace_mask_to_path (cairo_image_surface_t *mask,
{
cairo_status_t status;
cairo_image_surface_t *a1_mask;
unsigned char *row, *byte_ptr, byte;
uint8_t *row, *byte_ptr, byte;
int rows, cols, bytes_per_row;
int x, y, bit;
double xoff, yoff;

View file

@ -651,7 +651,7 @@ _cairo_svg_document_emit_bitmap_glyph_data (cairo_svg_document_t *document,
cairo_image_surface_t *image;
cairo_scaled_glyph_t *scaled_glyph;
cairo_status_t status;
unsigned char *row, *byte;
uint8_t *row, *byte;
int rows, cols;
int x, y, bit;
@ -677,7 +677,7 @@ _cairo_svg_document_emit_bitmap_glyph_data (cairo_svg_document_t *document,
for (y = 0, row = image->data, rows = image->height; rows; row += image->stride, rows--, y++) {
for (x = 0, byte = row, cols = (image->width + 7) / 8; cols; byte++, cols--) {
unsigned char output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
uint8_t output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
for (bit = 7; bit >= 0 && x < image->width; bit--, x++) {
if (output_byte & (1 << bit)) {
_cairo_output_stream_printf (document->xml_node_glyphs,