Skip to content

Conversation

@nical
Copy link
Contributor

@nical nical commented Jan 19, 2017

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 Reviewable

@glennw
Copy link
Member

glennw commented Jan 19, 2017

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 774969c has been approved by glennw

@bors-servo
Copy link
Contributor

⌛ Testing commit 774969c with merge 7bafd4b...

bors-servo pushed a commit that referenced this pull request Jan 20, 2017
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis

Copy link
Member

@kvark kvark left a 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,
Copy link
Member

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 {
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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 {
Copy link
Member

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.

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.

4 participants