Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node-graph/gcore/src/raster/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
6 changes: 5 additions & 1 deletion node-graph/gstd/src/wasm_application_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
9 changes: 5 additions & 4 deletions node-graph/wgpu-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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,
};

{
Expand Down