Port RsvgPaintServer to Rust
I think RsvgPaintServer
is at a point where it is easy to port to Rust. The implementation has several parts:
-
Header file:
- Structs for the different kinds of paint servers; could nicely be a Rust enum with variants.
- Function prototypes for the node creation functions (all on the Rust side now), like
rsvg_node_linear_gradient_new()
. - Function prototypes for the "configure this Cairo context based on a pattern or gradient" like
gradient_resolve_fallbacks_and_set_pattern()
.
-
C file:
-
rsvg_paint_server_parse()
- the simple parser, easily doable in Rust since it just composes parts that already exist in the Rust parsers. It would be good to redorsvg_get_url_string()
withrust-cssparser
, since it basically just gets the contents of aurl(#blahblah) rest
attribute and returns the rest part of the string. -
rsvg_paint_server_ref()
andunref()
. These are so thatrsvg_state_clone()
and friends can avoid copying paint servers, but I'm not sure it's even worth it to avoid copying them, since we are doing so much copying of styles anyway.
-
-
Configure a Cairo context from this paint server:
- Two easy functions, one for solid colors, and one for gradients/patterns.