diff --git a/node-graph/gcore/src/raster/color.rs b/node-graph/gcore/src/raster/color.rs index 336ce114df..61487db88f 100644 --- a/node-graph/gcore/src/raster/color.rs +++ b/node-graph/gcore/src/raster/color.rs @@ -864,7 +864,7 @@ impl Color { /// ``` #[inline(always)] pub fn to_rgba8_srgb(&self) -> [u8; 4] { - let gamma = self.to_gamma_srgb().to_gamma_srgb(); + let gamma = self.to_gamma_srgb(); [(gamma.red * 255.) as u8, (gamma.green * 255.) as u8, (gamma.blue * 255.) as u8, (gamma.alpha * 255.) as u8] } diff --git a/node-graph/gstd/src/wasm_application_io.rs b/node-graph/gstd/src/wasm_application_io.rs index f5e31a713b..a9d6c32635 100644 --- a/node-graph/gstd/src/wasm_application_io.rs +++ b/node-graph/gstd/src/wasm_application_io.rs @@ -136,7 +136,11 @@ async fn render_canvas(render_config: RenderConfig, data: impl GraphicElementRen // TODO: Instead of applying the transform here, pass the transform during the translation to avoid the O(Nr cost scene.append(&child, Some(kurbo::Affine::new(footprint.transform.to_cols_array()))); - exec.render_vello_scene(&scene, &surface_handle, footprint.resolution.x, footprint.resolution.y, &context) + let mut background = Color::from_rgb8_srgb(0x22, 0x22, 0x22); + if !data.contains_artboard() && !render_config.hide_artboards { + background = Color::WHITE; + } + exec.render_vello_scene(&scene, &surface_handle, footprint.resolution.x, footprint.resolution.y, &context, background) .await .expect("Failed to render Vello scene"); diff --git a/node-graph/wgpu-executor/src/lib.rs b/node-graph/wgpu-executor/src/lib.rs index a11d35cff9..0130bfa8a6 100644 --- a/node-graph/wgpu-executor/src/lib.rs +++ b/node-graph/wgpu-executor/src/lib.rs @@ -8,7 +8,7 @@ use dyn_any::{DynAny, StaticType}; use gpu_executor::{ComputePassDimensions, GPUConstant, StorageBufferOptions, TextureBufferOptions, TextureBufferType, ToStorageBuffer, ToUniformBuffer}; use graphene_core::application_io::{ApplicationIo, EditorApi, SurfaceHandle}; use graphene_core::transform::{Footprint, Transform}; -use graphene_core::{Cow, Node, SurfaceFrame, Type}; +use graphene_core::{Color, Cow, Node, SurfaceFrame, Type}; use anyhow::{bail, Result}; use futures::Future; @@ -133,7 +133,7 @@ pub use graphene_core::renderer::RenderContext; // } impl WgpuExecutor { - pub async fn render_vello_scene(&self, scene: &Scene, surface: &WgpuSurface, width: u32, height: u32, context: &RenderContext) -> Result<()> { + pub async fn render_vello_scene(&self, scene: &Scene, surface: &WgpuSurface, width: u32, height: u32, context: &RenderContext, background: Color) -> Result<()> { let surface = &surface.surface.inner; let surface_caps = surface.get_capabilities(&self.context.adapter); surface.configure( @@ -151,13 +151,14 @@ impl WgpuExecutor { ); let surface_texture = surface.get_current_texture()?; + let [r, g, b, _] = background.to_rgba8_srgb(); let render_params = RenderParams { // We are using an explicit opaque color here to eliminate the alpha premultiplication step // which would be required to support a transparent webgpu canvas - base_color: vello::peniko::Color::from_rgba8(0x22, 0x22, 0x22, 0xff), + base_color: vello::peniko::Color::from_rgba8(r, g, b, 0xff), width, height, - antialiasing_method: AaConfig::Msaa8, + antialiasing_method: AaConfig::Msaa16, }; {