trimmed whitespace

This commit is contained in:
Adam Nemecek 2020-02-27 08:13:14 -08:00
parent 060241e4d0
commit 3d39c5e9b7
20 changed files with 43 additions and 44 deletions

View File

@ -213,7 +213,7 @@ impl CanvasRenderingContext2D {
let paint_id = self.scene.push_paint(&paint);
let mut stroke_style = self.current_state.resolve_stroke_style();
// The smaller scale is relevant here, as we multiply by it and want to ensure it is always
// bigger than `HAIRLINE_STROKE_WIDTH`.
let transform_scale = f32::min(self.current_state.transform.m11(),
@ -289,7 +289,7 @@ impl CanvasRenderingContext2D {
self.composite_render_target_if_needed(composite_op, render_target_id);
}
fn push_render_target_if_needed(&mut self, composite_op: Option<CompositeOp>)
fn push_render_target_if_needed(&mut self, composite_op: Option<CompositeOp>)
-> Option<RenderTargetId> {
if composite_op.is_none() {
return None;

View File

@ -78,7 +78,7 @@ pub enum CompositeOp {
Copy,
/// The source that overlaps the destination replaces the destination.
SrcIn,
/// Destination which overlaps the source replaces the source.
/// Destination which overlaps the source replaces the source.
DestIn,
/// Source is placed where it falls outside of the destination.
SrcOut,
@ -87,7 +87,7 @@ pub enum CompositeOp {
}
/// Blend modes that can be applied to individual paths.
///
///
/// All blend modes preserve parts of the destination that are not overlapped by the source path.
/// Other Porter-Duff compositing operations are `CompositeOp`s.
#[derive(Clone, Copy, PartialEq, Debug)]

View File

@ -9,7 +9,7 @@
// except according to those terms.
//! Pathfinder's representation of a vector scene.
//!
//!
//! This module also contains various path utilities.
#[macro_use]

View File

@ -69,7 +69,7 @@ impl Segment {
}
/// Approximates an unit-length arc with a cubic Bézier curve.
///
///
/// The maximum supported sweep angle is π/2 (i.e. 90°).
pub fn arc(sweep_angle: f32) -> Segment {
Segment::arc_from_cos(f32::cos(sweep_angle))

View File

@ -343,7 +343,7 @@ impl<W> DemoApp<W> where W: Window {
for (index, eye_transform) in eye_transforms.iter().enumerate().skip(1) {
let weight = 1.0 / (index + 1) as f32;
scene_transform.perspective.transform =
scene_transform.perspective
scene_transform.perspective
.transform
.lerp(weight, &eye_transform.perspective.transform);
scene_transform.modelview_to_eye =

View File

@ -214,7 +214,7 @@ impl<W> DemoApp<W> where W: Window {
let base_transform = perspective.transform * Transform4F::from_translation(offset);
// Fill ground.
let transform = base_transform *
let transform = base_transform *
Transform4F::from_scale(Vector4F::new(ground_scale, 1.0, ground_scale, 1.0));
// Don't clear the first scene after drawing it.

View File

@ -83,7 +83,7 @@ impl DemoUIModel {
// Only relevant if in monochrome mode.
pub fn foreground_color(&self) -> ColorU {
match self.background_color {
BackgroundColor::Light | BackgroundColor::Transparent => ColorU::black(),
BackgroundColor::Light | BackgroundColor::Transparent => ColorU::black(),
BackgroundColor::Dark => ColorU::white(),
}
}

View File

@ -75,7 +75,7 @@ pub struct MLGraphicsRenderBufferInfo {
pub color: MLGraphicsRenderTarget,
pub depth: MLGraphicsRenderTarget,
}
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct MLGraphicsRenderTarget {

View File

@ -112,7 +112,7 @@ impl Display for GlWindowDisplay {
self.handle_events();
Ok(())
}
fn running(&self) -> bool {
self.running
}
@ -124,7 +124,7 @@ impl Display for GlWindowDisplay {
impl DisplayCamera for GlWindowCamera {
type Error = GlWindowError;
fn make_current(&mut self) -> Result<(), GlWindowError> {
let bounds = self.bounds();
unsafe {
@ -176,7 +176,7 @@ impl GlWindowDisplay {
let cameras = vec![
GlWindowCamera { gl_window: gl_window.clone(), start, eye: Eye::Left },
GlWindowCamera { gl_window: gl_window.clone(), start, eye: Eye::Right },
];
];
gl::load_with(|name| gl_window.get_proc_address(name) as *const _);
Ok(GlWindowDisplay {
resource_loader,
@ -251,4 +251,4 @@ impl From<io::Error> for GlWindowError {
}
impl DisplayError for GlWindowError {
}
}

View File

@ -91,7 +91,7 @@ pub extern "C" fn magicleap_pathfinder_demo_init(egl_display: EGLDisplay, egl_co
options.background_color = BackgroundColor::Transparent;
options.mode = Mode::VR;
options.jobs = Some(3);
let demo = DemoApp::new(window, window_size, options);
info!("Initialized app");
@ -144,7 +144,7 @@ pub struct MagicLeapPathfinderRenderOptions {
surface: EGLSurface,
bg_color: [f32; 4],
viewport: [u32; 4],
svg_filename: *const c_char,
svg_filename: *const c_char,
}
#[no_mangle]
@ -159,7 +159,7 @@ pub extern "C" fn magicleap_pathfinder_init() -> *mut c_void {
log::set_boxed_logger(Box::new(logger)).unwrap();
log::set_max_level(level);
info!("Initialized logging");
gl::load_with(|s| egl::get_proc_address(s) as *const c_void);
info!("Initialized gl");
@ -219,7 +219,7 @@ pub unsafe extern "C" fn magicleap_pathfinder_render(pf: *mut c_void, options: *
let transform = Transform2F::from_translation(svg.scene.bounds().size().scale(-0.5))
.post_mul(&Transform2F::from_scale(Vector2F::splat(scale)))
.post_mul(&Transform2F::from_translation(viewport_size.to_f32().scale(0.5)));
let render_options = RenderOptions {
transform: RenderTransform::Transform2D(transform),
dilation: Vector2F::default(),

View File

@ -21,10 +21,10 @@ use pdf::Pdf;
pub enum FileFormat {
/// Scalable Vector Graphics
SVG,
/// Portable Document Format
PDF,
/// PostScript
PS,
}
@ -63,18 +63,18 @@ fn export_svg<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
writeln!(writer, "</svg>")?;
Ok(())
}
fn export_pdf<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
let mut pdf = Pdf::new();
let view_box = scene.view_box();
pdf.add_page(view_box.size());
let height = view_box.size().y();
let tr = |v: Vector2F| -> Vector2F {
let r = v - view_box.origin();
Vector2F::new(r.x(), height - r.y())
};
for (paint, outline, _) in scene.paths() {
match paint {
Paint::Color(color) => pdf.set_fill_color(*color),
@ -85,7 +85,7 @@ fn export_pdf<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
// TODO(pcwalton): Patterns.
}
}
for contour in outline.contours() {
for (segment_index, segment) in contour.iter().enumerate() {
if segment_index == 0 {
@ -111,13 +111,13 @@ fn export_pdf<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
pdf.close();
}
}
// closes implicitly
pdf.fill();
}
pdf.write_to(writer)
}
fn export_ps<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
struct P(Vector2F);
impl fmt::Display for P {
@ -138,7 +138,7 @@ fn export_ps<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
)?;
writeln!(writer, "0 {} translate", view_box.size().y())?;
writeln!(writer, "1 -1 scale")?;
for (paint, outline, name) in scene.paths() {
if !name.is_empty() {
writeln!(writer, "newpath % {}", name)?;

View File

@ -133,22 +133,22 @@ impl Pdf {
.extend("/DeviceRGB cs /DeviceRGB CS\n1 j 1 J\n".bytes());
self.page_size = Some(size);
}
pub fn move_to(&mut self, p: Vector2F) {
writeln!(self.page_buffer, "{} {} m", p.x(), p.y()).unwrap();
}
pub fn line_to(&mut self, p: Vector2F) {
writeln!(self.page_buffer, "{} {} l", p.x(), p.y()).unwrap();
}
pub fn cubic_to(&mut self, c1: Vector2F, c2: Vector2F, p: Vector2F) {
writeln!(self.page_buffer, "{} {} {} {} {} {} c", c1.x(), c1.y(), c2.x(), c2.y(), p.x(), p.y()).unwrap();
}
pub fn fill(&mut self) {
writeln!(self.page_buffer, "f").unwrap();
}
pub fn close(&mut self) {
writeln!(self.page_buffer, "h").unwrap();
}
@ -203,7 +203,7 @@ impl Pdf {
pub fn write_to<W>(&mut self, writer: W) -> io::Result<()> where W: Write {
let mut out = Counter::new(writer);
out.write_all(b"%PDF-1.7\n%\xB5\xED\xAE\xFB\n")?;
if !self.page_buffer.is_empty() {
self.end_page();
}
@ -254,7 +254,7 @@ impl Pdf {
// Write the PDF EOF
out.write_all(b"%%EOF")?;
Ok(())
}
}

View File

@ -100,7 +100,7 @@ impl TextureAllocator {
TextureLocation { page, rect }
}
pub fn allocate_render_target(&mut self, requested_size: Vector2I, id: RenderTargetId)
pub fn allocate_render_target(&mut self, requested_size: Vector2I, id: RenderTargetId)
-> TextureLocation {
let page = PaintPageId(self.pages.len() as u32);
let rect = RectI::new(Vector2I::default(), requested_size);

View File

@ -472,7 +472,7 @@ where
}
self.stats.path_count = path_count;
self.flags.set(RendererFlags::INTERMEDIATE_DEST_FRAMEBUFFER_NEEDED,
self.flags.set(RendererFlags::INTERMEDIATE_DEST_FRAMEBUFFER_NEEDED,
needs_readable_framebuffer);
}
@ -857,7 +857,7 @@ where
self.set_uniforms_for_overlay_blend_mode(&mut textures, &mut uniforms, blend_mode);
}
BlendModeProgram::DodgeBurn => {
self.set_uniforms_for_dodge_burn_blend_mode(&mut textures,
self.set_uniforms_for_dodge_burn_blend_mode(&mut textures,
&mut uniforms,
blend_mode);
}

View File

@ -466,7 +466,7 @@ pub struct AlphaTileBlendModeProgram<D> where D: Device {
}
impl<D> AlphaTileBlendModeProgram<D> where D: Device {
pub fn new(device: &D, resources: &dyn ResourceLoader, name: &str)
pub fn new(device: &D, resources: &dyn ResourceLoader, name: &str)
-> AlphaTileBlendModeProgram<D> {
let alpha_tile_program =
AlphaTileProgram::from_fragment_shader_name(device, resources, name);

View File

@ -296,7 +296,7 @@ impl Palette {
// Render the actual texels.
//
// TODO(pcwalton): This is slow. Do more on GPU.
let mut paint_data = PaintData { pages: vec![] };
let mut paint_data = PaintData { pages: vec![] };
for page_index in 0..allocator.page_count() {
let page_index = PaintPageId(page_index);
let page_size = allocator.page_size(page_index);

View File

@ -190,7 +190,7 @@ impl Scene {
let prepared_options = options.prepare(self.bounds);
SceneBuilder::new(self, &prepared_options, listener).build(executor)
}
pub fn paths<'a>(&'a self) -> PathIter {
PathIter {
scene: self,

View File

@ -179,7 +179,7 @@ impl Build for OutlinePathBuilder {
self.flush_current_contour();
self.outline
}
fn build_and_reset(&mut self) -> Outline {
self.flush_current_contour();
mem::replace(&mut self.outline, Outline::new())
@ -218,5 +218,4 @@ impl FlatPathBuilder for OutlinePathBuilder {
let point = self.current_contour.position_of(point_index);
Point2D::new(point.x(), point.y())
}
}
}

View File

@ -603,7 +603,7 @@ impl<D> DebugTextureVertexArray<D> where D: Device {
let position_attr = device.get_vertex_attr(&debug_texture_program.program, "Position")
.unwrap();
let tex_coord_attr = device.get_vertex_attr(&debug_texture_program.program, "TexCoord")
let tex_coord_attr = device.get_vertex_attr(&debug_texture_program.program, "TexCoord")
.unwrap();
device.bind_buffer(&vertex_array, &vertex_buffer, BufferTarget::Vertex);

View File

@ -10,7 +10,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut args = std::env::args_os().skip(1);
let input = PathBuf::from(args.next().expect("no input given"));
let output = PathBuf::from(args.next().expect("no output given"));
let mut data = Vec::new();
File::open(input)?.read_to_end(&mut data)?;
let svg = BuiltSVG::from_tree(&Tree::from_data(&data, &Options::default()).unwrap());