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
impl CommandRecording
Sourcepub fn try_take_reusable(&mut self) -> Option<Self>
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();
}Sourcepub fn into_recorder(self) -> CommandRecorder
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.
pub fn from_primitives( primitives: impl IntoIterator<Item = DrawPrimitive>, ) -> Self
pub fn shape_capacity(&self) -> usize
Sourcepub fn pod_heap_bytes(&self) -> usize
pub fn pod_heap_bytes(&self) -> usize
The heap the POD tables hold, capacity included.
Sourcepub fn tables(&self) -> &RecordTables
pub fn tables(&self) -> &RecordTables
The published shape columns and their brush, stop and segment tables.
Sourcepub fn shape_recorder(&self) -> &Arc<ShapeRecorder> ⓘ
pub fn shape_recorder(&self) -> &Arc<ShapeRecorder> ⓘ
Shared ownership of the immutable shape recording.
Sourcepub fn len_in(&self, segments: &Range<u32>) -> usize
pub fn len_in(&self, segments: &Range<u32>) -> usize
The entries inside segments that draw, content markers left out.
Sourcepub fn shapes(&self) -> &ShapeRecords
pub fn shapes(&self) -> &ShapeRecords
The shape columns, with complete records available on demand.
pub fn brushes(&self) -> &[BrushRecord]
pub fn stops(&self) -> &[GradientStopRecord]
pub fn others(&self) -> &[DrawPrimitive]
pub fn segments(&self) -> &[RecordSegment]
Sourcepub fn all_segments(&self) -> Range<u32> ⓘ
pub fn all_segments(&self) -> Range<u32> ⓘ
Every segment, the range a placement without a content split draws.
Sourcepub fn bounds(&self) -> Option<Rect>
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.
pub fn summary(&self) -> RecordingSummary
pub fn content_markers(&self) -> u32
pub fn is_empty(&self) -> bool
Sourcepub fn fingerprint(&self) -> u64
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.
Sourcepub fn is_empty_in(&self, segments: &Range<u32>) -> bool
pub fn is_empty_in(&self, segments: &Range<u32>) -> bool
The segments of segments that draw anything.
pub fn segments_in(&self, segments: &Range<u32>) -> Iter<'_, RecordSegment> ⓘ
Sourcepub fn summary_in(&self, segments: &Range<u32>) -> RecordingSummary
pub fn summary_in(&self, segments: &Range<u32>) -> RecordingSummary
The summary of the entries inside segments only.
Sourcepub fn content_split(&self, behind: bool) -> Range<u32> ⓘ
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.
Sourcepub fn coverage_rects(
&self,
segments: Range<u32>,
) -> impl Iterator<Item = Rect> + '_
pub fn coverage_rects( &self, segments: Range<u32>, ) -> impl Iterator<Item = Rect> + '_
The coverage rect of every entry inside segments.
Sourcepub fn primitives(
&self,
segments: Range<u32>,
) -> impl Iterator<Item = DrawPrimitive> + '_
pub fn primitives( &self, segments: Range<u32>, ) -> impl Iterator<Item = DrawPrimitive> + '_
The primitives inside segments, materialised in recorded order,
content markers left out.
Sourcepub fn primitives_with_markers(
&self,
) -> impl Iterator<Item = DrawPrimitive> + '_
pub fn primitives_with_markers( &self, ) -> impl Iterator<Item = DrawPrimitive> + '_
Every primitive in recorded order, content markers included.
pub fn into_primitives_with_markers(self) -> Vec<DrawPrimitive>
Sourcepub fn materialize_shape(&self, index: usize) -> DrawPrimitive
pub fn materialize_shape(&self, index: usize) -> DrawPrimitive
The exact DrawPrimitive the record was made from.
Sourcepub fn brush_of(&self, record: &ShapeRecord) -> Brush
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.