Paint source refactor
Previously, DrawingCtx.set_source_paint_server
required a bunch of stuff: acquired_nodes, paint_server, opacity, bbox, current_color, values
.
It's easier if the caller resolves the paint source and converts it to user space coordinates, and calls just set_paint_source(paint_source, acquired_nodes)
. This is done in several steps:
-
A final RGBA color depends on a
cssparser::Color
, an opacity fromstroke-opacity
orfill-opacity
, and thecurrentColor
to resolve that case. Do that in a singleresolve_color
function. -
Gradients, instead of storing the plain stop-color values from the SVG code, now store the combined
stop-color + stop_opacity + { stroke_opacity / fill_opacity }
. -
Resolved patterns keep the
{ stroke_opacity / fill_opacity }
around so it can be used when painting the generated pattern surface.
Also, I've started refactoring the filters code that deals with paint sources: filter primitives may take inputs that are FillPaint
or StrokePaint
. I'll stop refactoring right there to rebase !387 (closed); that looks like a good next step.
This MR started as an experiment in replacing DrawingCtx.with_saved_cr
with a SavedCr
struct that saves the cr
when created, and restores it on Drop
. This removes two nested function frames; I'm not yet sure if it is obvious that SavedCr
really defines a context that lives for as long as its surrounding scope. It may let us remove the with_foo
functions gradually.