Skip to content

Commit 81504c3

Browse files
committed
feat: take PixelRead and WindowedDrawTarget from embedded-draw-target
Both traits were defined here, so a buffer implementing them satisfied this crate and nothing else -- a 3D rasterizer or an application needing the same readback had to implement a second, identical trait. Re-export them from embedded-draw-target instead. The paths and signatures are unchanged, so existing implementors and call sites are unaffected, but the trait identity is now shared across the ecosystem: one buffer can serve this crate's alpha compositor, a rasterizer's anti-aliasing, and plain embedded-graphics drawing at once.
1 parent a68e8e2 commit 81504c3

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "embedded-gui"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
edition = "2024"
55
rust-version = "1.87"
66
authors = ["Gerzain Mata <leftger@gmail.com>"]
@@ -51,6 +51,7 @@ embassy = ["embassy-time", "dep:embassy-sync"]
5151

5252
[dependencies]
5353
embedded-graphics-core = "0.4.1"
54+
embedded-draw-target = { version = "0.1", default-features = false }
5455
embedded-graphics-framebuf = "0.3"
5556
critical-section = "1.1"
5657
heapless = "0.9"

src/render.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,20 +360,19 @@ pub enum BlendMode {
360360
/// Implementing `PixelRead` additionally unlocks the `*_true_alpha` methods,
361361
/// which composite against the destination's actual current contents
362362
/// instead of dithering.
363-
pub trait PixelRead: DrawTarget {
364-
fn get_pixel(&self, point: Point) -> Self::Color;
365-
}
363+
///
364+
/// Re-exported from [`embedded_draw_target`] so that a buffer implementing it
365+
/// once is accepted by every crate in the ecosystem that needs readback,
366+
/// rather than by this one alone.
367+
pub use embedded_draw_target::PixelRead;
366368

367369
/// Capability trait for hardware display controllers (e.g. ST7789, ILI9341, SSD1306)
368370
/// supporting direct column/row address window setting (`set_address_window`).
369371
/// Allows rendering dirty regions by transmitting SPI/DMA transfers exclusively to
370372
/// the target sub-window instead of the full screen.
371-
pub trait WindowedDrawTarget: DrawTarget {
372-
fn set_window(
373-
&mut self,
374-
area: &embedded_graphics_core::primitives::Rectangle,
375-
) -> Result<(), Self::Error>;
376-
}
373+
///
374+
/// Re-exported from [`embedded_draw_target`].
375+
pub use embedded_draw_target::WindowedDrawTarget;
377376

378377
/// Pixel-plotting policy for a [`RenderCtx`]. Selected by the ctx's `C` type
379378
/// parameter so the *same* drawing calls composite differently depending on

0 commit comments

Comments
 (0)