Start on Scene::push_surface

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-08-30 18:17:54 +02:00
parent d473b52f5a
commit e12eaf8c58
3 changed files with 18 additions and 1 deletions

View file

@ -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;

View file

@ -37,6 +37,10 @@ struct PathSprite {
shader_data: shaders::GPUISprite,
}
pub struct Surface {
pub bounds: RectF,
}
impl Renderer {
pub fn new(
device: metal::Device,

View file

@ -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<Quad>,
underlines: Vec<Underline>,
images: Vec<Image>,
surfaces: Vec<Surface>,
shadows: Vec<Shadow>,
glyphs: Vec<Glyph>,
image_glyphs: Vec<ImageGlyph>,
@ -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()
}