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

Gradient not painted correctly #161

Closed
paulrouget opened this issue Feb 1, 2016 · 7 comments
Closed

Gradient not painted correctly #161

paulrouget opened this issue Feb 1, 2016 · 7 comments

Comments

@paulrouget
Copy link
Collaborator

@paulrouget paulrouget commented Feb 1, 2016

<style>
  div {
    width: 50px;
    height: 50px;
    background-color: #00f;
    margin: 20px;
  }
</style>

<div style="background-image: linear-gradient(135deg, #F00 50%, transparent 50%)"></div>
<div style="background-image: linear-gradient(135deg, #F00,     transparent 50%)"></div>

screen shot 2016-02-01 at 11 31 19

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Feb 1, 2016

Yeah, this is the issue whereby we don't tessellate non-axis-aligned gradients.

I now feel like the best solution to this problem may be to just use the upgraded clip rect infrastructure, when we have it—i.e. clip out in the fragment shader. That will depend on a bit of infrastructure we don't yet have, though: the matrix/clip stack.

@paulrouget, would it be better if I rendered the gradient correctly, but spilling outside the box, for now until we have that infrastructure? I can do that real quick if that's an improvement.

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Feb 1, 2016

Dependency: #154.

@paulrouget
Copy link
Collaborator Author

@paulrouget paulrouget commented Feb 2, 2016

@paulrouget, would it be better if I rendered the gradient correctly, but spilling outside the box, for now until we have that infrastructure? I can do that real quick if that's an improvement.

Spilling will be a problem too.

We can use a PNG instead of a linear-gradient for now.

@paulrouget
Copy link
Collaborator Author

@paulrouget paulrouget commented Feb 2, 2016

P1 -> P2. Browserhtml workaround: browserhtml/browserhtml#861

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Feb 2, 2016

Actually, I'll fix it for real. :)

pcwalton added a commit that referenced this issue Feb 2, 2016
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.
@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Feb 2, 2016

@paulrouget I have a fix ready. Sorry for making you go through the work of making a PNG workaround.

pcwalton added a commit to pcwalton/webrender that referenced this issue Feb 2, 2016
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 servo#161.
pcwalton added a commit to pcwalton/webrender that referenced this issue Feb 2, 2016
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 servo#161.
pcwalton added a commit to pcwalton/webrender that referenced this issue Feb 2, 2016
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 servo#161.
pcwalton added a commit to pcwalton/webrender that referenced this issue Feb 2, 2016
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 servo#161.
@glennw glennw closed this in #165 Feb 2, 2016
@paulrouget
Copy link
Collaborator Author

@paulrouget paulrouget commented Feb 3, 2016

This doesn't appear to be fixed.

I see this now:

screen shot 2016-02-03 at 06 50 46

@paulrouget paulrouget reopened this Feb 3, 2016
pcwalton added a commit to pcwalton/webrender that referenced this issue Feb 5, 2016
1. When the first stop of a gradient was not at position 0%, WebRender
   did not draw the solid color from 0% to that first stop, in violation
   of CSS-IMAGES-3.

2. Certain gradient angles would cause the segments to be too narrow.
   This patch fixes this by correcting the trigonometric calculations.

Closes servo#161.
@glennw glennw closed this in #175 Feb 5, 2016
zakorgy pushed a commit to zakorgy/webrender that referenced this issue May 7, 2018
Update gfx to 3af6c00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.