Skip to content

Conversation

@changm
Copy link
Contributor

@changm changm commented Jan 19, 2017

@kvark r? Required to do the gamma look up table stuff. The unfortunate side effect of this is that the Glyph keys require ColorU as u8 rgb channels instead of floats since f32 doesn't implement std::eq :/. Also, all the other API calls expects color information as ColorF. Instead of making users of the api give text as ColorU, we just translate it into/out of ColorU when we create the glyph key. I'd be happy if you become picky again and find a better way :)


This change is Reviewable

@glennw
Copy link
Member

glennw commented Jan 19, 2017

@changm Looks like there are compile errors on travis / appveyor.

@emilio
Copy link
Member

emilio commented Jan 19, 2017

I think you should be able to implement Eq in ColorF if you don't care about Inf/Nan

@glennw
Copy link
Member

glennw commented Jan 19, 2017

@changm @emilio You could implement Eq, but quantizing is probably a good idea. That way, we won't end up with extra keys / glyphs being rasterized into the cache due to very slight floating point differences.

@changm changm force-pushed the coloru branch 3 times, most recently from 972114e to 81d7bf5 Compare January 19, 2017 22:48
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #756) made this pull request unmergeable. Please resolve the merge conflicts.

@changm
Copy link
Contributor Author

changm commented Jan 20, 2017

@glennw @kvark hoorah! Finally can merge r?

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.

Looks good, just have one concern.

}

#[allow(non_snake_case)]
pub fn from_colorF(color: ColorF) -> ColorU {
Copy link
Member

Choose a reason for hiding this comment

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

Typically, in Rust this is done by implementing the From and Into traits:

impl From<ColorF> for ColorU {}
impl Into<ColorF> for ColorU {}

known_heap_size!(0, ColorF);

#[derive(Clone, Copy, Hash, Eq, Debug, Deserialize, PartialEq, PartialOrd, Ord, Serialize)]
pub struct ColorU {
Copy link
Member

Choose a reason for hiding this comment

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

It feels slightly wrong that both ColorU and ColorF are exposed in webrender_traits. Shouldn't one of them be just an implementation detail (hidden inside webrender)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need it for GlyphKey :(. Otherwise yes, I would've just passed ColorF around until we were inside webrender.


impl ColorU {
fn round_to_int(x: f32) -> u8 {
assert!((0.0 <= x) && (x <= 1.0));
Copy link
Member

Choose a reason for hiding this comment

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

You may want to make these debug_assert! instead (assertions run in release by default in rust).

@kvark
Copy link
Member

kvark commented Jan 24, 2017

Thanks @changm !
Looks like everything is addressed, merging.
@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 2e8f719 has been approved by kvark

@bors-servo
Copy link
Contributor

⚡ Test exempted - status

@bors-servo bors-servo merged commit 2e8f719 into servo:master Jan 24, 2017
bors-servo pushed a commit that referenced this pull request Jan 24, 2017
Pipe text color information to rasterize_glyphs

@kvark r? Required to do the gamma look up table stuff. The unfortunate side effect of this is that the Glyph keys require ColorU as u8 rgb channels instead of floats since f32 doesn't implement std::eq :/. Also, all the other API calls expects color information as ColorF. Instead of making users of the api give text as ColorU, we just translate it into/out of ColorU when we create the glyph key. I'd be happy if you become picky again and find a better way :)

<!-- 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/748)
<!-- Reviewable:end -->
@changm changm deleted the coloru branch January 24, 2017 01:20
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.

5 participants