WIP: Port the gdk pixbufloader to rust
This implements the pixbufloader in rust.
It seems to work in very limited testing. I tested by doing the following:
mkdir ~/loaders
cp /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/* ~/loaders/
cp gdk-pixbuf-loader/target/release/libpixbufloader_svg.so ~/loaders/
/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders > loaders/loaders.cache
export GDK_PIXBUF_MODULEDIR=$HOME/loaders/
export GDK_PIXBUF_MODULE_FILE=$GDK_PIXBUF_MODULEDIR/loaders.cache
nautilus
cat /proc/`pidof nautilus`/smaps | grep -i svg
if there are better ways to test let me know.
There are quite a few things to discuss before thinking about merging this
-
Doing a pixbufloader in rust means we are statically linking rsvg... is that a problem? -
is there any specific concern about ABI? eg shall we check the .so entry points? shall we use no panic etc? -
The module is called libpixbufloader_svg.so
because cargo does not let me use hyphens -
In Cargo.toml
I usedlibrsvg = { path = ".." }
... is that ok? -
Later we will need to figure out how to integrate with Makefiles -
I did not remove the old code for now -
I had to manually bind various GdkPixbuf
types since they either are not in thegdkpixbuf-sys
crate or they are opaque while in our case we need to assign fields... shall these be sent upstream or writing loaders is not in scope for thath crate? -
I used the new rust API, this means however that size_func
,prepare
, etc are called only at end... is this ok? -
I am creating the librsvg::Loader
just at the last step... would it be better to create it early and let it consume the input stream as we feed data to it? -
Is the size stuff correct or shall we use the legacy sizing
present in the c_api -
Since the lib can only use the public API, I reimplemented the code that copies a cairo surface to a pixbuf... it is probably buggy with regard to endianness. How do we avoid this duplication? Maybe we need to expose a PixbufRenderer
in the API...
With regard to the bindings, I filed: https://github.com/gtk-rs/gtk-rs/issues/241 gdk-pixbuf#167 (closed)
Edited by Paolo Borelli