Skip to main content

PaintClass

Enum PaintClass 

Source
pub enum PaintClass {
    SolidCoverage,
    Gradient,
    Image,
    ImageFiltered,
    BlurredRect,
    LayerComposite,
    Glyph,
    Uber,
}
Expand description

Which specialised strip program an instance can be drawn with.

The strip fragment stage dispatches on the instance’s colour source and paint type, and a mobile GPU charges every fragment for the branches that dispatch could take, not the one it does (the S1 ablation: a program keeping only coverage, solid and gradients ran S1’s fragments at less than half the cost of the whole one). So the one strip.wgsl source is compiled once per class, each keeping only its own branches (crate::gpu::shader_src::strip_class_source), and a pass’s instances are drawn in runs of one class each (split_class_runs).

Coverage (strip and rect) and the solid paint are in every class, which is what lets a short solid run be drawn by its non-solid neighbour’s program (see Self::draws). Self::Uber is the whole program — the source unchanged — and draws everything.

Mostly derived from the instance alone (Self::of_flag): bits 29-30 of GpuStrip::paint_and_rect_flag name the colour source and bits 26-28 the paint type. The one split the flag cannot make is an image’s: whether it samples nearest/bilinear from the atlas (Self::Image) or needs the bicubic or external-texture path (Self::ImageFiltered) is in its encoded record, so Self::of_flag answers the superset and the renderer refines it per draw from the resolved record (Self::of_image).

Variants§

§

SolidCoverage

Coverage plus the inline solid colour — and nothing else.

§

Gradient

Adds the linear, radial and sweep gradients.

§

Image

Adds atlas image sampling at nearest and bilinear quality — every atlas glyph not drawn as a glyph quad, and every image not drawn bicubic.

§

ImageFiltered

Adds every image path: Self::Image’s, plus bicubic atlas sampling and the externally bound texture. Kept apart because the bicubic and external code is what an image fragment pays for most, taken or not.

§

BlurredRect

Adds the blurred rounded rectangle.

§

LayerComposite

Adds the layer colour source a composite reads its finished page through.

§

Glyph

Adds the glyph quad: one nearest load from the atlas texel the instance’s payload names, with no paint transform and no extend mode — what a cached glyph run draws with. Independent of the image program family, since it never samples bilinearly.

§

Uber

The whole program, every branch: what a run too short to be worth its own pipeline switch, and every run under FRUST_ENGINE_UBER_PROGRAM, is drawn with.

Implementations§

Source§

impl PaintClass

Source

pub const ALL: [Self; 8]

Every class, in index order.

Source

pub const SPECIALISED: [Self; 7]

The classes compiled from a specialisation of the source — every class but Self::Uber, which is the source itself.

Source

pub const fn of_flag(paint_and_rect_flag: u32) -> Self

The class of an instance whose packed descriptor is paint_and_rect_flag (RECT_STRIP_FLAG may be set or not).

A colour source or paint type the shader does not name maps to Self::Uber rather than to a guess: the whole program reads it exactly as it always did. An image maps to Self::ImageFiltered, the class that draws every image — the flag does not say which path the record takes (see Self::of_image).

A glyph quad is Self::Glyph only on a rect instance: its payload names the atlas texel under the instance’s own corner, which is only the glyph’s corner when the instance is the glyph’s whole rectangle. A strip carrying the glyph paint type is not an encoding the engine emits, and is read as reserved.

Source

pub const fn of_instance(strip: &GpuStrip) -> Self

The class of strip, as far as its flag says (Self::of_flag).

Source

pub const fn of_image(quality: u32, external: bool) -> Self

The class of an image paint whose encoded record samples at quality (the shader’s IMAGE_QUALITY_* numbering: 0 nearest, 1 bilinear, 2 bicubic) from the external texture (external) or the atlas.

Only an atlas image at nearest or bilinear quality is Self::Image; a bicubic or external one needs Self::ImageFiltered. The renderer asks this once per resolved paint, from the record it lowered.

Source

pub const fn index(self) -> usize

This class’s position in Self::ALL.

Source

pub const fn label(self) -> &'static str

A short name for logs, pipeline labels and shader-library names.

Source

pub const fn draws(self, other: Self) -> bool

Whether this class’s program draws an instance of class other exactly as Self::Uber would.

A class draws itself and the solid paint (coverage and solid are in every program); Self::ImageFiltered also draws Self::Image; Self::Uber draws everything.

Source

pub const fn admits_flag(self, paint_and_rect_flag: u32) -> bool

Whether this class’s program draws an instance whose flag is paint_and_rect_flag, as far as the flag can tell: an image instance is admitted by either image class, since which one its record needs is not in the flag (Self::of_flag).

Trait Implementations§

Source§

impl Clone for PaintClass

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 Copy for PaintClass

Source§

impl Debug for PaintClass

Source§

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

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

impl Eq for PaintClass

Source§

impl Hash for PaintClass

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for PaintClass

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for PaintClass

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

impl PartialOrd for PaintClass

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for PaintClass

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

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

Source§

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

Source§

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

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

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,