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

Add tiling for gradients #1078

Merged
merged 3 commits into from Apr 6, 2017
Merged

Add tiling for gradients #1078

merged 3 commits into from Apr 6, 2017

Conversation

@eqrion
Copy link
Contributor

eqrion commented Apr 6, 2017

This adds tile_size and tile_spacing fields to linear and radial gradient
display items to control tiling. A gradient is tiled starting at bounds.origin,
with tile size of tile_size and spacing between tiles of tile_spacing. Tiles
will fill and be clipped to bounds.


This change is Reviewable

eqrion added 3 commits Mar 30, 2017
This commit adds `tile_size` and `tile_spacing` fields to linear and
radial gradients. Tiles start at `rect.origin` and are `tile_size` with
`tile_spacing` between each tile.

Tiling is implemented inside the gradient shaders, not by decomposing
the display item into multiple primitives. This has the advantage of
being simple to implement, and in the best case where there is no
spacing it should be just as fast as transforming the gradient into a
repeating gradient.

This has the disadvantage that large tile spacing can cause many
dropped fragments. There may be good reason to investigate decomposing
to multiple primitives in these cases.
@eqrion
Copy link
Contributor Author

eqrion commented Apr 6, 2017

r? @kvark @glennw

I've successfully ran the Servo WPT, CSS tests with this change. On the gecko side this should simplify some code for us and let us create less display items.

@kvark kvark self-requested a review Apr 6, 2017
@kvark
Copy link
Member

kvark commented Apr 6, 2017

The test coverage is really impressive, thank you!
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Apr 6, 2017

📌 Commit e790b58 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Apr 6, 2017

Testing commit e790b58 with merge 4c5d98c...

bors-servo added a commit that referenced this pull request Apr 6, 2017
Add tiling for gradients

This adds `tile_size` and `tile_spacing` fields to linear and radial gradient
display items to control tiling. A gradient is tiled starting at `bounds.origin`,
with tile size of `tile_size` and spacing between tiles of `tile_spacing`. Tiles
will fill and be clipped to `bounds`.

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

bors-servo commented Apr 6, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing 4c5d98c to master...

@bors-servo bors-servo merged commit e790b58 into servo:master Apr 6, 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
@eqrion eqrion deleted the eqrion:gradients-3 branch Apr 6, 2017
@kvark
Copy link
Member

kvark commented Apr 7, 2017

When testing #1087 on the latest, I tried hooking up to servo and made the following change:

-                builder.push_gradient(rect, clip, gradient);
+                builder.push_gradient(rect, clip, gradient, rect.size, webrender_traits::LayoutSize::zero());

And got 2 WPT failures:

  • /_mozilla/css/border-image-linear-gradient.html
  • /_mozilla/css/linear_gradients_parsing_a.html

Could this PR be causing them?
wpt.log.zip

@eqrion
Copy link
Contributor Author

eqrion commented Apr 7, 2017

The log looks like the failures I was seeing when testing #1074.

Can you give it a try with the following diff? It makes gradient start stop relative like the #1074 expects.

diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 8c390487f5..091df7e9c8 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -952,8 +952,8 @@ impl FragmentDisplayListBuilding for Fragment {
             })
         }
 
-        let center = Point2D::new(absolute_bounds.origin.x + absolute_bounds.size.width / 2,
-                                  absolute_bounds.origin.y + absolute_bounds.size.height / 2);
+        let center = Point2D::new(absolute_bounds.size.width / 2,
+                                  absolute_bounds.size.height / 2);
@kvark
Copy link
Member

kvark commented Apr 7, 2017

Ah, right, the change makes sense. Testing now.

@kvark
Copy link
Member

kvark commented Apr 7, 2017

Hmm, still failing in /_mozilla/css/border-image-linear-gradient.html with that change.

@eqrion
Copy link
Contributor Author

eqrion commented Apr 7, 2017

I got the same thing with the patch, but looking at the reftest comparison they are a fuzzy match with 16 or so pixels (IIRC).

Is that what you're getting too?

@kvark
Copy link
Member

kvark commented Apr 7, 2017

@rlhunt indeed, there is about 40 pixels along a horisontal line that show a 1-value difference (33/34) with the reference. Interesting to see why, but not a showstopper.

@glennw
Copy link
Member

glennw commented Apr 7, 2017

@kvark @rlhunt I'm not sure if this is relevant - but the WPT/CSS test runner doesn't (currently) support fuzzy reftests.

@glennw
Copy link
Member

glennw commented Apr 7, 2017

So anything we land in WR has to result in exact matches for the WPT/CSS tests (which we've managed to do OK so far).

@eqrion
Copy link
Contributor Author

eqrion commented Apr 7, 2017

@glennw Okay, I'd be happy to investigate the fuzziness further. I'll take a look at it next chance I get.

I'm not sure the best way to debug something like this, so I'm open to suggestions. I might take a look at renderdoc.

@eqrion eqrion mentioned this pull request Apr 10, 2017
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.