MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / render_vello_scene

Method render_vello_scene

node-graph/libraries/wgpu-executor/src/lib.rs:67–98  ·  view source on GitHub ↗
(&self, scene: &Scene, size: UVec2, context: &RenderContext, background: Option<Color>)

Source from the content-addressed store, hash-verified

65 fn from(editor_api: &'a EditorApi<T>) -> Self {
66 editor_api.application_io.as_ref().unwrap().gpu_executor().unwrap()
67 }
68}
69
70impl WgpuExecutor {
71 pub async fn render_vello_scene(&self, scene: &Scene, size: UVec2, context: &RenderContext, background: Option<Color>) -> Result<Texture> {
72 let texture = self.request_texture(size).await;
73
74 let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
75
76 let SRGBA8 { red, green, blue, alpha } = background.unwrap_or(Color::TRANSPARENT).into();
77 let render_params = RenderParams {
78 base_color: vello::peniko::Color::from_rgba8(red, green, blue, alpha),
79 width: size.x,
80 height: size.y,
81 antialiasing_method: AaConfig::Msaa16,
82 };
83
84 {
85 let mut renderer = self.inner.vello_renderer.lock().await;
86 for (image_brush, texture) in context.resource_overrides.iter() {
87 let texture_view = wgpu::TexelCopyTextureInfoBase {
88 texture: (**texture).clone(),
89 mip_level: 0,
90 origin: Origin3d::ZERO,
91 aspect: TextureAspect::All,
92 };
93 renderer.override_image(&image_brush.image, Some(texture_view));
94 }
95
96 {
97 let queue = self.context().queue.lock();
98 renderer.render_to_texture(&self.context().device, &queue, scene, &texture_view, &render_params)?;
99 }
100 for (image_brush, _) in context.resource_overrides.iter() {
101 renderer.override_image(&image_brush.image, None);

Callers 2

render_overlaysMethod · 0.80
renderFunction · 0.80

Calls 5

lockMethod · 0.80
request_textureMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected