-
Notifications
You must be signed in to change notification settings - Fork 306
Apply gamma correction for coregraphics fonts #774
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
| } | ||
|
|
||
| // Assumes the pixels here are linear values from CG | ||
| fn gamma_correct_pixels(&self, pixels: &mut Vec<u8>, width: usize, |
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: As far as I understand it, pixels's length cannot change, right? If so, you could probably make it a &mut [u8] so you save an indirection.
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.
Ahh good point. Thanks! Since I already have the dwrite gamma correction also using vector, can I fix this + dwrite + the gamma-lut library in a follow up patch? Too many patches in mid flight right now.
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.
Sounds fine to me :)
|
@bors-servo r+ |
|
📌 Commit 130bc43 has been approved by |
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.
Got a few places where the code could look nicer (in addition to @emilio 's note, plus a question.
webrender/src/platform/macos/font.rs
Outdated
| use std::collections::HashMap; | ||
| use std::collections::hash_map::Entry; | ||
| use webrender_traits::{ColorU, FontKey, FontRenderMode, GlyphDimensions}; | ||
| use gamma_lut; |
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.
would be cleaner to use gamma_lut::{GammaLut, Color as ColorLut};
webrender/src/platform/macos/font.rs
Outdated
| match render_mode { | ||
| FontRenderMode::Alpha => { | ||
| self.gamma_lut.preblend_grayscale_bgra(pixels, width, height, | ||
| gamma_lut::Color::new(color.r, |
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.
could move the ColorLut initialization out of the match
webrender/src/platform/macos/font.rs
Outdated
| FontContext { | ||
| cg_fonts: HashMap::new(), | ||
| ct_fonts: HashMap::new(), | ||
| gamma_lut: gamma_lut::GammaLut::new(contrast, gamma, gamma), |
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.
given that you pass the same gamma as both paint gamma and device gamma, the whole LUT'ing thing becomes just a contrast application, according to the source:
if (src - dst).abs() < (1.0 / 256.0) {
let mut ii : f32 = 0.0;
for i in 0..256 {
let raw_srca = ii / 255.0;
let srca = apply_contrast(raw_srca, adjusted_contrast);
table[i] = round_to_u8(255.0 * srca);
ii += 1.0;
}
}Is this by design? Are we going to use different gamma parameters here in the long term?
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.
It is by design at the moment, it's just a port from Skia - http://searchfox.org/mozilla-central/source/gfx/skia/skia/src/core/SkPaint.cpp#1498
Also, that bit of code isn't the src/dst gamma. That's after the luminance conversion - http://searchfox.org/mozilla-central/source/gfx/skia/skia/src/core/SkMaskGamma.cpp#79. We don't actually hit that if block.
Gamma correction for dwrite fonts Same as #774 (review) but for dwrite fonts! <!-- 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/775) <!-- Reviewable:end -->
|
@kvark Did I answer your question? If so, please merge. Thanks! |
|
Thanks!
@bors-servo r+
… On Jan 25, 2017, at 12:12, Mason Chang ***@***.***> wrote:
@kvark Did I answer your question? If so, please merge. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
📌 Commit cffd17d has been approved by |
|
🔒 Merge conflict |
|
☔ The latest upstream changes (presumably #770) made this pull request unmergeable. Please resolve the merge conflicts. |
Gamma correction for dwrite fonts Same as #774 (review) but for dwrite fonts! <!-- 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/775) <!-- Reviewable:end -->
|
@bors-servo r=kvark |
|
📌 Commit 259bab0 has been approved by |
Apply gamma correction for coregraphics fonts I finished Jeff's port of Skia's gamma mask code here - https://github.com/changm/gamma-lut-rs, which is the packaged added in this patch. The original source is here - http://searchfox.org/mozilla-central/source/gfx/skia/skia/src/core/SkMaskGamma.cpp <!-- 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/774) <!-- Reviewable:end -->
|
☀️ Test successful - status-travis |
I finished Jeff's port of Skia's gamma mask code here - https://github.com/changm/gamma-lut-rs, which is the packaged added in this patch.
The original source is here - http://searchfox.org/mozilla-central/source/gfx/skia/skia/src/core/SkMaskGamma.cpp
This change is