diff --git a/crates/gpui/src/platform/mac.rs b/crates/gpui/src/platform/mac.rs index 1d2f5fc8ae..4ff73fcff2 100644 --- a/crates/gpui/src/platform/mac.rs +++ b/crates/gpui/src/platform/mac.rs @@ -13,6 +13,7 @@ use cocoa::base::{BOOL, NO, YES}; pub use dispatcher::Dispatcher; pub use fonts::FontSystem; use platform::{MacForegroundPlatform, MacPlatform}; +pub use renderer::Surface; use std::{rc::Rc, sync::Arc}; use window::Window; diff --git a/crates/gpui/src/platform/mac/renderer.rs b/crates/gpui/src/platform/mac/renderer.rs index 8fdbda15e8..711d9e48b5 100644 --- a/crates/gpui/src/platform/mac/renderer.rs +++ b/crates/gpui/src/platform/mac/renderer.rs @@ -37,6 +37,10 @@ struct PathSprite { shader_data: shaders::GPUISprite, } +pub struct Surface { + pub bounds: RectF, +} + impl Renderer { pub fn new( device: metal::Device, diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 086af5f64d..00b8d3c88b 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -10,7 +10,7 @@ use crate::{ fonts::{FontId, GlyphId}, geometry::{rect::RectF, vector::Vector2F}, json::ToJson, - platform::CursorStyle, + platform::{current::Surface, CursorStyle}, ImageData, }; pub use mouse_region::*; @@ -34,6 +34,7 @@ pub struct Layer { quads: Vec, underlines: Vec, images: Vec, + surfaces: Vec, shadows: Vec, glyphs: Vec, image_glyphs: Vec, @@ -249,6 +250,10 @@ impl Scene { self.active_layer().push_image(image) } + pub fn push_surface(&mut self, surface: Surface) { + self.active_layer().push_surface(surface) + } + pub fn push_underline(&mut self, underline: Underline) { self.active_layer().push_underline(underline) } @@ -329,6 +334,7 @@ impl Layer { quads: Default::default(), underlines: Default::default(), images: Default::default(), + surfaces: Default::default(), shadows: Default::default(), image_glyphs: Default::default(), glyphs: Default::default(), @@ -391,6 +397,12 @@ impl Layer { } } + fn push_surface(&mut self, surface: Surface) { + if can_draw(surface.bounds) { + self.surfaces.push(surface); + } + } + pub fn images(&self) -> &[Image] { self.images.as_slice() }