GNOME Bugzilla – Bug 621699
make librsvg gio friendly
Last modified: 2010-06-22 16:02:43 UTC
librsvg should have gio convenience functions, e.g. to read data from a GInputStream (instead of having to do that yourself via rsvg_handle_write + _close), and to create a handle from GFile, or GInputStream. This will also make it easy to support .svg.gz loading by just using a GConverterInputStream later. I also think we should just make gio mandatory, instead of optional in configure. Proposed patch attached.
Created attachment 163729 [details] [review] Add GIO convenience to librsvg Adds rsvg_handle_read_stream() to read the handle's data from a GInputStream, and rsvg_handle_new_from_{gfile,stream} convenience functions analogous to rsvg_handle_new_from_{file,data}.
Created attachment 163742 [details] [review] Use GConverter for gzip support Supporting gzipped input is now easy! Remove libgsf, and just use GZlibDecompressor on gio >= 2.24.0. Use a memory input stream to store the data from rsvg_handle_write(), and process all the data in rsvg_handle_close(). This may or may not constitute a behaviour change; not sure.
Wow! I like these patches very much! Please commit and let's fix any issues in git master.
Review of attachment 163742 [details] [review]: I did a similar work last night. In my patch, each gzipped data chunk is converted in rsvg_handle_write(). I prefer my approach since there is no need to allocate extra memory. Can you change this patch to such approach? ::: rsvg-base.c @@ +1742,3 @@ + converter = G_CONVERTER (g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP)); + new_input_stream = g_converter_input_stream_new (priv->data_input_stream, + converter); This converter object is leaking.
Created attachment 163804 [details] [review] My patch For the reference I attach the patch.
I will be off-line by Sunday, so please feel free to go ahead.
I changed the code back to the way it was before with libgsf: _write with gzipped data stores the data, then processes all-at-once in _close, while non-gzipped data is processed in the chunks as passed to _write. So there shouldn't be any behaviour change, anymore. About your patch: that might be a good idea since it saves memory, but I'm not sure it works like that; don't you have to check to G_ERROR_NO_SPACE and provide a bigger output buffer in this case? Anyway, that can be improved later.
Also, should I make gio required, or add some #if GLIB_CHECK_VERSION (2, 16, 0) to the rsvg.h header around the new functions?
I think depending GIO is reasonable, but GConverter part should be encolosed by GLIB_CHECK_VERSION because GConvert is a brand new feature in GIO.
Fixed on master. I made gio required, but kept the libgsf code for when gio version is < 2.24.
I also created a gnome-2-30 branch that doesn't contain these recent changes.