Commit 54cc3ddf authored by Dan Sheppard's avatar Dan Sheppard
Browse files

Tidying; performance improvements.

parent 04a6984e
......@@ -696,13 +696,11 @@ dependencies = [
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
"stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tánaiste 0.1.1",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"webgl_generator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -962,11 +960,6 @@ dependencies = [
"crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "linked-hash-map"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lock_api"
version = "0.1.5"
......@@ -1718,17 +1711,6 @@ dependencies = [
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_yaml"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
"yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sha-1"
version = "0.7.0"
......@@ -2504,14 +2486,6 @@ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "yaml-rust"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f"
"checksum RustyXML 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9222d58bccd9e6e3b82098a2ec142ad34e5d433de986d46cec03ad3a2b5fd529"
......@@ -2621,7 +2595,6 @@ dependencies = [
"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
"checksum libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "bff3ac7d6f23730d3b533c35ed75eef638167634476a499feef16c428d74b57b"
"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
......@@ -2708,7 +2681,6 @@ dependencies = [
"checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4"
"checksum serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "4b90a9fbe1211e57d3e1c15670f1cb00802988fb23a1a4aad7a2b63544f1920e"
"checksum serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d48f9f99cd749a2de71d29da5f948de7f2764cc5a9d7f3c97e3514d4ee6eabf2"
"checksum serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0887a8e097a69559b56aa2526bf7aff7c3048cf627dff781f0b56a6001534593"
"checksum sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9d1f3b5de8a167ab06834a7c883bd197f2191e1dda1a22d9ccfeedbf9aded"
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
......@@ -2795,4 +2767,3 @@ dependencies = [
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
"checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
"checksum yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "95acf0db5515d07da9965ec0e0ba6cc2d825e2caeb7303b66ca441729801254e"
......@@ -10,21 +10,19 @@ stdweb-derive = "*"
serde = "*"
serde_derive = "*"
serde_json = "*"
serde_yaml = "*"
lazy_static = "*"
rand="*"
itertools = "*"
hsl = "*"
yaml-rust="*"
url="*"
base64="*"
"t\u00e1naiste" = { version="0.1.1", path="../t\u00e1naiste" }
"t\u00E1naiste" = { version="0.1.1", path="../t\u00E1naiste" }
[build-dependencies]
webgl_generator = "*"
cargo-web="*"
regex = "*"
#[profile.release]
#lto = true
[profile.release]
lto = true
......@@ -27,7 +27,7 @@ pub struct Compositor {
impl Compositor {
pub fn new(xfercache: &XferCache, xferclerk: Box<XferClerk>) -> Compositor {
let mut out = Compositor {
Compositor {
train_manager: TrainManager::new(),
components: ComponentManager::new(),
bp_per_screen: 1.,
......@@ -40,8 +40,7 @@ impl Compositor {
pacer: PsychicPacer::new(30000.),
xfercache: xfercache.clone(),
xferclerk: xferclerk
};
out
}
}
pub fn get_prop_trans(&self) -> f32 { self.train_manager.get_prop_trans() }
......@@ -135,8 +134,6 @@ impl Compositor {
}
self.components.add(c);
}
fn get_max_y(&self) -> i32 { self.train_manager.get_max_y() }
pub fn all_printing_leafs(&self) -> Vec<Leaf> {
self.train_manager.all_printing_leafs()
......@@ -145,10 +142,8 @@ impl Compositor {
pub fn register_compositor_ticks(ar: &mut AppRunner) {
ar.add_timer(|cs,t| {
let max_y = cs.with_compo(|co| {
co.tick(t);
co.get_max_y()
});
cs.with_compo(|co| co.tick(t) );
let max_y = cs.get_all_landscapes().get_low_watermark();
cs.with_stage(|s| s.set_limit(&DOWN,max_y as f64));
vec!{}
},None);
......
......@@ -36,6 +36,17 @@ impl AllLandscapesImpl {
}
out
}
pub fn get_low_watermark(&self) -> i32 {
let mut max = 0;
for lid in self.vs.every() {
if let Some(ls) = self.vs.get(lid) {
let wm = ls.get_low_watermark().unwrap_or(0);
max = max.min(wm)
}
}
max
}
}
#[derive(Clone)]
......@@ -57,8 +68,12 @@ impl AllLandscapes {
self.0.borrow_mut().with(lid,cb)
}
pub fn every<F,G>(&mut self, mut cb: F) -> Vec<Option<G>>
pub fn every<F,G>(&mut self, cb: F) -> Vec<Option<G>>
where F: FnMut(usize, &mut Landscape) -> G {
self.0.borrow_mut().every(cb)
}
pub fn get_low_watermark(&self) -> i32 {
self.0.borrow().get_low_watermark()
}
}
......@@ -31,4 +31,8 @@ impl Landscape {
pub fn set_plot(&mut self, plot: Plot) {
self.plot = Some(plot);
}
pub fn get_low_watermark(&self) -> Option<i32> {
self.plot.as_ref().map(|x| x.get_low_watermark())
}
}
......@@ -15,4 +15,8 @@ impl Plot {
pub fn get_height(&self) -> i32 { self.y_height }
pub fn get_letter(&self) -> &str { &self.letter }
pub fn has_cog(&self) -> bool { self.cog }
pub fn get_low_watermark(&self) -> i32 {
self.y_base + self.y_height
}
}
......@@ -16,6 +16,7 @@ impl DrawnResponse {
fn populate(&mut self) {
let mut shapes = Vec::<DrawnShape>::new();
let specs = self.sr.get_shapes(&self.part);
shapes.reserve(specs.len());
for spec in specs {
shapes.push(DrawnShape::new(spec.create()));
}
......
......@@ -26,6 +26,12 @@ impl SourceResponseImpl {
out
}
pub fn expect(&mut self, amt: usize) {
for (k,v) in &mut self.shapes {
v.reserve(amt);
}
}
pub fn get_source_name(&self) -> &str { &self.source_name }
fn add_shape(&mut self, part: &Option<String>, item: ShapeSpec) {
......@@ -60,6 +66,10 @@ impl SourceResponse {
SourceResponse(Rc::new(RefCell::new(SourceResponseImpl::new(source_name,parts))))
}
pub fn expect(&self, amt: usize) {
self.0.borrow_mut().expect(amt);
}
pub fn add_shape(&mut self, part: &Option<String>, item: ShapeSpec) {
self.0.borrow_mut().add_shape(part,item);
}
......
......@@ -46,11 +46,7 @@ impl Carriage {
pub(in super) fn is_done(&self) -> bool {
self.response.as_ref().map(|x| x.get_response().is_done()).unwrap_or(false)
}
pub(in super) fn get_max_y(&self) -> i32 {
self.response.as_ref().map(|x| x.get_response().get_max_y()).unwrap_or(0)
}
pub fn draw_drawings(&mut self, ds: &mut DrawingSession) {
if let Some(ref mut response) = self.response {
response.each_shape(|s| s.redraw(ds));
......
......@@ -170,16 +170,6 @@ impl Train {
Some(self.carriages.leaf_carriages(leaf))
}
/* Maximum y of all carriages (for y endstop) */
pub(in super) fn get_max_y(&self) -> i32 {
let mut max = 0;
for c in self.carriages.all_carriages() {
let y = c.get_max_y();
if y > max { max = y; }
}
max
}
/* how much redrawing is needed? */
pub fn calc_level(&mut self, leaf: &Leaf, oom: &StateManager) -> ComponentRedo {
/* Any change due to component changes? */
......
......@@ -163,19 +163,6 @@ impl TrainManager {
cb(current_train);
}
}
/* used by COMPOSITOR to determine y-limit for viewport scrolling */
pub fn get_max_y(&self) -> i32 {
let mut max = 0;
if let Some(ref current_train) = self.current_train {
max = current_train.get_max_y();
}
if let Some(ref transition_train) = self.transition_train {
let y = transition_train.get_max_y();
if y > max { max = y; }
}
max
}
/* ***********************************************************
* Methods used to manage future creation/destruction based on
......
......@@ -16,7 +16,6 @@ use controller::output::{ OutputAction, Report, ViewportReport };
use data::{ BackendConfig, BackendStickManager, HttpManager, HttpXferClerk, XferCache, XferClerk };
use debug::add_debug_sticks;
use dom::domutil;
use mosquito::Bottle;
use print::Printer;
use tácode::Tácode;
......@@ -43,7 +42,6 @@ impl App {
let browser_el = browser_el.clone();
let bottle_el = domutil::query_selector2(&outer_el.clone().into(),".bottle");
let swarm_el = domutil::query_selector2(&outer_el.clone().into(),".swarm");
let mut bottle = Bottle::new(bottle_el,swarm_el.unwrap());
domutil::inner_html(&browser_el.clone().into(),CANVAS);
let canv_el : HtmlElement = domutil::query_selector(&browser_el.clone().into(),"canvas").try_into().unwrap();
let bsm = BackendStickManager::new(config);
......@@ -68,10 +66,7 @@ impl App {
};
let dsm = CombinedSourceManager::new(&tc,config,&out.als,&out.http_clerk);
out.csl.add_compsource(Box::new(dsm));
out.run_actions(&startup_actions());
/* XXX */
bottle.make("mosquito-cog");
out.run_actions(&startup_actions());
out
}
......
......@@ -76,7 +76,7 @@ fn exe_resize(cg: &App, sz: Dot<i32,i32>) {
fn exe_component_add(a: &mut App, name: &str) {
if let Some(c) = a.get_component(name) {
a.with_compo(|co| {
let mut cs = co.get_component_set();
let cs = co.get_component_set();
cs.add(c)
});
}
......
......@@ -15,8 +15,8 @@ pub struct MousePhysicsImpl {
#[derive(Clone)]
pub struct MousePhysics(Arc<Mutex<MousePhysicsImpl>>);
const LETHARGY : f64 = 3500.;
const BOING : f64 = 1.00;
const LETHARGY : f64 = 2500.;
const BOING : f64 = 4.00;
const EPS : f64 = 0.01;
const MUL: i32 = 20;
const MAXPERIOD : f64 = 100.;
......
......@@ -74,7 +74,7 @@ impl ViewportReportImpl {
for item in items {
item.to_json(&mut out);
}
let mut ty = Vec::<JSONValue>::new();
let ty = Vec::<JSONValue>::new();
JSONValue::Object(out)
}
......
......@@ -12,7 +12,6 @@ extern crate stdweb_derive;
extern crate lazy_static;
#[macro_use]
extern crate serde_json;
extern crate yaml_rust;
extern crate rand;
extern crate itertools;
extern crate hsl;
......@@ -30,7 +29,6 @@ mod data;
mod debug;
mod dom;
mod drawing;
mod mosquito;
mod print;
mod program;
mod shape;
......
use std::collections::HashMap;
use stdweb::unstable::TryInto;
use stdweb::web::{ HtmlElement, Element, INode, IElement, CloneKind };
use dom::domutil;
use util::ValueStore;
use super::Mosquito;
pub struct Bottle {
templates: HashMap<String,Element>,
mosquitos: ValueStore<Mosquito>,
swarm_el: Element
}
impl Bottle {
pub fn new(bottle_el: Option<Element>, swarm_el: Element) -> Bottle {
let mut out = Bottle {
templates: HashMap::<String,Element>::new(),
mosquitos: ValueStore::<Mosquito>::new(),
swarm_el
};
if let Some(el) = bottle_el {
out.init(el);
}
out
}
fn init(&mut self, el: Element) {
for node in el.child_nodes().iter() {
let htel : Option<HtmlElement> = node.try_into().ok();
if let Some(htel) = htel {
let classes = domutil::get_classes(&htel);
let citer = classes.iter().filter(|x| x.starts_with("mosquito-"));
for c in citer {
let m : Element = htel.clone().into();
self.templates.insert(c.to_string(),m);
}
}
}
}
pub fn make(&mut self, name: &str) -> Option<Mosquito> {
if let Some(t) = self.templates.get(name) {
let c = t.clone_node(CloneKind::Deep).ok().unwrap();
self.swarm_el.append_child(&c);
let mut m = Mosquito::new(&c);
let m2 = m.clone();
m.set_id(self.mosquitos.store(m2));
Some(m)
} else {
None
}
}
}
mod bottle;
mod mosquito;
pub use self::bottle::Bottle;
pub use self::mosquito::Mosquito;
use std::cell::RefCell;
use std::rc::Rc;
use stdweb::web::Element;
use dom::domutil;
pub struct MosquitoImpl {
id: Option<usize>,
pos: (i32,i32),
el: Element
}
impl MosquitoImpl {
fn new(el: &Element) -> MosquitoImpl {
let mut out = MosquitoImpl {
id: None,
pos: (0,0),
el: el.clone()
};
domutil::add_attr(el,"style","position: fixed;");
out
}
fn set_id(&mut self, id: usize) {
self.id = Some(id);
}
}
#[derive(Clone)]
pub struct Mosquito(Rc<RefCell<MosquitoImpl>>);
impl Mosquito {
pub fn new(el: &Element) -> Mosquito {
Mosquito(Rc::new(RefCell::new(MosquitoImpl::new(el))))
}
pub(in super) fn set_id(&mut self, id: usize) {
self.0.borrow_mut().set_id(id);
}
}
......@@ -14,7 +14,7 @@ pub enum ShapeSpec {
}
impl ShapeSpec {
pub fn create(&self) -> Box<Shape> {
pub fn create(self) -> Box<Shape> {
match self {
ShapeSpec::PinPoly(pp) => pp.create(),
ShapeSpec::PinRect(pr) => pr.create(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment