-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add bit order and direction support to ImageRaw
and Framebuffer
#711
base: master
Are you sure you want to change the base?
Conversation
Hey Ralf, I just pushed some changes to this branch. Hopefully that's ok with you. If not, please let me know and I'll fork this PR into a new one. I'll see if I can integrate |
Sure that is OK. Great to see some progress on this.
Good luck! While you are at it you could also try to use the rotation or orientation types from https://github.com/embedded-graphics/display-driver-hal, if you like. I think we should release a first alpha after this PR is merged to make it easier to depend on the new features. |
I've just added horizontal/vertical support for < 8BPP, using this PR in TODO
|
Should we revert the change I made in e-g 0.7 that I would suggest to change the But we would also need an additional constructor, that could be used in |
One more difference between |
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 PR is enormous. Did it suffer from a little scope creep? I'm getting a bit concerned by the number of traits e-g has now. I appreciate we might need them all but I still think it's worth raising.
Looks like the CI has a doc check failure, nothing too difficult.
A bit, but most changes are directly related to finishing and optimizing the framebuffer implementation. I needed a working framebuffer implementation for other projects and didn't want to wait any longer.
If you have any concrete examples of traits which aren't necessary we could discuss to remove them. |
I've just updated the branch to the latest master version. While I'm not sure what my involvement with the e-g project will be in the future I would like to get this PR, or at least part of it, merged. |
@rfuest I think my contributions will be limited to bugfixes going forward, but I'm happy to take a look at this. I'll need to familiarize myself with the situation, though, which will take some time. |
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 was an experience for sure.
I'm not convinced ColorType
is a good addition. It feels like extreme deduplication that just causes trait-bloat and overcomplicates things. I have similar feelings for StorablePixelColor
.
Running clippy on the PR gives me 16 warnings. I don't know how many are from this PR, but you might want to clean up the ones introduced here.
#[cfg_attr(feature = "defmt", derive(::defmt::Format))] | ||
pub enum DataOrderEnum { | ||
/// Default data order. | ||
Default, |
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.
Instead of an indirect terminology, can we use MostSignificantFirst
/ LeastSignificantFirst
here?
Also, I think deny(missing_docs)
is a terrible idea if that results in multiplying trivial comments like the one above.
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.
Instead of an indirect terminology, can we use
MostSignificantFirst
/LeastSignificantFirst
here?
I don't like this either, but for bits the default order is Msb0
and for bytes it is LittleEndian
.
assert_eq!(framebuffer.data(), &expected_data); | ||
} | ||
} | ||
macro_rules! impl_framebuffer_tests { |
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 have to say, this really feels like a test suite that needs some tests to test itself, but I also understand the motivation of not wanting to write the same thing 15 times over.
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 have to say, this really feels like a test suite that needs some tests to test itself, ...
It's not great, but I couldn't come up with something better.
..., but I also understand the motivation of not wanting to write the same thing 15 times over.
Make that 56 times 😉.
{ | ||
let size = self.size(); | ||
|
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.
Shouldn't this part shrink the area to the image and try to draw that? Just doing nothing might be surprising for users.
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.
Users aren't supposed to call this method directly. area
should never be outside the image.
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.
If that's the case, taking the condition should be unreachable!()
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.
You are probably right, but I haven't looked at this code in detail for a long time and don't want to change it in this PR, without taking a closer look first.
@@ -110,8 +111,11 @@ impl<T: StyledDimensions<S>, S> Dimensions for Styled<T, S> { | |||
} | |||
} | |||
|
|||
impl<T: StyledDrawable<S>, S> Drawable for Styled<T, S> { | |||
type Color = T::Color; | |||
impl<T: StyledDrawable<S>, S: ColorType> ColorType for Styled<T, S> { |
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.
And this was the point where I started wondering if ColorType
should have been blanket-implemented for every drawable instead, and if you should have kept Drawable::Color. There are breaking changes, and there are soul-breaking changes, and this feels the latter.
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.
The ColorType
trait was the change I wasn't sure about. It was inspired by the ErrorType
trait in embedded-hal
. I like the idea of having one common place to specify the color type, instead of associated color types in 6 separate traits, but it causes a lot of changes.
There are breaking changes, and there are soul-breaking changes, and this feels the latter.
That might be a little dramatic. Would this affect the average user? And most library authors should only need to change a few lines of code.
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.
That might be a little dramatic.
Of course, that came after an hour and a half of reading the PR :)
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.
Of course, that came after an hour and a half of reading the PR :)
OK, I can understand that and thanks for taking the time to review this PR, which should never have gotten so huge.
I've updated the changelog, because the entries were still included in the |
Tested on Win11, AMD 5950X
This reverts commit 9ef61f1.
This draft PR contains the latest WIP version of my experiment with adding bit order and direction settings to
ImageRaw
andFramebuffer
.Closes #697