[gtk+] cssimage: Handle 0x0 images
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssimage: Handle 0x0 images
- Date: Wed, 16 Dec 2015 00:55:27 +0000 (UTC)
commit bf130da741b63c1cdd92969f513aa74258dc3d62
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 15 21:23:59 2015 +0100
cssimage: Handle 0x0 images
0x0 images can happen when we fail to load an image - or when we
successfully load a 0x0 image.
gtk/gtkcssimagesurface.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssimagesurface.c b/gtk/gtkcssimagesurface.c
index ac812dd..1570e83 100644
--- a/gtk/gtkcssimagesurface.c
+++ b/gtk/gtkcssimagesurface.c
@@ -46,11 +46,18 @@ gtk_css_image_surface_draw (GtkCssImage *image,
double height)
{
GtkCssImageSurface *surface = GTK_CSS_IMAGE_SURFACE (image);
+ int image_width, image_height;
+
+ image_width = cairo_image_surface_get_width (surface->surface);
+ image_height = cairo_image_surface_get_height (surface->surface);
+
+ if (image_width == 0 || image_height == 0)
+ return;
cairo_rectangle (cr, 0, 0, width, height);
cairo_scale (cr,
- width / cairo_image_surface_get_width (surface->surface),
- height / cairo_image_surface_get_height (surface->surface));
+ width / image_width,
+ height / image_height);
cairo_set_source_surface (cr, surface->surface, 0, 0);
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
cairo_fill (cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]