Skip to content

Commit

Permalink
Add 2x to blade.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Nov 26, 2024
1 parent e9e430d commit 5f895fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/gpui/examples/painting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl PaintingViewer {
path.line_to(point(px(60.), px(100.)));
path.line_to(point(px(80.), px(140.)));
// go back to close the path
path.line_to(point(px(81.), px(141.)));
path.move_to(point(px(81.), px(141.)));
path.line_to(point(px(60.), px(101.)));
path.line_to(point(px(50.), px(161.)));
path.line_to(point(px(20.), px(101.)));
Expand Down
19 changes: 13 additions & 6 deletions crates/gpui/src/platform/blade/blade_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{BladeAtlas, PATH_TEXTURE_FORMAT};
use crate::{
AtlasTextureKind, AtlasTile, Bounds, ContentMask, DevicePixels, GPUSpecs, Hsla,
MonochromeSprite, Path, PathId, PathVertex, PolychromeSprite, PrimitiveBatch, Quad,
ScaledPixels, Scene, Shadow, Size, Underline,
ScaledPixels, Scene, Shadow, Size, Underline, PATH_SUBPIXEL_VARIANTS,
};
use bytemuck::{Pod, Zeroable};
use collections::HashMap;
Expand Down Expand Up @@ -622,12 +622,19 @@ impl BladeRenderer {
for path in paths {
let tile = &self.path_tiles[&path.id];
let tex_info = self.atlas.get_texture_info(tile.texture_id);
let origin = path.bounds.intersect(&path.content_mask.bounds).origin;
let origin = path
.bounds
.intersect(&path.content_mask.bounds)
.origin
.map(|p| (p / PATH_SUBPIXEL_VARIANTS).floor());
let size = tile
.bounds
.size
.map(|s| s / PATH_SUBPIXEL_VARIANTS as i32)
.map(Into::into);

let sprites = [PathSprite {
bounds: Bounds {
origin: origin.map(|p| p.floor()),
size: tile.bounds.size.map(Into::into),
},
bounds: Bounds { origin, size },
color: path.color,
tile: (*tile).clone(),
}];
Expand Down
5 changes: 3 additions & 2 deletions crates/gpui/src/platform/mac/metal_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,11 @@ impl MetalRenderer {
.intersect(&path.content_mask.bounds)
.origin
.map(|p| (p / PATH_SUBPIXEL_VARIANTS).floor());
let size = path
let size = tile
.bounds
.size
.map(|s| (s / PATH_SUBPIXEL_VARIANTS).floor());
.map(|s| s / PATH_SUBPIXEL_VARIANTS as i32)
.map(Into::into);
sprites.push(PathSprite {
bounds: Bounds { origin, size },
color: path.color,
Expand Down

0 comments on commit 5f895fd

Please sign in to comment.