mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
Merge pull request #162 from simbleau/issue-161
Factored out file loading on render tick for winit bin
This commit is contained in:
commit
38b44b13c4
|
@ -6,7 +6,7 @@ use clap::{App, Arg};
|
||||||
|
|
||||||
use piet_gpu_hal::{BufferUsage, Error, Instance, InstanceFlags, Session};
|
use piet_gpu_hal::{BufferUsage, Error, Instance, InstanceFlags, Session};
|
||||||
|
|
||||||
use piet_gpu::{test_scenes, PietGpuRenderContext, Renderer};
|
use piet_gpu::{test_scenes, PicoSvg, PietGpuRenderContext, Renderer};
|
||||||
|
|
||||||
const WIDTH: usize = 2048;
|
const WIDTH: usize = 2048;
|
||||||
const HEIGHT: usize = 1536;
|
const HEIGHT: usize = 1536;
|
||||||
|
@ -243,7 +243,11 @@ fn main() -> Result<(), Error> {
|
||||||
if matches.is_present("flip") {
|
if matches.is_present("flip") {
|
||||||
scale = -scale;
|
scale = -scale;
|
||||||
}
|
}
|
||||||
test_scenes::render_svg(&mut ctx, input, scale);
|
let xml_str = std::fs::read_to_string(input).unwrap();
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
let svg = PicoSvg::load(&xml_str, scale).unwrap();
|
||||||
|
println!("parsing time: {:?}", start.elapsed());
|
||||||
|
test_scenes::render_svg(&mut ctx, &svg);
|
||||||
} else {
|
} else {
|
||||||
test_scenes::render_scene(&mut ctx);
|
test_scenes::render_scene(&mut ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use piet::kurbo::Point;
|
||||||
use piet::{RenderContext, Text, TextAttribute, TextLayoutBuilder};
|
use piet::{RenderContext, Text, TextAttribute, TextLayoutBuilder};
|
||||||
use piet_gpu_hal::{CmdBuf, Error, ImageLayout, Instance, Session, SubmittedCmdBuf};
|
use piet_gpu_hal::{CmdBuf, Error, ImageLayout, Instance, Session, SubmittedCmdBuf};
|
||||||
|
|
||||||
use piet_gpu::{test_scenes, PietGpuRenderContext, Renderer};
|
use piet_gpu::{test_scenes, PicoSvg, PietGpuRenderContext, Renderer};
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
|
@ -29,6 +29,25 @@ fn main() -> Result<(), Error> {
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
|
// Collect SVG if input
|
||||||
|
let svg = match matches.value_of("INPUT") {
|
||||||
|
Some(file) => {
|
||||||
|
let mut scale = matches
|
||||||
|
.value_of("scale")
|
||||||
|
.map(|scale| scale.parse().unwrap())
|
||||||
|
.unwrap_or(8.0);
|
||||||
|
if matches.is_present("flip") {
|
||||||
|
scale = -scale;
|
||||||
|
}
|
||||||
|
let xml_str = std::fs::read_to_string(file).unwrap();
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
let svg = PicoSvg::load(&xml_str, scale).unwrap();
|
||||||
|
println!("parsing time: {:?}", start.elapsed());
|
||||||
|
Some(svg)
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_inner_size(winit::dpi::LogicalSize {
|
.with_inner_size(winit::dpi::LogicalSize {
|
||||||
|
@ -106,15 +125,8 @@ fn main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ctx = PietGpuRenderContext::new();
|
let mut ctx = PietGpuRenderContext::new();
|
||||||
if let Some(input) = matches.value_of("INPUT") {
|
if let Some(svg) = &svg {
|
||||||
let mut scale = matches
|
test_scenes::render_svg(&mut ctx, svg);
|
||||||
.value_of("scale")
|
|
||||||
.map(|scale| scale.parse().unwrap())
|
|
||||||
.unwrap_or(8.0);
|
|
||||||
if matches.is_present("flip") {
|
|
||||||
scale = -scale;
|
|
||||||
}
|
|
||||||
test_scenes::render_svg(&mut ctx, input, scale);
|
|
||||||
} else {
|
} else {
|
||||||
use piet_gpu::{Blend, BlendMode::*, CompositionMode::*};
|
use piet_gpu::{Blend, BlendMode::*, CompositionMode::*};
|
||||||
let blends = [
|
let blends = [
|
||||||
|
|
|
@ -21,7 +21,7 @@ use piet_gpu_hal::{
|
||||||
ImageLayout, Pipeline, QueryPool, Session,
|
ImageLayout, Pipeline, QueryPool, Session,
|
||||||
};
|
};
|
||||||
|
|
||||||
use pico_svg::PicoSvg;
|
pub use pico_svg::PicoSvg;
|
||||||
use stages::{ClipBinding, ElementBinding, ElementCode};
|
use stages::{ClipBinding, ElementBinding, ElementCode};
|
||||||
|
|
||||||
use crate::stages::{ClipCode, Config, ElementStage};
|
use crate::stages::{ClipCode, Config, ElementStage};
|
||||||
|
|
|
@ -21,12 +21,7 @@ pub fn render_blend_test(rc: &mut PietGpuRenderContext, i: usize, blend: Blend)
|
||||||
rc.restore().unwrap();
|
rc.restore().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_svg(rc: &mut impl RenderContext, filename: &str, scale: f64) {
|
pub fn render_svg(rc: &mut impl RenderContext, svg: &PicoSvg) {
|
||||||
let xml_str = std::fs::read_to_string(filename).unwrap();
|
|
||||||
let start = std::time::Instant::now();
|
|
||||||
let svg = PicoSvg::load(&xml_str, scale).unwrap();
|
|
||||||
println!("parsing time: {:?}", start.elapsed());
|
|
||||||
|
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
svg.render(rc);
|
svg.render(rc);
|
||||||
println!("flattening and encoding time: {:?}", start.elapsed());
|
println!("flattening and encoding time: {:?}", start.elapsed());
|
||||||
|
|
Loading…
Reference in a new issue