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
impl PaintClass
Sourcepub const SPECIALISED: [Self; 7]
pub const SPECIALISED: [Self; 7]
The classes compiled from a specialisation of the source — every class
but Self::Uber, which is the source itself.
Sourcepub const fn of_flag(paint_and_rect_flag: u32) -> Self
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.
Sourcepub const fn of_instance(strip: &GpuStrip) -> Self
pub const fn of_instance(strip: &GpuStrip) -> Self
The class of strip, as far as its flag says (Self::of_flag).
Sourcepub const fn of_image(quality: u32, external: bool) -> Self
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.
Sourcepub const fn label(self) -> &'static str
pub const fn label(self) -> &'static str
A short name for logs, pipeline labels and shader-library names.
Sourcepub const fn draws(self, other: Self) -> bool
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.
Sourcepub const fn admits_flag(self, paint_and_rect_flag: u32) -> bool
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
impl Clone for PaintClass
impl Copy for PaintClass
Source§impl Debug for PaintClass
impl Debug for PaintClass
impl Eq for PaintClass
Source§impl Hash for PaintClass
impl Hash for PaintClass
Source§impl Ord for PaintClass
impl Ord for PaintClass
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PaintClass
impl PartialEq for PaintClass
Source§impl PartialOrd for PaintClass
impl PartialOrd for PaintClass
impl StructuralPartialEq for PaintClass
Auto Trait Implementations§
impl Freeze for PaintClass
impl RefUnwindSafe for PaintClass
impl Send for PaintClass
impl Sync for PaintClass
impl Unpin for PaintClass
impl UnsafeUnpin for PaintClass
impl UnwindSafe for PaintClass
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.