Skip to main content

ViewportState

Struct ViewportState 

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

What the widget keeps between frames. One per viewport; the application owns it.

Implementations§

Source§

impl ViewportState

Source

pub fn new() -> ViewportState

An empty state.

Source

pub fn mapping(&self) -> Option<Mapping>

The mapping of the last frame drawn.

Source

pub fn in_gesture(&self) -> bool

Whether a gesture is in progress.

Source

pub fn set_display_transform(&mut self, transform: Arc<dyn DisplayTransform>)

Replaces the display transform (the application’s colour management; LinearSrgb by default).

Source

pub fn display_transform(&self) -> &Arc<dyn DisplayTransform>

The display transform in use.

Source

pub fn display_target(&self) -> Option<DisplayTarget>

The display target the last frame was drawn for.

Source

pub fn display_resolution(&self) -> Option<&Resolution>

What the last frame was drawn for: the wanted target, the surface’s, the one drawn and why it carries less, if it does.

Source

pub fn sink(&self) -> TileSink

Where the source delivers the image’s tiles (give it to the source when making it).

Source

pub fn before_sink(&self) -> TileSink

Where a second source delivers the “before” image of a comparison.

Source

pub fn stats(&self) -> &Arc<Stats>

What happened to the tiles, counted.

Source

pub fn notices_waiting(&self) -> usize

Changes and readouts the source sent that wait for the next draw: at most NOTICES, however long the viewport is not drawn (the others are folded, counted as coalesced in stats).

Source

pub fn tiles_complete(&self) -> bool

No request outstanding and every wanted exact tile on screen (after the last frame).

Source

pub fn outstanding(&self) -> usize

Requests waiting for an answer.

Source

pub fn tile_count(&self) -> usize

Tiles held.

Source

pub fn texture_bytes(&self) -> usize

Bytes of tile textures held.

Source

pub fn set_tile_size(&mut self, side: u32)

The side of a tile wanted, in pixels (256 by default; the device’s largest texture side at most).

Source

pub fn set_texture_budget(&mut self, bytes: usize)

The texture budget, in bytes (256 MB by default). Tiles drawn in the current frame are never evicted, so a view larger than the budget still shows whole.

Source

pub fn set_upload_budget(&mut self, budget: UploadBudget)

How much one frame uploads at most (UploadBudget::DEFAULT, 8 MiB, by default). Tiles over it wait for the next frames, the visible area’s first, and are kept when the view moves. UploadBudget::UNLIMITED opts out: every tile arrived goes up in the frame that takes it in.

Source

pub fn upload_budget(&self) -> UploadBudget

The upload budget.

Source

pub fn set_prepare_on_worker(&mut self, on: bool)

Converts tiles on the thread that delivers them (the source’s worker) instead of the interface thread: the display transform of the CPU path, the half-float texels of the GPU path. On by default: the source’s thread runs the display transform (DisplayTransform is Send + Sync), and a tile converted with a transform replaced meanwhile is shown, marked stale and asked for again. false opts out: the interface thread converts each tile when it takes it in, for a source whose threads must not run the transform, or one delivering from the interface thread anyway (the conversion then happens there either way). See docs/threading.md for the measurements.

Source

pub fn prepare_on_worker(&self) -> bool

Whether tiles are converted on the delivering thread.

Source

pub fn upload_report(&self) -> UploadReport

What the last frame uploaded, and what waits.

Source

pub fn transfers(&self) -> Transfers

Tile pixels copied to the GPU since the state was made, counted where the copy happens (up to the last paint); device tiles count as bound, with no byte.

Source

pub fn frame_transfers(&self) -> Transfers

What the last whole frame copied, its paint included: from the start of the frame before the last one to the start of the last one. Zero bytes on a view drawn from device tiles alone.

Source

pub fn last_error(&self) -> Option<&str>

The last error about tiles: one a source reported (TileSink::failed), or a device tile refused and why.

Source

pub fn set_settle(&mut self, seconds: f64)

How long the view stays still before exact tiles are asked for, in seconds (0.1 by default; 0 asks at once).

Source

pub fn loupe(&self) -> &Loupe

The loupe’s settings.

Source

pub fn loupe_mut(&mut self) -> &mut Loupe

The loupe’s settings, to change (turn it on for a tool, change its magnification).

Source

pub fn loupe_frame(&self) -> Option<&LoupeFrame>

What the loupe showed in the last frame, if it showed.

Source

pub fn cursor(&self) -> Option<&Cursor>

The cursor resolved for the pointer in the last frame (after the on_cursor hook), while the pointer is over the viewport.

Source

pub fn cursor_shown(&self) -> Option<&Shown>

What the cursor showed in the last frame, while the pointer is over the viewport.

Source

pub fn refresh_cursor(&mut self)

Forgets the cursor resolved, so the next frame asks the on_cursor hook again (its answer changed for the same situation).

Source

pub fn hooks_mut(&mut self) -> &mut Hooks

The hooks, to set or remove.

Source

pub fn hooks(&self) -> &Hooks

The hooks.

Source

pub fn trace(&self) -> impl Iterator<Item = &TraceEntry>

What the hooks decided lately, oldest first.

Source

pub fn propose(&mut self, view: &mut View, to: View) -> bool

Changes the view from outside the widget (a menu’s “zoom in”), through the before_view hook like a gesture. Returns whether the view changed; the signal comes with the next frame’s output.

Source

pub fn zoom_in(&mut self, view: &mut View) -> bool

One ladder step up around the centre (a command).

Source

pub fn zoom_out(&mut self, view: &mut View) -> bool

One ladder step down around the centre (a command).

Trait Implementations§

Source§

impl Debug for ViewportState

Source§

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

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

impl Default for ViewportState

Source§

fn default() -> ViewportState

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,