Quantize to subpixel boundaries.
This doesn't break meshes the way the previous "discard if too thin" code did. It fixes several issues observed on Wikipedia when using Pathfinder in Firefox. Closes #72.
This commit is contained in:
parent
6c2c34aa3c
commit
aa3ecf28a5
|
@ -29,9 +29,7 @@ freetype-sys = "0.6"
|
|||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-graphics = "0.13"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies.core-text]
|
||||
git = "https://github.com/servo/core-text-rs.git"
|
||||
core-text = "9.2"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
dwrite-sys = "0.2"
|
||||
|
|
|
@ -100,6 +100,10 @@ vec2 hintPosition(vec2 position, vec4 pathHints) {
|
|||
return vec2(position.x, y);
|
||||
}
|
||||
|
||||
vec2 quantize(vec2 position) {
|
||||
return (floor(position * 10000.0 + 0.5) - 0.5) / 10000.0;
|
||||
}
|
||||
|
||||
/// Converts the given 2D position in clip space to device pixel space (with origin in the lower
|
||||
/// left).
|
||||
vec2 convertClipToScreenSpace(vec2 position, ivec2 framebufferSize) {
|
||||
|
|
|
@ -63,9 +63,9 @@ void main() {
|
|||
mat2 transformLinear = globalTransformLinear * localTransformLinear;
|
||||
|
||||
// Perform the linear component of the transform (everything but translation).
|
||||
fromPosition = transformLinear * fromPosition;
|
||||
ctrlPosition = transformLinear * ctrlPosition;
|
||||
toPosition = transformLinear * toPosition;
|
||||
fromPosition = quantize(transformLinear * fromPosition);
|
||||
ctrlPosition = quantize(transformLinear * ctrlPosition);
|
||||
toPosition = quantize(transformLinear * toPosition);
|
||||
|
||||
// Choose correct quadrant for rotation.
|
||||
vec4 bounds = fetchFloat4Data(uPathBounds, pathID, uPathBoundsDimensions);
|
||||
|
@ -89,9 +89,7 @@ void main() {
|
|||
|
||||
// Compute position and dilate. If too thin, discard to avoid artefacts.
|
||||
vec2 dilation = vec2(0.0), position;
|
||||
if (abs(v02.x) < 0.0001) {
|
||||
position.x = 0.0;
|
||||
} else if (aTessCoord.x < 0.5) {
|
||||
if (aTessCoord.x < 0.5) {
|
||||
position.x = min(min(fromPosition.x, toPosition.x), ctrlPosition.x);
|
||||
dilation.x = -1.0;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue