Skip to main content

CommandRecording

Struct CommandRecording 

Source
pub struct CommandRecording { /* private fields */ }
Expand description

A completed draw command with shared shape data, ordered segments and non-shape primitives. Bounds and content metadata are recorded while drawing; the complete fingerprint is computed when a cache first requests it. Use CommandRecorder to build a command and Self::into_recorder to edit it.

Implementations§

Source§

impl CommandRecording

Source

pub fn try_take_reusable(&mut self) -> Option<Self>

Takes this recording when no retained reader shares its shape data.

The returned recording keeps the existing data and capacities. This recording is reset to an empty value. Pass the returned recording to CommandRecorder::reusing to clear it for another draw. If another strong or weak reference shares the shape data, this returns None and leaves the recording unchanged.

use cranpose_ui_graphics::{Brush, Color, CommandRecorder, DrawPrimitive, Rect};

let mut builder = CommandRecorder::default();
builder.push_primitive(DrawPrimitive::Rect {
    rect: Rect {
        x: 0.0,
        y: 0.0,
        width: 1.0,
        height: 1.0,
    },
    brush: Brush::Solid(Color::RED),
    stroke: None,
});
let mut completed = builder.finish();
if let Some(storage) = completed.try_take_reusable() {
    let mut recorder = CommandRecorder::reusing(storage);
    recorder.push_content();
    let _next = recorder.finish();
}
Source

pub fn into_recorder(self) -> CommandRecorder

Returns owned command data for further recording. Shape data is copied only when a retained reader still shares it.

Source

pub fn from_primitives( primitives: impl IntoIterator<Item = DrawPrimitive>, ) -> Self

Source

pub fn shape_capacity(&self) -> usize

Source

pub fn pod_heap_bytes(&self) -> usize

The heap the POD tables hold, capacity included.

Source

pub fn tables(&self) -> &RecordTables

The published shape columns and their brush, stop and segment tables.

Source

pub fn shape_recorder(&self) -> &Arc<ShapeRecorder> ⓘ

Shared ownership of the immutable shape recording.

Source

pub fn len_in(&self, segments: &Range<u32>) -> usize

The entries inside segments that draw, content markers left out.

Source

pub fn shapes(&self) -> &ShapeRecords

The shape columns, with complete records available on demand.

Source

pub fn brushes(&self) -> &[BrushRecord]

Source

pub fn stops(&self) -> &[GradientStopRecord]

Source

pub fn others(&self) -> &[DrawPrimitive]

Source

pub fn segments(&self) -> &[RecordSegment]

Source

pub fn all_segments(&self) -> Range<u32> ⓘ

Every segment, the range a placement without a content split draws.

Source

pub fn bounds(&self) -> Option<Rect>

A rect containing every entry’s coverage rect: exact for rects and the other lanes, the disc around the band for a scope-recorded arc.

Source

pub fn summary(&self) -> RecordingSummary

Source

pub fn content_markers(&self) -> u32

Source

pub fn len(&self) -> usize

Entries of every lane, content markers included.

Source

pub fn is_empty(&self) -> bool

Source

pub fn fingerprint(&self) -> u64

A hash over every entry, table and marker in recorded order, so two recordings with equal fingerprints draw the same pixels. Computed the first time it is asked for, so a recording nothing caches never pays for it.

Source

pub fn is_empty_in(&self, segments: &Range<u32>) -> bool

The segments of segments that draw anything.

Source

pub fn segments_in(&self, segments: &Range<u32>) -> Iter<'_, RecordSegment> ⓘ

Source

pub fn summary_in(&self, segments: &Range<u32>) -> RecordingSummary

The summary of the entries inside segments only.

Source

pub fn content_split(&self, behind: bool) -> Range<u32> ⓘ

The segments before the last content marker (behind) or after it; with no marker, behind is empty and overlay is everything.

Source

pub fn coverage_rects( &self, segments: Range<u32>, ) -> impl Iterator<Item = Rect> + '_

The coverage rect of every entry inside segments.

Source

pub fn primitives( &self, segments: Range<u32>, ) -> impl Iterator<Item = DrawPrimitive> + '_

The primitives inside segments, materialised in recorded order, content markers left out.

Source

pub fn primitives_with_markers( &self, ) -> impl Iterator<Item = DrawPrimitive> + '_

Every primitive in recorded order, content markers included.

Source

pub fn into_primitives_with_markers(self) -> Vec<DrawPrimitive>

Source

pub fn materialize_shape(&self, index: usize) -> DrawPrimitive

The exact DrawPrimitive the record was made from.

Source

pub fn brush_of(&self, record: &ShapeRecord) -> Brush

The brush of a record: its solid colour, or the gradient rebuilt from the tables exactly as the app gave it.

Trait Implementations§

Source§

impl Clone for CommandRecording

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 Debug for CommandRecording

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CommandRecording

Source§

fn default() -> Self

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

impl PartialEq for CommandRecording

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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.