Revert "Revert recent anti-aliasing improvements (#24289)" and fix selection top right corner radius issue (#24342)

Release Notes:

- N/A

----

To fix #24289 mention issue and revert PathBuilder and MSAA.

I'm sorry about of this, in #22808 I was forgotten this bit of detail.


![image](https://github.com/user-attachments/assets/112afda2-088c-41d0-83bd-808f6cd2f9d5)

So, add `move_to` here, we can fix the selection top right corner radius
issue.

## After change

<img width="1383" alt="image"
src="https://github.com/user-attachments/assets/28ea103c-d652-41d6-bbe0-7fd042d81e77"
/>
This commit is contained in:
Jason Lee 2025-02-06 17:03:23 +08:00 committed by GitHub
parent 1f2205d75c
commit f08b1d78ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 586 additions and 113 deletions

View file

@ -8149,8 +8149,9 @@ impl HighlightedRange {
};
let top_curve_width = curve_width(first_line.start_x, first_line.end_x);
let mut path = gpui::Path::new(first_top_right - top_curve_width);
path.curve_to(first_top_right + curve_height, first_top_right);
let mut builder = gpui::PathBuilder::fill();
builder.move_to(first_top_right - top_curve_width);
builder.curve_to(first_top_right + curve_height, first_top_right);
let mut iter = lines.iter().enumerate().peekable();
while let Some((ix, line)) = iter.next() {
@ -8161,42 +8162,42 @@ impl HighlightedRange {
match next_top_right.x.partial_cmp(&bottom_right.x).unwrap() {
Ordering::Equal => {
path.line_to(bottom_right);
builder.line_to(bottom_right);
}
Ordering::Less => {
let curve_width = curve_width(next_top_right.x, bottom_right.x);
path.line_to(bottom_right - curve_height);
builder.line_to(bottom_right - curve_height);
if self.corner_radius > Pixels::ZERO {
path.curve_to(bottom_right - curve_width, bottom_right);
builder.curve_to(bottom_right - curve_width, bottom_right);
}
path.line_to(next_top_right + curve_width);
builder.line_to(next_top_right + curve_width);
if self.corner_radius > Pixels::ZERO {
path.curve_to(next_top_right + curve_height, next_top_right);
builder.curve_to(next_top_right + curve_height, next_top_right);
}
}
Ordering::Greater => {
let curve_width = curve_width(bottom_right.x, next_top_right.x);
path.line_to(bottom_right - curve_height);
builder.line_to(bottom_right - curve_height);
if self.corner_radius > Pixels::ZERO {
path.curve_to(bottom_right + curve_width, bottom_right);
builder.curve_to(bottom_right + curve_width, bottom_right);
}
path.line_to(next_top_right - curve_width);
builder.line_to(next_top_right - curve_width);
if self.corner_radius > Pixels::ZERO {
path.curve_to(next_top_right + curve_height, next_top_right);
builder.curve_to(next_top_right + curve_height, next_top_right);
}
}
}
} else {
let curve_width = curve_width(line.start_x, line.end_x);
path.line_to(bottom_right - curve_height);
builder.line_to(bottom_right - curve_height);
if self.corner_radius > Pixels::ZERO {
path.curve_to(bottom_right - curve_width, bottom_right);
builder.curve_to(bottom_right - curve_width, bottom_right);
}
let bottom_left = point(line.start_x, bottom_right.y);
path.line_to(bottom_left + curve_width);
builder.line_to(bottom_left + curve_width);
if self.corner_radius > Pixels::ZERO {
path.curve_to(bottom_left - curve_height, bottom_left);
builder.curve_to(bottom_left - curve_height, bottom_left);
}
}
}
@ -8204,24 +8205,26 @@ impl HighlightedRange {
if first_line.start_x > last_line.start_x {
let curve_width = curve_width(last_line.start_x, first_line.start_x);
let second_top_left = point(last_line.start_x, start_y + self.line_height);
path.line_to(second_top_left + curve_height);
builder.line_to(second_top_left + curve_height);
if self.corner_radius > Pixels::ZERO {
path.curve_to(second_top_left + curve_width, second_top_left);
builder.curve_to(second_top_left + curve_width, second_top_left);
}
let first_bottom_left = point(first_line.start_x, second_top_left.y);
path.line_to(first_bottom_left - curve_width);
builder.line_to(first_bottom_left - curve_width);
if self.corner_radius > Pixels::ZERO {
path.curve_to(first_bottom_left - curve_height, first_bottom_left);
builder.curve_to(first_bottom_left - curve_height, first_bottom_left);
}
}
path.line_to(first_top_left + curve_height);
builder.line_to(first_top_left + curve_height);
if self.corner_radius > Pixels::ZERO {
path.curve_to(first_top_left + top_curve_width, first_top_left);
builder.curve_to(first_top_left + top_curve_width, first_top_left);
}
path.line_to(first_top_right - top_curve_width);
builder.line_to(first_top_right - top_curve_width);
window.paint_path(path, self.color);
if let Ok(path) = builder.build() {
window.paint_path(path, self.color);
}
}
}