Closed Bug 1571974 Opened 5 years ago Closed 4 years ago

[wr-intro] Change cs_line_decoration to pass pre-swizzled width / height values.

Categories

(Core :: Graphics: WebRender, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: gw, Assigned: jimb)

References

Details

Attachments

(3 files)

We could (probably?) optimize or simplify the vertex and fragment shaders in the line decoration cache shader a bit by providing the data from the CPU in a pre-swizzled format, depending on the orientation of the line.

Context: https://github.com/servo/webrender/issues/3189

Blocks: wr-intro
Priority: -- → P3
Assignee: nobody → jimb
Status: NEW → ASSIGNED

Without this change, get_line_decoration_sizes returns an (inline_size,
block_size) pair, where inline_size is parallel to the line being decorated, and
block_size perpendicular. However, these values are generally used as the
dimensions of an axis-aligned bounding box for the line, not as specific
parameters to the rendering process, so it makes sense to arrange them into a
LayoutSize value in this function, since it is already taking the orientation
into account anyway.

The caller, SceneBuilder::add_line, then doesn't need to swap the components,
and the adjustment of the clipping rectangle to avoid partial dots looks a bit
more natural: widths with widths, heights with heights.

Depends on D60924

We want to use the same line decoration (dashed, dotted, wavy) shader code for
both horizontal and vertical lines, so it makes sense for them to use a
coordinate system that has been rotated (transposed, actually) so that .x always
runs parallel to the line being decorated, and .y is always perpendicular.

Before this patch, we passed the orientation enum as a vertex attribute, used a
switch to swap coordinates in the vertex shader, and then swapped them again in
the fragment shader.

This patch trades the orientation for a f32 'axis select' vertex attribute, and
uses mix to swap them in the vertex shader. Then no consideration is necessary
in the fragment shader: the vLocalPos varying is already in the appropriate form.

Since get_line_decoration_sizes is already thinking in terms of line-parallel
coordinates, it might seem like a good idea for decoration jobs to simply use
line-parallel coordinates throughout. However, this actually results in more
swapping and opportunities for confusion: much of the CPU work is concerned with
the rectangle the decoration's mask occupies in the texture cache, which is
axis-aligned.

Depends on D60925

Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7c493fcca41f
Implement Debug for render_target::LineDecorationJob. r=jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
Attachment #9122813 - Attachment description: Bug 1571974: Make prim_store::get_line_decoration_sizes return an oriented LayoutSize. r?jrmuizel → Bug 1571974: Make prim_store::get_line_decoration_sizes return an oriented LayoutSize. r?kvark
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3549dd471446
Make prim_store::get_line_decoration_sizes return an oriented LayoutSize. r=kvark
https://hg.mozilla.org/integration/autoland/rev/dfb21632ea19
Simplify orientation handling in line decoration shaders. r=kvark
Backout by opoprus@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/801277ae423f
Backed out 2 changesets for turning bug 1518179 into perma bc failures. on a CLOSED TREE
Pushed by opoprus@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9f54a1daf2f2
Make prim_store::get_line_decoration_sizes return an oriented LayoutSize. r=kvark
https://hg.mozilla.org/integration/autoland/rev/71ce2bbd8188
Simplify orientation handling in line decoration shaders. r=kvark
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: