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

text antialiasing issue with opacity < 1 #166

Closed
paulrouget opened this issue Feb 2, 2016 · 8 comments
Closed

text antialiasing issue with opacity < 1 #166

paulrouget opened this issue Feb 2, 2016 · 8 comments

Comments

@paulrouget
Copy link
Collaborator

@paulrouget paulrouget commented Feb 2, 2016

I guess it's an antialiasing issue. The top text here has a dark outline. That makes text opacity animations very ugly.

screen shot 2016-02-02 at 08 39 41

<style>
  body {
    padding: 20px;
    background: rgb(65, 149, 250);
  }
</style>

<div style="opacity: 0.8; color: white">FOOBAR</div>
<div style="opacity: 1.0; color: white">FOOBAR</div>
@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Feb 2, 2016

$10 says it's one of those annoying glBlendFunc()/premultiplied alpha issues.

@glennw
Copy link
Member

@glennw glennw commented Feb 2, 2016

Yep, this is occurring on Linux as well, so probably an issue like @pcwalton mentioned above rather than an issue with the platform font rasterizing.

@glennw glennw mentioned this issue Feb 2, 2016
15 of 15 tasks complete
@glennw
Copy link
Member

@glennw glennw commented Feb 3, 2016

@pcwalton Changing https://github.com/glennw/webrender/blob/master/src/renderer.rs#L988 from 0,0,0,0 -> 1,1,1,0 fixes this issue. However, it introduces artifacts into the box shadows in the ref tests.

I think this is a correct fix - any thoughts on what effect that would have on box shadow and if it can be worked around? I'll investigate further - just posting this in case you know straight away what the issue might be?

@glennw
Copy link
Member

@glennw glennw commented Feb 3, 2016

Interestingly the blur on text_shadow_blur_a.html remains the same with that change (which is a text-shadow), but the blur on text_shadow_blur_ref.html (which is a box shadow) is what starts to show artifacts.

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Feb 3, 2016

@glennw Hmm, but I think our blend mode is wrong if we're relying on (1,1,1,0) instead of (0,0,0,0).

@glennw
Copy link
Member

@glennw glennw commented Feb 3, 2016

I'm not sure what blend mode you would use.

A traditional alpha blend is:

Result.rgb = Dest.rgb*(1-Source.alpha) + Source.rgb * Source.alpha.

Pre-multipled alpha blend is:

Result.rgb = Dest.rgb*(1-Source.alpha) + Source.rgb.

In both cases, the destination color is going to be modulated by the inverse source alpha, so you will get black fringing if drawing text with alpha on a black FBO, which is the case for text with opacity at the moment.

Or is there another alternative?

@glennw
Copy link
Member

@glennw glennw commented Feb 3, 2016

Hmmm, perhaps we could make of separate blend func to store the alpha but just use the color. I'll try that.

@glennw
Copy link
Member

@glennw glennw commented Feb 4, 2016

I have a fix for this, but it exposes an unrelated issue in the texture cache - working on fixing that now.

glennw pushed a commit that referenced this issue Feb 5, 2016
@pcwalton pcwalton closed this in #174 Feb 5, 2016
glennw pushed a commit that referenced this issue Feb 5, 2016
pcwalton added a commit to pcwalton/webrender that referenced this issue Jun 10, 2016
It was disabled as a fix for servo#166, but that caused regressions on pages
that depend on blending. The issues related to the blur on box shadows
discussed in that issue seem to be resolved now, so the clear-color
solution works fine.

Addresses browserhtml/browserhtml#1068.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.