Skip to main content

GlRegion

Struct GlRegion 

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

A physical-pixel rectangle in GL bottom-left coordinates (origin at the framebuffer’s bottom-left corner, y increasing upward). The glow backend’s read coordinates, composite rect_origin, SDF, and backdrop_uv_remap all operate in this one consistent system, so a copyTexSubImage2D from the bottom-left framebuffer lines up with rect_uv.y increasing upward and nothing is rendered upside-down (DESIGN §5).

Fields are private: the only way to obtain one is from_bottom_px from already-bottom-left inputs, so the “never flipped” invariant holds by construction.

Implementations§

Source§

impl GlRegion

Source

pub fn from_bottom_px(origin_bl: [u32; 2], size: [u32; 2], scale: Scale) -> Self

Build from a bottom-left physical-pixel origin and size. Named _bl/from_bottom_px because the input is required to already be GL-origin (egui’s from_bottom_px field); the constructor performs no flip, which is the whole point of the type.

Source

pub fn intersect(&self, other: &GlRegion) -> Option<GlRegion>

Intersect with another region in the same bottom-left space — the clip_rect ∩ viewport step the adapter runs before grabbing. Saturating; returns None when the two are disjoint or touch only at an edge (zero area), the blur no-op. The result keeps self’s Scale; both inputs are expected to share it (same frame, same DPI).

Source

pub fn clip_to(&self, extent: [u32; 2]) -> Option<GlRegion>

Clip to a framebuffer of size extent (the framebuffer ∩ step). Equivalent to intersect with the box origin (0, 0), size extent; None when the region lies fully outside the framebuffer (the no-op).

Source

pub fn origin_bl(self) -> [u32; 2]

The bottom-left origin, physical pixels. Used by the grab to set copyTexSubImage2D / blitFramebuffer read coordinates directly — GL’s read origin is bottom-left, so no flip.

Source

pub fn size(self) -> [u32; 2]

Width and height, physical pixels. The grab texture is sized to this.

Source

pub fn into_region(self) -> Region

Reinterpret as the orientation-free Region the seam speaks. Pure reinterpret — no arithmetic, no flip: the bottom-left numbers pass straight through, and every compute consumer on the glow path (grab_source, the SDF, backdrop_uv_remap, the composite uniforms) treats the resulting Region as bottom-left consistently, so no coordinate is ever double-interpreted. This is the single line a review checks for a hidden height − y.

The one consumer that must not receive an into_region()’d value is a human-facing error: Region’s Display is documented top-left, so a bottom-left number printed through it would mislead a debugger. That is why BlurError::GrabFailed carries a GlRegion directly (which prints with an explicit bottom-left marker), not a reinterpreted Region.

Trait Implementations§

Source§

impl Clone for GlRegion

Source§

fn clone(&self) -> GlRegion

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 GlRegion

Source§

impl Debug for GlRegion

Source§

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

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

impl Display for GlRegion

Source§

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

Prints with an explicit bottom-left marker so an error message can never be mistaken for the top-left Region convention.

Source§

impl PartialEq for GlRegion

Source§

fn eq(&self, other: &GlRegion) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for GlRegion

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.