Skip to content

Commit

Permalink
chore: expose more apis
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Oct 19, 2024
1 parent a3fc86b commit 169d6f9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
14 changes: 13 additions & 1 deletion violet-wgpu/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl AppBuilder {
/// A running application instance of violet
pub struct AppInstance {
pub frame: Frame,
root: Entity,
pub root: Entity,
scale_factor: f64,
current_time: Instant,
start_time: Instant,
Expand Down Expand Up @@ -293,6 +293,18 @@ impl AppInstance {
pub fn frame(&self) -> &Frame {
&self.frame
}

pub fn root(&self) -> Entity {
self.root
}

pub fn text_system(&self) -> &Arc<Mutex<TextSystem>> {
&self.text_system
}

pub fn layout_changes_rx(&self) -> &flume::Receiver<(Entity, LayoutUpdateEvent)> {
&self.layout_changes_rx
}
}

struct WindowEventHandler {
Expand Down
16 changes: 6 additions & 10 deletions violet-wgpu/src/graphics/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use winit::{dpi::PhysicalSize, window::Window};
/// Represents the Gpu and graphics state
#[derive(Debug)]
pub struct Gpu {
pub adapter: Adapter,
pub device: wgpu::Device,
pub queue: wgpu::Queue,
pub adapter: Arc<Adapter>,
pub device: Arc<wgpu::Device>,
pub queue: Arc<wgpu::Queue>,
}

pub struct Surface {
Expand Down Expand Up @@ -138,9 +138,9 @@ impl Gpu {

(
Self {
adapter,
device,
queue,
adapter: Arc::new(adapter),
device: Arc::new(device),
queue: Arc::new(queue),
},
Surface {
surface,
Expand All @@ -149,8 +149,4 @@ impl Gpu {
},
)
}

// pub fn surface_caps(&self) -> &SurfaceCapabilities {
// &self.surface_caps
// }
}
23 changes: 14 additions & 9 deletions violet-wgpu/src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use violet_core::{
Frame, Rect,
};
use wgpu::{
BindGroup, BindGroupLayout, BufferUsages, CommandEncoder, Operations, RenderPassDescriptor,
ShaderStages, StoreOp, TextureFormat, TextureView,
BindGroup, BindGroupLayout, BufferUsages, CommandEncoder, LoadOp, Operations,
RenderPassDescriptor, ShaderStages, StoreOp, TextureFormat, TextureView,
};

use crate::{
Expand Down Expand Up @@ -280,6 +280,7 @@ impl MainRenderer {
frame: &mut Frame,
encoder: &mut CommandEncoder,
target_view: &TextureView,
clear: bool,
) -> anyhow::Result<()> {
puffin::profile_function!();

Expand All @@ -289,12 +290,16 @@ impl MainRenderer {
view: target_view,
resolve_target: None,
ops: Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 0.0,
}),
load: if clear {
LoadOp::Clear(wgpu::Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 0.0,
})
} else {
LoadOp::Load
},
store: StoreOp::Store,
},
})],
Expand Down Expand Up @@ -390,7 +395,7 @@ impl MainRenderer {
Ok(())
}

fn resize(
pub fn resize(
&mut self,
ctx: &RendererContext,
physical_size: winit::dpi::PhysicalSize<u32>,
Expand Down
2 changes: 1 addition & 1 deletion violet-wgpu/src/renderer/window_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl WindowRenderer {
});

self.main_renderer
.draw(&mut self.ctx, frame, &mut encoder, &view)
.draw(&mut self.ctx, frame, &mut encoder, &view, true)
.context("Failed to draw shapes")?;

{
Expand Down

0 comments on commit 169d6f9

Please sign in to comment.