Page MenuHomePhabricator

Bug 1571974: Simplify orientation handling in line decoration shaders. r?jrmuizel
ClosedPublic

Authored by jimb on Jan 24 2020, 12:59 AM.

Details

Summary

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.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jimb created this revision.Jan 24 2020, 12:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2020, 12:59 AM
phab-bot requested review of this revision.Jan 24 2020, 12:59 AM
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: Restricted Project.
jimb updated this revision to Diff 221957.Jan 24 2020, 6:10 AM
jimb edited the summary of this revision. (Show Details)
jrmuizel edited reviewers, added: kvark; removed: jrmuizel.Jan 24 2020, 3:43 PM

Moving to kvark

kvark requested changes to this revision.Jan 24 2020, 4:49 PM
kvark added inline comments.
gfx/wr/webrender/res/cs_line_decoration.glsl
28

amazing comments!

gfx/wr/webrender/src/renderer.rs
459

this should be F32 now

This revision now requires changes to proceed.Jan 24 2020, 4:49 PM
kvark awarded a token.Jan 24 2020, 4:49 PM
jimb updated this revision to Diff 222306.Jan 24 2020, 9:27 PM
jimb marked an inline comment as done.Jan 24 2020, 9:39 PM
kvark accepted this revision.Jan 24 2020, 9:46 PM
This revision is now accepted and ready to land.Jan 24 2020, 9:46 PM
opoprus reopened this revision.Feb 3 2020, 8:04 PM
This revision is now accepted and ready to land.Feb 3 2020, 8:04 PM