-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Do not use lookup tables for put_image_data #9911
Conversation
r? @michaelwu |
Thanks for the PR!
The math rounds down by default, so if the result was something like 5.75 in floating point, the final result would be 5 rather than 6. Adding 128 before dividing allows us to round up in these cases. From a floating point POV, it looks like you're adding .5 before rounding down.
Correct. You shouldn't need to put those tests back on the failing list if the math here is correct. However, you might need to do the rounding thing I suggested to get the results accurate enough to not fail tests.
It looks like we only use the table for the Get. Either way - your PR is on the right track. |
See also |
Yeah don't worry about it. It's tricky since you have to worry about alignment too. |
5abc32f
to
368f532
Compare
Out of curiosity, why is the premultiplication for
Ahh gotcha, makes a lot more sense now. |
@@ -795,6 +790,11 @@ fn is_zero_size_gradient(pattern: &Pattern) -> bool { | |||
false | |||
} | |||
|
|||
fn premultiply_channel_by_alpha(channel: u8, alpha: u16) -> u8 { |
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 felt like this could be spun out into a helper, not least because those ((((
s looked potentially confusing, but happy to put it back in put_image_data
.
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.
Can you put this function in the block where it's used?
368f532
to
b1e087f
Compare
@bors-servo: try |
Don't use lookup tables for put_image_data and GetImageData Fixes #9599 "This is the first Rust code I have ever written" (and also my first time writing real browser code, it's been quite the learning experience). Some questions: > For really fast CPU results, use integer SIMD instructions to handle more than one pixel at a time. This was out of the scope of #9599, right? I started looking into doing that, but it seems to be a lot more work than the `E-easy` label would suggest. [`std::simd`](https://doc.rust-lang.org/1.0.0/std/simd/index.html) is marked as "unstable", is that a blocker? > 128 can be added before dividing to round more accurately. @michaelwu, what did you mean by that? Also, the #9599 is `Do not use lookup tables for {Get,Put}ImageData operations`, but we only use lookup tables for the `Put`, not the `Get`, right? Sorry for all the noobish questions. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9911) <!-- Reviewable:end -->
💔 Test failed - mac-rel-wpt |
|
b1e087f
to
33f67b0
Compare
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize]; | ||
let alpha = chunk[3] as u16; | ||
if alpha != 0 { | ||
chunk[0] = ((chunk[0] as u16 * 255 + (alpha / 2)) / alpha) as u8; |
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.
After lots of Googling, I took this from https://bugzilla.mozilla.org/show_bug.cgi?id=659725#c31. Not sure what the best solution here is though.
@bors-servo: try |
Don't use lookup tables for put_image_data and GetImageData Fixes #9599 "This is the first Rust code I have ever written" (and also my first time writing real browser code, it's been quite the learning experience). Some questions: > For really fast CPU results, use integer SIMD instructions to handle more than one pixel at a time. This was out of the scope of #9599, right? I started looking into doing that, but it seems to be a lot more work than the `E-easy` label would suggest. [`std::simd`](https://doc.rust-lang.org/1.0.0/std/simd/index.html) is marked as "unstable", is that a blocker? > 128 can be added before dividing to round more accurately. @michaelwu, what did you mean by that? Also, the #9599 is `Do not use lookup tables for {Get,Put}ImageData operations`, but we only use lookup tables for the `Put`, not the `Get`, right? Sorry for all the noobish questions. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9911) <!-- Reviewable:end -->
💔 Test failed - mac-rel-wpt |
💔 Test failed - linux-rel |
Hmm, three timeouts that I don't think have anything to do with my PR?
|
Yes, those are known intermittent failures. |
faccaf8
to
3055581
Compare
@bors-servo: try |
Do not use lookup tables for put_image_data Fixes #9599 "This is the first Rust code I have ever written" (and also my first time writing real browser code, it's been quite the learning experience). Some questions: > For really fast CPU results, use integer SIMD instructions to handle more than one pixel at a time. This was out of the scope of #9599, right? I started looking into doing that, but it seems to be a lot more work than the `E-easy` label would suggest. [`std::simd`](https://doc.rust-lang.org/1.0.0/std/simd/index.html) is marked as "unstable", is that a blocker? > 128 can be added before dividing to round more accurately. @michaelwu, what did you mean by that? Also, the #9599 is `Do not use lookup tables for {Get,Put}ImageData operations`, but we only use lookup tables for the `Put`, not the `Get`, right? Sorry for all the noobish questions. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9911) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor |
@michaelwu Despite the |
@bors-servo: r=michaelwu |
📌 Commit 3055581 has been approved by |
Do not use lookup tables for put_image_data Fixes #9599 "This is the first Rust code I have ever written" (and also my first time writing real browser code, it's been quite the learning experience). Some questions: > For really fast CPU results, use integer SIMD instructions to handle more than one pixel at a time. This was out of the scope of #9599, right? I started looking into doing that, but it seems to be a lot more work than the `E-easy` label would suggest. [`std::simd`](https://doc.rust-lang.org/1.0.0/std/simd/index.html) is marked as "unstable", is that a blocker? > 128 can be added before dividing to round more accurately. @michaelwu, what did you mean by that? Also, the #9599 is `Do not use lookup tables for {Get,Put}ImageData operations`, but we only use lookup tables for the `Put`, not the `Get`, right? Sorry for all the noobish questions. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9911) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor |
👀 Test was successful, but fast-forwarding failed: 422 Update is not a fast forward |
Do not use lookup tables for put_image_data Fixes #9599 "This is the first Rust code I have ever written" (and also my first time writing real browser code, it's been quite the learning experience). Some questions: > For really fast CPU results, use integer SIMD instructions to handle more than one pixel at a time. This was out of the scope of #9599, right? I started looking into doing that, but it seems to be a lot more work than the `E-easy` label would suggest. [`std::simd`](https://doc.rust-lang.org/1.0.0/std/simd/index.html) is marked as "unstable", is that a blocker? > 128 can be added before dividing to round more accurately. @michaelwu, what did you mean by that? Also, the #9599 is `Do not use lookup tables for {Get,Put}ImageData operations`, but we only use lookup tables for the `Put`, not the `Get`, right? Sorry for all the noobish questions. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9911) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor |
Fixes #9599
"This is the first Rust code I have ever written" (and also my first time writing real browser code, it's been quite the learning experience).
Some questions:
This was out of the scope of #9599, right? I started looking into doing that, but it seems to be a lot more work than the
E-easy
label would suggest.std::simd
is marked as "unstable", is that a blocker?@michaelwu, what did you mean by that?
#9599 mentions #8086, but this isn't just a revert of that PR, correct? I didn't touch
script/
at all. Do I need to re-add the tests here: https://github.com/servo/servo/pull/8086/files#diff-d6e07693f6e7f8f93e2113a102d1d405L1 ?Also, the #9599 is
Do not use lookup tables for {Get,Put}ImageData operations
, but we only use lookup tables for thePut
, not theGet
, right?Sorry for all the noobish questions.