Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

KYovchevski
Copy link

No description provided.

/// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice on adding bytes long :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change stride to stride_in_bytes :)

pub data: &'a [u8],
pub width: u32,
pub height: u32,
pub stride: u32,
/// The stride between the rows of pixels, in bytes.
Copy link
Member

@MarijnS95 MarijnS95 Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no need to prefix with The here, same for the other doc-comments?

Comment on lines 23 to 28
let mut surface = kernel::rgba_surface {
width: surface.width as i32,
height: surface.height as i32,
stride: surface.stride as i32,
stride: surface.stride_in_bytes as i32,
ptr: surface.data.as_ptr() as *mut u8,
};
Copy link
Member

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 to kernel::RgbaSurface?

Copy link
Author

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 an impl 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.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants