Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Respect paths' content masks when copying them from MSAA texture to drawable (#35688)
Max Brunsfeld40129147c64f
diff --git a/crates/gpui/src/platform/blade/blade_renderer.rs b/crates/gpui/src/platform/blade/blade_renderer.rsindex 2e18d2be222..46d3c16c72a 100644--- a/crates/gpui/src/platform/blade/blade_renderer.rs+++ b/crates/gpui/src/platform/blade/blade_renderer.rs@@ -606,7 +606,7 @@ impl BladeRenderer {xy_position: v.xy_position,st_position: v.st_position,color: path.color,- bounds: path.bounds.intersect(&path.content_mask.bounds),+ bounds: path.clipped_bounds(),}));}let vertex_buf = unsafe { self.instance_belt.alloc_typed(&vertices, &self.gpu) };@@ -735,13 +735,13 @@ impl BladeRenderer {paths.iter().map(|path| PathSprite {- bounds: path.bounds,+ bounds: path.clipped_bounds(),}).collect()} else {- let mut bounds = first_path.bounds;+ let mut bounds = first_path.clipped_bounds();for path in paths.iter().skip(1) {- bounds = bounds.union(&path.bounds);+ bounds = bounds.union(&path.clipped_bounds());}vec![PathSprite { bounds }]};diff --git a/crates/gpui/src/platform/mac/metal_renderer.rs b/crates/gpui/src/platform/mac/metal_renderer.rsindex fb5cb852d65..629654014d5 100644--- a/crates/gpui/src/platform/mac/metal_renderer.rs+++ b/crates/gpui/src/platform/mac/metal_renderer.rs@@ -791,13 +791,13 @@ impl MetalRenderer {sprites = paths.iter().map(|path| PathSprite {- bounds: path.bounds,+ bounds: path.clipped_bounds(),}).collect();} else {- let mut bounds = first_path.bounds;+ let mut bounds = first_path.clipped_bounds();for path in paths.iter().skip(1) {- bounds = bounds.union(&path.bounds);+ bounds = bounds.union(&path.clipped_bounds());}sprites = vec![PathSprite { bounds }];}diff --git a/crates/gpui/src/platform/windows/directx_renderer.rs b/crates/gpui/src/platform/windows/directx_renderer.rsindex 72cc12a5b4a..ac285b79ace 100644--- a/crates/gpui/src/platform/windows/directx_renderer.rs+++ b/crates/gpui/src/platform/windows/directx_renderer.rs@@ -435,7 +435,7 @@ impl DirectXRenderer {xy_position: v.xy_position,st_position: v.st_position,color: path.color,- bounds: path.bounds.intersect(&path.content_mask.bounds),+ bounds: path.clipped_bounds(),}));}@@ -487,13 +487,13 @@ impl DirectXRenderer {paths.iter().map(|path| PathSprite {- bounds: path.bounds,+ bounds: path.clipped_bounds(),}).collect::<Vec<_>>()} else {- let mut bounds = first_path.bounds;+ let mut bounds = first_path.clipped_bounds();for path in paths.iter().skip(1) {- bounds = bounds.union(&path.bounds);+ bounds = bounds.union(&path.clipped_bounds());}vec![PathSprite { bounds }]};diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rsindex ec8d720cdfa..c527dfe750b 100644--- a/crates/gpui/src/scene.rs+++ b/crates/gpui/src/scene.rs@@ -8,7 +8,12 @@ use crate::{AtlasTextureId, AtlasTile, Background, Bounds, ContentMask, Corners, Edges, Hsla, Pixels,Point, Radians, ScaledPixels, Size, bounds_tree::BoundsTree, point,};-use std::{fmt::Debug, iter::Peekable, ops::Range, slice};+use std::{+ fmt::Debug,+ iter::Peekable,+ ops::{Add, Range, Sub},+ slice,+};#[allow(non_camel_case_types, unused)]pub(crate) type PathVertex_ScaledPixels = PathVertex<ScaledPixels>;@@ -793,6 +798,16 @@ impl Path<Pixels> {}}+impl<T> Path<T>+where+ T: Clone + Debug + Default + PartialEq + PartialOrd + Add<T, Output = T> + Sub<Output = T>,+{+ #[allow(unused)]+ pub(crate) fn clipped_bounds(&self) -> Bounds<T> {+ self.bounds.intersect(&self.content_mask.bounds)+ }+}+impl From<Path<ScaledPixels>> for Primitive {fn from(path: Path<ScaledPixels>) -> Self {Primitive::Path(path)