Skip to content

svg: store image resources in the svg struct

Paolo Borelli requested to merge pborelli/librsvg:image into master

I was tempted to mark this as WIP, but it compiles and passes make check :) See below the commit message for a few things that might need to be done before merging

This makes it consistent with xml resources. It also allows images to be cached in case they are rendered more than once. The images are loaded lazily during rendering which goes in the opposite direction with the goal of having an immutable Svg object, but at least this is the same of other resources. Beside images are just used in two places, and filters/images was already doing a hack to load the image at rendering time.

Apart from the commit message,

Thinks I like:

  • I like we store resources in svg and things are more consistent
  • I like that code goes away from handle
  • I like the hack for load_options in filters/image is gone

Things I do not like:

  • I do not like having to go through draw_ctx, but at the moment that has access to Svg and also to acquire_xml node we go through that indirection
  • I do not like we load at render time, this seems somewhat the opposite direction of what we want... at the same time filters was loading at render time anyway so maybe it is not that bad

Things that need checking

  • I did not put much attention in the refcounting of shared surfaces, ths needs to be double checked
  • I was not sure if we should return SharedImageSurface all the way, I decided to convert into ImageSurface since that was what the calling code expected
  • Error handling needs improvements, before we were reporting load errors, but now they are lost

Merge request reports