mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Fix Vello rendering the infinite canvas without a white background color (#2361)
Fix infinite canvas for vello Remove debugging fill Remove debug log
This commit is contained in:
parent
e7cde88c04
commit
6becaef980
3 changed files with 11 additions and 6 deletions
|
@ -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]
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue