Skip to content

Commit 11147b9

Browse files
committed
Reformat
1 parent 61ec1fc commit 11147b9

File tree

6 files changed

+51
-66
lines changed

6 files changed

+51
-66
lines changed

examples/scenes/src/pico_svg.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,19 @@ impl Parser {
173173
}));
174174
}
175175
if let Some(stroke_color) = node.attribute("stroke")
176-
&& stroke_color != "none" {
177-
let width = node
178-
.attribute("stroke-width")
179-
.map(|a| f64::from_str(a).unwrap_or(1.0))
180-
.unwrap_or(1.0)
181-
* self.scale.abs();
182-
let color = parse_color(stroke_color);
183-
let color = modify_opacity(color, "stroke-opacity", node);
184-
// TODO: Handle recursive opacity properly
185-
let color = modify_opacity(color, "opacity", node);
186-
items.push(Item::Stroke(StrokeItem { width, color, path }));
187-
}
176+
&& stroke_color != "none"
177+
{
178+
let width = node
179+
.attribute("stroke-width")
180+
.map(|a| f64::from_str(a).unwrap_or(1.0))
181+
.unwrap_or(1.0)
182+
* self.scale.abs();
183+
let color = parse_color(stroke_color);
184+
let color = modify_opacity(color, "stroke-opacity", node);
185+
// TODO: Handle recursive opacity properly
186+
let color = modify_opacity(color, "opacity", node);
187+
items.push(Item::Stroke(StrokeItem { width, color, path }));
188+
}
188189
}
189190
other => eprintln!("Unhandled node type {other}"),
190191
}

examples/scenes/src/svg.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ fn scene_from_files_inner(files: &[PathBuf]) -> std::result::Result<SceneSet, an
4040
for file in read_dir(path)? {
4141
let entry = file?;
4242
if let Some(extension) = Path::new(&entry.file_name()).extension()
43-
&& extension == "svg" {
44-
scenes.push(example_scene_of(entry.path()));
45-
}
43+
&& extension == "svg"
44+
{
45+
scenes.push(example_scene_of(entry.path()));
46+
}
4647
}
4748
// Ensure a consistent order within directories
4849
scenes[start_index..].sort_by_key(|scene| scene.config.name.to_lowercase());

examples/with_winit/src/lib.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,16 @@ impl ApplicationHandler<UserEvent> for VelloApp {
412412
..
413413
}) = &self.state
414414
&& *valid_surface
415-
&& touch.location.y > surface.config.height as f64 * 2. / 3.
416-
{
417-
self.navigation_fingers.insert(touch.id);
418-
// The left third of the navigation zone navigates backwards
419-
if touch.location.x < surface.config.width as f64 / 3. {
420-
self.scene_ix = self.scene_ix.saturating_sub(1);
421-
} else if touch.location.x > 2. * surface.config.width as f64 / 3. {
422-
self.scene_ix = self.scene_ix.saturating_add(1);
423-
}
415+
&& touch.location.y > surface.config.height as f64 * 2. / 3.
416+
{
417+
self.navigation_fingers.insert(touch.id);
418+
// The left third of the navigation zone navigates backwards
419+
if touch.location.x < surface.config.width as f64 / 3. {
420+
self.scene_ix = self.scene_ix.saturating_sub(1);
421+
} else if touch.location.x > 2. * surface.config.width as f64 / 3. {
422+
self.scene_ix = self.scene_ix.saturating_add(1);
424423
}
424+
}
425425
}
426426
TouchPhase::Ended | TouchPhase::Cancelled => {
427427
// We intentionally ignore the result here
@@ -484,9 +484,10 @@ impl ApplicationHandler<UserEvent> for VelloApp {
484484
y: position.y,
485485
};
486486
if self.mouse_down
487-
&& let Some(prior) = self.prior_position {
488-
self.transform = self.transform.then_translate(position - prior);
489-
}
487+
&& let Some(prior) = self.prior_position
488+
{
489+
self.transform = self.transform.then_translate(position - prior);
490+
}
490491
self.prior_position = Some(position);
491492
}
492493
WindowEvent::RedrawRequested => {
@@ -577,10 +578,10 @@ impl ApplicationHandler<UserEvent> for VelloApp {
577578
.and_then(|renderer| renderer.profile_result.take())
578579
&& (self.profile_stored.is_none()
579580
|| self.profile_taken.elapsed() > Duration::from_secs(1))
580-
{
581-
self.profile_stored = Some(profiling_result);
582-
self.profile_taken = Instant::now();
583-
}
581+
{
582+
self.profile_stored = Some(profiling_result);
583+
self.profile_taken = Instant::now();
584+
}
584585
#[cfg(feature = "wgpu-profiler")]
585586
if let Some(profiling_result) = self.profile_stored.as_ref() {
586587
stats::draw_gpu_profiling(

sparse_strips/vello_common/src/clip.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -218,24 +218,16 @@ fn intersect_impl<S: Simd>(
218218
// fill.
219219
(Region::Fill(_), Region::Fill(_)) => {
220220
flush_strip(&mut strip_state, &mut target.strips, cur_y);
221-
start_strip(&mut strip_state, &mut target.alphas, overlap.end, true);
221+
start_strip(&mut strip_state, &target.alphas, overlap.end, true);
222222
}
223223
// One fill one strip, so we simply use the alpha mask from the strip region.
224224
(Region::Strip(s), Region::Fill(_))
225225
| (Region::Fill(_), Region::Strip(s)) => {
226226
// If possible, don't create a new strip but just extend the current one.
227-
if should_create_new_strip(
228-
&strip_state,
229-
&mut target.alphas,
230-
overlap.start,
231-
) {
227+
if should_create_new_strip(&strip_state, &target.alphas, overlap.start)
228+
{
232229
flush_strip(&mut strip_state, &mut target.strips, cur_y);
233-
start_strip(
234-
&mut strip_state,
235-
&mut target.alphas,
236-
overlap.start,
237-
false,
238-
);
230+
start_strip(&mut strip_state, &target.alphas, overlap.start, false);
239231
}
240232

241233
let s_alphas = &s.alphas[(overlap.start - s.start) as usize * 4..]
@@ -245,18 +237,10 @@ fn intersect_impl<S: Simd>(
245237
// Two strips, we need to multiply the opacitie masks from both paths.
246238
(Region::Strip(s_region_1), Region::Strip(s_region_2)) => {
247239
// Once again, only create a new strip if we can't extend the current one.
248-
if should_create_new_strip(
249-
&strip_state,
250-
&mut target.alphas,
251-
overlap.start,
252-
) {
240+
if should_create_new_strip(&strip_state, &target.alphas, overlap.start)
241+
{
253242
flush_strip(&mut strip_state, &mut target.strips, cur_y);
254-
start_strip(
255-
&mut strip_state,
256-
&mut target.alphas,
257-
overlap.start,
258-
false,
259-
);
243+
start_strip(&mut strip_state, &target.alphas, overlap.start, false);
260244
}
261245

262246
let num_blocks = overlap.width() / Tile::HEIGHT;

sparse_strips/vello_cpu/src/dispatch/multi_threaded.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,10 @@ impl MultiThreadedDispatcher {
255255
let tasks = self.task_batch.as_slice();
256256
let path = self.batch_path.elements();
257257
let task_sender = self.task_sender.as_mut().unwrap();
258-
let clip_path = self
259-
.clip_context
260-
.get()
261-
.map(|c| OwnedClip {
262-
strips: c.strips.into(),
263-
alphas: c.alphas.into(),
264-
});
258+
let clip_path = self.clip_context.get().map(|c| OwnedClip {
259+
strips: c.strips.into(),
260+
alphas: c.alphas.into(),
261+
});
265262
let task = RenderTask {
266263
idx: task_idx,
267264
clip_path,
@@ -635,9 +632,9 @@ impl Debug for MultiThreadedDispatcher {
635632
}
636633

637634
#[derive(Debug)]
638-
struct OwnedClip {
635+
pub(crate) struct OwnedClip {
639636
strips: Box<[Strip]>,
640-
alphas: Box<[u8]>
637+
alphas: Box<[u8]>,
641638
}
642639

643640
#[derive(Debug)]

sparse_strips/vello_hybrid/examples/winit/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ impl ApplicationHandler for App<'_> {
204204
}
205205
Key::Character(ch) => {
206206
if let Some(scene) = self.scenes.get_mut(self.current_scene)
207-
&& scene.handle_key(ch.as_str()) {
208-
window.request_redraw();
209-
}
207+
&& scene.handle_key(ch.as_str())
208+
{
209+
window.request_redraw();
210+
}
210211
}
211212
_ => {}
212213
},

0 commit comments

Comments
 (0)