Skip to main content

CustomRenderPrimitive

Enum CustomRenderPrimitive 

Source
pub enum CustomRenderPrimitive {
    Texture {
        order: DrawOrder,
        handle: ImportedTextureHandle,
        bounds: Bounds<ScaledPixels>,
        content_mask: ContentMask<ScaledPixels>,
        radii: Corners<ScaledPixels>,
        opacity: f32,
        flip_v: bool,
    },
}
Expand description

A drawable the application produced itself, drawn in the composite pass rather than translated into GPUI’s own primitives.

It rides crate::PaintSurface’s machinery — the ordering, the content mask, one accumulation list and one batch — but is drawn by a fragment path of its own: what it samples is RGBA, where that surface is YCbCr video.

Variants§

§

Texture

A texture produced outside GPUI, sampled in the composite pass.

Fields

§order: DrawOrder

Assigned by the scene, so the texture composites with its siblings in order.

§handle: ImportedTextureHandle

The token the renderer resolves to the texture it samples.

§bounds: Bounds<ScaledPixels>

Where the texture lands, in scaled pixels.

§content_mask: ContentMask<ScaledPixels>

What may clip it.

§radii: Corners<ScaledPixels>

Corner radii, in scaled pixels: the element converts at paint time, as paint_quad does, because the renderer has no scale factor of its own.

§opacity: f32

Multiplied into the sample.

§flip_v: bool

The producer’s textures have a top-left origin; the scene’s quads do not.

Implementations§

Source§

impl CustomRenderPrimitive

Source

pub fn order(&self) -> DrawOrder

The order the scene assigned it.

Source

pub fn order_mut(&mut self) -> &mut DrawOrder

The order, for the scene to assign.

Source

pub fn bounds(&self) -> &Bounds<ScaledPixels>

Where it lands.

Source

pub fn content_mask(&self) -> &ContentMask<ScaledPixels>

What may clip it.

Source

pub fn to_quad_record(&self) -> Quad

Encode this primitive into the quad instance record the backends’ shaders read.

Both renderers draw it through their quad pipeline, so its geometry, its content-mask clip and its corner SDF are the quads’ rather than a second implementation of them. That leaves two values with no field of their own: the opacity rides in the solid background’s alpha, which the quad vertex entry point forwards as a scratch field the texturing path does not read, and flip_v rides in the border style, which a textured quad has no other use for. Encoding it here rather than in each renderer is what keeps the two in step with the shaders.

Trait Implementations§

Source§

impl Clone for CustomRenderPrimitive

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 CustomRenderPrimitive

Source§

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

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

impl From<CustomRenderPrimitive> for Primitive

Source§

fn from(custom: CustomRenderPrimitive) -> Self

Converts to this type from the input type.

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.