-
Notifications
You must be signed in to change notification settings - Fork 2
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
Improve variable naming for RgbaSurface. Remove unnecessary comments. #6
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,18 @@ pub mod bc6h; | |
pub mod bc7; | ||
pub mod etc1; | ||
|
||
/// Describes a 2D uncompressed little endian RGBA image. | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct RgbaSurface<'a> { | ||
/// The pixel data for the image. | ||
/// The data does not need to be tightly packed, but if it isn't, stride must be different from `width * 4`. | ||
/// | ||
/// Expected to be at least `stride * height` bytes long. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice on adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change |
||
pub data: &'a [u8], | ||
pub width: u32, | ||
pub height: u32, | ||
pub stride: u32, | ||
/// The stride between the rows of pixels, in bytes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's no need to prefix with |
||
pub stride_in_bytes: u32, | ||
} | ||
|
||
#[inline(always)] | ||
|
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.
Any idea why every file is manually converting from
RgbaSurface
tokernel::RgbaSurface
?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's taken from Graham's code.
kernel::rgba_surface
appears to be part of the generated code, so adding animpl
for it seems like it would be hacky, since you'll be relying on it matching the generated Rust code for the struct.I assume this might be the reason it also isn't straight up using
kernel::rgba_surface
as part of the interface. I think it would be more user friendly to have a struct that is unlikely to change between versions, and if you have changes to the kernel struct, you only change the conversion rather than the user having to change their 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.
Generated code is imported into this crate, so you should be able to safely implement an
impl From<RgbaSurface> for kernel::rgba_surface
and do away with a bunch of duplicated code.