diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-08-04 10:59:27 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-08-06 12:21:30 +0200 |
commit | 94d507d9f24fafba92a7bdc6b706fe48be350c48 (patch) | |
tree | 45a63fa245d3781221d233244e41f35dd155e6bb /src/quick | |
parent | 4825b69e054284d8e4d9cd91ac87d307b1431625 (diff) |
Fix regression in antialiasing on outlined text
After e8d9bc1bcada7d94af5a33d64a9afc860ede5b84, outline text would
blend with the background rather than the fill color on the inner
side of the outline. We should do the mix with the fill color like
before this change, but for performance, we should still discard
all pixels which are not part of the outline, which we do using
step() instead of multiplying by 1.0 - a.
Task-number: QTBUG-85514
Change-Id: I4b252bdbd9dae5ee599ba7c5d1cc3609fef61622
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 4da53ed1d6433730d0604b948ba3b5abeabd1eb0)
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/scenegraph/shaders/distancefieldoutlinetext.frag | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders/outlinedtext.frag | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders/outlinedtext_core.frag | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb | bin | 1780 -> 1863 bytes | |||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb | bin | 1771 -> 1876 bytes | |||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/outlinedtext.frag | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb | bin | 2067 -> 2174 bytes | |||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/outlinedtext_a.frag | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb | bin | 1357 -> 1437 bytes |
12 files changed, 12 insertions, 8 deletions
diff --git a/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag b/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag index f7cdeb9064..7a063e0a9d 100644 --- a/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag +++ b/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag @@ -12,5 +12,6 @@ void main() { mediump float d = texture2D(_qt_texture, sampleCoord).a; mediump float a = smoothstep(alphaMin, alphaMax, d); - gl_FragColor = (1.0 - a) * styleColor * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); + gl_FragColor = step(1.0 - a, 1.0) * mix(styleColor, color, a) + * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); } diff --git a/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag b/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag index 622e353019..73cf9a1c29 100644 --- a/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag +++ b/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag @@ -16,5 +16,6 @@ void main() { float d = texture(_qt_texture, sampleCoord).r; float a = smoothstep(alphaMin, alphaMax, d); - fragColor = (1.0 - a) * styleColor * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); + fragColor = step(1.0 - a, 1.0) * mix(styleColor, color, a) + * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); } diff --git a/src/quick/scenegraph/shaders/outlinedtext.frag b/src/quick/scenegraph/shaders/outlinedtext.frag index 5fe2b14e24..1075261d5f 100644 --- a/src/quick/scenegraph/shaders/outlinedtext.frag +++ b/src/quick/scenegraph/shaders/outlinedtext.frag @@ -17,5 +17,5 @@ void main() texture2D(_qt_texture, sCoordRight).a, 0.0, 1.0) - glyph, 0.0, 1.0); - gl_FragColor = outline * styleColor; + gl_FragColor = outline * styleColor + step(1.0 - glyph, 1.0) * glyph * color; } diff --git a/src/quick/scenegraph/shaders/outlinedtext_core.frag b/src/quick/scenegraph/shaders/outlinedtext_core.frag index 4d7c614185..f3273cbdb6 100644 --- a/src/quick/scenegraph/shaders/outlinedtext_core.frag +++ b/src/quick/scenegraph/shaders/outlinedtext_core.frag @@ -21,5 +21,5 @@ void main() texture(_qt_texture, sCoordRight).r, 0.0, 1.0) - glyph, 0.0, 1.0); - fragColor = outline * styleColor; + fragColor = outline * styleColor + step(1.0 - glyph, 1.0) * glyph * color; } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag index 945ef56fee..b1551d8ef4 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag @@ -21,5 +21,6 @@ void main() { float d = texture(_qt_texture, sampleCoord).r; float a = smoothstep(ubuf.alphaMin, ubuf.alphaMax, d); - fragColor = (1.0 - a) * ubuf.styleColor * smoothstep(ubuf.outlineAlphaMax0, ubuf.outlineAlphaMax1, d); + fragColor = step(1.0 - a, 1.0) * mix(ubuf.styleColor, ubuf.color, a) + * smoothstep(ubuf.outlineAlphaMax0, ubuf.outlineAlphaMax1, d); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb Binary files differindex 942db41a5a..eae467fab0 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag index 7ccd06610a..7c6bd9a493 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag @@ -21,5 +21,6 @@ void main() { float d = texture(_qt_texture, sampleCoord).a; float a = smoothstep(ubuf.alphaMin, ubuf.alphaMax, d); - fragColor = (1.0 - a) * ubuf.styleColor * smoothstep(ubuf.outlineAlphaMax0, ubuf.outlineAlphaMax1, d); + fragColor = step(1.0 - a, 1.0) * mix(ubuf.styleColor, ubuf.color, a) + * smoothstep(ubuf.outlineAlphaMax0, ubuf.outlineAlphaMax1, d); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb Binary files differindex 00e0497248..d02e1d4c7f 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.frag b/src/quick/scenegraph/shaders_ng/outlinedtext.frag index aac9e4bff8..947d161a50 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.frag +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.frag @@ -29,5 +29,5 @@ void main() texture(_qt_texture, sCoordRight).r, 0.0, 1.0) - glyph, 0.0, 1.0); - fragColor = outline * ubuf.styleColor; + fragColor = outline * ubuf.styleColor + step(1.0 - glyph, 1.0) * glyph * ubuf.color; } diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb Binary files differindex 95924de0c8..1756ee9d4b 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag index 481d8c94d0..5b7bd9ca82 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag @@ -29,5 +29,5 @@ void main() texture(_qt_texture, sCoordRight).a, 0.0, 1.0) - glyph, 0.0, 1.0); - fragColor = outline * ubuf.styleColor; + fragColor = outline * ubuf.styleColor + step(1.0 - glyph, 1.0) * glyph * ubuf.color; } diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb Binary files differindex ddceb17a94..f44b92dc28 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb |