From d895388809663cb4e22e8d3817faf5b244c3a8c5 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 23 Feb 2024 23:33:45 -0800 Subject: [PATCH] linux: profile text system functions --- crates/gpui/src/platform/linux/text_system.rs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/gpui/src/platform/linux/text_system.rs b/crates/gpui/src/platform/linux/text_system.rs index e4ed7a43cf..497d615588 100644 --- a/crates/gpui/src/platform/linux/text_system.rs +++ b/crates/gpui/src/platform/linux/text_system.rs @@ -1,22 +1,19 @@ -//todo!(linux) remove -#[allow(unused)] -use crate::{point, size, FontStyle, FontWeight, Point, ShapedGlyph}; use crate::{ - Bounds, DevicePixels, Font, FontFeatures, FontId, FontMetrics, FontRun, GlyphId, LineLayout, - Pixels, PlatformTextSystem, RenderGlyphParams, SharedString, Size, + point, size, Bounds, DevicePixels, Font, FontFeatures, FontId, FontMetrics, FontRun, FontStyle, + FontWeight, GlyphId, LineLayout, Pixels, PlatformTextSystem, Point, RenderGlyphParams, + ShapedGlyph, SharedString, Size, }; -use anyhow::Ok; -use anyhow::Result; -use anyhow::{anyhow, Context}; +use anyhow::{anyhow, Context, Ok, Result}; use collections::HashMap; -use cosmic_text::fontdb::Query; use cosmic_text::{ - Attrs, AttrsList, BufferLine, CacheKey, Family, Font as CosmicTextFont, FontSystem, SwashCache, + fontdb::Query, Attrs, AttrsList, BufferLine, CacheKey, Family, Font as CosmicTextFont, + FontSystem, SwashCache, }; use parking_lot::{RwLock, RwLockUpgradableReadGuard}; -use pathfinder_geometry::rect::RectF; -use pathfinder_geometry::rect::RectI; -use pathfinder_geometry::vector::{Vector2F, Vector2I}; +use pathfinder_geometry::{ + rect::{RectF, RectI}, + vector::{Vector2F, Vector2I}, +}; use smallvec::SmallVec; use std::{borrow::Cow, sync::Arc}; @@ -197,6 +194,7 @@ impl PlatformTextSystem for LinuxTextSystem { } impl LinuxTextSystemState { + #[profiling::function] fn add_fonts(&mut self, fonts: Vec>) -> Result<()> { let db = self.font_system.db_mut(); for bytes in fonts { @@ -212,6 +210,7 @@ impl LinuxTextSystemState { Ok(()) } + #[profiling::function] fn load_family( &mut self, name: &SharedString, @@ -289,6 +288,7 @@ impl LinuxTextSystemState { }) } + #[profiling::function] fn rasterize_glyph( &mut self, params: &RenderGlyphParams, @@ -321,6 +321,7 @@ impl LinuxTextSystemState { } // todo!(linux) This is all a quick first pass, maybe we should be using cosmic_text::Buffer + #[profiling::function] fn layout_line(&mut self, text: &str, font_size: Pixels, font_runs: &[FontRun]) -> LineLayout { let mut attrs_list = AttrsList::new(Attrs::new()); let mut offs = 0;