Skip to main content

LcdGfxCtx

Struct LcdGfxCtx 

Source
pub struct LcdGfxCtx<'a> { /* private fields */ }
Expand description

Cairo-style stateful 2D graphics context whose render target is an LcdBuffer. Borrows the buffer mutably for the lifetime of the ctx; let the ctx drop and the buffer is free to be uploaded / composited / read.

Implementations§

Source§

impl<'a> LcdGfxCtx<'a>

Source

pub fn new(buffer: &'a mut LcdBuffer) -> Self

Source

pub fn buffer(&self) -> &LcdBuffer

Read-only view of the underlying buffer — for callers that need to inspect output without releasing the ctx. Returns the base buffer; callers inspecting mid-paint while a layer is active see only state committed before the current layer’s push.

Trait Implementations§

Source§

impl<'a> DrawCtx for LcdGfxCtx<'a>

Source§

fn set_fill_color(&mut self, color: Color)

Source§

fn set_fill_linear_gradient(&mut self, gradient: LinearGradientPaint)

Source§

fn supports_fill_linear_gradient(&self) -> bool

Source§

fn set_fill_radial_gradient(&mut self, gradient: RadialGradientPaint)

Source§

fn supports_fill_radial_gradient(&self) -> bool

Source§

fn set_fill_pattern(&mut self, pattern: PatternPaint)

Source§

fn supports_fill_pattern(&self) -> bool

Source§

fn set_stroke_color(&mut self, color: Color)

Source§

fn set_stroke_linear_gradient(&mut self, gradient: LinearGradientPaint)

Source§

fn supports_stroke_linear_gradient(&self) -> bool

Source§

fn set_stroke_radial_gradient(&mut self, gradient: RadialGradientPaint)

Source§

fn supports_stroke_radial_gradient(&self) -> bool

Source§

fn set_stroke_pattern(&mut self, pattern: PatternPaint)

Source§

fn supports_stroke_pattern(&self) -> bool

Source§

fn set_line_width(&mut self, w: f64)

Source§

fn set_line_join(&mut self, j: LineJoin)

Source§

fn set_line_cap(&mut self, c: LineCap)

Source§

fn set_miter_limit(&mut self, limit: f64)

Source§

fn set_line_dash(&mut self, dashes: &[f64], offset: f64)

Source§

fn set_blend_mode(&mut self, m: CompOp)

Source§

fn set_global_alpha(&mut self, a: f64)

Source§

fn set_fill_rule(&mut self, r: FillRule)

Source§

fn set_font(&mut self, f: Arc<Font>)

Source§

fn set_font_size(&mut self, s: f64)

Source§

fn clip_rect(&mut self, x: f64, y: f64, w: f64, h: f64)

Source§

fn reset_clip(&mut self)

Source§

fn clear(&mut self, color: Color)

Fill the entire render target with color, ignoring the current clip.
Source§

fn begin_path(&mut self)

Source§

fn move_to(&mut self, x: f64, y: f64)

Source§

fn line_to(&mut self, x: f64, y: f64)

Source§

fn cubic_to(&mut self, cx1: f64, cy1: f64, cx2: f64, cy2: f64, x: f64, y: f64)

Source§

fn quad_to(&mut self, cx: f64, cy: f64, x: f64, y: f64)

Source§

fn arc_to( &mut self, cx: f64, cy: f64, r: f64, start_angle: f64, end_angle: f64, ccw: bool, )

Source§

fn circle(&mut self, cx: f64, cy: f64, r: f64)

Add a full circle contour to the current path.
Source§

fn rect(&mut self, x: f64, y: f64, w: f64, h: f64)

Add an axis-aligned rectangle contour to the current path.
Source§

fn rounded_rect(&mut self, x: f64, y: f64, w: f64, h: f64, r: f64)

Add a rounded-rectangle contour to the current path.
Source§

fn close_path(&mut self)

Source§

fn fill(&mut self)

Source§

fn stroke(&mut self)

Source§

fn fill_and_stroke(&mut self)

Source§

fn draw_triangles_aa( &mut self, vertices: &[[f32; 3]], indices: &[u32], color: Color, )

Submit pre-tessellated AA triangles with per-vertex coverage (x, y, alpha) and triangle indices. Read more
Source§

fn fill_text(&mut self, text: &str, x: f64, y: f64)

Draw text with the bottom of the baseline at (x, y).
Source§

fn fill_text_gsv(&mut self, text: &str, x: f64, y: f64, size: f64)

Draw text using the built-in AGG Glyph-Stroke-Vector font at size pixels. Useful before a proper font is loaded.
Source§

fn measure_text(&self, text: &str) -> Option<TextMetrics>

Measure text with the current font and font-size settings.
Source§

fn transform(&self) -> TransAffine

Current accumulated transform (CTM).
Source§

fn root_transform(&self) -> TransAffine

Current transform expressed in the root render target’s coordinate space, even when drawing inside an offscreen layer whose local CTM was reset to identity. Global overlays use this to submit app-level bounds.
Source§

fn save(&mut self)

Source§

fn restore(&mut self)

Source§

fn translate(&mut self, tx: f64, ty: f64)

Source§

fn rotate(&mut self, radians: f64)

Source§

fn scale(&mut self, sx: f64, sy: f64)

Source§

fn set_transform(&mut self, m: TransAffine)

Source§

fn reset_transform(&mut self)

Source§

fn push_layer(&mut self, width: f64, height: f64)

Begin a new transparent compositing layer of the given pixel dimensions. Read more
Source§

fn pop_layer(&mut self)

Composite the current layer back into the previous render target using SrcOver alpha blending, then discard the layer. Read more
Source§

fn draw_lcd_mask( &mut self, mask: &[u8], mask_w: u32, mask_h: u32, src_color: Color, dst_x: f64, dst_y: f64, )

Composite a pre-rasterized LCD subpixel mask onto the current render target, mixing src_color into the destination through per-channel coverage. Read more
Source§

fn has_lcd_mask_composite(&self) -> bool

Returns true if this backend supports [draw_lcd_mask] — i.e. it can composite per-channel LCD coverage onto the active target. Label queries this to decide between the LCD and grayscale AA paths; a backend that returns false will never see LCD text.
Source§

fn has_image_blit(&self) -> bool

Returns true if this context implements draw_image_rgba with actual pixel blitting. Label (and any other widget that uses a software backbuffer) gates its cache path on this method so it can fall back to direct fill_text() on render targets that don’t support blitting (e.g. the GL path). Read more
Source§

fn draw_image_rgba( &mut self, data: &[u8], img_w: u32, img_h: u32, dst_x: f64, dst_y: f64, dst_w: f64, dst_h: f64, )

Draw raw RGBA pixel data into dst_rect (Y-up local coordinates). Read more
Source§

fn as_any_mut(&mut self) -> Option<&mut dyn Any>

Optional escape hatch for widgets that need direct access to a backend-specific concrete context (e.g. to push a custom GPU draw command into the deferred command stream). Read more
Source§

fn snap_to_pixel(&mut self)

Opt-in pixel snapping. Strips the fractional part of the current CTM translation so subsequent integer-coordinate rect / fill / stroke / draw_image_rgba* calls land exactly on the physical pixel grid — no AA fringe on edges, no LINEAR-filter blur on 1:1 texture blits. Read more
Source§

fn supports_compositing_layers(&self) -> bool

Whether this backend implements real offscreen compositing layers. Read more
Source§

fn supports_retained_layers(&self) -> bool

Whether this backend can retain named offscreen layers across frames. Read more
Source§

fn push_layer_with_alpha(&mut self, width: f64, height: f64, _alpha: f64)

Begin a new transparent compositing layer that will be multiplied by alpha when composited back into the parent target. Read more
Source§

fn set_layer_rounded_clip( &mut self, _x: f64, _y: f64, _w: f64, _h: f64, _r: f64, )

Constrain subsequent drawing in the current layer to a rounded-rect mask. Used by window layers after shadows are drawn so chrome/content cannot write into rounded transparent corners. Read more
Source§

fn composite_retained_layer( &mut self, _key: u64, _width: f64, _height: f64, _alpha: f64, ) -> bool

Composite a previously retained backend layer. Returns true when the backend had a retained surface for key and drew it.
Source§

fn push_retained_layer_with_alpha( &mut self, _key: u64, width: f64, height: f64, alpha: f64, )

Begin rendering into a retained backend layer identified by key. Backends that do not retain layers may fall back to a transient layer.
Source§

fn gl_paint(&mut self, _screen_rect: Rect, _painter: &mut dyn GlPaint)

Render GPU content (3-D scene, video frame, etc.) inline at the correct painter-order position. Read more
Source§

fn draw_lcd_mask_arc( &mut self, mask: &Arc<Vec<u8>>, mask_w: u32, mask_h: u32, src_color: Color, dst_x: f64, dst_y: f64, )

Arc-keyed variant so GL backends can cache the uploaded texture on the Arc’s pointer identity — one glTexImage2D per unique raster, lifetime tied to the mask’s strong-ref count. Software backends fall through to the slice path.
Source§

fn draw_image_rgba_arc( &mut self, data: &Arc<Vec<u8>>, img_w: u32, img_h: u32, dst_x: f64, dst_y: f64, dst_w: f64, dst_h: f64, )

Same as [draw_image_rgba] but accepts an Arc<Vec<u8>> so the GL backend can key its texture cache on the Arc’s pointer identity and hold a Weak ref for automatic cleanup when the underlying buffer is dropped — the pattern MatterCAD implements with C# ConditionalWeakTable. Read more
Source§

fn draw_lcd_backbuffer_arc( &mut self, color: &Arc<Vec<u8>>, alpha: &Arc<Vec<u8>>, w: u32, h: u32, dst_x: f64, dst_y: f64, dst_w: f64, dst_h: f64, )

Composite a two-plane LcdCoverage-mode backbuffer onto the active render target at (dst_x, dst_y) with size (dst_w, dst_h) (in local coords). Inputs are two Arc<Vec<u8>>, each 3 bytes per pixel, top-row-first: Read more
Source§

fn capture_screenshot(&mut self) -> bool

Snapshot the current frame’s surface into the backend’s internal screenshot texture (allocating / resizing as needed). Must be called inside the active frame, after end_frame has flushed the 2-D render but before the platform shell calls present. Read more
Source§

fn has_captured_screenshot(&self) -> bool

True if a previously-captured screenshot is held by the backend and available for Self::draw_captured_screenshot.
Source§

fn captured_screenshot_size(&self) -> Option<(u32, u32)>

Dimensions of the held capture, or None when no capture exists.
Source§

fn draw_captured_screenshot( &mut self, _dst_x: f64, _dst_y: f64, _dst_w: f64, _dst_h: f64, ) -> bool

Draw the held capture into (dst_x, dst_y, dst_w, dst_h) using the backend’s preferred filtered sampling. Returns true if the capture exists and was drawn.
Source§

fn read_captured_screenshot(&mut self) -> (Vec<u8>, u32, u32)

Read the held capture’s pixels back to CPU memory as Y-down RGBA8 — for Save / Copy. This is intentionally a single-shot synchronous readback; widgets should NOT call this every frame. Returns (empty, 0, 0) on backends without a capture or without GPU readback support.
Source§

fn visuals(&self) -> Visuals

Return the currently-active Visuals palette. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for LcdGfxCtx<'a>

§

impl<'a> RefUnwindSafe for LcdGfxCtx<'a>

§

impl<'a> Send for LcdGfxCtx<'a>

§

impl<'a> Sync for LcdGfxCtx<'a>

§

impl<'a> Unpin for LcdGfxCtx<'a>

§

impl<'a> UnsafeUnpin for LcdGfxCtx<'a>

§

impl<'a> !UnwindSafe for LcdGfxCtx<'a>

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> Downcast for T
where T: Any,

Source§

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

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

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

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

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

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

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

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

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
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> 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
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.