-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uefi(gop): add a embedded_graphics_core::DrawTarget for (a wrapper of) GraphicsOutput #820
base: main
Are you sure you want to change the base?
Conversation
…) GraphicsOutput Given that PixelFormat for UEFI is dynamic and DrawTarget needs it to be static. We (anyway) need to bridge the gap by asserting this dynamically and providing API to create the best wrapper. In some cases, we might even need to convert the pixel to the target format by relying on Blt or similar.
This is only a WIP and address partially #781. This is open for suggestions and ideas before I go further in the design. |
I like the idea! 👍🏻 |
|
||
// FIXME: offer conversions from C to current pixel color format? | ||
struct GraphicsDisplay<C: PixelColor> { | ||
color: C, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Although this is not consistent across the code-base, personally I prefer Box<dyn PixelColor
for all non-performance critical stuff. Having a generic parameter has the consequence that all wrapping structs (that library users may create in higher levels) are also forced to be generic. But this is just a nit and you don't have to address it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'm open to Box<dyn PixelColor>
really :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would imply a dependency on the alloc
feature, tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, correct
# Generic gate to code that uses unstable features of Rust. You usually need a nightly toolchain. | ||
unstable = [] | ||
|
||
[dependencies] | ||
bitflags = "2.0.0" | ||
embedded-graphics-core = { version = "0.4.0", optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we do not need a feature flag for this. What do you @nicholasbishop think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would imagine that the embedded-graphics-core closure would bloat a bit things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this will end up in a binary, if the GOP is not used. Probalby, at least with LTO, this stuff should be garbage-collected?! What do you think? I'm not sure here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something something rust zero cost abstraction yada yada? :D
more seriously: I was reasoning on a purely "developer" side, bringing more dependency is more annoying usually, but this might be a fair tradeoff here given it's tailored for embedded systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having the feature flag is good. Over time we'll likely add interop with more crates like this (one example I've thought about before: conversion between our Time
and the time
crate), and I wouldn't want to make all such crates required.
I'm uncertain about the feature name, draw_target
seems a little generic. Maybe embedded_graphics
to reflect crate name?
Also, I think we can drop it from the default features, I'd like to keep that set minimal.
Making this generic over pixel format pushes the burden of handling them (correctly) on the consumer, no? That doesn't sound very nice to me. A usage snippet would be nice… |
This is an open discussion, my idea regarding this is: there's no way around if we want it to be nice on the consumer. (1) Have generic over PixelFormat |
The way I see it: Just draw into a
|
|
I agree, it's good alternative design. |
I know. You can use |
I think this wasn't too far from the finishing line. Any update, @RaitoBezarius ? |
Given that PixelFormat for UEFI is dynamic and DrawTarget needs it to be static.
We (anyway) need to bridge the gap by asserting this dynamically and providing API to create the
best wrapper.
In some cases, we might even need to convert the pixel to the target format by relying on Blt or similar.