Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: linebender/vello
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: daf0817ef9f32df132c6776a8d56568192283fa4
Choose a base ref
..
head repository: linebender/vello
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 786f41bf357b74382ce0f328e47acc67c5be4836
Choose a head ref
Showing with 13 additions and 14 deletions.
  1. +2 −6 examples/simple/src/main.rs
  2. +5 −4 examples/with_winit/src/lib.rs
  3. +2 −2 vello_encoding/src/mask.rs
  4. +4 −2 vello_encoding/src/math.rs
8 changes: 2 additions & 6 deletions examples/simple/src/main.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ use vello::{AaConfig, DebugLayers, Renderer, RendererOptions, Scene};
use winit::application::ApplicationHandler;
use winit::dpi::LogicalSize;
use winit::event::*;
use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::window::Window;

use vello::wgpu;
@@ -74,15 +74,12 @@ impl<'s> ApplicationHandler for SimpleVelloApp<'s> {

// Save the Window and Surface to a state variable
self.state = RenderState::Active(ActiveRenderState { window, surface });

event_loop.set_control_flow(ControlFlow::Poll);
}

fn suspended(&mut self, event_loop: &ActiveEventLoop) {
fn suspended(&mut self, _event_loop: &ActiveEventLoop) {
if let RenderState::Active(state) = &self.state {
self.state = RenderState::Suspended(Some(state.window.clone()));
}
event_loop.set_control_flow(ControlFlow::Wait);
}

fn window_event(
@@ -109,7 +106,6 @@ impl<'s> ApplicationHandler for SimpleVelloApp<'s> {
WindowEvent::Resized(size) => {
self.context
.resize_surface(&mut render_state.surface, size.width, size.height);
render_state.window.request_redraw();
}

// This is where all the rendering happens
9 changes: 5 additions & 4 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ use std::time::Instant;
use web_time::Instant;
use winit::application::ApplicationHandler;
use winit::event::*;
use winit::event_loop::ControlFlow;
use winit::keyboard::*;

#[cfg(all(feature = "wgpu-profiler", not(target_arch = "wasm32")))]
@@ -257,7 +256,6 @@ impl<'s> ApplicationHandler<UserEvent> for VelloApp<'s> {

Some(render_state)
};
event_loop.set_control_flow(ControlFlow::Poll);
}

fn window_event(
@@ -474,6 +472,10 @@ impl<'s> ApplicationHandler<UserEvent> for VelloApp<'s> {
let _rendering_span = tracing::trace_span!("Actioning Requested Redraw").entered();
let encoding_span = tracing::trace_span!("Encoding scene").entered();

render_state.window.request_redraw();

render_state.window.request_redraw();

let Some(RenderState { surface, window }) = &mut self.state else {
return;
};
@@ -702,14 +704,13 @@ impl<'s> ApplicationHandler<UserEvent> for VelloApp<'s> {
}
}

fn suspended(&mut self, event_loop: &winit::event_loop::ActiveEventLoop) {
fn suspended(&mut self, _event_loop: &winit::event_loop::ActiveEventLoop) {
log::info!("Suspending");
#[cfg(not(target_arch = "wasm32"))]
// When we suspend, we need to remove the `wgpu` Surface
if let Some(render_state) = self.state.take() {
self.cached_window = Some(render_state.window);
}
event_loop.set_control_flow(ControlFlow::Wait);
}
}

4 changes: 2 additions & 2 deletions vello_encoding/src/mask.rs
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ fn one_mask(slope: f64, mut translation: f64, is_pos: bool) -> u8 {
/// Make a lookup table of half-plane masks.
///
/// The table is organized into two blocks each with `MASK_HEIGHT/2` slopes.
/// The first block is negative slopes (x decreases as y increates),
/// The first block is negative slopes (x decreases as y increases),
/// the second as positive.
pub fn make_mask_lut() -> Vec<u8> {
(0..MASK_WIDTH * MASK_HEIGHT)
@@ -78,7 +78,7 @@ fn one_mask_16(slope: f64, mut translation: f64, is_pos: bool) -> u16 {
/// Make a lookup table of half-plane masks.
///
/// The table is organized into two blocks each with `MASK16_HEIGHT/2` slopes.
/// The first block is negative slopes (x decreases as y increates),
/// The first block is negative slopes (x decreases as y increases),
/// the second as positive.
pub fn make_mask_lut_16() -> Vec<u8> {
let v16 = (0..MASK16_WIDTH * MASK16_HEIGHT)
6 changes: 4 additions & 2 deletions vello_encoding/src/math.rs
Original file line number Diff line number Diff line change
@@ -77,7 +77,8 @@ pub fn point_to_f32(point: kurbo::Point) -> [f32; 2] {
[point.x as f32, point.y as f32]
}

/// Converts an f32 to IEEE-754 binary16 format represented as the bits of a u16.
/// Converts an `f32` to IEEE-754 binary16 format represented as the bits of a `u16`.
///
/// This implementation was adapted from Fabian Giesen's `float_to_half_fast3`()
/// function which can be found at <https://gist.github.com/rygorous/2156668#file-gistfile1-cpp-L285>
///
@@ -122,7 +123,8 @@ pub(crate) fn f32_to_f16(val: f32) -> u16 {
output | (sign >> 16) as u16
}

/// Convertes a 16-bit precision IEEE-754 binary16 float to a f32.
/// Converts a 16-bit precision IEEE-754 binary16 float to a `f32`.
///
/// This implementation was adapted from Fabian Giesen's `half_to_float()`
/// function which can be found at <https://gist.github.com/rygorous/2156668#file-gistfile1-cpp-L574>
pub fn f16_to_f32(bits: u16) -> f32 {