pub struct Encoding {
pub path_tags: Vec<PathTag>,
pub path_data: Vec<u32>,
pub draw_tags: Vec<DrawTag>,
pub draw_data: Vec<u32>,
pub transforms: Vec<Transform>,
pub styles: Vec<Style>,
pub resources: Resources,
pub n_paths: u32,
pub n_path_segments: u32,
pub n_clips: u32,
pub n_open_clips: u32,
pub flags: u32,
}Expand description
Encoded data streams for a scene.
§Invariants
- At least one transform and style must be encoded before any path data or draw object.
Fields§
The path tag stream.
path_data: Vec<u32>The path data stream.
Stores all coordinates on paths.
Stored as u32 as all comparisons are performed bitwise.
The draw tag stream.
draw_data: Vec<u32>The draw data stream.
transforms: Vec<Transform>The transform stream.
styles: Vec<Style>The style stream
resources: ResourcesLate bound resource data.
n_paths: u32Number of encoded paths.
n_path_segments: u32Number of encoded path segments.
n_clips: u32Number of encoded clips/layers.
n_open_clips: u32Number of unclosed clips/layers.
flags: u32Flags that capture the current state of the encoding.
Implementations§
Source§impl Encoding
impl Encoding
Sourcepub const FORCE_NEXT_TRANSFORM: u32 = 1
pub const FORCE_NEXT_TRANSFORM: u32 = 1
Forces encoding of the next transform even if it matches the current transform in the stream.
Sourcepub const FORCE_NEXT_STYLE: u32 = 2
pub const FORCE_NEXT_STYLE: u32 = 2
Forces encoding of the next style even if it matches the current style in the stream.
Sourcepub fn append(&mut self, other: &Self, transform: &Option<Transform>)
pub fn append(&mut self, other: &Self, transform: &Option<Transform>)
Appends another encoding to this one with an optional transform.
Sourcepub fn encode_mark(&mut self, kind: MarkKind)
pub fn encode_mark(&mut self, kind: MarkKind)
Marks a keyed boundary here (Mark).
Sourcepub fn stream_offsets(&self) -> StreamOffsets
pub fn stream_offsets(&self) -> StreamOffsets
Returns a snapshot of the current stream offsets.
Sourcepub fn encode_fill_style(&mut self, fill: Fill)
pub fn encode_fill_style(&mut self, fill: Fill)
Encodes a fill style.
Sourcepub fn encode_stroke_style(&mut self, stroke: &Stroke) -> bool
pub fn encode_stroke_style(&mut self, stroke: &Stroke) -> bool
Encodes a stroke style.
Returns false if the stroke had zero width and so couldn’t be encoded.
Sourcepub fn encode_transform(&mut self, transform: Transform) -> bool
pub fn encode_transform(&mut self, transform: Transform) -> bool
Encodes a transform.
If the given transform is different from the current one, encodes it and returns true. Otherwise, encodes nothing and returns false.
Sourcepub fn encode_path(&mut self, is_fill: bool) -> PathEncoder<'_>
pub fn encode_path(&mut self, is_fill: bool) -> PathEncoder<'_>
Returns an encoder for encoding a path. If is_fill is true, all subpaths will
be automatically closed.
Sourcepub fn encode_shape(&mut self, shape: &impl Shape, is_fill: bool) -> bool
pub fn encode_shape(&mut self, shape: &impl Shape, is_fill: bool) -> bool
Encodes a shape. If is_fill is true, all subpaths will be automatically closed.
Returns true if a non-zero number of segments were encoded.
Sourcepub fn encode_empty_shape(&mut self)
pub fn encode_empty_shape(&mut self)
Encode an empty path.
This is useful for bookkeeping when a path is absolutely required (for example in pushing a clip layer). It is almost always the case, however, that an application can be optimized to not use this method.
Sourcepub fn encode_path_elements(
&mut self,
path: impl Iterator<Item = PathEl>,
is_fill: bool,
) -> bool
pub fn encode_path_elements( &mut self, path: impl Iterator<Item = PathEl>, is_fill: bool, ) -> bool
Encodes a path element iterator. If is_fill is true, all subpaths will be automatically
closed. Returns true if a non-zero number of segments were encoded.
Sourcepub fn encode_brush<'b>(&mut self, brush: impl Into<BrushRef<'b>>, alpha: f32)
pub fn encode_brush<'b>(&mut self, brush: impl Into<BrushRef<'b>>, alpha: f32)
Encodes a brush with an optional alpha modifier.
Sourcepub fn encode_color(&mut self, color: impl Into<DrawColor>)
pub fn encode_color(&mut self, color: impl Into<DrawColor>)
Encodes a solid color brush.
Sourcepub fn encode_linear_gradient(
&mut self,
gradient: DrawLinearGradient,
color_stops: impl Iterator<Item = ColorStop>,
alpha: f32,
extend: Extend,
)
pub fn encode_linear_gradient( &mut self, gradient: DrawLinearGradient, color_stops: impl Iterator<Item = ColorStop>, alpha: f32, extend: Extend, )
Encodes a linear gradient brush.
Sourcepub fn encode_radial_gradient(
&mut self,
gradient: DrawRadialGradient,
color_stops: impl Iterator<Item = ColorStop>,
alpha: f32,
extend: Extend,
)
pub fn encode_radial_gradient( &mut self, gradient: DrawRadialGradient, color_stops: impl Iterator<Item = ColorStop>, alpha: f32, extend: Extend, )
Encodes a radial gradient brush.
Sourcepub fn encode_sweep_gradient(
&mut self,
gradient: DrawSweepGradient,
color_stops: impl Iterator<Item = ColorStop>,
alpha: f32,
extend: Extend,
)
pub fn encode_sweep_gradient( &mut self, gradient: DrawSweepGradient, color_stops: impl Iterator<Item = ColorStop>, alpha: f32, extend: Extend, )
Encodes a radial gradient brush.
Sourcepub fn encode_image<'b>(
&mut self,
brush: impl Into<ImageBrushRef<'b>>,
alpha: f32,
)
pub fn encode_image<'b>( &mut self, brush: impl Into<ImageBrushRef<'b>>, alpha: f32, )
Encodes an image brush.
pub fn encode_blurred_rounded_rect( &mut self, color: impl Into<DrawColor>, width: f32, height: f32, radius: f32, std_dev: f32, )
Sourcepub fn encode_begin_clip(&mut self, parameters: DrawBeginClip)
pub fn encode_begin_clip(&mut self, parameters: DrawBeginClip)
Encodes a begin clip command.
Sourcepub fn encode_end_clip(&mut self)
pub fn encode_end_clip(&mut self)
Encodes an end clip command.
Sourcepub fn force_next_transform_and_style(&mut self)
pub fn force_next_transform_and_style(&mut self)
Forces the next transform and style to be encoded even if they match the current state.