summaryrefslogtreecommitdiffstats
path: root/common/pixman_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/pixman_utils.c')
-rw-r--r--common/pixman_utils.c165
1 files changed, 85 insertions, 80 deletions
diff --git a/common/pixman_utils.c b/common/pixman_utils.c
index 1136aa7..f113cf5 100644
--- a/common/pixman_utils.c
+++ b/common/pixman_utils.c
@@ -206,12 +206,12 @@ void spice_pixman_fill_rect(pixman_image_t *dest,
depth = spice_pixman_image_get_bpp(dest);
/* stride is in bytes, depth in bits */
- ASSERT(x >= 0);
- ASSERT(y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(x + width <= pixman_image_get_width(dest));
- ASSERT(y + height <= pixman_image_get_height(dest));
+ spice_assert(x >= 0);
+ spice_assert(y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(x + width <= pixman_image_get_width(dest));
+ spice_assert(y + height <= pixman_image_get_height(dest));
if (pixman_fill(bits,
stride / 4,
@@ -231,7 +231,7 @@ void spice_pixman_fill_rect(pixman_image_t *dest,
byte_width = 2 * width;
value = (value & 0xffff) * 0x00010001;
} else {
- ASSERT (depth == 32)
+ spice_assert (depth == 32);
byte_line = ((uint8_t *)bits) + stride * y + x * 4;
byte_width = 4 * width;
}
@@ -298,13 +298,13 @@ void spice_pixman_fill_rect_rop(pixman_image_t *dest,
depth = spice_pixman_image_get_bpp(dest);
/* stride is in bytes, depth in bits */
- ASSERT(x >= 0);
- ASSERT(y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(x + width <= pixman_image_get_width(dest));
- ASSERT(y + height <= pixman_image_get_height(dest));
- ASSERT(rop >= 0 && rop < 16);
+ spice_assert(x >= 0);
+ spice_assert(y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(x + width <= pixman_image_get_width(dest));
+ spice_assert(y + height <= pixman_image_get_height(dest));
+ spice_assert(rop >= 0 && rop < 16);
if (depth == 8) {
solid_rop_8_func_t rop_func = solid_rops_8[rop];
@@ -358,13 +358,13 @@ void spice_pixman_tile_rect(pixman_image_t *dest,
tile_width = pixman_image_get_width(tile);
tile_height = pixman_image_get_height(tile);
- ASSERT(x >= 0);
- ASSERT(y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(x + width <= pixman_image_get_width(dest));
- ASSERT(y + height <= pixman_image_get_height(dest));
- ASSERT(depth == spice_pixman_image_get_bpp(tile));
+ spice_assert(x >= 0);
+ spice_assert(y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(x + width <= pixman_image_get_width(dest));
+ spice_assert(y + height <= pixman_image_get_height(dest));
+ spice_assert(depth == spice_pixman_image_get_bpp(tile));
tile_start_x = (x - offset_x) % tile_width;
if (tile_start_x < 0) {
@@ -406,7 +406,7 @@ void spice_pixman_tile_rect(pixman_image_t *dest,
}
}
} else {
- ASSERT (depth == 32);
+ spice_assert (depth == 32);
byte_line = ((uint8_t *)bits) + stride * y + x * 4;
tile_line = ((uint8_t *)tile_bits) + tile_stride * tile_start_y + tile_start_x * 4;
@@ -449,14 +449,14 @@ void spice_pixman_tile_rect_rop(pixman_image_t *dest,
tile_width = pixman_image_get_width(tile);
tile_height = pixman_image_get_height(tile);
- ASSERT(x >= 0);
- ASSERT(y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(x + width <= pixman_image_get_width(dest));
- ASSERT(y + height <= pixman_image_get_height(dest));
- ASSERT(rop >= 0 && rop < 16);
- ASSERT(depth == spice_pixman_image_get_bpp(tile));
+ spice_assert(x >= 0);
+ spice_assert(y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(x + width <= pixman_image_get_width(dest));
+ spice_assert(y + height <= pixman_image_get_height(dest));
+ spice_assert(rop >= 0 && rop < 16);
+ spice_assert(depth == spice_pixman_image_get_bpp(tile));
tile_start_x = (x - offset_x) % tile_width;
if (tile_start_x < 0) {
@@ -504,7 +504,7 @@ void spice_pixman_tile_rect_rop(pixman_image_t *dest,
} else {
tiled_rop_32_func_t rop_func = tiled_rops_32[rop];
- ASSERT (depth == 32);
+ spice_assert (depth == 32);
byte_line = ((uint8_t *)bits) + stride * y + x * 4;
tile_line = ((uint8_t *)tile_bits) + tile_stride * tile_start_y + tile_start_x * 4;
@@ -536,6 +536,11 @@ void spice_pixman_blit(pixman_image_t *dest,
uint8_t *src_line;
int byte_width;
+ if (!src) {
+ fprintf(stderr, "missing src!");
+ return;
+ }
+
bits = pixman_image_get_data(dest);
stride = pixman_image_get_stride(dest);
depth = spice_pixman_image_get_bpp(dest);
@@ -569,17 +574,17 @@ void spice_pixman_blit(pixman_image_t *dest,
return;
}
- ASSERT(src_x >= 0);
- ASSERT(src_y >= 0);
- ASSERT(dest_x >= 0);
- ASSERT(dest_y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(dest_x + width <= pixman_image_get_width(dest));
- ASSERT(dest_y + height <= pixman_image_get_height(dest));
- ASSERT(src_x + width <= pixman_image_get_width(src));
- ASSERT(src_y + height <= pixman_image_get_height(src));
- ASSERT(depth == src_depth);
+ spice_assert(src_x >= 0);
+ spice_assert(src_y >= 0);
+ spice_assert(dest_x >= 0);
+ spice_assert(dest_y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(dest_x + width <= pixman_image_get_width(dest));
+ spice_assert(dest_y + height <= pixman_image_get_height(dest));
+ spice_assert(src_x + width <= pixman_image_get_width(src));
+ spice_assert(src_y + height <= pixman_image_get_height(src));
+ spice_assert(depth == src_depth);
if (pixman_blt(src_bits,
bits,
@@ -601,7 +606,7 @@ void spice_pixman_blit(pixman_image_t *dest,
byte_width = width * 2;
src_line = ((uint8_t *)src_bits) + src_stride * src_y + src_x * 2;
} else {
- ASSERT (depth == 32);
+ spice_assert (depth == 32);
byte_line = ((uint8_t *)bits) + stride * dest_y + dest_x * 4;
byte_width = width * 4;
src_line = ((uint8_t *)src_bits) + src_stride * src_y + src_x * 4;
@@ -660,17 +665,17 @@ void spice_pixman_blit_rop (pixman_image_t *dest,
return;
}
- ASSERT(src_x >= 0);
- ASSERT(src_y >= 0);
- ASSERT(dest_x >= 0);
- ASSERT(dest_y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(dest_x + width <= pixman_image_get_width(dest));
- ASSERT(dest_y + height <= pixman_image_get_height(dest));
- ASSERT(src_x + width <= pixman_image_get_width(src));
- ASSERT(src_y + height <= pixman_image_get_height(src));
- ASSERT(depth == src_depth);
+ spice_assert(src_x >= 0);
+ spice_assert(src_y >= 0);
+ spice_assert(dest_x >= 0);
+ spice_assert(dest_y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(dest_x + width <= pixman_image_get_width(dest));
+ spice_assert(dest_y + height <= pixman_image_get_height(dest));
+ spice_assert(src_x + width <= pixman_image_get_width(src));
+ spice_assert(src_y + height <= pixman_image_get_height(src));
+ spice_assert(depth == src_depth);
if (depth == 8) {
copy_rop_8_func_t rop_func = copy_rops_8[rop];
@@ -697,7 +702,7 @@ void spice_pixman_blit_rop (pixman_image_t *dest,
} else {
copy_rop_32_func_t rop_func = copy_rops_32[rop];
- ASSERT (depth == 32);
+ spice_assert (depth == 32);
byte_line = ((uint8_t *)bits) + stride * dest_y + dest_x * 4;
src_line = ((uint8_t *)src_bits) + src_stride * src_y + src_x * 4;
@@ -756,17 +761,17 @@ void spice_pixman_blit_colorkey (pixman_image_t *dest,
return;
}
- ASSERT(src_x >= 0);
- ASSERT(src_y >= 0);
- ASSERT(dest_x >= 0);
- ASSERT(dest_y >= 0);
- ASSERT(width > 0);
- ASSERT(height > 0);
- ASSERT(dest_x + width <= pixman_image_get_width(dest));
- ASSERT(dest_y + height <= pixman_image_get_height(dest));
- ASSERT(src_x + width <= pixman_image_get_width(src));
- ASSERT(src_y + height <= pixman_image_get_height(src));
- ASSERT(depth == spice_pixman_image_get_bpp(src));
+ spice_assert(src_x >= 0);
+ spice_assert(src_y >= 0);
+ spice_assert(dest_x >= 0);
+ spice_assert(dest_y >= 0);
+ spice_assert(width > 0);
+ spice_assert(height > 0);
+ spice_assert(dest_x + width <= pixman_image_get_width(dest));
+ spice_assert(dest_y + height <= pixman_image_get_height(dest));
+ spice_assert(src_x + width <= pixman_image_get_width(src));
+ spice_assert(src_y + height <= pixman_image_get_height(src));
+ spice_assert(depth == spice_pixman_image_get_bpp(src));
if (depth == 8) {
byte_line = ((uint8_t *)bits) + stride * dest_y + dest_x;
@@ -806,7 +811,7 @@ void spice_pixman_blit_colorkey (pixman_image_t *dest,
src_line += src_stride;
}
} else {
- ASSERT (depth == 32);
+ spice_assert (depth == 32);
byte_line = ((uint8_t *)bits) + stride * dest_y + dest_x * 4;
src_line = ((uint8_t *)src_bits) + src_stride * src_y + src_x * 4;
@@ -925,7 +930,7 @@ pixman_format_code_t spice_surface_format_to_pixman(uint32_t surface_format)
return PIXMAN_a8r8g8b8;
default:
printf("Unknown surface format %d\n", surface_format);
- abort();
+ spice_abort();
break;
}
return (pixman_format_code_t)0; /* Not reached */
@@ -961,7 +966,7 @@ pixman_format_code_t spice_bitmap_format_to_pixman(int bitmap_format,
case SPICE_BITMAP_FMT_INVALID:
default:
printf("Unknown bitmap format %d\n", bitmap_format);
- abort();
+ spice_abort();
return PIXMAN_a8r8g8b8;
}
}
@@ -1131,7 +1136,7 @@ static void bitmap_8_32_to_32(uint8_t *dest, int dest_stride,
#endif
if (!palette) {
- PANIC("No palette");
+ spice_error("No palette");
return;
}
@@ -1177,7 +1182,7 @@ static void bitmap_8_16_to_16_555(uint8_t *dest, int dest_stride,
#endif
if (!palette) {
- PANIC("No palette");
+ spice_error("No palette");
return;
}
@@ -1223,7 +1228,7 @@ static void bitmap_4be_32_to_32(uint8_t* dest, int dest_stride,
#endif
if (!palette) {
- PANIC("No palette");
+ spice_error("No palette");
return;
}
@@ -1273,7 +1278,7 @@ static void bitmap_4be_16_to_16_555(uint8_t* dest, int dest_stride,
#endif
if (!palette) {
- PANIC("No palette");
+ spice_error("No palette");
return;
}
@@ -1323,7 +1328,7 @@ static void bitmap_1be_32_to_32(uint8_t* dest, int dest_stride,
uint32_t fore_color;
uint32_t back_color;
- ASSERT(palette != NULL);
+ spice_assert(palette != NULL);
if (!palette) {
return;
@@ -1355,7 +1360,7 @@ static void bitmap_1be_16_to_16_555(uint8_t* dest, int dest_stride,
uint16_t fore_color;
uint16_t back_color;
- ASSERT(palette != NULL);
+ spice_assert(palette != NULL);
if (!palette) {
return;
@@ -1461,7 +1466,7 @@ pixman_image_t *spice_bitmap_to_pixman(pixman_image_t *dest_image,
dest = (uint8_t *)pixman_image_get_data(dest_image);
dest_stride = pixman_image_get_stride(dest_image);
if (!(flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) {
- ASSERT(height > 0);
+ spice_assert(height > 0);
dest += dest_stride * (height - 1);
dest_stride = -dest_stride;
}
@@ -1485,7 +1490,7 @@ pixman_image_t *spice_bitmap_to_pixman(pixman_image_t *dest_image,
} else if (palette_surface_format == SPICE_SURFACE_FMT_16_555) {
bitmap_8_16_to_16_555(dest, dest_stride, src, src_stride, width, end, palette);
} else {
- PANIC("Unsupported palette format");
+ spice_error("Unsupported palette format");
}
break;
case SPICE_BITMAP_FMT_4BIT_BE:
@@ -1495,7 +1500,7 @@ pixman_image_t *spice_bitmap_to_pixman(pixman_image_t *dest_image,
} else if (palette_surface_format == SPICE_SURFACE_FMT_16_555) {
bitmap_4be_16_to_16_555(dest, dest_stride, src, src_stride, width, end, palette);
} else {
- PANIC("Unsupported palette format");
+ spice_error("Unsupported palette format");
}
break;
case SPICE_BITMAP_FMT_1BIT_BE:
@@ -1505,11 +1510,11 @@ pixman_image_t *spice_bitmap_to_pixman(pixman_image_t *dest_image,
} else if (palette_surface_format == SPICE_SURFACE_FMT_16_555) {
bitmap_1be_16_to_16_555(dest, dest_stride, src, src_stride, width, end, palette);
} else {
- PANIC("Unsupported palette format");
+ spice_error("Unsupported palette format");
}
break;
default:
- PANIC("Unsupported bitmap format");
+ spice_error("Unsupported bitmap format");
break;
}