diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-04-03 15:49:36 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-04-03 15:49:36 +0200 |
commit | 3c9a6f78229492ffcceb6c065af8c7fbacef52ab (patch) | |
tree | 0193283af56a08c0b8cae33d5343856f9dbbb04a /common | |
parent | a96278aed129704cf2188073bd3bc0edf9b1626c (diff) | |
download | spice-gtk-3c9a6f78229492ffcceb6c065af8c7fbacef52ab.tar.gz spice-gtk-3c9a6f78229492ffcceb6c065af8c7fbacef52ab.tar.xz spice-gtk-3c9a6f78229492ffcceb6c065af8c7fbacef52ab.zip |
common: get rid of abort() in canvases
Diffstat (limited to 'common')
-rw-r--r-- | common/canvas_base.c | 219 | ||||
-rw-r--r-- | common/gdi_canvas.c | 106 | ||||
-rw-r--r-- | common/gl_canvas.c | 33 | ||||
-rw-r--r-- | common/pixman_utils.c | 5 | ||||
-rw-r--r-- | common/sw_canvas.c | 24 |
5 files changed, 220 insertions, 167 deletions
diff --git a/common/canvas_base.c b/common/canvas_base.c index 11a0b1a..a974d0b 100644 --- a/common/canvas_base.c +++ b/common/canvas_base.c @@ -35,31 +35,36 @@ #include "mutex.h" -#ifndef CANVAS_ERROR -#define CANVAS_ERROR(format, ...) { \ - printf("%s: " format "\n", __FUNCTION__, ## __VA_ARGS__); \ - abort(); \ +#ifndef spice_return_if_fail +#define spice_return_if_fail(x) if (!(x)) { \ + fprintf(stderr, "(%s:%d) %s: condition %s failed\n", __FILE__, __LINE__, __FUNCTION__, #x); \ + return; \ } #endif -#ifndef ASSERT -#define ASSERT(x) if (!(x)) { \ - printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \ - abort(); \ +#ifndef spice_return_val_if_fail +#define spice_return_val_if_fail(x, val) if (!(x)) { \ + fprintf(stderr, "(%s:%d) %s: condition %s failed\n", __FILE__, __LINE__, __FUNCTION__, #x); \ + return (val); \ } #endif -#ifndef WARN -#define WARN(x) printf("warning: %s\n", x) +#ifndef spice_warn_if_reached +#define spice_warn_if_reached() do { \ + fprintf(stderr, "(%s:%d) %s: should not be reached", __FILE__, __LINE__, __FUNCTION__); \ +}while(0) #endif -#define PANIC(str) { \ - printf("%s: panic: %s", __FUNCTION__, str); \ - abort(); \ -} +#ifndef spice_warning +#define spice_warning(x) do { \ + fprintf(stderr, "(%s:%d) %s: warning %s", __FILE__, __LINE__, __FUNCTION__, (x)); \ +} while(0) +#endif -#ifndef DBG -#define DBG(level, format, ...) printf("%s: debug: " format "\n", __FUNCTION__, ## __VA_ARGS__); +#ifndef spice_critical +#define spice_critical(x) do { \ + fprintf(stderr, "(%s:%d) %s: CRITICAL %s", __FILE__, __LINE__, __FUNCTION__, (x)); \ +} while(0) #endif #define ROUND(_x) ((int)floor((_x) + 0.5)) @@ -119,9 +124,9 @@ static inline uint32_t canvas_16bpp_to_32bpp(uint32_t color) static HDC create_compatible_dc() { HDC dc = CreateCompatibleDC(NULL); - if (!dc) { - CANVAS_ERROR("create compatible DC failed"); - } + + spice_return_val_if_fail(dc != NULL, NULL); + return dc; } @@ -407,7 +412,8 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image, if (setjmp(quic_data->jmp_env)) { pixman_image_unref(surface); - CANVAS_ERROR("quic error, %s", quic_data->message_buf); + spice_warning(quic_data->message_buf); + return NULL; } quic_data->chunks = image->u.quic.data; @@ -417,10 +423,11 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image, (uint32_t *)image->u.quic.data->chunk[0].data, image->u.quic.data->chunk[0].len >> 2, &type, &width, &height) == QUIC_ERROR) { - CANVAS_ERROR("quic decode begin failed"); + spice_warning("quic decode begin failed"); + return NULL; } - switch (type) { + switch (type) { case QUIC_IMAGE_TYPE_RGBA: as_type = QUIC_IMAGE_TYPE_RGBA; pixman_format = PIXMAN_a8r8g8b8; @@ -444,11 +451,12 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image, case QUIC_IMAGE_TYPE_INVALID: case QUIC_IMAGE_TYPE_GRAY: default: - CANVAS_ERROR("unexpected image type"); + spice_warn_if_reached(); + return NULL; } - ASSERT((uint32_t)width == image->descriptor.width); - ASSERT((uint32_t)height == image->descriptor.height); + spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL); + spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL); surface = surface_create( #ifdef WIN32 @@ -457,16 +465,15 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image, pixman_format, width, height, FALSE); - if (surface == NULL) { - CANVAS_ERROR("create surface failed"); - } + spice_return_val_if_fail(surface != NULL, NULL); dest = (uint8_t *)pixman_image_get_data(surface); stride = pixman_image_get_stride(surface); if (quic_decode(quic_data->quic, as_type, dest, stride) == QUIC_ERROR) { pixman_image_unref(surface); - CANVAS_ERROR("quic decode failed"); + spice_warning("quic decode failed"); + return NULL; } if (invers) { @@ -522,11 +529,11 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in int height; uint8_t *dest; - ASSERT(image->u.jpeg.data->num_chunks == 1); /* TODO: Handle chunks */ + spice_return_val_if_fail(image->u.jpeg.data->num_chunks == 1, NULL); canvas->jpeg->ops->begin_decode(canvas->jpeg, image->u.jpeg.data->chunk[0].data, image->u.jpeg.data->chunk[0].len, &width, &height); - ASSERT((uint32_t)width == image->descriptor.width); - ASSERT((uint32_t)height == image->descriptor.height); + spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL); + spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL); surface = surface_create( #ifdef WIN32 @@ -535,7 +542,8 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in PIXMAN_x8r8g8b8, width, height, FALSE); if (surface == NULL) { - CANVAS_ERROR("create surface failed"); + spice_warning("create surface failed"); + return NULL; } dest = (uint8_t *)pixman_image_get_data(surface); @@ -578,13 +586,13 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, int alpha_size; int lz_alpha_width, lz_alpha_height, n_comp_pixels, lz_alpha_top_down; - ASSERT(image->u.jpeg_alpha.data->num_chunks == 1); + spice_return_val_if_fail(image->u.jpeg_alpha.data->num_chunks == 1, NULL); canvas->jpeg->ops->begin_decode(canvas->jpeg, image->u.jpeg_alpha.data->chunk[0].data, image->u.jpeg_alpha.jpeg_size, &width, &height); - ASSERT((uint32_t)width == image->descriptor.width); - ASSERT((uint32_t)height == image->descriptor.height); + spice_return_val_if_fail((uint32_t)width == image->descriptor.width, NULL); + spice_return_val_if_fail((uint32_t)height == image->descriptor.height, NULL); if (image->u.jpeg_alpha.flags & SPICE_JPEG_ALPHA_FLAGS_TOP_DOWN) { alpha_top_down = TRUE; @@ -597,7 +605,8 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, width, height, width*height, alpha_top_down); if (surface == NULL) { - CANVAS_ERROR("create surface failed"); + spice_warning("create surface failed"); + return NULL; } dest = (uint8_t *)pixman_image_get_data(surface); @@ -611,11 +620,11 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, lz_decode_begin(lz_data->lz, comp_alpha_buf, alpha_size, &lz_alpha_type, &lz_alpha_width, &lz_alpha_height, &n_comp_pixels, &lz_alpha_top_down, NULL); - ASSERT(lz_alpha_type == LZ_IMAGE_TYPE_XXXA); - ASSERT(!!lz_alpha_top_down == !!alpha_top_down); - ASSERT(lz_alpha_width == width); - ASSERT(lz_alpha_height == height); - ASSERT(n_comp_pixels == width * height); + spice_return_val_if_fail(lz_alpha_type == LZ_IMAGE_TYPE_XXXA, NULL); + spice_return_val_if_fail(!!lz_alpha_top_down == !!alpha_top_down, NULL); + spice_return_val_if_fail(lz_alpha_width == width, NULL); + spice_return_val_if_fail(lz_alpha_height == height, NULL); + spice_return_val_if_fail(n_comp_pixels == width * height, NULL); if (!alpha_top_down) { decomp_alpha_buf = dest + stride * (height - 1); @@ -670,7 +679,8 @@ static pixman_image_t *canvas_bitmap_to_surface(CanvasBase *canvas, SpiceBitmap* format, bitmap->x, bitmap->y, FALSE); if (image == NULL) { - CANVAS_ERROR("create surface failed"); + spice_warning("create surface failed"); + return NULL; } spice_bitmap_convert_to_pixman(format, image, @@ -730,7 +740,8 @@ static inline SpicePalette *canvas_get_localized_palette(CanvasBase *canvas, Spi break; case SPICE_SURFACE_FMT_16_565: default: - PANIC("Unsupported palette depth"); + spice_warn_if_reached(); + return NULL; } *free_palette = TRUE; return copy; @@ -758,22 +769,24 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int if (decomp_buf) { free(decomp_buf); } - CANVAS_ERROR("lz error, %s", lz_data->message_buf); + spice_warning(lz_data->message_buf); + return NULL; } free_palette = FALSE; if (image->descriptor.type == SPICE_IMAGE_TYPE_LZ_RGB) { - ASSERT(image->u.lz_rgb.data->num_chunks == 1); /* TODO: Handle chunks */ + spice_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */ comp_buf = image->u.lz_rgb.data->chunk[0].data; comp_size = image->u.lz_rgb.data->chunk[0].len; palette = NULL; } else if (image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) { - ASSERT(image->u.lz_plt.data->num_chunks == 1); /* TODO: Handle chunks */ + spice_return_val_if_fail(image->u.lz_plt.data->num_chunks == 1, NULL); /* TODO: Handle chunks */ comp_buf = image->u.lz_plt.data->chunk[0].data; comp_size = image->u.lz_plt.data->chunk[0].len; palette = canvas_get_localized_palette(canvas, image->u.lz_plt.palette, image->u.lz_plt.palette_id, image->u.lz_plt.flags, &free_palette); } else { - CANVAS_ERROR("unexpected image type"); + spice_warn_if_reached(); + return NULL; } lz_decode_begin(lz_data->lz, comp_buf, comp_size, &type, @@ -806,13 +819,14 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int } break; default: - CANVAS_ERROR("unexpected LZ image type"); + spice_warn_if_reached(); + return NULL; } - ASSERT((unsigned)width == image->descriptor.width); - ASSERT((unsigned)height == image->descriptor.height); + spice_return_val_if_fail((unsigned)width == image->descriptor.width, NULL); + spice_return_val_if_fail((unsigned)height == image->descriptor.height, NULL); - ASSERT((image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) || (n_comp_pixels == width * height)); + spice_return_val_if_fail((image->descriptor.type == SPICE_IMAGE_TYPE_LZ_PLT) || (n_comp_pixels == width * height), NULL); #ifdef WIN32 lz_data->decode_data.dc = canvas->dc; #endif @@ -858,9 +872,7 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int static pixman_image_t *canvas_get_glz_rgb_common(CanvasBase *canvas, uint8_t *data, int want_original) { - if (canvas->glz_data.decoder == NULL) { - CANVAS_ERROR("glz not supported"); - } + spice_return_val_if_fail(canvas->glz_data.decoder != NULL, NULL); canvas->glz_data.decoder->ops->decode(canvas->glz_data.decoder, data, NULL, @@ -875,12 +887,12 @@ static pixman_image_t *canvas_get_glz_rgb_common(CanvasBase *canvas, uint8_t *da static pixman_image_t *canvas_get_glz(CanvasBase *canvas, SpiceImage *image, int want_original) { - ASSERT(image->descriptor.type == SPICE_IMAGE_TYPE_GLZ_RGB); + spice_return_val_if_fail(image->descriptor.type == SPICE_IMAGE_TYPE_GLZ_RGB, NULL); #ifdef WIN32 canvas->glz_data.decode_data.dc = canvas->dc; #endif - ASSERT(image->u.lz_rgb.data->num_chunks == 1); /* TODO: Handle chunks */ + spice_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */ return canvas_get_glz_rgb_common(canvas, image->u.lz_rgb.data->chunk[0].data, want_original); } @@ -890,11 +902,9 @@ static pixman_image_t *canvas_get_zlib_glz_rgb(CanvasBase *canvas, SpiceImage *i uint8_t *glz_data; pixman_image_t *surface; - if (canvas->zlib == NULL) { - CANVAS_ERROR("zlib not supported"); - } + spice_return_val_if_fail(canvas->zlib != NULL, NULL); - ASSERT(image->u.zlib_glz.data->num_chunks == 1); /* TODO: Handle chunks */ + spice_return_val_if_fail(image->u.zlib_glz.data->num_chunks == 1, NULL); /* TODO: Handle chunks */ glz_data = (uint8_t*)spice_malloc(image->u.zlib_glz.glz_data_size); canvas->zlib->ops->decode(canvas->zlib, image->u.zlib_glz.data->chunk[0].data, image->u.zlib_glz.data->chunk[0].len, @@ -1142,9 +1152,11 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage break; } default: - CANVAS_ERROR("invalid image type"); + spice_warn_if_reached(); + return NULL; } + spice_return_val_if_fail(surface != NULL, NULL); surface_format = spice_pixman_image_get_format(surface); if (descriptor->flags & SPICE_IMAGE_FLAGS_HIGH_BITS_SET && @@ -1180,7 +1192,8 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage #ifdef SW_CANVAS_CACHE } else if (descriptor->flags & SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME) { if (IS_IMAGE_LOSSY(descriptor)) { - CANVAS_ERROR("invalid cache replace request: the image is lossy"); + spice_warning("invalid cache replace request: the image is lossy"); + return NULL; } canvas->bits_cache->ops->replace_lossy(canvas->bits_cache, descriptor->id, surface); #ifdef DEBUG_DUMP_SURFACE @@ -1257,8 +1270,11 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage return canvas_get_bits(canvas, &image->u.bitmap, want_original, &format); } default: - CANVAS_ERROR("invalid image type"); + spice_warn_if_reached(); + return NULL; } + + return NULL; } #endif @@ -1296,9 +1312,7 @@ static pixman_image_t* canvas_get_image_from_self(SpiceCanvas *canvas, surface = pixman_image_create_bits(spice_surface_format_to_pixman (canvas_base->format), width, height, NULL, 0); - if (surface == NULL) { - CANVAS_ERROR("create surface failed"); - } + spice_return_val_if_fail(surface != NULL, NULL); dest = (uint8_t *)pixman_image_get_data(surface); dest_stride = pixman_image_get_stride(surface); @@ -1341,9 +1355,7 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b canvas->dc, #endif PIXMAN_a1, bitmap->x, bitmap->y, TRUE); - if (surface == NULL) { - CANVAS_ERROR("create surface failed"); - } + spice_return_val_if_fail(surface != NULL, NULL); spice_chunks_linearize(bitmap->data); src_line = bitmap->data->chunk[0].data; @@ -1358,7 +1370,7 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b #else if (!(bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) { #endif - ASSERT(bitmap->y > 0); + spice_return_val_if_fail(bitmap->y > 0, NULL); dest_line += dest_stride * ((int)bitmap->y - 1); dest_stride = -dest_stride; } @@ -1397,7 +1409,8 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b default: pixman_image_unref(surface); surface = NULL; - CANVAS_ERROR("invalid bitmap format"); + spice_warn_if_reached(); + return NULL; } } else { switch (bitmap->format) { @@ -1428,7 +1441,8 @@ static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* b default: pixman_image_unref(surface); surface = NULL; - CANVAS_ERROR("invalid bitmap format"); + spice_warn_if_reached(); + return NULL; } } return surface; @@ -1442,12 +1456,10 @@ static inline pixman_image_t *canvas_A1_invers(pixman_image_t *src_surf) uint8_t *src_line, *end_line, *dest_line; int src_stride, line_size, dest_stride; - ASSERT(pixman_image_get_depth(src_surf) == 1); + spice_return_val_if_fail(pixman_image_get_depth(src_surf) == 1, NULL); invers = pixman_image_create_bits(PIXMAN_a1, width, height, NULL, 0); - if (invers == NULL) { - CANVAS_ERROR("create surface failed"); - } + spice_return_val_if_fail(invers != NULL, NULL); src_line = (uint8_t *)pixman_image_get_data(src_surf); src_stride = pixman_image_get_stride(src_surf); @@ -1507,7 +1519,8 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int break; #endif default: - CANVAS_ERROR("invalid image type"); + spice_warn_if_reached(); + return NULL; } #if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE) @@ -1531,7 +1544,8 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int static inline void canvas_raster_glyph_box(const SpiceRasterGlyph *glyph, SpiceRect *r) { - ASSERT(r); + spice_return_if_fail(r != NULL); + r->top = glyph->render_pos.y + glyph->glyph_origin.y; r->bottom = r->top + glyph->height; r->left = glyph->render_pos.x + glyph->glyph_origin.x; @@ -1606,8 +1620,8 @@ static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des //todo: support SPICE_STRING_FLAGS_RASTER_TOP_DOWN canvas_raster_glyph_box(glyph, &glyph_box); - ASSERT(glyph_box.top >= bounds->top && glyph_box.bottom <= bounds->bottom); - ASSERT(glyph_box.left >= bounds->left && glyph_box.right <= bounds->right); + spice_return_if_fail(glyph_box.top >= bounds->top && glyph_box.bottom <= bounds->bottom); + spice_return_if_fail(glyph_box.left >= bounds->left && glyph_box.right <= bounds->right); rect_offset(&glyph_box, -bounds->left, -bounds->top); dest += glyph_box.top * dest_stride; @@ -1668,7 +1682,8 @@ static void canvas_put_glyph_bits(SpiceRasterGlyph *glyph, int bpp, uint8_t *des break; } default: - CANVAS_ERROR("invalid bpp"); + spice_warn_if_reached(); + return; } } @@ -1681,7 +1696,7 @@ static pixman_image_t *canvas_get_str_mask(CanvasBase *canvas, SpiceString *str, int dest_stride; int i; - ASSERT(str->length > 0); + spice_return_val_if_fail(str->length > 0, NULL); glyph = str->glyphs[0]; canvas_raster_glyph_box(glyph, &bounds); @@ -1696,9 +1711,8 @@ static pixman_image_t *canvas_get_str_mask(CanvasBase *canvas, SpiceString *str, str_mask = pixman_image_create_bits((bpp == 1) ? PIXMAN_a1 : PIXMAN_a8, bounds.right - bounds.left, bounds.bottom - bounds.top, NULL, 0); - if (str_mask == NULL) { - CANVAS_ERROR("create surface failed"); - } + spice_return_val_if_fail(str_mask != NULL, NULL); + dest = (uint8_t *)pixman_image_get_data(str_mask); dest_stride = pixman_image_get_stride(str_mask); for (i = 0; i < str->length; i++) { @@ -1725,9 +1739,7 @@ static pixman_image_t *canvas_scale_surface(pixman_image_t *src, const SpiceRect surface = pixman_image_create_bits(spice_pixman_image_get_format (src), width, height, NULL, 0); - if (surface == NULL) { - CANVAS_ERROR("create surface failed"); - } + spice_return_val_if_fail(surface != NULL, NULL); sx = (double)(src_area->right - src_area->left) / width; sy = (double)(src_area->bottom - src_area->top) / height; @@ -1736,7 +1748,7 @@ static pixman_image_t *canvas_scale_surface(pixman_image_t *src, const SpiceRect pixman_image_set_transform (src, &transform); pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE); - ASSERT(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); + spice_return_val_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST, NULL); pixman_image_set_filter(src, (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ?PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD, NULL, 0); @@ -1909,7 +1921,8 @@ static void canvas_clip_pixman(CanvasBase *canvas, break; } default: - CANVAS_ERROR("invalid clip type"); + spice_warn_if_reached(); + return; } } @@ -2057,6 +2070,8 @@ static void draw_brush(SpiceCanvas *canvas, } } else { tile = canvas_get_image(canvas_base, pattern->pat, FALSE); + spice_return_if_fail(tile != NULL); + if (rop == SPICE_ROP_COPY) { canvas->ops->fill_tiled_rects(canvas, rects, n_rects, tile, offset_x, offset_y); } else { @@ -2072,7 +2087,8 @@ static void draw_brush(SpiceCanvas *canvas, canvas->ops->fill_solid_rects_rop(canvas, rects, n_rects, 0, rop); break; default: - CANVAS_ERROR("invalid brush type"); + spice_warn_if_reached(); + return; } } @@ -2191,6 +2207,8 @@ static void canvas_draw_copy(SpiceCanvas *spice_canvas, SpiceRect *bbox, SpiceCl } } else { src_image = canvas_get_image(canvas, copy->src_bitmap, FALSE); + spice_return_if_fail(src_image != NULL); + if (rect_is_same_size(bbox, ©->src_area)) { if (rop == SPICE_ROP_COPY) { spice_canvas->ops->blit_image(spice_canvas, &dest_region, @@ -2296,6 +2314,8 @@ static void canvas_draw_transparent(SpiceCanvas *spice_canvas, SpiceRect *bbox, } } else { src_image = canvas_get_image(canvas, transparent->src_bitmap, FALSE); + spice_return_if_fail(src_image != NULL); + if (rect_is_same_size(bbox, &transparent->src_area)) { spice_canvas->ops->colorkey_image(spice_canvas, &dest_region, src_image, @@ -2373,6 +2393,8 @@ static void canvas_draw_alpha_blend(SpiceCanvas *spice_canvas, SpiceRect *bbox, } } else { src_image = canvas_get_image(canvas, alpha_blend->src_bitmap, TRUE); + spice_return_if_fail(src_image != NULL); + if (rect_is_same_size(bbox, &alpha_blend->src_area)) { spice_canvas->ops->blend_image(spice_canvas, &dest_region, alpha_blend->alpha_flags & SPICE_ALPHA_FLAGS_DEST_HAS_ALPHA, @@ -2456,6 +2478,7 @@ static void canvas_draw_opaque(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spice } } else { src_image = canvas_get_image(canvas, opaque->src_bitmap, FALSE); + spice_return_if_fail(src_image != NULL); if (rect_is_same_size(bbox, &opaque->src_area)) { spice_canvas->ops->blit_image(spice_canvas, &dest_region, @@ -2558,6 +2581,8 @@ static void canvas_draw_blend(SpiceCanvas *spice_canvas, SpiceRect *bbox, SpiceC } } else { src_image = canvas_get_image(canvas, blend->src_bitmap, FALSE); + spice_return_if_fail(src_image != NULL); + if (rect_is_same_size(bbox, &blend->src_area)) { if (rop == SPICE_ROP_COPY) spice_canvas->ops->blit_image(spice_canvas, &dest_region, @@ -3104,7 +3129,8 @@ static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, gc.tile_offset_y = stroke->brush.u.pattern.pos.y; break; default: - CANVAS_ERROR("invalid brush type"); + spice_warn_if_reached(); + return; } stroke_lines_init(&lines); @@ -3123,7 +3149,7 @@ static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, } if (seg->flags & SPICE_PATH_BEZIER) { - ASSERT((point - end_point) % 3 == 0); + spice_return_if_fail((point - end_point) % 3 == 0); for (; point + 2 < end_point; point += 3) { stroke_lines_append_bezier(&lines, &point[0], @@ -3206,7 +3232,8 @@ static void canvas_draw_rop3(SpiceCanvas *spice_canvas, SpiceRect *bbox, } if (pixman_image_get_width(s) - src_pos.x < width || pixman_image_get_height(s) - src_pos.y < heigth) { - CANVAS_ERROR("bad src bitmap size"); + spice_critical("bad src bitmap size"); + return; } if (rop3->brush.type == SPICE_BRUSH_TYPE_PATTERN) { SpiceCanvas *_surface_canvas; @@ -3300,7 +3327,7 @@ static void canvas_base_group_end(SpiceCanvas *spice_canvas) static void unimplemented_op(SpiceCanvas *canvas) { - PANIC("unimplemented canvas operation"); + spice_critical("unimplemented canvas operation"); } inline static void canvas_base_init_ops(SpiceCanvasOps *ops) diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c index d57aafc..a11ba90 100644 --- a/common/gdi_canvas.c +++ b/common/gdi_canvas.c @@ -321,14 +321,14 @@ static void set_path(GdiCanvas *canvas, SpicePath *s) BeginPath(canvas->dc); if (!MoveToEx(canvas->dc, (int)fix_to_double(point->x), (int)fix_to_double(point->y), NULL)) { - CANVAS_ERROR("MoveToEx failed"); + spice_critical("MoveToEx failed"); return; } point++; } if (seg->flags & SPICE_PATH_BEZIER) { - ASSERT((point - end_point) % 3 == 0); + spice_return_if_fail((point - end_point) % 3 == 0); for (; point + 2 < end_point; point += 3) { POINT points[3]; @@ -339,7 +339,7 @@ static void set_path(GdiCanvas *canvas, SpicePath *s) points[2].x = (int)fix_to_double(point[2].x); points[2].y = (int)fix_to_double(point[2].y); if (!PolyBezierTo(canvas->dc, points, 3)) { - CANVAS_ERROR("PolyBezierTo failed"); + spice_critical("PolyBezierTo failed"); return; } } @@ -347,7 +347,7 @@ static void set_path(GdiCanvas *canvas, SpicePath *s) for (; point < end_point; point++) { if (!LineTo(canvas->dc, (int)fix_to_double(point->x), (int)fix_to_double(point->y))) { - CANVAS_ERROR("LineTo failed"); + spice_critical("LineTo failed"); } } } @@ -356,12 +356,12 @@ static void set_path(GdiCanvas *canvas, SpicePath *s) if (seg->flags & SPICE_PATH_CLOSE) { if (!CloseFigure(canvas->dc)) { - CANVAS_ERROR("CloseFigure failed"); + spice_critical("CloseFigure failed"); } } if (!EndPath(canvas->dc)) { - CANVAS_ERROR("EndPath failed"); + spice_critical("EndPath failed"); } } @@ -375,7 +375,7 @@ static void set_scale_mode(GdiCanvas *canvas, uint8_t scale_mode) } else if (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) { SetStretchBltMode(canvas->dc, COLORONCOLOR); } else { - CANVAS_ERROR("Unknown ScaleMode"); + spice_critical("Unknown ScaleMode"); } } @@ -384,7 +384,7 @@ static void set_clip(GdiCanvas *canvas, SpiceClip *clip) switch (clip->type) { case SPICE_CLIP_TYPE_NONE: if (SelectClipRgn(canvas->dc, NULL) == ERROR) { - CANVAS_ERROR("SelectClipRgn failed"); + spice_critical("SelectClipRgn failed"); } break; case SPICE_CLIP_TYPE_RECTS: { @@ -406,26 +406,27 @@ static void set_clip(GdiCanvas *canvas, SpiceClip *clip) combaine_hrgn = CreateRectRgn(now->left, now->top, now->right, now->bottom); if (!combaine_hrgn) { - CANVAS_ERROR("Unable to CreateRectRgn"); + spice_critical("Unable to CreateRectRgn"); DeleteObject(main_hrgn); return; } if (CombineRgn(main_hrgn, main_hrgn, combaine_hrgn, RGN_OR) == ERROR) { - CANVAS_ERROR("Unable to CombineRgn"); + spice_critical("Unable to CombineRgn"); DeleteObject(combaine_hrgn); return; } DeleteObject(combaine_hrgn); } if (SelectClipRgn(canvas->dc, main_hrgn) == ERROR) { - CANVAS_ERROR("Unable to SelectClipRgn"); + spice_critical("Unable to SelectClipRgn"); } DeleteObject(main_hrgn); } break; } default: - CANVAS_ERROR("invalid clip type"); + spice_warn_if_reached(); + return; } } @@ -435,7 +436,8 @@ static void copy_bitmap(const uint8_t *src_image, int height, int src_stride, int copy_width = MIN(dest_stride, src_stride); int y = 0; - ASSERT(dest_stride >= 0 && src_stride >= 0); + spice_return_if_fail(dest_stride >= 0 && src_stride >= 0); + while (y < height) { memcpy(dest_bitmap, src_image, copy_width); src_image += src_stride; @@ -526,13 +528,13 @@ static uint8_t *create_bitmap(HBITMAP *bitmap, HBITMAP *prev_bitmap, HDC *dc, *dc = create_compatible_dc(); if (!*dc) { - CANVAS_ERROR("create_compatible_dc() failed"); + spice_critical("create_compatible_dc() failed"); return NULL; } *bitmap = CreateDIBSection(*dc, &bitmap_info.inf, 0, (VOID **)&data, NULL, 0); if (!*bitmap) { - CANVAS_ERROR("Unable to CreateDIBSection"); + spice_critical("Unable to CreateDIBSection"); DeleteDC(*dc); return NULL; } @@ -558,7 +560,8 @@ static uint8_t *create_bitmap(HBITMAP *bitmap, HBITMAP *prev_bitmap, HDC *dc, nstride = width * 4; break; default: - CANVAS_ERROR("invalid bitmap bits size"); + spice_warn_if_reached(); + return; } if (bitmap_data) { @@ -631,7 +634,8 @@ static HBRUSH get_brush(GdiCanvas *canvas, SpiceBrush *brush, RecurciveMutex **b switch (brush->type) { case SPICE_BRUSH_TYPE_SOLID: if (!(hbrush = CreateSolidBrush(get_color_ref(canvas, brush->u.color)))) { - CANVAS_ERROR("CreateSolidBrush failed"); + spice_critical("CreateSolidBrush failed"); + return NULL; } return hbrush; case SPICE_BRUSH_TYPE_PATTERN: { @@ -646,19 +650,21 @@ static HBRUSH get_brush(GdiCanvas *canvas, SpiceBrush *brush, RecurciveMutex **b if (gdi_surface) { bitmap = (HBITMAP)GetCurrentObject(gdi_surface->dc, OBJ_BITMAP); if (!bitmap) { - CANVAS_ERROR("GetCurrentObject failed"); + spice_critical("GetCurrentObject failed"); + return NULL; } *brush_lock = gdi_surface->lock; } else { surface = canvas_get_image(&canvas->base, brush->u.pattern.pat, FALSE); if (!create_bitmap_from_pixman(&bitmap, &prev_bitmap, &dc, surface, 0)) { - CANVAS_ERROR("create_bitmap failed"); + spice_critical("create_bitmap failed"); return NULL; } } if (!(hbrush = CreatePatternBrush(bitmap))) { - CANVAS_ERROR("CreatePatternBrush failed"); + spice_critical("CreatePatternBrush failed"); + return NULL; } if (!gdi_surface) { @@ -670,7 +676,7 @@ static HBRUSH get_brush(GdiCanvas *canvas, SpiceBrush *brush, RecurciveMutex **b case SPICE_BRUSH_TYPE_NONE: return NULL; default: - CANVAS_ERROR("invalid brush type"); + spice_warn_if_reached(); return NULL; } } @@ -685,12 +691,13 @@ static HBRUSH set_brush(HDC dc, HBRUSH hbrush, SpiceBrush *brush) HBRUSH prev_hbrush; prev_hbrush = (HBRUSH)SelectObject(dc, hbrush); if (!SetBrushOrgEx(dc, brush->u.pattern.pos.x, brush->u.pattern.pos.y, NULL)) { - CANVAS_ERROR("SetBrushOrgEx failed"); + spice_critical("SetBrushOrgEx failed"); + return NULL; } return prev_hbrush; } default: - CANVAS_ERROR("invalid brush type"); + spice_warn_if_reached(); return NULL; } } @@ -746,7 +753,8 @@ uint8_t calc_rop3(uint16_t rop3_bits, int brush) if (rop3_bits & SPICE_ROPD_OP_BLACKNESS || rop3_bits & SPICE_ROPD_OP_WHITENESS || rop3_bits & SPICE_ROPD_OP_INVERS) { - CANVAS_ERROR("invalid rop3 type"); + spice_warn_if_reached("invalid rop3 type"); + return 0; } return rop3; } @@ -795,7 +803,8 @@ static struct BitmapData get_mask_bitmap(struct GdiCanvas *canvas, struct SpiceQ _bitmap = (HBITMAP)GetCurrentObject(gdi_surface->dc, OBJ_BITMAP); if (!_bitmap) { - CANVAS_ERROR ("GetCurrentObject failed"); + spice_critical("GetCurrentObject failed"); + return bitmap; } bitmap.dc = gdi_surface->dc; bitmap.hbitmap = _bitmap; @@ -843,13 +852,15 @@ static void gdi_draw_bitmap(HDC dest_dc, const SpiceRect *src, const SpiceRect * (dest->bottom - dest->top) == (src->bottom - src->top)) { if (!BitBlt(dest_dc, dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top, src_dc, src->left, src->top, rast_oper)) { - CANVAS_ERROR("BitBlt failed"); + spice_critical("BitBlt failed"); + return; } } else { if (!StretchBlt(dest_dc, dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top, src_dc, src->left, src->top, src->right - src->left, src->bottom - src->top, rast_oper)) { - CANVAS_ERROR("StretchBlt failed"); + spice_critical("StretchBlt failed"); + return; } } } else { @@ -859,7 +870,8 @@ static void gdi_draw_bitmap(HDC dest_dc, const SpiceRect *src, const SpiceRect * dest->bottom - dest->top, src_dc, src->left, src->top, bitmapmask->hbitmap, bitmapmask->pos.x, bitmapmask->pos.y, rast_oper)) { - CANVAS_ERROR("MaskBlt failed"); + spice_critical("MaskBlt failed"); + return; } } } @@ -898,7 +910,7 @@ static void draw_str_mask_bitmap(struct GdiCanvas *canvas, bitmap.hbitmap = (HBITMAP)1; if (!(surface = canvas_get_str_mask(&canvas->base, str, n, &pos))) { - CANVAS_ERROR("unable to canvas_get_str_mask"); + spice_critical("unable to canvas_get_str_mask"); return; } @@ -939,7 +951,8 @@ static void draw_str_mask_bitmap(struct GdiCanvas *canvas, dest_stride = dest_stride * 4; break; default: - CANVAS_ERROR("unsupported bitmap bits size"); + spice_warn_if_reached(); + return; } dest_stride = dest_stride + 3; dest_stride = dest_stride & ~3; @@ -1011,10 +1024,8 @@ static void gdi_canvas_draw_fill(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spi RecurciveLock lock(*canvas->lock); - if (!(brush = get_brush(canvas, &fill->brush, &brush_lock))) { - CANVAS_ERROR("no braash"); - return; - } + brush = get_brush(canvas, &fill->brush, &brush_lock); + spice_return_if_fail(brush != NULL); bitmapmask = get_mask_bitmap(canvas, &fill->mask); @@ -1117,18 +1128,18 @@ static void gdi_canvas_put_image(SpiceCanvas *spice_canvas, HDC dc, const SpiceR rects[i].x2, rects[i].y2); if (!combaine_hrgn) { - CANVAS_ERROR("CreateRectRgn failed"); + spice_critical("CreateRectRgn failed"); DeleteObject(main_hrgn); return; } if (!CombineRgn(main_hrgn, main_hrgn, combaine_hrgn, RGN_OR)) { - CANVAS_ERROR("CombineRgn failed in put_image"); + spice_critical("CombineRgn failed in put_image"); return; } DeleteObject(combaine_hrgn); } if (SelectClipRgn(canvas->dc, main_hrgn) == ERROR) { - CANVAS_ERROR("SelectClipRgn failed in put_image"); + spice_critical("SelectClipRgn failed in put_image"); DeleteObject(main_hrgn); return; } @@ -1232,7 +1243,8 @@ static void gdi_draw_bitmap_alpha(HDC dest_dc, const SpiceRect *src, const Spice if (!AlphaBlend(dest_dc, dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top, src_dc, src->left, src->top, src->right - src->left, src->bottom - src->top, bf)) { - CANVAS_ERROR("AlphaBlend failed"); + spice_critical("AlphaBlend failed"); + return; } } @@ -1576,7 +1588,7 @@ static void gdi_canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spi draw_str_mask_bitmap(canvas, str, 4, &dest, &src, &text->fore_brush); } else if (str->flags & SPICE_STRING_FLAGS_RASTER_A8) { - WARN("untested path A8 glyphs, doing nothing"); + spice_warning("untested path A8 glyphs, doing nothing"); if (0) { SpiceRect dest; SpiceRect src; @@ -1584,7 +1596,7 @@ static void gdi_canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spi draw_str_mask_bitmap(canvas, str, 8, &dest, &src, &text->fore_brush); } } else { - WARN("untested path vector glyphs, doing nothing"); + spice_warning("untested path vector glyphs, doing nothing"); if (0) { } } @@ -1596,9 +1608,8 @@ static uint32_t *gdi_get_userstyle(GdiCanvas *canvas, uint8_t nseg, SPICE_FIXED2 uint32_t *local_style; int i; - if (nseg == 0) { - CANVAS_ERROR("bad nseg"); - } + spice_return_val_if_fail(nseg != 0, NULL); + local_style = spice_new(uint32_t , nseg); if (start_is_gap) { @@ -1697,9 +1708,8 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S } bitmap_info; GdiImage image; #endif - //CANVAS_ERROR("untested path stroke brush with pattern"); #if 0 - ASSERT(surface) + spice_return_if_fail(surface != NULL) surface_to_image(surface, &image); memset(&bitmap_info, 0, sizeof(bitmap_info)); @@ -1718,7 +1728,8 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S logbrush.lbHatch = (LONG)GlobalAlloc(GMEM_MOVEABLE, image.height * -image.stride + sizeof(BITMAPINFO)); if (!logbrush.lbHatch) { - CANVAS_ERROR("GlobalAlloc failed"); + spice_critical("GlobalAlloc failed"); + return; } copy_bitmap(image.pixels - (image.height - 1) * -image.stride, image.height, -image.stride, @@ -1727,7 +1738,8 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S logbrush.lbHatch = (LONG)GlobalAlloc(GMEM_MOVEABLE, image.height * image.stride + sizeof(BITMAPINFO)); if (!logbrush.lbHatch) { - CANVAS_ERROR("GlobalAlloc failed"); + spice_critical("GlobalAlloc failed"); + return; } copy_bitmap(image.pixels, image.height, image.stride, (uint8_t *)logbrush.lbHatch, image.width); diff --git a/common/gl_canvas.c b/common/gl_canvas.c index 3edb2c7..9baf7e8 100644 --- a/common/gl_canvas.c +++ b/common/gl_canvas.c @@ -88,7 +88,8 @@ static pixman_image_t *canvas_surf_to_trans_surf(GLCImage *image, ret = pixman_image_create_bits(PIXMAN_a8r8g8b8, width, height, NULL, 0); if (ret == NULL) { - CANVAS_ERROR("create surface failed"); + spice_critical("create surface failed"); + return NULL; } src_line = image->pixels; @@ -127,7 +128,7 @@ static GLCPath get_path(GLCanvas *canvas, SpicePath *s) } if (seg->flags & SPICE_PATH_BEZIER) { - ASSERT((point - end_point) % 3 == 0); + spice_return_val_if_fail((point - end_point) % 3 == 0, path); for (; point + 2 < end_point; point += 3) { glc_path_curve_to(path, fix_to_double(point[0].x), fix_to_double(point[0].y), @@ -193,7 +194,8 @@ static void set_clip(GLCanvas *canvas, SpiceRect *bbox, SpiceClip *clip) break; } default: - CANVAS_ERROR("invalid clip type"); + spice_warn_if_reached(); + return; } } @@ -219,7 +221,7 @@ static inline void surface_to_image(GLCanvas *canvas, pixman_image_t *surface, G { int depth = pixman_image_get_depth(surface); - ASSERT(depth == 32 || depth == 24); + spice_return_if_fail(depth == 32 || depth == 24); image->format = (depth == 24) ? GLC_IMAGE_RGB32 : GLC_IMAGE_ARGB32; image->width = pixman_image_get_width(surface); image->height = pixman_image_get_height(surface); @@ -270,7 +272,8 @@ static void set_brush(GLCanvas *canvas, SpiceBrush *brush) case SPICE_BRUSH_TYPE_NONE: return; default: - CANVAS_ERROR("invalid brush type"); + spice_warn_if_reached(); + return; } } @@ -328,7 +331,7 @@ static void set_op(GLCanvas *canvas, uint16_t rop_decriptor) op = GLC_OP_OR_INVERTED; break; default: - WARN("GLC_OP_NOOP"); + spice_warning("GLC_OP_NOOP"); op = GLC_OP_NOOP; } glc_set_op(canvas->glc, op); @@ -524,7 +527,8 @@ static void gl_canvas_draw_rop3(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spic d = pixman_image_create_bits(PIXMAN_x8r8g8b8, image.width, image.height, NULL, 0); if (d == NULL) { - CANVAS_ERROR("create surface failed"); + spice_critical("create surface failed"); + return; } image.pixels = (uint8_t *)pixman_image_get_data(d); image.stride = pixman_image_get_stride(d); @@ -559,7 +563,8 @@ static void gl_canvas_draw_rop3(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spic if (pixman_image_get_width(s) - src_pos.x < image.width || pixman_image_get_height(s) - src_pos.y < image.height) { - CANVAS_ERROR("bad src bitmap size"); + spice_critical("bad src bitmap size"); + return; } if (rop3->brush.type == SPICE_BRUSH_TYPE_PATTERN) { @@ -613,7 +618,7 @@ static void gl_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, Sp set_brush(canvas, &stroke->brush); if (stroke->attr.flags & SPICE_LINE_FLAGS_STYLED) { - WARN("SPICE_LINE_FLAGS_STYLED"); + spice_warning("SPICE_LINE_FLAGS_STYLED"); } glc_set_line_width(canvas->glc, 1.0); @@ -661,7 +666,7 @@ static void gl_canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spic pixman_image_unref(mask); } else if (str->flags & SPICE_STRING_FLAGS_RASTER_A8) { - WARN("untested path A8 glyphs, doing nothing"); + spice_warning("untested path A8 glyphs, doing nothing"); if (0) { SpicePoint pos; pixman_image_t *mask = canvas_get_str_mask(&canvas->base, str, 8, &pos); @@ -673,7 +678,7 @@ static void gl_canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spic pixman_image_unref(mask); } } else { - WARN("untested path vector glyphs, doing nothing"); + spice_warning("untested path vector glyphs, doing nothing"); if (0) { //draw_vector_str(canvas, str, &text->fore_brush, text->fore_mode); } @@ -703,7 +708,8 @@ static void gl_canvas_read_bits(SpiceCanvas *spice_canvas, uint8_t *dest, int de GLCanvas *canvas = (GLCanvas *)spice_canvas; GLCImage image; - ASSERT(dest_stride > 0); + spice_return_if_fail(dest_stride > 0); + image.format = GLC_IMAGE_RGB32; image.height = area->bottom - area->top; image.width = area->right - area->left; @@ -746,7 +752,8 @@ static void gl_canvas_put_image(SpiceCanvas *spice_canvas, const SpiceRect *dest GLCImage image; uint32_t i; - ASSERT(src_stride <= 0) + spice_return_if_fail(src_stride <= 0) + glc_clip_reset(canvas->glc); if (clip) { diff --git a/common/pixman_utils.c b/common/pixman_utils.c index bdc18c9..705f7b2 100644 --- a/common/pixman_utils.c +++ b/common/pixman_utils.c @@ -547,6 +547,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); diff --git a/common/sw_canvas.c b/common/sw_canvas.c index 37083df..fb889de 100644 --- a/common/sw_canvas.c +++ b/common/sw_canvas.c @@ -73,8 +73,10 @@ static pixman_image_t *canvas_get_pixman_brush(SwCanvas *canvas, case SPICE_BRUSH_TYPE_NONE: return NULL; default: - CANVAS_ERROR("invalid brush type"); + spice_warn_if_reached(); + return NULL; } + return NULL; } static pixman_image_t *get_image(SpiceCanvas *canvas) @@ -467,8 +469,8 @@ static void __scale_image(SpiceCanvas *spice_canvas, pixman_image_set_transform(src, &transform); pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE); - ASSERT(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || - scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); + spice_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || + scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); pixman_image_set_filter(src, (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ? PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD, @@ -548,8 +550,8 @@ static void __scale_image_rop(SpiceCanvas *spice_canvas, pixman_image_set_transform(src, &transform); pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE); - ASSERT(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || - scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); + spice_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || + scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); pixman_image_set_filter(src, (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ? PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD, @@ -749,8 +751,8 @@ static void __blend_scale_image(SpiceCanvas *spice_canvas, pixman_image_set_transform(src, &transform); pixman_image_set_repeat(src, PIXMAN_REPEAT_NONE); - ASSERT(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || - scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); + spice_return_if_fail(scale_mode == SPICE_IMAGE_SCALE_MODE_INTERPOLATE || + scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST); pixman_image_set_filter(src, (scale_mode == SPICE_IMAGE_SCALE_MODE_NEAREST) ? PIXMAN_FILTER_NEAREST : PIXMAN_FILTER_GOOD, @@ -1054,7 +1056,7 @@ static void canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, /* Nothing else makes sense for text and we should deprecate it * and actually it means OVER really */ - ASSERT(text->fore_mode == SPICE_ROPD_OP_PUT); + spice_return_if_fail(text->fore_mode == SPICE_ROPD_OP_PUT); pixman_region32_init_rect(&back_region, text->back_area.left, @@ -1077,10 +1079,10 @@ static void canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, } else if (str->flags & SPICE_STRING_FLAGS_RASTER_A4) { depth = 4; } else if (str->flags & SPICE_STRING_FLAGS_RASTER_A8) { - WARN("untested path A8 glyphs"); + spice_warning("untested path A8 glyphs"); depth = 8; } else { - WARN("unsupported path vector glyphs"); + spice_warning("unsupported path vector glyphs"); pixman_region32_fini (&dest_region); return; } @@ -1123,7 +1125,7 @@ static void canvas_read_bits(SpiceCanvas *spice_canvas, uint8_t *dest, uint8_t *dest_end; int bpp; - ASSERT(canvas && area); + spice_return_if_fail(canvas && area); surface = canvas->image; |