Remove `tile-svg` and the serialization code.

They can be added later if needed, but for now they're just bitrotting.
This commit is contained in:
Patrick Walton 2019-03-05 15:38:10 -08:00
parent 33aa6f905d
commit 8dc3a84d09
6 changed files with 0 additions and 318 deletions

20
Cargo.lock generated
View File

@ -1048,26 +1048,6 @@ dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "tile-svg"
version = "0.1.0"
dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0",
"pathfinder_renderer 0.1.0",
"pathfinder_svg 0.1.0",
"quickcheck 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"svgtypes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"usvg 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "ucd-util" name = "ucd-util"
version = "0.1.3" version = "0.1.3"

View File

@ -11,6 +11,5 @@ members = [
"ui", "ui",
"utils/area-lut", "utils/area-lut",
"utils/gamma-lut", "utils/gamma-lut",
"utils/tile-svg",
"utils/svg-to-skia" "utils/svg-to-skia"
] ]

View File

@ -16,7 +16,6 @@ pub mod gpu_data;
pub mod paint; pub mod paint;
pub mod post; pub mod post;
pub mod scene; pub mod scene;
pub mod serialization;
pub mod tiles; pub mod tiles;
pub mod z_buffer; pub mod z_buffer;

View File

@ -1,114 +0,0 @@
// pathfinder/renderer/src/serialization.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use byteorder::{LittleEndian, WriteBytesExt};
use crate::gpu_data::{BuiltScene, FillBatchPrimitive};
use crate::gpu_data::{MaskTileBatchPrimitive, SolidTileScenePrimitive};
use crate::paint::ObjectShader;
use std::io::{self, Write};
use std::mem;
pub trait RiffSerialize {
fn write<W>(&self, writer: &mut W) -> io::Result<()> where W: Write;
}
impl RiffSerialize for BuiltScene {
fn write<W>(&self, writer: &mut W) -> io::Result<()>
where
W: Write,
{
writer.write_all(b"RIFF")?;
let header_size = 4 * 6;
let solid_tiles_size = self.solid_tiles.len() * mem::size_of::<SolidTileScenePrimitive>();
let batch_sizes: Vec<_> = self
.batches
.iter()
.map(|batch| BatchSizes {
fills: (batch.fills.len() * mem::size_of::<FillBatchPrimitive>()),
mask_tiles: (batch.mask_tiles.len() * mem::size_of::<MaskTileBatchPrimitive>()),
})
.collect();
let total_batch_sizes: usize = batch_sizes.iter().map(|sizes| 8 + sizes.total()).sum();
let shaders_size = self.shaders.len() * mem::size_of::<ObjectShader>();
writer.write_u32::<LittleEndian>(
(4 + 8 + header_size + 8 + solid_tiles_size + 8 + shaders_size + total_batch_sizes)
as u32,
)?;
writer.write_all(b"PF3S")?;
writer.write_all(b"head")?;
writer.write_u32::<LittleEndian>(header_size as u32)?;
writer.write_u32::<LittleEndian>(FILE_VERSION)?;
writer.write_u32::<LittleEndian>(self.batches.len() as u32)?;
writer.write_f32::<LittleEndian>(self.view_box.origin().x())?;
writer.write_f32::<LittleEndian>(self.view_box.origin().y())?;
writer.write_f32::<LittleEndian>(self.view_box.size().x())?;
writer.write_f32::<LittleEndian>(self.view_box.size().y())?;
writer.write_all(b"shad")?;
writer.write_u32::<LittleEndian>(shaders_size as u32)?;
for &shader in &self.shaders {
let fill_color = shader.fill_color;
writer.write_all(&[fill_color.r, fill_color.g, fill_color.b, fill_color.a])?;
}
writer.write_all(b"soli")?;
writer.write_u32::<LittleEndian>(solid_tiles_size as u32)?;
for &tile_primitive in &self.solid_tiles {
writer.write_i16::<LittleEndian>(tile_primitive.tile_x)?;
writer.write_i16::<LittleEndian>(tile_primitive.tile_y)?;
writer.write_u16::<LittleEndian>(tile_primitive.shader.0)?;
}
for (batch, sizes) in self.batches.iter().zip(batch_sizes.iter()) {
writer.write_all(b"batc")?;
writer.write_u32::<LittleEndian>(sizes.total() as u32)?;
writer.write_all(b"fill")?;
writer.write_u32::<LittleEndian>(sizes.fills as u32)?;
for fill_primitive in &batch.fills {
writer.write_u16::<LittleEndian>(fill_primitive.px.0)?;
writer.write_u32::<LittleEndian>(fill_primitive.subpx.0)?;
writer.write_u16::<LittleEndian>(fill_primitive.mask_tile_index)?;
}
writer.write_all(b"mask")?;
writer.write_u32::<LittleEndian>(sizes.mask_tiles as u32)?;
for &tile_primitive in &batch.mask_tiles {
writer.write_i16::<LittleEndian>(tile_primitive.tile.tile_x)?;
writer.write_i16::<LittleEndian>(tile_primitive.tile.tile_y)?;
writer.write_i16::<LittleEndian>(tile_primitive.tile.backdrop)?;
writer.write_u16::<LittleEndian>(tile_primitive.shader.0)?;
}
}
return Ok(());
const FILE_VERSION: u32 = 0;
struct BatchSizes {
fills: usize,
mask_tiles: usize,
}
impl BatchSizes {
fn total(&self) -> usize {
8 + self.fills + 8 + self.mask_tiles
}
}
}
}

View File

@ -1,32 +0,0 @@
[package]
name = "tile-svg"
version = "0.1.0"
authors = ["Patrick Walton <pcwalton@mimiga.net>"]
edition = "2018"
[features]
pf-no-simd = []
[dependencies]
arrayvec = "0.4"
byteorder = "1.2"
clap = "2.32"
fixedbitset = "0.1"
hashbrown = "0.1"
jemallocator = "0.1"
rayon = "1.0"
svgtypes = "0.3"
usvg = "0.4"
[dependencies.pathfinder_geometry]
path = "../../geometry"
[dependencies.pathfinder_renderer]
path = "../../renderer"
[dependencies.pathfinder_svg]
path = "../../svg"
[dev-dependencies]
quickcheck = "0.7"
rand = "0.5"

View File

@ -1,150 +0,0 @@
// pathfinder/utils/tile-svg/main.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(clippy::float_cmp)]
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
extern crate rand;
use clap::{App, Arg};
use jemallocator;
use pathfinder_renderer::builder::SceneBuilder;
use pathfinder_renderer::gpu_data::BuiltScene;
use pathfinder_renderer::scene::{BuildTransform, Scene};
use pathfinder_renderer::serialization::RiffSerialize;
use pathfinder_renderer::z_buffer::ZBuffer;
use pathfinder_svg::SceneExt;
use rayon::ThreadPoolBuilder;
use std::fs::File;
use std::io::BufWriter;
use std::path::PathBuf;
use std::time::{Duration, Instant};
use usvg::{Options as UsvgOptions, Tree};
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
fn main() {
let matches = App::new("tile-svg")
.arg(
Arg::with_name("runs")
.short("r")
.long("runs")
.value_name("COUNT")
.takes_value(true)
.help("Run a benchmark with COUNT runs"),
)
.arg(
Arg::with_name("jobs")
.short("j")
.long("jobs")
.value_name("THREADS")
.takes_value(true)
.help("Number of threads to use"),
)
.arg(
Arg::with_name("INPUT")
.help("Path to the SVG file to render")
.required(true)
.index(1),
)
.arg(
Arg::with_name("OUTPUT")
.help("Path to the output PF3 data")
.required(false)
.index(2),
)
.get_matches();
let runs: usize = match matches.value_of("runs") {
Some(runs) => runs.parse().unwrap(),
None => 1,
};
let jobs: Option<usize> = matches
.value_of("jobs")
.map(|string| string.parse().unwrap());
let input_path = PathBuf::from(matches.value_of("INPUT").unwrap());
let output_path = matches.value_of("OUTPUT").map(PathBuf::from);
// Set up Rayon.
let mut thread_pool_builder = ThreadPoolBuilder::new();
if let Some(jobs) = jobs {
thread_pool_builder = thread_pool_builder.num_threads(jobs);
}
thread_pool_builder.build_global().unwrap();
// Build scene.
let usvg = Tree::from_file(&input_path, &UsvgOptions::default()).unwrap();
let scene = Scene::from_tree(usvg);
println!(
"Scene bounds: {:?} View box: {:?}",
scene.bounds, scene.view_box
);
println!(
"{} objects, {} paints",
scene.objects.len(),
scene.paints.len()
);
let (mut elapsed_object_build_time, mut elapsed_scene_build_time) = (0.0, 0.0);
let mut built_scene = BuiltScene::new(&scene.view_box);
for _ in 0..runs {
let z_buffer = ZBuffer::new(&scene.view_box);
let start_time = Instant::now();
let built_objects = match jobs {
Some(1) => scene.build_objects_sequentially(&BuildTransform::None, &z_buffer),
_ => scene.build_objects(&BuildTransform::None, &z_buffer),
};
elapsed_object_build_time += duration_to_ms(&(Instant::now() - start_time));
let start_time = Instant::now();
built_scene = BuiltScene::new(&scene.view_box);
built_scene.shaders = scene.build_shaders();
let mut scene_builder = SceneBuilder::new(built_objects, z_buffer, &scene.view_box);
built_scene.solid_tiles = scene_builder.build_solid_tiles();
while let Some(batch) = scene_builder.build_batch() {
built_scene.batches.push(batch);
}
elapsed_scene_build_time += duration_to_ms(&(Instant::now() - start_time));
}
elapsed_object_build_time /= runs as f64;
elapsed_scene_build_time /= runs as f64;
let total_elapsed_time = elapsed_object_build_time + elapsed_scene_build_time;
println!(
"{:.3}ms ({:.3}ms objects, {:.3}ms scene) elapsed",
total_elapsed_time, elapsed_object_build_time, elapsed_scene_build_time
);
println!("{} solid tiles", built_scene.solid_tiles.len());
for (batch_index, batch) in built_scene.batches.iter().enumerate() {
println!(
"Batch {}: {} fills, {} mask tiles",
batch_index,
batch.fills.len(),
batch.mask_tiles.len()
);
}
if let Some(output_path) = output_path {
built_scene
.write(&mut BufWriter::new(File::create(output_path).unwrap()))
.unwrap();
}
}
fn duration_to_ms(duration: &Duration) -> f64 {
duration.as_secs() as f64 * 1000.0 + f64::from(duration.subsec_micros()) / 1000.0
}