Skip to main content

Encoding

Struct Encoding 

Source
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§

§path_tags: Vec<PathTag>

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.

§draw_tags: Vec<DrawTag>

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: Resources

Late bound resource data.

§n_paths: u32

Number of encoded paths.

§n_path_segments: u32

Number of encoded path segments.

§n_clips: u32

Number of encoded clips/layers.

§n_open_clips: u32

Number of unclosed clips/layers.

§flags: u32

Flags that capture the current state of the encoding.

Implementations§

Source§

impl Encoding

Source

pub const FORCE_NEXT_TRANSFORM: u32 = 1

Forces encoding of the next transform even if it matches the current transform in the stream.

Source

pub const FORCE_NEXT_STYLE: u32 = 2

Forces encoding of the next style even if it matches the current style in the stream.

Source

pub fn new() -> Self

Creates a new encoding.

Source

pub fn is_empty(&self) -> bool

Returns true if the encoding is empty.

Source

pub fn reset(&mut self)

Clears the encoding.

Source

pub fn append(&mut self, other: &Self, transform: &Option<Transform>)

Appends another encoding to this one with an optional transform.

Source

pub fn encode_mark(&mut self, kind: MarkKind)

Marks a keyed boundary here (Mark).

Source

pub fn stream_offsets(&self) -> StreamOffsets

Returns a snapshot of the current stream offsets.

Source

pub fn encode_fill_style(&mut self, fill: Fill)

Encodes a fill style.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn encode_brush<'b>(&mut self, brush: impl Into<BrushRef<'b>>, alpha: f32)

Encodes a brush with an optional alpha modifier.

Source

pub fn encode_color(&mut self, color: impl Into<DrawColor>)

Encodes a solid color brush.

Source

pub fn encode_linear_gradient( &mut self, gradient: DrawLinearGradient, color_stops: impl Iterator<Item = ColorStop>, alpha: f32, extend: Extend, )

Encodes a linear gradient brush.

Source

pub fn encode_radial_gradient( &mut self, gradient: DrawRadialGradient, color_stops: impl Iterator<Item = ColorStop>, alpha: f32, extend: Extend, )

Encodes a radial gradient brush.

Source

pub fn encode_sweep_gradient( &mut self, gradient: DrawSweepGradient, color_stops: impl Iterator<Item = ColorStop>, alpha: f32, extend: Extend, )

Encodes a radial gradient brush.

Source

pub fn encode_image<'b>( &mut self, brush: impl Into<ImageBrushRef<'b>>, alpha: f32, )

Encodes an image brush.

Source

pub fn encode_blurred_rounded_rect( &mut self, color: impl Into<DrawColor>, width: f32, height: f32, radius: f32, std_dev: f32, )

Source

pub fn encode_begin_clip(&mut self, parameters: DrawBeginClip)

Encodes a begin clip command.

Source

pub fn encode_end_clip(&mut self)

Encodes an end clip command.

Source

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.

Source

pub fn swap_last_path_tags(&mut self)

Trait Implementations§

Source§

impl Clone for Encoding

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Encoding

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.