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
6 changes: 2 additions & 4 deletions crates/encoding/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

use super::{DrawColor, DrawTag, PathEncoder, PathTag, Style, Transform};

use peniko::{
kurbo::{Shape, Stroke},
BlendMode, BrushRef, Fill,
};
use peniko::kurbo::{Shape, Stroke};
use peniko::{BlendMode, BrushRef, Fill};

#[cfg(feature = "full")]
use {
Expand Down
10 changes: 5 additions & 5 deletions crates/encoding/src/glyph_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use std::collections::HashMap;

use super::{Encoding, StreamOffsets};

use peniko::{
kurbo::{BezPath, Shape},
Fill, Style,
};
use skrifa::{instance::NormalizedCoord, outline::OutlinePen, GlyphId, OutlineGlyphCollection};
use peniko::kurbo::{BezPath, Shape};
use peniko::{Fill, Style};
use skrifa::instance::NormalizedCoord;
use skrifa::outline::OutlinePen;
use skrifa::{GlyphId, OutlineGlyphCollection};

#[derive(Copy, Clone, PartialEq, Eq, Hash, Default, Debug)]
pub struct GlyphKey {
Expand Down
3 changes: 2 additions & 1 deletion crates/encoding/src/image_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

use guillotiere::{size2, AtlasAllocator};
use peniko::Image;
use std::collections::{hash_map::Entry, HashMap};
use std::collections::hash_map::Entry;
use std::collections::HashMap;

const DEFAULT_ATLAS_SIZE: i32 = 1024;
const MAX_ATLAS_SIZE: i32 = 8192;
Expand Down
6 changes: 2 additions & 4 deletions crates/encoding/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use bytemuck::{Pod, Zeroable};
use peniko::{
kurbo::{Cap, Join, Shape, Stroke},
Fill,
};
use peniko::kurbo::{Cap, Join, Shape, Stroke};
use peniko::Fill;

use super::Monoid;

Expand Down
18 changes: 6 additions & 12 deletions crates/shaders/src/compile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
// Copyright 2023 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use {
naga::{
front::wgsl,
valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags},
AddressSpace, ArraySize, ImageClass, Module, StorageAccess, WithSpan,
},
std::{
collections::{HashMap, HashSet},
path::Path,
},
thiserror::Error,
};
use naga::front::wgsl;
use naga::valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags};
use naga::{AddressSpace, ArraySize, ImageClass, Module, StorageAccess, WithSpan};
use std::collections::{HashMap, HashSet};
use std::path::Path;
use thiserror::Error;

pub mod permutations;
pub mod preprocess;
Expand Down
6 changes: 2 additions & 4 deletions crates/shaders/src/compile/msl.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Copyright 2023 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use super::{BindType, ShaderInfo};
use crate::types::msl::BindingIndex;
use naga::back::msl as naga_msl;
use {
super::{BindType, ShaderInfo},
crate::types::msl::BindingIndex,
};

pub fn translate(shader: &ShaderInfo) -> Result<String, naga_msl::Error> {
let mut map = naga_msl::EntryPointResourceMap::default();
Expand Down
9 changes: 3 additions & 6 deletions crates/shaders/src/compile/preprocess.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Copyright 2023 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{
collections::{HashMap, HashSet},
fs,
path::Path,
vec,
};
use std::collections::{HashMap, HashSet};
use std::path::Path;
use std::{fs, vec};

pub fn get_imports(shader_dir: &Path) -> HashMap<String, String> {
let mut imports = HashMap::new();
Expand Down
15 changes: 8 additions & 7 deletions crates/tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright 2024 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{env, fs::File, num::NonZeroUsize, path::Path, sync::Arc};
use std::env;
use std::fs::File;
use std::num::NonZeroUsize;
use std::path::Path;
use std::sync::Arc;

use anyhow::{anyhow, bail, Result};
use vello::{
block_on_wgpu,
peniko::{Blob, Color, Format, Image},
util::RenderContext,
RendererOptions, Scene,
};
use vello::peniko::{Blob, Color, Format, Image};
use vello::util::RenderContext;
use vello::{block_on_wgpu, RendererOptions, Scene};
use wgpu::{
BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, ImageCopyBuffer,
TextureDescriptor, TextureFormat, TextureUsages,
Expand Down
8 changes: 3 additions & 5 deletions crates/tests/tests/smoke.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Copyright 2024 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use vello::{
kurbo::{Affine, Rect},
peniko::{Brush, Color, Format},
Scene,
};
use vello::kurbo::{Affine, Rect};
use vello::peniko::{Brush, Color, Format};
use vello::Scene;
use vello_tests::TestParams;

#[test]
Expand Down
17 changes: 6 additions & 11 deletions examples/headless/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
// Copyright 2023 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{
fs::File,
num::NonZeroUsize,
path::{Path, PathBuf},
};
use std::fs::File;
use std::num::NonZeroUsize;
use std::path::{Path, PathBuf};

use anyhow::{anyhow, bail, Context, Result};
use clap::{CommandFactory, Parser};
use scenes::{ImageCache, SceneParams, SceneSet, SimpleText};
use vello::{
block_on_wgpu,
kurbo::{Affine, Vec2},
util::RenderContext,
RendererOptions, Scene,
};
use vello::kurbo::{Affine, Vec2};
use vello::util::RenderContext;
use vello::{block_on_wgpu, RendererOptions, Scene};
use wgpu::{
BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, ImageCopyBuffer,
TextureDescriptor, TextureFormat, TextureUsages,
Expand Down
6 changes: 2 additions & 4 deletions examples/scenes/src/download.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright 2022 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{
io::Seek,
path::{Path, PathBuf},
};
use std::io::Seek;
use std::path::{Path, PathBuf};

use anyhow::{bail, Context, Result};
use byte_unit::Byte;
Expand Down
4 changes: 3 additions & 1 deletion examples/scenes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub use simple_text::SimpleText;
pub use svg::{default_scene, scene_from_files};
pub use test_scenes::test_scenes;

use vello::{kurbo::Vec2, peniko::Color, Scene};
use vello::kurbo::Vec2;
use vello::peniko::Color;
use vello::Scene;

pub struct SceneParams<'a> {
pub time: f64,
Expand Down
9 changes: 4 additions & 5 deletions examples/scenes/src/mmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

use std::cmp::Ordering;

use rand::{seq::SliceRandom, Rng};
use rand::seq::SliceRandom;
use rand::Rng;
use vello::kurbo::{Affine, BezPath, CubicBez, Line, ParamCurve, PathSeg, Point, QuadBez, Stroke};
use vello::peniko::Color;
use vello::{
kurbo::{Affine, BezPath, CubicBez, Line, ParamCurve, PathSeg, Point, QuadBez, Stroke},
Scene,
};
use vello::Scene;

use crate::{SceneParams, TestScene};

Expand Down
13 changes: 6 additions & 7 deletions examples/scenes/src/simple_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

use std::sync::Arc;

use vello::{
glyph::Glyph,
kurbo::Affine,
peniko::{Blob, Brush, BrushRef, Font, StyleRef},
skrifa::{raw::FontRef, MetadataProvider},
Scene,
};
use vello::glyph::Glyph;
use vello::kurbo::Affine;
use vello::peniko::{Blob, Brush, BrushRef, Font, StyleRef};
use vello::skrifa::raw::FontRef;
use vello::skrifa::MetadataProvider;
use vello::Scene;

// This is very much a hack to get things working.
// On Windows, can set this to "c:\\Windows\\Fonts\\seguiemj.ttf" to get color emoji
Expand Down
9 changes: 4 additions & 5 deletions examples/scenes/src/svg.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright 2022 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{
fs::read_dir,
path::{Path, PathBuf},
};
use std::fs::read_dir;
use std::path::{Path, PathBuf};

use anyhow::{Ok, Result};
use instant::Instant;
use vello::{kurbo::Vec2, Scene};
use vello::kurbo::Vec2;
use vello::Scene;
use vello_svg::usvg;
use vello_svg::usvg::TreeParsing;

Expand Down
10 changes: 4 additions & 6 deletions examples/simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ use vello::kurbo::{Affine, Circle, Ellipse, Line, RoundedRect, Stroke};
use vello::peniko::Color;
use vello::util::{RenderContext, RenderSurface};
use vello::{AaConfig, Renderer, RendererOptions, Scene};
use winit::{
dpi::LogicalSize,
event::*,
event_loop::{ControlFlow, EventLoop},
window::{Window, WindowBuilder},
};
use winit::dpi::LogicalSize;
use winit::event::*;
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::{Window, WindowBuilder};

// Simple struct to hold the state of the renderer
pub struct ActiveRenderState<'s> {
Expand Down
18 changes: 7 additions & 11 deletions examples/with_bevy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ use vello::kurbo::{Affine, Point, Rect, Stroke};
use vello::peniko::{Color, Fill, Gradient};
use vello::{Renderer, RendererOptions, Scene};

use bevy::{
prelude::*,
render::{
extract_component::{ExtractComponent, ExtractComponentPlugin},
render_asset::RenderAssets,
render_resource::{
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
},
renderer::{RenderDevice, RenderQueue},
RenderApp,
},
use bevy::prelude::*;
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
use bevy::render::render_asset::RenderAssets;
use bevy::render::render_resource::{
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
};
use bevy::render::renderer::{RenderDevice, RenderQueue};
use bevy::render::RenderApp;

#[derive(Resource)]
struct VelloRenderer(SyncCell<Renderer>);
Expand Down
6 changes: 4 additions & 2 deletions examples/with_winit/src/hot_reload.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright 2023 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{path::Path, time::Duration};
use std::path::Path;
use std::time::Duration;

use anyhow::Result;
use notify_debouncer_mini::{new_debouncer, notify::*, DebounceEventResult};
use notify_debouncer_mini::notify::*;
use notify_debouncer_mini::{new_debouncer, DebounceEventResult};

pub(crate) fn hot_reload(mut f: impl FnMut() -> Option<()> + Send + 'static) -> Result<impl Sized> {
let mut debouncer = new_debouncer(
Expand Down
28 changes: 13 additions & 15 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use instant::Instant;
use std::collections::HashSet;
use std::num::NonZeroUsize;
use std::{collections::HashSet, sync::Arc};
use std::sync::Arc;

use clap::{CommandFactory, Parser};
use scenes::{ImageCache, SceneParams, SceneSet, SimpleText};
use vello::kurbo::{Affine, Vec2};
use vello::peniko::Color;
use vello::util::RenderSurface;
use vello::{
kurbo::{Affine, Vec2},
util::RenderContext,
AaConfig, Renderer, Scene,
};
use vello::{BumpAllocators, RendererOptions};

use winit::{
event_loop::{EventLoop, EventLoopBuilder},
window::Window,
};
use vello::util::{RenderContext, RenderSurface};
use vello::{AaConfig, BumpAllocators, Renderer, RendererOptions, Scene};

use winit::event_loop::{EventLoop, EventLoopBuilder};
use winit::window::Window;

#[cfg(not(any(target_arch = "wasm32", target_os = "android")))]
mod hot_reload;
Expand Down Expand Up @@ -90,7 +85,9 @@ fn run(
render_cx: RenderContext,
#[cfg(target_arch = "wasm32")] render_state: RenderState,
) {
use winit::{event::*, event_loop::ControlFlow, keyboard::*};
use winit::event::*;
use winit::event_loop::ControlFlow;
use winit::keyboard::*;
let mut renderers: Vec<Option<Renderer>> = vec![];
#[cfg(not(target_arch = "wasm32"))]
let mut render_cx = render_cx;
Expand Down Expand Up @@ -648,7 +645,8 @@ fn store_profiling(
}

fn create_window(event_loop: &winit::event_loop::EventLoopWindowTarget<UserEvent>) -> Arc<Window> {
use winit::{dpi::LogicalSize, window::WindowBuilder};
use winit::dpi::LogicalSize;
use winit::window::WindowBuilder;
Arc::new(
WindowBuilder::new()
.with_inner_size(LogicalSize::new(1044, 800))
Expand Down
8 changes: 3 additions & 5 deletions examples/with_winit/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

use scenes::SimpleText;
use std::collections::VecDeque;
use vello::{
kurbo::{Affine, PathEl, Rect, Stroke},
peniko::{Brush, Color, Fill},
AaConfig, BumpAllocators, Scene,
};
use vello::kurbo::{Affine, PathEl, Rect, Stroke};
use vello::peniko::{Brush, Color, Fill};
use vello::{AaConfig, BumpAllocators, Scene};

const SLIDING_WINDOW_SIZE: usize = 100;

Expand Down
3 changes: 3 additions & 0 deletions rustfmt.toml

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the relevant file to look at.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use_field_init_shorthand = true
newline_style = "Unix"
# TODO: imports_granularity = "Module" - Wait for this to be stable.
6 changes: 2 additions & 4 deletions src/cpu_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
//! Note that while this CPU implementation is useful for testing and debugging,
//! a full CPU fallback for targets without wgpu hasn't been implemented yet.

use std::{
cell::{Ref, RefCell, RefMut},
ops::{Deref, DerefMut},
};
use std::cell::{Ref, RefCell, RefMut};
use std::ops::{Deref, DerefMut};

use bytemuck::Pod;

Expand Down
Loading