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

Fix alpha fading on subpixel text. #1886

Merged
merged 1 commit into from Oct 17, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -89,10 +89,10 @@ void main(void) {
modulate_color = alpha * vColor;
break;
case MODE_SUBPX_PASS0:
modulate_color = vec4(alpha);
modulate_color = vec4(alpha) * vColor.a;
break;
case MODE_SUBPX_PASS1:
modulate_color = vColor;
modulate_color = alpha * vColor;
break;
}

@@ -1162,7 +1162,7 @@ impl FrameBuilder {
font.variations.clone(),
font.synthetic_italics,
);
let mut prim = TextRunPrimitiveCpu {
let prim = TextRunPrimitiveCpu {
font: prim_font,
glyph_range,
glyph_count,
@@ -1187,12 +1187,6 @@ impl FrameBuilder {
if shadow.blur_radius == 0.0 {
let mut text_prim = prim.clone();
text_prim.font.color = shadow.color.into();
// If we have translucent text, we need to ensure it won't go
// through the subpixel blend mode, which doesn't work with
// traditional alpha blending.
if shadow.color.a != 1.0 {
text_prim.font.render_mode = text_prim.font.render_mode.limit_by(FontRenderMode::Alpha);
}
text_prim.offset += shadow.offset;
fast_shadow_prims.push((idx, text_prim));
}
@@ -1211,12 +1205,6 @@ impl FrameBuilder {
self.shadow_prim_stack[idx].1.push((prim_index, clip_and_scroll));
}

// We defer this until after fast-shadows so that shadows of transparent text
// get subpixel-aa
if color.a != 1.0 {
prim.font.render_mode = prim.font.render_mode.limit_by(FontRenderMode::Alpha);
}

// Create (and add to primitive store) the primitive that will be
// used for both the visual element and also the shadow(s).
let prim_index = self.create_primitive(
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -163,7 +163,7 @@ root:
origin: 20 410
size: 32
font: "FreeSans.ttf"
color: [50, 50, 50, 0.1]
color: [50, 50, 50, 0.5]

- type: rect
bounds: [270, 370, 250, 50]
@@ -172,7 +172,7 @@ root:
origin: 280 410
size: 32
font: "FreeSans.ttf"
color: [50, 50, 50, 0.1]
color: [50, 50, 50, 0.5]

- type: rect
bounds: [530, 370, 250, 50]
@@ -181,7 +181,7 @@ root:
origin: 540 410
size: 32
font: "FreeSans.ttf"
color: [50, 50, 50, 0.1]
color: [50, 50, 50, 0.5]

- type: rect
bounds: [10, 430, 250, 50]
@@ -190,7 +190,7 @@ root:
origin: 20 470
size: 32
font: "FreeSans.ttf"
color: [50, 50, 50, 0.1]
color: [50, 50, 50, 0.5]

- type: rect
bounds: [270, 430, 250, 50]
@@ -199,7 +199,7 @@ root:
origin: 280 470
size: 32
font: "FreeSans.ttf"
color: [50, 50, 50, 0.1]
color: [50, 50, 50, 0.5]

- type: rect
bounds: [530, 430, 250, 50]
@@ -208,4 +208,4 @@ root:
origin: 540 470
size: 32
font: "FreeSans.ttf"
color: [50, 50, 50, 0.1]
color: [50, 50, 50, 0.5]
@@ -28,8 +28,10 @@ options(disable-subpixel) == ahem.yaml ahem-ref.yaml
platform(linux) == isolated-text.yaml isolated-text.png
platform(mac) == white-opacity.yaml white-opacity.png
fuzzy(1,4) platform(linux) options(disable-subpixel) == colors.yaml colors-alpha.png
fuzzy(1,2) platform(linux) == colors.yaml colors-subpx.png
fuzzy(1,4) platform(linux) == colors.yaml colors-subpx.png
platform(linux) options(disable-subpixel) == border-radius.yaml border-radius-alpha.png
platform(linux) == border-radius.yaml border-radius-subpx.png
options(disable-aa) == transparent-no-aa.yaml transparent-no-aa-ref.yaml
!= diacritics.yaml diacritics-ref.yaml
fuzzy(1,1) platform(linux) options(disable-subpixel) == text-masking.yaml text-masking-alpha.png
fuzzy(1,44) platform(linux) == text-masking.yaml text-masking-subpx.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,28 @@
---
root:
items:
- bounds: [0, 0, 750, 100]
"clip-rect": [0, 0, 750, 100]
"clip-and-scroll": 0
type: rect
color: [180, 180, 180]
- bounds: [0, 0, 750, 100]
"clip-rect": [0, 0, 750, 100]
type: clip
id: 1
"content-size": [750, 100]
"image-mask":
image: "text-masking-mask.png"
rect: [0, 0, 750, 100]
repeat: false
- text: "Cats making all the muffins knock over christmas tree"
origin: 40 40
size: 20
"clip-and-scroll": 1
font: "FreeSans.ttf"
- text: "Cats making all the muffins knock over christmas tree"
origin: 40 80
size: 20
color: white
"clip-and-scroll": 1
font: "FreeSans.ttf"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.