diff --git a/gpui/src/platform/mac/renderer.rs b/gpui/src/platform/mac/renderer.rs index 6b3801d649..05f2c14838 100644 --- a/gpui/src/platform/mac/renderer.rs +++ b/gpui/src/platform/mac/renderer.rs @@ -160,7 +160,7 @@ impl Renderer { layer_id, atlas_id, sprite: shaders::GPUISprite { - origin: origin.to_float2(), + origin: origin.floor().to_float2(), size: size.to_float2(), atlas_origin: atlas_origin.to_float2(), color: path.color.to_uchar4(), diff --git a/gpui/src/platform/mac/shaders/shaders.metal b/gpui/src/platform/mac/shaders/shaders.metal index cd4bcb2efb..9f750644d1 100644 --- a/gpui/src/platform/mac/shaders/shaders.metal +++ b/gpui/src/platform/mac/shaders/shaders.metal @@ -193,6 +193,8 @@ vertex SpriteFragmentInput sprite_vertex( }; } +#define MAX_WINDINGS 8. + fragment float4 sprite_fragment( SpriteFragmentInput input [[stage_in]], texture2d atlas [[ texture(GPUISpriteFragmentInputIndexAtlas) ]] @@ -202,7 +204,10 @@ fragment float4 sprite_fragment( float4 sample = atlas.sample(atlas_sampler, input.atlas_position); float mask; if (input.compute_winding) { - mask = fmod(sample.r * 255., 2.); + mask = fmod(sample.r * MAX_WINDINGS, 2.); + if (mask > 1) { + mask = 2. - mask; + } } else { mask = sample.a; } @@ -239,6 +244,6 @@ fragment float4 path_winding_fragment( ); float f = (input.st_position.x * input.st_position.x) - input.st_position.y; float distance = f / length(gradient); - float alpha = saturate(0.5 - distance) / 255.; + float alpha = saturate(0.5 - distance) / MAX_WINDINGS; return float4(alpha, 0., 0., 1.); }