Skip to content

Commit 6becaef

Browse files
authored
Fix Vello rendering the infinite canvas without a white background color (#2361)
Fix infinite canvas for vello Remove debugging fill Remove debug log
1 parent e7cde88 commit 6becaef

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

node-graph/gcore/src/raster/color.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ impl Color {
864864
/// ```
865865
#[inline(always)]
866866
pub fn to_rgba8_srgb(&self) -> [u8; 4] {
867-
let gamma = self.to_gamma_srgb().to_gamma_srgb();
867+
let gamma = self.to_gamma_srgb();
868868
[(gamma.red * 255.) as u8, (gamma.green * 255.) as u8, (gamma.blue * 255.) as u8, (gamma.alpha * 255.) as u8]
869869
}
870870

node-graph/gstd/src/wasm_application_io.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ async fn render_canvas(render_config: RenderConfig, data: impl GraphicElementRen
136136
// TODO: Instead of applying the transform here, pass the transform during the translation to avoid the O(Nr cost
137137
scene.append(&child, Some(kurbo::Affine::new(footprint.transform.to_cols_array())));
138138

139-
exec.render_vello_scene(&scene, &surface_handle, footprint.resolution.x, footprint.resolution.y, &context)
139+
let mut background = Color::from_rgb8_srgb(0x22, 0x22, 0x22);
140+
if !data.contains_artboard() && !render_config.hide_artboards {
141+
background = Color::WHITE;
142+
}
143+
exec.render_vello_scene(&scene, &surface_handle, footprint.resolution.x, footprint.resolution.y, &context, background)
140144
.await
141145
.expect("Failed to render Vello scene");
142146

node-graph/wgpu-executor/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use dyn_any::{DynAny, StaticType};
88
use gpu_executor::{ComputePassDimensions, GPUConstant, StorageBufferOptions, TextureBufferOptions, TextureBufferType, ToStorageBuffer, ToUniformBuffer};
99
use graphene_core::application_io::{ApplicationIo, EditorApi, SurfaceHandle};
1010
use graphene_core::transform::{Footprint, Transform};
11-
use graphene_core::{Cow, Node, SurfaceFrame, Type};
11+
use graphene_core::{Color, Cow, Node, SurfaceFrame, Type};
1212

1313
use anyhow::{bail, Result};
1414
use futures::Future;
@@ -133,7 +133,7 @@ pub use graphene_core::renderer::RenderContext;
133133
// }
134134

135135
impl WgpuExecutor {
136-
pub async fn render_vello_scene(&self, scene: &Scene, surface: &WgpuSurface, width: u32, height: u32, context: &RenderContext) -> Result<()> {
136+
pub async fn render_vello_scene(&self, scene: &Scene, surface: &WgpuSurface, width: u32, height: u32, context: &RenderContext, background: Color) -> Result<()> {
137137
let surface = &surface.surface.inner;
138138
let surface_caps = surface.get_capabilities(&self.context.adapter);
139139
surface.configure(
@@ -151,13 +151,14 @@ impl WgpuExecutor {
151151
);
152152
let surface_texture = surface.get_current_texture()?;
153153

154+
let [r, g, b, _] = background.to_rgba8_srgb();
154155
let render_params = RenderParams {
155156
// We are using an explicit opaque color here to eliminate the alpha premultiplication step
156157
// which would be required to support a transparent webgpu canvas
157-
base_color: vello::peniko::Color::from_rgba8(0x22, 0x22, 0x22, 0xff),
158+
base_color: vello::peniko::Color::from_rgba8(r, g, b, 0xff),
158159
width,
159160
height,
160-
antialiasing_method: AaConfig::Msaa8,
161+
antialiasing_method: AaConfig::Msaa16,
161162
};
162163

163164
{

0 commit comments

Comments
 (0)