瀏覽代碼

Remove some println calls

Johannes Hofmann 8 年之前
父節點
當前提交
78d7b41aee
共有 4 個檔案被更改,包括 14 行新增21 行删除
  1. 14
    17
      src/main.rs
  2. 0
    2
      src/map_view_gl.rs
  3. 0
    1
      src/tile_cache.rs
  4. 0
    1
      src/tile_loader.rs

+ 14
- 17
src/main.rs 查看文件

@@ -38,10 +38,6 @@ use std::time::{Duration, Instant};
38 38
 #[cfg(target_os = "android")]
39 39
 android_start!(main);
40 40
 
41
-fn resize_callback(width: u32, height: u32) {
42
-    println!("Window resized to {}x{}", width, height);
43
-}
44
-
45 41
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
46 42
 enum Action {
47 43
     Nothing,
@@ -171,17 +167,23 @@ fn main() {
171 167
 
172 168
     let mut window = glutin::WindowBuilder::new().build().unwrap();
173 169
     window.set_title(&("DeltaMap - ".to_string() + sources.current_name()));
174
-    window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
175
-    let _ = unsafe { window.make_current() };
176 170
 
177
-    let proxy = window.create_window_proxy();
171
+    //TODO Find a safe way to trigger a redraw from a resize callback.
172
+    //TODO The callback is only allowed to access static content.
173
+    window.set_window_resize_callback(None);
178 174
 
175
+    let _ = unsafe { window.make_current() };
179 176
     let cx = context::Context::from_window(&window);
180
-    let mut map = map_view_gl::MapViewGl::new(
181
-        &cx,
182
-        window.get_inner_size_pixels().unwrap(),
183
-        move || { proxy.wakeup_event_loop(); },
184
-    );
177
+
178
+    let mut map = {
179
+        let proxy = window.create_window_proxy();
180
+
181
+        map_view_gl::MapViewGl::new(
182
+            &cx,
183
+            window.get_inner_size_pixels().unwrap(),
184
+            move || { proxy.wakeup_event_loop(); },
185
+        )
186
+    };
185 187
 
186 188
     let mut input_state = InputState {
187 189
         mouse_position: (0, 0),
@@ -193,7 +195,6 @@ fn main() {
193 195
     let mut last_draw = Instant::now();
194 196
 
195 197
     'outer: for event in window.wait_events() {
196
-        let mut start_loop = Instant::now();
197 198
         let start_source_id = sources.current().id();
198 199
 
199 200
         let mut redraw = false;
@@ -221,7 +222,6 @@ fn main() {
221 222
             if diff + draw_dur * 2 < milli16 {
222 223
                 if let Some(dur) = milli16.checked_sub(draw_dur * 2) {
223 224
                     std::thread::sleep(dur);
224
-                    println!("SLEEP {}", dur.as_secs() as f64 + f64::from(dur.subsec_nanos()) * 1e-9);
225 225
 
226 226
                     for event in window.poll_events() {
227 227
                         match handle_event(event, &mut map, &mut input_state, &mut sources) {
@@ -244,9 +244,6 @@ fn main() {
244 244
             let _ = window.swap_buffers();
245 245
 
246 246
             last_draw = Instant::now();
247
-
248
-            let diff = start_loop.elapsed();
249
-            println!("EVENT LOOP SECS {}", diff.as_secs() as f64 + f64::from(diff.subsec_nanos()) * 1e-9);
250 247
         }
251 248
 
252 249
         // set window title

+ 0
- 2
src/map_view_gl.rs 查看文件

@@ -27,8 +27,6 @@ impl<'a> MapViewGl<'a> {
27 27
     pub fn new<F>(cx: &Context, initial_size: (u32, u32), update_func: F) -> MapViewGl
28 28
         where F: Fn() + Sync + Send + 'static,
29 29
     {
30
-        println!("version: {}", cx.gl_version());
31
-        println!("max texture size: {}", cx.max_texture_size());
32 30
         unsafe {
33 31
             let mut program = Program::from_paths(cx, "shader/map.vert", "shader/map.frag");
34 32
 

+ 0
- 1
src/tile_cache.rs 查看文件

@@ -66,7 +66,6 @@ impl TileCache {
66 66
             }
67 67
 
68 68
             self.map.insert(t, img);
69
-            println!("CACHE SIZE: {} tiles", self.map.len());
70 69
         }
71 70
 
72 71
         let tile = Tile::new(tile_coord, source.id());

+ 0
- 1
src/tile_loader.rs 查看文件

@@ -164,7 +164,6 @@ impl TileLoader {
164 164
                     let ele: Option<TileRequest> = queue.lock().ok().and_then(|mut q| q.pop());
165 165
 
166 166
                     if let Some(request) = ele {
167
-                        println!("thread {}: queue {:?} {:?}", thread_id, request.tile, request.path);
168 167
                         if client_opt.is_none() {
169 168
                             client_opt = Client::builder().build().ok();
170 169
                         }