Replace commented out printlns with proper debug statements

This commit is contained in:
Patrick Walton 2019-04-29 16:43:24 -07:00
parent d06746f28d
commit 8606cd013e
17 changed files with 213 additions and 149 deletions

51
Cargo.lock generated
View File

@ -180,6 +180,16 @@ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "chrono"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clap"
version = "2.32.0"
@ -351,6 +361,7 @@ dependencies = [
"pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0",
"pathfinder_simd 0.3.0",
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sdl2 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sdl2-sys 0.32.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -404,6 +415,18 @@ dependencies = [
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "env_logger"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "error-chain"
version = "0.12.0"
@ -997,6 +1020,7 @@ dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0",
@ -1014,6 +1038,7 @@ version = "0.3.0"
dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_simd 0.3.0",
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1026,6 +1051,7 @@ version = "0.1.0"
dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0",
"pathfinder_gpu 0.1.0",
"pathfinder_renderer 0.1.0",
@ -1072,6 +1098,7 @@ dependencies = [
"byteorder 1.3.1 (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)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0",
"pathfinder_gpu 0.1.0",
"pathfinder_simd 0.3.0",
@ -1161,6 +1188,16 @@ dependencies = [
"num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pretty_env_logger"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "0.4.27"
@ -1715,6 +1752,16 @@ dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "time"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ucd-util"
version = "0.1.3"
@ -1966,6 +2013,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49"
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf79daa4e11e5def06e55306aa3601b87de6b5149671529318da048f67cdd77b"
@ -1989,6 +2037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum egl 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a373bc9844200b1ff15bd1b245931d1c20d09d06e4ec09f361171f29a4b0752d"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38"
"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
"checksum euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a7698bdda3d7444a79d33bdc96e8b518d44ea3ff101d8492a6ca1207b886ea"
"checksum euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15"
@ -2062,6 +2111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
"checksum png 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f54b9600d584d3b8a739e1662a595fab051329eff43f20e7d8cc22872962145b"
"checksum png 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9adebf7fb91ccf5eac9da1a8e00e83cb8ae882c3e8d8e4ad59da73cb8c82a2c9"
"checksum pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8b3f4e0475def7d9c2e5de8e5a1306949849761e107b360d03e98eafaffd61"
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quickcheck 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4537d3e4edf73a15dd059b75bed1c292d17d3ea7517f583cebe716794fcf816"
@ -2128,6 +2178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"

View File

@ -15,6 +15,10 @@ version = "0.21"
default-features = false
features = ["png_codec"]
[dependencies.log]
version = "0.4"
features = ["release_max_level_warn"]
[dependencies.pathfinder_geometry]
path = "../../geometry"

View File

@ -10,6 +10,9 @@
//! A demo app for Pathfinder.
#[macro_use]
extern crate log;
use crate::device::{GroundLineVertexArray, GroundProgram, GroundSolidVertexArray};
use crate::ui::{DemoUI, UIAction};
use crate::window::{Event, Keycode, OcularTransform, SVGPath, View, Window, WindowSize};
@ -437,7 +440,7 @@ impl<W> DemoApp<W> where W: Window {
self.window.make_current(view);
if self.camera.mode() != Mode::VR {
self.draw_environment(0);
self.draw_environment();
}
self.render_vector_scene();
@ -469,11 +472,9 @@ impl<W> DemoApp<W> where W: Window {
_ => return,
};
/*
println!("scene_transform.perspective={:?}", scene_transform.perspective);
println!("scene_transform.modelview_to_eye={:?}", scene_transform.modelview_to_eye);
println!("modelview transform={:?}", modelview_transform);
*/
debug!("scene_transform.perspective={:?}", scene_transform.perspective);
debug!("scene_transform.modelview_to_eye={:?}", scene_transform.modelview_to_eye);
debug!("modelview transform={:?}", modelview_transform);
let viewport = self.window.viewport(View::Stereo(render_scene_index));
self.renderer.replace_dest_framebuffer(DestFramebuffer::Default {
@ -489,7 +490,7 @@ impl<W> DemoApp<W> where W: Window {
rect: Some(viewport),
});
self.draw_environment(render_scene_index);
self.draw_environment();
let scene_framebuffer = self.scene_framebuffer.as_ref().unwrap();
let scene_texture = self.renderer.device.framebuffer_texture(scene_framebuffer);
@ -509,13 +510,11 @@ impl<W> DemoApp<W> where W: Window {
.post_mul(&modelview_transform.to_transform())
.post_mul(&quad_scale_transform);
/*
println!("eye transform({}).modelview_to_eye={:?}",
debug!("eye transform({}).modelview_to_eye={:?}",
render_scene_index,
eye_transform.modelview_to_eye);
println!("eye transform_matrix({})={:?}", render_scene_index, eye_transform_matrix);
println!("---");
*/
debug!("eye transform_matrix({})={:?}", render_scene_index, eye_transform_matrix);
debug!("---");
self.renderer.reproject_texture(scene_texture,
&scene_transform_matrix.transform,
@ -606,7 +605,7 @@ impl<W> DemoApp<W> where W: Window {
self.frame_counter += 1;
}
fn draw_environment(&self, viewport_index: u32) {
fn draw_environment(&self) {
// TODO(pcwalton): Use the viewport index!
let frame = &self.current_frame.as_ref().unwrap();
@ -912,7 +911,7 @@ fn build_scene(scene: &Scene,
});
if result.is_err() {
eprintln!("Scene building crashed! Dumping scene:");
error!("Scene building crashed! Dumping scene:");
println!("{:?}", scene);
process::exit(1);
}

View File

@ -12,6 +12,7 @@ color-backtrace = "0.1"
gl = "0.6"
jemallocator = "0.1"
nfd = "0.0.4"
pretty_env_logger = "0.3"
sdl2 = "0.32"
sdl2-sys = "0.32"

View File

@ -35,6 +35,7 @@ const DEFAULT_WINDOW_HEIGHT: u32 = 800;
fn main() {
color_backtrace::install();
pretty_env_logger::init();
let window = WindowImpl::new();
let window_size = window.size();

View File

@ -11,5 +11,9 @@ serde = "1.0"
serde_derive = "1.0"
smallvec = "0.6"
[dependencies.log]
version = "0.4"
features = ["release_max_level_warn"]
[dependencies.pathfinder_simd]
path = "../simd"

View File

@ -16,6 +16,7 @@ use crate::segment::{CubicSegment, Segment};
use crate::util::lerp;
use arrayvec::ArrayVec;
use smallvec::SmallVec;
use std::fmt::Debug;
use std::mem;
#[derive(Clone, Copy, Debug)]
@ -25,7 +26,7 @@ impl TEdge for Edge {
#[inline]
fn point_is_inside(&self, point: &Point2DF32) -> bool {
let area = (self.0.to() - self.0.from()).det(*point - self.0.from());
//println!("point_is_inside({:?}, {:?}), area={}", self, point, area);
debug!("point_is_inside({:?}, {:?}), area={}", self, point, area);
area >= 0.0
}
@ -72,13 +73,13 @@ impl TEdge for AxisAlignedEdge {
}
}
trait TEdge {
trait TEdge: Debug {
fn point_is_inside(&self, point: &Point2DF32) -> bool;
fn intersect_line_segment(&self, segment: &LineSegmentF32) -> ArrayVec<[f32; 3]>;
fn trivially_test_segment(&self, segment: &Segment) -> EdgeRelativeLocation {
let from_inside = self.point_is_inside(&segment.baseline.from());
//println!("point {:?} inside {:?}: {:?}", segment.baseline.from(), self, from_inside);
debug!("point {:?} inside {:?}: {:?}", segment.baseline.from(), self, from_inside);
if from_inside != self.point_is_inside(&segment.baseline.to()) {
return EdgeRelativeLocation::Intersecting;
}
@ -125,8 +126,8 @@ trait TEdge {
fn intersect_cubic_segment(&self, segment: &Segment, mut t_min: f32, mut t_max: f32)
-> Option<f32> {
/*println!("... intersect_cubic_segment({:?}, {:?}, t=({}, {}))",
self, segment, t_min, t_max);*/
debug!("... intersect_cubic_segment({:?}, {:?}, t=({}, {}))", self, segment, t_min, t_max);
let mut segment = segment.as_cubic_segment().split_after(t_min);
segment = segment.as_cubic_segment().split_before(t_max / (1.0 - t_min));
@ -161,7 +162,7 @@ trait TEdge {
}
}
trait ContourClipper where Self::Edge: TEdge {
trait ContourClipper where Self::Edge: TEdge + Debug {
type Edge;
fn contour_mut(&mut self) -> &mut Contour;
@ -191,7 +192,7 @@ trait ContourClipper where Self::Edge: TEdge {
match edge.trivially_test_segment(&segment) {
EdgeRelativeLocation::Outside => return,
EdgeRelativeLocation::Inside => {
//println!("trivial test inside, pushing segment");
debug!("trivial test inside, pushing segment");
self.push_segment(&segment);
return;
}
@ -199,22 +200,22 @@ trait ContourClipper where Self::Edge: TEdge {
}
// We have a potential intersection.
//println!("potential intersection: {:?} edge: {:?}", segment, edge);
debug!("potential intersection: {:?} edge: {:?}", segment, edge);
let mut starts_inside = edge.point_is_inside(&segment.baseline.from());
let intersection_ts = edge.intersect_segment(&segment);
let mut last_t = 0.0;
//println!("... intersections: {:?}", intersection_ts);
debug!("... intersections: {:?}", intersection_ts);
for t in intersection_ts {
let (before_split, after_split) = segment.split((t - last_t) / (1.0 - last_t));
// Push the split segment if appropriate.
/*println!("... ... edge={:?} before_split={:?} t={:?} starts_inside={:?}",
edge.0,
debug!("... ... edge={:?} before_split={:?} t={:?} starts_inside={:?}",
edge,
before_split,
t,
starts_inside);*/
starts_inside);
if starts_inside {
//println!("... split segment case, pushing segment");
debug!("... split segment case, pushing segment");
self.push_segment(&before_split);
}
@ -226,13 +227,12 @@ trait ContourClipper where Self::Edge: TEdge {
// No more intersections. Push the last segment if applicable.
if starts_inside {
//println!("... last segment case, pushing segment");
debug!("... last segment case, pushing segment");
self.push_segment(&segment);
}
}
fn push_segment(&mut self, segment: &Segment) {
//println!("... push_segment({:?}, edge={:?}", segment, edge);
let contour = self.contour_mut();
if let Some(last_position) = contour.last_position() {
if last_position != segment.baseline.from() {
@ -368,19 +368,19 @@ impl PolygonClipper3D {
pub fn clip(mut self) -> Vec<Point3DF32> {
// TODO(pcwalton): Fast path for completely contained polygon?
//println!("before clipping against bottom: {:?}", self.subject);
debug!("before clipping against bottom: {:?}", self.subject);
self.clip_against(Edge3D::Bottom);
//println!("before clipping against top: {:?}", self.subject);
debug!("before clipping against top: {:?}", self.subject);
self.clip_against(Edge3D::Top);
//println!("before clipping against left: {:?}", self.subject);
debug!("before clipping against left: {:?}", self.subject);
self.clip_against(Edge3D::Left);
//println!("before clipping against right: {:?}", self.subject);
debug!("before clipping against right: {:?}", self.subject);
self.clip_against(Edge3D::Right);
//println!("before clipping against far: {:?}", self.subject);
debug!("before clipping against far: {:?}", self.subject);
self.clip_against(Edge3D::Far);
//println!("before clipping against near: {:?}", self.subject);
debug!("before clipping against near: {:?}", self.subject);
self.clip_against(Edge3D::Near);
//println!("after clipping: {:?}", self.subject);
debug!("after clipping: {:?}", self.subject);
self.subject
}

View File

@ -68,12 +68,10 @@ impl<'a> ContourDilator<'a> {
}
let next_vector = (next_position - position).normalize();
/*
println!("prev={} cur={} next={}",
debug!("prev={} cur={} next={}",
prev_point_index,
current_point_index,
next_point_index);
*/
// Calculate new position by moving the point by the bisector.
let bisector = prev_vector.yx() + next_vector.yx();
@ -85,8 +83,7 @@ impl<'a> ContourDilator<'a> {
};
let new_position = position - scaled_bisector;
/*
println!("dilate(): prev={}({:?}) cur={}({:?}) next={}({:?}) bisector={:?}({:?}, {:?})",
debug!("dilate(): prev={}({:?}) cur={}({:?}) next={}({:?}) bisector={:?}({:?}, {:?})",
prev_point_index,
prev_position,
current_point_index,
@ -96,22 +93,12 @@ impl<'a> ContourDilator<'a> {
bisector,
bisector_length,
scaled_bisector);
*/
/*if bisector_length == 0.0 {
println!("dilate({:?}): {:?} -> {:?} (bisector {:?}, length {:?})",
self.amount,
position,
new_position,
bisector,
bisector_length);
}*/
// Update all points.
let mut point_index = current_point_index;
while point_index != next_point_index {
self.contour.points[point_index as usize] = new_position;
//println!("... updating {:?}", point_index);
debug!("... updating {:?}", point_index);
point_index = self.contour.next_point_index_of(point_index);
}

View File

@ -14,6 +14,8 @@
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate log;
pub mod basic;
pub mod clip;

View File

@ -93,10 +93,10 @@ impl Offset for SegmentPF3 {
return;
}
//println!("--- SPLITTING ---");
//println!("... PRE-SPLIT: {:?}", self);
debug!("--- SPLITTING ---");
debug!("... PRE-SPLIT: {:?}", self);
let (before, after) = self.split(0.5);
//println!("... AFTER-SPLIT: {:?} {:?}", before, after);
debug!("... AFTER-SPLIT: {:?} {:?}", before, after);
before.offset(distance, contour);
after.offset(distance, contour);
}
@ -179,8 +179,8 @@ impl Offset for SegmentPF3 {
let (this_p, other_p) = (self.sample(t), other.sample(t));
let vector = this_p - other_p;
let square_distance = vector.square_length();
/*println!("this_p={:?} other_p={:?} vector={:?} sqdist={:?} min={:?} max={:?}",
this_p, other_p, vector, square_distance, min, max);*/
debug!("this_p={:?} other_p={:?} vector={:?} sqdist={:?} min={:?} max={:?}",
this_p, other_p, vector, square_distance, min, max);
if square_distance < min || square_distance > max {
return false;
}

View File

@ -13,6 +13,10 @@ version = "0.21"
default-features = false
features = ["png_codec"]
[dependencies.log]
version = "0.4"
features = ["release_max_level_warn"]
[dependencies.pathfinder_geometry]
path = "../geometry"

View File

@ -10,6 +10,9 @@
//! An OpenGL implementation of the device abstraction.
#[macro_use]
extern crate log;
use gl::types::{GLboolean, GLchar, GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint, GLvoid};
use pathfinder_geometry::basic::point::Point2DI32;
use pathfinder_geometry::basic::rect::RectI32;
@ -24,6 +27,7 @@ use std::mem;
use std::ptr;
use std::str;
use std::time::Duration;
pub struct GLDevice {
version: GLVersion,
default_framebuffer: GLuint,
@ -254,7 +258,7 @@ impl Device for GLDevice {
info_log.len() as GLint,
ptr::null_mut(),
info_log.as_mut_ptr() as *mut GLchar); ck();
eprintln!("Shader info log:\n{}", String::from_utf8_lossy(&info_log));
error!("Shader info log:\n{}", String::from_utf8_lossy(&info_log));
panic!("{:?} shader '{}' compilation failed", kind, name);
}

View File

@ -13,6 +13,10 @@ serde = "1.0"
serde_json = "1.0"
smallvec = "0.6"
[dependencies.log]
version = "0.4"
features = ["release_max_level_warn"]
[dependencies.pathfinder_geometry]
path = "../geometry"

View File

@ -174,12 +174,12 @@ impl RenderTransform {
bounds.lower_right().to_3d(),
bounds.lower_left().to_3d(),
];
//println!("-----");
//println!("bounds={:?} ORIGINAL quad={:?}", self.bounds, points);
debug!("-----");
debug!("bounds={:?} ORIGINAL quad={:?}", bounds, points);
for point in &mut points {
*point = perspective.transform.transform_point(*point);
}
//println!("... PERSPECTIVE quad={:?}", points);
debug!("... PERSPECTIVE quad={:?}", points);
// Compute depth.
let quad = [
@ -188,10 +188,10 @@ impl RenderTransform {
points[2].perspective_divide(),
points[3].perspective_divide(),
];
//println!("... PERSPECTIVE-DIVIDED points = {:?}", quad);
debug!("... PERSPECTIVE-DIVIDED points = {:?}", quad);
points = PolygonClipper3D::new(points).clip();
//println!("... CLIPPED quad={:?}", points);
debug!("... CLIPPED quad={:?}", points);
for point in &mut points {
*point = point.perspective_divide()
}

View File

@ -98,7 +98,7 @@ impl BuiltObject {
builder: &SceneBuilder,
segment: &LineSegmentF32,
tile_coords: Point2DI32) {
//println!("add_fill({:?} ({}, {}))", segment, tile_x, tile_y);
debug!("add_fill({:?} ({:?}))", segment, tile_coords);
// Ensure this fill is in bounds. If not, cull it.
if self.tile_coords_to_local_index(tile_coords).is_none() {
@ -111,7 +111,6 @@ impl BuiltObject {
let shuffle_mask = I32x4::new(0x0c08_0400, 0x0d05_0901, 0, 0).as_u8x16();
let tile_upper_left = tile_coords.to_f32().0.xyxy() * tile_size;
//F32x4::new(tile_x as f32, tile_y as f32, tile_x as f32, tile_y as f32) * tile_size;
let segment = (segment.0 - tile_upper_left) * F32x4::splat(256.0);
let segment =
@ -124,15 +123,14 @@ impl BuiltObject {
// Cull degenerate fills.
if (px.0 & 0xf) as u8 == ((px.0 >> 8) & 0xf) as u8 &&
(subpx.0 & 0xff) as u8 == ((subpx.0 >> 16) & 0xff) as u8 {
//println!("... ... culling!");
debug!("... culling!");
return;
}
// Allocate global tile if necessary.
let alpha_tile_index = self.get_or_allocate_alpha_tile_index(builder, tile_coords);
//println!("... ... OK, pushing");
debug!("... OK, pushing");
self.fills.push(FillBatchPrimitive { px, subpx, alpha_tile_index });
}
@ -166,12 +164,11 @@ impl BuiltObject {
LineSegmentF32::new(&right, &left)
};
/*println!("... emitting active fill {} -> {} winding {} @ tile {},{}",
debug!("... emitting active fill {} -> {} winding {} @ tile {:?}",
left.x(),
right.x(),
winding,
tile_x,
tile_y);*/
tile_coords);
while winding != 0 {
self.add_fill(builder, &segment, tile_coords);
@ -187,11 +184,11 @@ impl BuiltObject {
builder: &SceneBuilder,
mut segment: LineSegmentF32,
tile_y: i32) {
/*println!("... generate_fill_primitives_for_line(): segment={:?} tile_y={} ({}-{})",
debug!("... generate_fill_primitives_for_line(): segment={:?} tile_y={} ({}-{})",
segment,
tile_y,
tile_y as f32 * TILE_HEIGHT as f32,
(tile_y + 1) as f32 * TILE_HEIGHT as f32);*/
(tile_y + 1) as f32 * TILE_HEIGHT as f32);
let winding = segment.from_x() > segment.to_x();
let (segment_left, segment_right) = if !winding {
@ -204,8 +201,10 @@ impl BuiltObject {
let segment_tile_left = f32::floor(segment_left) as i32 / TILE_WIDTH as i32;
let segment_tile_right =
util::alignup_i32(f32::ceil(segment_right) as i32, TILE_WIDTH as i32);
/*println!("segment_tile_left={} segment_tile_right={} tile_rect={:?}",
segment_tile_left, segment_tile_right, self.tile_rect);*/
debug!("segment_tile_left={} segment_tile_right={} tile_rect={:?}",
segment_tile_left,
segment_tile_right,
self.tile_rect());
for subsegment_tile_x in segment_tile_left..segment_tile_right {
let (mut fill_from, mut fill_to) = (segment.from(), segment.to());

View File

@ -10,6 +10,9 @@
//! The CPU portion of Pathfinder's renderer.
#[macro_use]
extern crate log;
pub mod builder;
pub mod gpu;
pub mod gpu_data;

View File

@ -74,7 +74,9 @@ impl<'a> Tiler<'a> {
// Pack and cull.
self.pack_and_cull();
//println!("{:#?}", self.built_object);
// Done!
debug!("{:#?}", self.built_object);
}
fn generate_strip(&mut self, strip_origin_y: i32) {
@ -126,8 +128,9 @@ impl<'a> Tiler<'a> {
let mut last_segment_x = -9999.0;
let tile_top = (i32::from(tile_y) * TILE_HEIGHT as i32) as f32;
//println!("---------- tile y {}({}) ----------", tile_y, tile_top);
//println!("old active edges: {:#?}", self.old_active_edges);
debug!("---------- tile y {}({}) ----------", tile_y, tile_top);
debug!("old active edges: {:#?}", self.old_active_edges);
for mut active_edge in self.old_active_edges.drain(..) {
// Determine x-intercept and winding.
@ -139,7 +142,7 @@ impl<'a> Tiler<'a> {
-1
};
/*println!("tile Y {}({}): segment_x={} edge_winding={} current_tile_x={} \
debug!("tile Y {}({}): segment_x={} edge_winding={} current_tile_x={} \
current_subtile_x={} current_winding={}",
tile_y,
tile_top,
@ -148,8 +151,7 @@ impl<'a> Tiler<'a> {
current_tile_x,
current_subtile_x,
current_winding);
println!("... segment={:#?} crossing={:?}", active_edge.segment, active_edge.crossing);
*/
debug!("... segment={:#?} crossing={:?}", active_edge.segment, active_edge.crossing);
// FIXME(pcwalton): Remove this debug code!
debug_assert!(segment_x >= last_segment_x);
@ -173,7 +175,7 @@ impl<'a> Tiler<'a> {
// Move over to the correct tile, filling in as we go.
while current_tile_x < segment_tile_x {
//println!("... emitting backdrop {} @ tile {}", current_winding, current_tile_x);
debug!("... emitting backdrop {} @ tile {}", current_winding, current_tile_x);
let current_tile_coords = Point2DI32::new(current_tile_x, tile_y);
if let Some(tile_index) = self.built_object
.tile_coords_to_local_index(current_tile_coords) {
@ -188,7 +190,6 @@ impl<'a> Tiler<'a> {
// Do final subtile fill, if necessary.
debug_assert_eq!(current_tile_x, segment_tile_x);
//debug_assert!(current_tile_x <= self.built_object.tile_rect.max_x());
let segment_subtile_x =
segment_x - (i32::from(current_tile_x) * TILE_WIDTH as i32) as f32;
if segment_subtile_x > current_subtile_x {
@ -207,7 +208,7 @@ impl<'a> Tiler<'a> {
current_winding += edge_winding;
// Process the edge.
//println!("about to process existing active edge {:#?}", active_edge);
debug!("about to process existing active edge {:#?}", active_edge);
debug_assert!(f32::abs(active_edge.crossing.y() - tile_top) < 0.1);
active_edge.process(self.builder, &mut self.built_object, tile_y);
if !active_edge.segment.is_none() {
@ -227,8 +228,8 @@ impl<'a> Tiler<'a> {
// TODO(pcwalton): Could use a bitset of processed edges…
let prev_endpoint_index = contour.prev_endpoint_index_of(point_index.point());
let next_endpoint_index = contour.next_endpoint_index_of(point_index.point());
/*
println!("adding new active edge, tile_y={} point_index={} prev={} next={} pos={:?} \
debug!("adding new active edge, tile_y={} point_index={} prev={} next={} pos={:?} \
prevpos={:?} nextpos={:?}",
tile_y,
point_index.point(),
@ -237,10 +238,10 @@ impl<'a> Tiler<'a> {
contour.position_of(point_index.point()),
contour.position_of(prev_endpoint_index),
contour.position_of(next_endpoint_index));
*/
if contour.point_is_logically_above(point_index.point(), prev_endpoint_index) {
//println!("... adding prev endpoint");
debug!("... adding prev endpoint");
process_active_segment(
contour,
prev_endpoint_index,
@ -254,15 +255,13 @@ impl<'a> Tiler<'a> {
point_index: PointIndex::new(point_index.contour(), prev_endpoint_index),
y: contour.position_of(prev_endpoint_index).y(),
});
//println!("... done adding prev endpoint");
debug!("... done adding prev endpoint");
}
if contour.point_is_logically_above(point_index.point(), next_endpoint_index) {
/*
println!("... adding next endpoint {} -> {}",
point_index.point(),
next_endpoint_index);
*/
debug!("... adding next endpoint {} -> {}", point_index.point(), next_endpoint_index);
process_active_segment(
contour,
point_index.point(),
@ -276,7 +275,8 @@ impl<'a> Tiler<'a> {
point_index: PointIndex::new(point_index.contour(), next_endpoint_index),
y: contour.position_of(next_endpoint_index).y(),
});
//println!("... done adding next endpoint");
debug!("... done adding next endpoint");
}
}
@ -325,10 +325,10 @@ fn process_active_segment(
tile_y: i32,
) {
let mut active_edge = ActiveEdge::from_segment(&contour.segment_after(from_endpoint_index));
//println!("... process_active_segment({:#?})", active_edge);
debug!("... process_active_segment({:#?})", active_edge);
active_edge.process(builder, built_object, tile_y);
if !active_edge.segment.is_none() {
//println!("... ... pushing resulting active edge: {:#?}", active_edge);
debug!("... ... pushing resulting active edge: {:#?}", active_edge);
active_edges.push(active_edge);
}
}
@ -377,8 +377,8 @@ impl ActiveEdge {
}
fn process(&mut self, builder: &SceneBuilder, built_object: &mut BuiltObject, tile_y: i32) {
//let tile_bottom = ((i32::from(tile_y) + 1) * TILE_HEIGHT as i32) as f32;
//println!("process_active_edge({:#?}, tile_y={}({}))", self, tile_y, tile_bottom);
let tile_bottom = ((i32::from(tile_y) + 1) * TILE_HEIGHT as i32) as f32;
debug!("process_active_edge({:#?}, tile_y={}({}))", self, tile_y, tile_bottom);
let mut segment = self.segment;
let winding = segment.baseline.y_winding();
@ -425,8 +425,7 @@ impl ActiveEdge {
split_t = next_t;
}
/*
println!("... tile_y={} winding={} segment={:?} t={} before_segment={:?}
debug!("... tile_y={} winding={} segment={:?} t={} before_segment={:?}
after_segment={:?}",
tile_y,
winding,
@ -434,7 +433,6 @@ impl ActiveEdge {
split_t,
before_segment,
after_segment);
*/
let line = before_segment.baseline.orient(winding);
match self.process_line_segment(&line, builder, built_object, tile_y) {
@ -463,8 +461,11 @@ impl ActiveEdge {
tile_y: i32,
) -> Option<LineSegmentF32> {
let tile_bottom = ((i32::from(tile_y) + 1) * TILE_HEIGHT as i32) as f32;
/*println!("process_line_segment({:?}, tile_y={}) tile_bottom={}",
line_segment, tile_y, tile_bottom);*/
debug!("process_line_segment({:?}, tile_y={}) tile_bottom={}",
line_segment,
tile_y,
tile_bottom);
if line_segment.max_y() <= tile_bottom {
built_object.generate_fill_primitives_for_line(builder, *line_segment, tile_y);
return None;