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

Reimplement arbitrary rotation angles for linear gradients by clipping in the fragment shader. #165

Merged
merged 1 commit into from Feb 2, 2016

Conversation

@pcwalton
Copy link
Collaborator

pcwalton commented Feb 2, 2016

This reintroduces the clip-in rect in the FS. Since we'll need it anyway
when we have arbitrary matrix/clip stacks, this seems harmless.

Color strips for non-axis-aligned linear gradients are submitted as
axis-aligned rects centered at the appropriate point, just as
axis-aligned ones are. However, we reuse one of the vertex fields to
store the rotation angle. The vertex shader detects this condition,
rotates the rectangle around its midpoint, and passes the clip rect on
to the fragment shader.

Additionally, this patch eliminates the ugly (-10000,10000) spans for
linear gradient strips that we had before. It was necessary to tighten
this up in order to avoid needless fragment shader invocations in the
non-axis-aligned case, so I went ahead and fixed it everywhere.

Closes #161.

@pcwalton pcwalton force-pushed the pcwalton:gradient-rotation branch 2 times, most recently from f0746e4 to db9bfa2 Feb 2, 2016
@pcwalton
Copy link
Collaborator Author

pcwalton commented Feb 2, 2016

@glennw How's this?

if (PointInRect(vPosition, vClipOutRect.xy, vClipOutRect.zw)) {
discard;
}

// Clip in.
if (vClipInRect != vec4(0.0) && !PointInRect(vPosition, vClipInRect.xy, vClipInRect.zw)) {

This comment has been minimized.

@glennw

glennw Feb 2, 2016

Member

Does it work fine if we remove this conditional now?

@pcwalton pcwalton force-pushed the pcwalton:gradient-rotation branch from db9bfa2 to f005628 Feb 2, 2016
@pcwalton
Copy link
Collaborator Author

pcwalton commented Feb 2, 2016

@glennw Oops, I had that change made locally but forgot to commit. Fixed.

in the fragment shader.

This reintroduces the clip-in rect in the FS. Since we'll need it anyway
when we have arbitrary matrix/clip stacks, this seems harmless.

Color strips for non-axis-aligned linear gradients are submitted as
axis-aligned rects centered at the appropriate point, just as
axis-aligned ones are. However, we reuse one of the vertex fields to
store the rotation angle. The vertex shader detects this condition,
rotates the rectangle around its midpoint, and passes the clip rect on
to the fragment shader.

Additionally, this patch eliminates the ugly (-10000,10000) spans for
linear gradient strips that we had before. It was necessary to tighten
this up in order to avoid needless fragment shader invocations in the
non-axis-aligned case, so I went ahead and fixed it everywhere.

Closes #161.
glennw added a commit that referenced this pull request Feb 2, 2016
Reimplement arbitrary rotation angles for linear gradients by clipping in the fragment shader.
@glennw glennw merged commit 67179c6 into servo:master Feb 2, 2016
@glennw
Copy link
Member

glennw commented Feb 2, 2016

Thanks!

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.

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