Skip to content

Add API on stacking contexts to configure glyph raster mode. #2673

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

Merged
merged 1 commit into from
Apr 20, 2018

Conversation

glennw
Copy link
Member

@glennw glennw commented Apr 19, 2018

This allows configuring per-stacking context whether glyphs are
rasterized in screen space or local space.

Also add a reftest for the raster modes.

In the future, we may want to change this to be a more general
raster mode for all primitives and/or allow an individual scale
value for x/y in local space mode.


This change is Reviewable

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

r? @gankro

@staktrace heads up that this adds a new parameter to push_stacking_context.

If you pass GlyphRasterSpace::Screen here unconditionally, this will maintain current behaviour.

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

NOTE: The scale parameter for local space glyph rasterization is currently ignored. I plan to support using that as a follow up.

@glennw glennw force-pushed the local-glyph-mode branch 2 times, most recently from ae1e47c to dd5a1e5 Compare April 19, 2018 08:16
@staktrace
Copy link
Contributor

@glennw Noted, thanks!

@Gankra
Copy link
Contributor

Gankra commented Apr 19, 2018

Reviewed 22 of 22 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


webrender/src/display_list_flattener.rs, line 337 at r1 (raw file):

            root_scroll_node,
            None,
            GlyphRasterSpace::Local(1.0),

Why should the root be rendered in local space? (why isn't this forcing everything to be greyscale?)


webrender_api/src/display_item.rs, line 476 at r1 (raw file):

//           this change occurs, we'll update the naming of this.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum GlyphRasterSpace {

This needs to be marked #[repr(u8)] to be used in a public API (forces a well-defined and stable layout that cbindgen knows about).


Comments from Reviewable

@Gankra
Copy link
Contributor

Gankra commented Apr 19, 2018

overall looks good, just one question and an easy fix to the type decl.

r=me with those addressed.

@glennw glennw force-pushed the local-glyph-mode branch from dd5a1e5 to cb6f329 Compare April 19, 2018 20:35
@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

Review status: 20 of 22 files reviewed at latest revision, 2 unresolved discussions.


webrender/src/display_list_flattener.rs, line 337 at r1 (raw file):

Previously, Gankro (Alexis Beingessner) wrote…

Why should the root be rendered in local space? (why isn't this forcing everything to be greyscale?)

The root stacking context here never actually contains any elements - it contains the user supplied stacking contexts. I changed it to screen for consistency though.


webrender_api/src/display_item.rs, line 476 at r1 (raw file):

Previously, Gankro (Alexis Beingessner) wrote…

This needs to be marked #[repr(u8)] to be used in a public API (forces a well-defined and stable layout that cbindgen knows about).

Done.


Comments from Reviewable

@mstange
Copy link
Contributor

mstange commented Apr 19, 2018

What happens if you have a stacking context with GlyphRasterSpace::Local, and then inside of that, you have a stacking context with GlyphRasterSpace::Screen? Does GlyphRasterSpace::Screen take effect? Or does the inner stacking context rasterize glyphs in the local space of the closest ancestor stacking context with GlyphRasterSpace::Local?

In Gecko, we'll want to use GlyphRasterSpace::Local for animated transforms. However, if there's a non-animated transform inside an animated transform, we don't want to rasterize that inner transform's glyphs in screen space.

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

@mstange It only references the direct parent stacking context. It sounds like this will match the behaviour you want?

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

Oh, I misread - you want the opposite to what it does now.

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

@mstange So the options are either that Gecko needs to know about the hierarchy and specify Local in that case for the inner stacking context, or WR can implicitly match that.

WR does have access to the complete stacking context stack at the flatten step, so it's easy to do that as a follow up, if that's easiest for Gecko?

@mstange
Copy link
Contributor

mstange commented Apr 19, 2018

Hmm, I think it would be very easy to do this on the Gecko side. The WebRenderCommandsBuilder can just have a boolean field that says "am I inside an animated transform at the moment".

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

The GlyphRasterSpace enum is exposing an apparent compiler bug when used with the repr(u8) tag - the condition https://github.com/servo/webrender/pull/2673/files#diff-33603c013bcfbe19d5d30c93a810759aL648 appears to get evaluated incorrectly during the writing-modes-ref.yaml reftest.

I added a commit that removes the f32 from that enum, which is currently unused, and that works around the compiler bug.

The previous commit can be used as a test case for this compiler bug - I have not managed to reduce it to a smaller case yet.

@glennw
Copy link
Member Author

glennw commented Apr 19, 2018

re-r? @gankro based on the above comment.

Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

r=me with nit

(stacking_context.allow_subpixel_aa, stacking_context.glyph_raster_space)
}
None => {
(true, GlyphRasterSpace::Local(1.0))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be ScreenSpace too?

This allows configuring per-stacking context whether glyphs are
rasterized in screen space or local space.

Also add a reftest for the raster modes.

In the future, we may want to change this to be a more general
raster mode for all primitives and/or allow an individual scale
value for x/y in local space mode.
@glennw glennw force-pushed the local-glyph-mode branch from fd7d2e3 to 2646fa2 Compare April 20, 2018 01:31
@Gankra
Copy link
Contributor

Gankra commented Apr 20, 2018

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 2646fa2 has been approved by Gankro

@bors-servo
Copy link
Contributor

⌛ Testing commit 2646fa2 with merge eb9415a...

bors-servo pushed a commit that referenced this pull request Apr 20, 2018
Add API on stacking contexts to configure glyph raster mode.

This allows configuring per-stacking context whether glyphs are
rasterized in screen space or local space.

Also add a reftest for the raster modes.

In the future, we may want to change this to be a more general
raster mode for all primitives and/or allow an individual scale
value for x/y in local space mode.

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

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: Gankro
Pushing eb9415a to master...

@bors-servo bors-servo merged commit 2646fa2 into servo:master Apr 20, 2018
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.

6 participants