forked from enlightenment/efl
evas - loader - rsvg - work around rsvg now returning 0 sized dims
also work around rsvg now returning a 0 em/ex values for dimensions too. rsvg 2.52 brought us this fun. @fix
This commit is contained in:
parent
f2f1cc42a2
commit
c0826212ef
|
@ -99,16 +99,26 @@ read_svg_header(int scale_down, double dpi, int size_w, int size_h)
|
||||||
{
|
{
|
||||||
rsvg_handle_set_dpi(rsvg, 75.0);
|
rsvg_handle_set_dpi(rsvg, 75.0);
|
||||||
|
|
||||||
#ifndef HAVE_SVG_2_51
|
#ifdef HAVE_SVG_2_51
|
||||||
rsvg_handle_get_dimensions(rsvg, &dim);
|
|
||||||
width = dim.width;
|
|
||||||
height = dim.height;
|
|
||||||
#else
|
|
||||||
double owidth, oheight;
|
double owidth, oheight;
|
||||||
|
|
||||||
rsvg_handle_get_intrinsic_size_in_pixels(rsvg, &owidth, &oheight);
|
rsvg_handle_get_intrinsic_size_in_pixels(rsvg, &owidth, &oheight);
|
||||||
width = ceil(owidth);
|
width = ceil(owidth);
|
||||||
height = ceil(oheight);
|
height = ceil(oheight);
|
||||||
|
if ((width == 0) || (height == 0))
|
||||||
|
{
|
||||||
|
RsvgLength l1, l2;
|
||||||
|
gboolean has_l1, has_l2, has_vb;
|
||||||
|
RsvgRectangle vb;
|
||||||
|
|
||||||
|
rsvg_handle_get_intrinsic_dimensions(rsvg, &has_l1, &l1, &has_l2, &l2, &has_vb, &vb);
|
||||||
|
width = ceil(vb.width);
|
||||||
|
height = ceil(vb.height);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
rsvg_handle_get_dimensions(rsvg, &dim);
|
||||||
|
width = dim.width;
|
||||||
|
height = dim.height;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((width < 1) || (height < 1)) return 0;
|
if ((width < 1) || (height < 1)) return 0;
|
||||||
|
@ -153,18 +163,21 @@ read_svg_data(void)
|
||||||
if (!shm_addr) return 0;
|
if (!shm_addr) return 0;
|
||||||
|
|
||||||
memset(shm_addr, 0, width * height * sizeof (DATA32));
|
memset(shm_addr, 0, width * height * sizeof (DATA32));
|
||||||
surface = cairo_image_surface_create_for_data((unsigned char *)shm_addr, CAIRO_FORMAT_ARGB32,
|
surface = cairo_image_surface_create_for_data((unsigned char *)shm_addr,
|
||||||
width, height, width * sizeof(DATA32));;
|
CAIRO_FORMAT_ARGB32,
|
||||||
|
width, height,
|
||||||
|
width * sizeof(DATA32));;
|
||||||
if (!surface) return 0;
|
if (!surface) return 0;
|
||||||
|
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
if (!cr) return 0;
|
if (!cr) return 0;
|
||||||
|
|
||||||
|
if ((dim.em > 0.0) && (dim.ex > 0.0))
|
||||||
cairo_scale(cr, (double) width / dim.em, (double) height / dim.ex);
|
cairo_scale(cr, (double) width / dim.em, (double) height / dim.ex);
|
||||||
|
else
|
||||||
|
cairo_scale(cr, (double)1, (double)1);
|
||||||
|
|
||||||
#ifndef HAVE_SVG_2_51
|
#ifdef HAVE_SVG_2_51
|
||||||
rsvg_handle_render_cairo(rsvg, cr);
|
|
||||||
#else
|
|
||||||
RsvgRectangle vp =
|
RsvgRectangle vp =
|
||||||
{
|
{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
|
@ -172,8 +185,9 @@ read_svg_data(void)
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
};
|
};
|
||||||
|
|
||||||
rsvg_handle_render_document(rsvg, cr, &vp, NULL);
|
rsvg_handle_render_document(rsvg, cr, &vp, NULL);
|
||||||
|
#else
|
||||||
|
rsvg_handle_render_cairo(rsvg, cr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
|
Loading…
Reference in New Issue