Skip to content
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

Implement repetition and spacing for tiled images. #972

Merged
merged 3 commits into from Mar 10, 2017

Conversation

@nical
Copy link
Collaborator

nical commented Mar 8, 2017

Followup of PR #897. This should cover the all of the remaining cases when rendering tiled images (image display item specifically).
If the image is tiled and repeated along the same dimension it is decomposed into a primitive for each repetition, taking spacing into account. These primitives are then split in a per tile basis.


This change is Reviewable

@nical nical force-pushed the nical:image-repeat-spacing branch from 546f47e to 72d274b Mar 8, 2017
@nical
Copy link
Collaborator Author

nical commented Mar 8, 2017

r? @kvark

@nical
Copy link
Collaborator Author

nical commented Mar 9, 2017

Sadly the test tile-repeat-prim-or-decompose.yaml which I just added fails on travis (but not on my computer) due to rounding differences. It would be great to be able to fuzz tests (my attempt at using gecko's fuzzing syntax didn't work).

@nical
Copy link
Collaborator Author

nical commented Mar 9, 2017

I just added some basic support for fuzzy reftests in wrench using the same syntax as gecko. I'll move the commit into a separate PR but just pushing it here temporarily to check that it fixes the test.

@kvark
Copy link
Member

kvark commented Mar 9, 2017

due to rounding differences

Did you find out what exactly those differences are?

@glennw
Copy link
Member

glennw commented Mar 9, 2017

Specifically - the reftests are run with OSMesa, so if you're running the reftests locally with the headless.py script, they should match exactly - and if they don't we should find out why. I'm not against adding fuzzy tests (we will need them), but in this case it'd be good to know what the cause is - since I've come across several super subtle bugs recently that caused fuzzy results.


// Decompose each vertical repetition into rows.
let layout_stride = info.stretch_size.height + info.tile_spacing.height;
let num_repetitions = (item_rect.size.width / layout_stride).ceil() as u32;

This comment has been minimized.

@kvark

kvark Mar 9, 2017

Member

shouldn't this be item_rect.size.height / layout_stride?

This comment has been minimized.

@nical

nical Mar 10, 2017

Author Collaborator

Oops!

item_rect.size.width,
info.stretch_size.height
).intersection(&item_rect) {
self.decompose_image_row(scroll_layer_id, context, &row_rect, item_clip, info, image_size, tile_size);

This comment has been minimized.

@kvark

kvark Mar 9, 2017

Member

it's a bit weird to see decompose_image_row called from inside of this loop, since it's supposed to handle image repetitions (which is not the case for this loop, is it?)

This comment has been minimized.

@nical

nical Mar 10, 2017

Author Collaborator

It is (or maybe I misunderstand your question). decompose_image_row handles horizontal repetition (of a given row) and this loop takes care of the vertical repetition by splitting the primitive into rows.

let layout_stride = info.stretch_size.width + info.tile_spacing.width;
let num_repetitions = (item_rect.size.width / layout_stride).ceil() as u32;
for i in 0..num_repetitions {
if let Some(img_rect) = rect(

This comment has been minimized.

@kvark

kvark Mar 9, 2017

Member

rename to column_rect for consistency?

This comment has been minimized.

@nical

nical Mar 10, 2017

Author Collaborator

I find column_rect a bit misleading in the sense that the rect doesn't describe an entire column of the image but just a single repetition within the current row. Granted img_rect isn't great either since it is not the rect for the entire image.

@nical
Copy link
Collaborator Author

nical commented Mar 10, 2017

For the fuzzy test, if you want to have a look the easiest is to copy paste the entire log in reftest analyzer. The max difference is 1 for a lot of pixels and you can see bands of differing pixels in lines perpendicular to the stretching direction.
It and looks very much like the sampling interpolation rounding differently. The "correct" value for these pixels isn't strictly defined, it's really up to the precision/rounding behavior of the sampler.
I'm currently battling with the headless.py locally (for some reason I'm getting a max texture size of zero which causes a panic as soon as we try to add something to the texture caches).

@nical nical force-pushed the nical:image-repeat-spacing branch from fcb3c39 to 9c8a125 Mar 10, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Mar 10, 2017

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

@nical nical force-pushed the nical:image-repeat-spacing branch from 9c8a125 to 4ebb047 Mar 10, 2017
@kvark
kvark approved these changes Mar 10, 2017
Copy link
Member

kvark left a comment

Thanks for moving the fuzzing out to a separate PR.

I'm currently battling with the headless.py locally

I guess that's the last point of concern then. Please confirm that your headless OSmesa tests match the Travis ones.

@nical
Copy link
Collaborator Author

nical commented Mar 10, 2017

Yep, OSMesa gives me the same result on my desktop as travis (unsurprisingly).

@kvark
Copy link
Member

kvark commented Mar 10, 2017

Great, thanks!
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Mar 10, 2017

📌 Commit 4ebb047 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Mar 10, 2017

Testing commit 4ebb047 with merge 461f188...

bors-servo added a commit that referenced this pull request Mar 10, 2017
Implement repetition and spacing for tiled images.

Followup of PR #897. This should cover the all of the remaining cases when rendering tiled images (image display item specifically).
If the image is tiled and repeated along the same dimension it is decomposed into a primitive for each repetition, taking spacing into account. These primitives are then split in a per tile basis.

<!-- 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/972)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 10, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing 461f188 to master...

@bors-servo bors-servo merged commit 4ebb047 into servo:master Mar 10, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.