-
Notifications
You must be signed in to change notification settings - Fork 306
Add ImageDescriptor to describe the layout and format of images in memory. #756
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
Conversation
|
@bors-servo r+ |
|
📌 Commit 774969c has been approved by |
Add ImageDescriptor to describe the layout and format of images in memory. The most notable change is that this moves the responsibility of specifying whether images are opaque to the consumer of the webrender api rather than webrender itself, which should be more efficient, and lets us handle opaque RGBA surfaces efficiently. r? @glennw <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/756) <!-- Reviewable:end -->
|
☀️ Test successful - status-travis |
kvark
left a comment
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.
@nical
Sorry about the late review!
A few things need to be addressed.
| height: 2, | ||
| stride: None, | ||
| format: ImageFormat::A8, | ||
| is_opaque: 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 don't think this one is opaque
| format, ref data) => { | ||
| let stride = if let Some(stride) = stride { | ||
| &ApiMsg::AddImage(ref key, ref descriptor, ref data) => { | ||
| let stride = if let Some(stride) = descriptor.stride { |
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: could be rewritten via unwrap_or
| ImageFormat::RGBA8 | ImageFormat::RGB8 => width*4, | ||
| ImageFormat::RGBAF32 => width*16, | ||
| match descriptor.format { | ||
| ImageFormat::A8 => descriptor.width, |
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.
don't we have just a ImageFormat::bytes_per_pixel()? we should
| self.images.insert(*key, CachedImage { | ||
| width: width, height: height, stride: stride, | ||
| format: format, | ||
| width: descriptor.width, |
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 reason we don't want to store the descriptor directly in CachedImage?
| ImageFormat::RGBA8 | ImageFormat::RGB8 => width*4, | ||
| ImageFormat::RGBAF32 => width*16, | ||
| match descriptor.format { | ||
| ImageFormat::A8 => descriptor.width, |
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.
duplicated code, one more reason to add ImageFormat::bytes_per_pixel()
| // This assumes that A8 textures are never opaque, since they are | ||
| // typically used for alpha masks. We could revisit that if it | ||
| // ever becomes an issue in real world usage. | ||
| pub fn is_image_opaque(format: ImageFormat, bytes: &[u8]) -> bool { |
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.
Let's move it to wrench, it's not idiomatic to WR any more.
The most notable change is that this moves the responsibility of specifying whether images are opaque to the consumer of the webrender api rather than webrender itself, which should be more efficient, and lets us handle opaque RGBA surfaces efficiently.
r? @glennw
This change is