mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
Merge pull request #104 from ishitatsuyuki/winit-clap
This commit is contained in:
commit
1e5dcebecd
|
@ -1,6 +1,8 @@
|
||||||
use piet_gpu_hal::{Error, ImageLayout, Instance, Session, SubmittedCmdBuf};
|
use piet_gpu_hal::{Error, ImageLayout, Instance, Session, SubmittedCmdBuf};
|
||||||
|
|
||||||
use piet_gpu::{render_scene, PietGpuRenderContext, Renderer, HEIGHT, WIDTH};
|
use piet_gpu::{render_scene, PietGpuRenderContext, Renderer, HEIGHT, WIDTH, render_svg};
|
||||||
|
|
||||||
|
use clap::{App, Arg};
|
||||||
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
|
@ -11,6 +13,17 @@ use winit::{
|
||||||
const NUM_FRAMES: usize = 2;
|
const NUM_FRAMES: usize = 2;
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
|
let matches = App::new("piet-gpu test")
|
||||||
|
.arg(Arg::with_name("INPUT").index(1))
|
||||||
|
.arg(Arg::with_name("flip").short("f").long("flip"))
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("scale")
|
||||||
|
.short("s")
|
||||||
|
.long("scale")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
|
.get_matches();
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -36,7 +49,18 @@ fn main() -> Result<(), Error> {
|
||||||
.collect::<Result<Vec<_>, Error>>()?;
|
.collect::<Result<Vec<_>, Error>>()?;
|
||||||
|
|
||||||
let mut ctx = PietGpuRenderContext::new();
|
let mut ctx = PietGpuRenderContext::new();
|
||||||
render_scene(&mut ctx);
|
if let Some(input) = matches.value_of("INPUT") {
|
||||||
|
let mut scale = matches
|
||||||
|
.value_of("scale")
|
||||||
|
.map(|scale| scale.parse().unwrap())
|
||||||
|
.unwrap_or(8.0);
|
||||||
|
if matches.is_present("flip") {
|
||||||
|
scale = -scale;
|
||||||
|
}
|
||||||
|
render_svg(&mut ctx, input, scale);
|
||||||
|
} else {
|
||||||
|
render_scene(&mut ctx);
|
||||||
|
}
|
||||||
let n_paths = ctx.path_count();
|
let n_paths = ctx.path_count();
|
||||||
let n_pathseg = ctx.pathseg_count();
|
let n_pathseg = ctx.pathseg_count();
|
||||||
let n_trans = ctx.trans_count();
|
let n_trans = ctx.trans_count();
|
||||||
|
|
Loading…
Reference in a new issue