Browse Source

Update glutin (to 0.17) and become DPI aware

Johannes Hofmann 7 years ago
parent
commit
cd29a5f0c8
6 changed files with 78 additions and 42 deletions
  1. 6
    6
      Cargo.lock
  2. 1
    1
      Cargo.toml
  3. 2
    2
      src/coord.rs
  4. 49
    29
      src/main.rs
  5. 16
    2
      src/map_view_gl.rs
  6. 4
    2
      src/marker_layer.rs

+ 6
- 6
Cargo.lock View File

280
  "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
280
  "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
281
  "gl 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
281
  "gl 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
282
  "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
282
  "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
283
- "glutin 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
283
+ "glutin 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
284
  "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
284
  "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
285
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
285
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
286
  "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
286
  "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
431
 
431
 
432
 [[package]]
432
 [[package]]
433
 name = "glutin"
433
 name = "glutin"
434
-version = "0.16.0"
434
+version = "0.17.0"
435
 source = "registry+https://github.com/rust-lang/crates.io-index"
435
 source = "registry+https://github.com/rust-lang/crates.io-index"
436
 dependencies = [
436
 dependencies = [
437
  "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
437
  "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
447
  "shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
447
  "shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
448
  "wayland-client 0.20.10 (registry+https://github.com/rust-lang/crates.io-index)",
448
  "wayland-client 0.20.10 (registry+https://github.com/rust-lang/crates.io-index)",
449
  "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
449
  "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
450
- "winit 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
450
+ "winit 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
451
  "x11-dl 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
451
  "x11-dl 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
452
 ]
452
 ]
453
 
453
 
1709
 
1709
 
1710
 [[package]]
1710
 [[package]]
1711
 name = "winit"
1711
 name = "winit"
1712
-version = "0.15.1"
1712
+version = "0.16.0"
1713
 source = "registry+https://github.com/rust-lang/crates.io-index"
1713
 source = "registry+https://github.com/rust-lang/crates.io-index"
1714
 dependencies = [
1714
 dependencies = [
1715
  "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
1715
  "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
1807
 "checksum gl 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81457bb802910ad5b535eb48541c51830a761804aa5b7087adbc9d049aa57aca"
1807
 "checksum gl 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81457bb802910ad5b535eb48541c51830a761804aa5b7087adbc9d049aa57aca"
1808
 "checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a"
1808
 "checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a"
1809
 "checksum gleam 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12b793fcf40a23dd372f184c228ab3eb96f88c50bb4fba8319c483aa025a4e45"
1809
 "checksum gleam 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12b793fcf40a23dd372f184c228ab3eb96f88c50bb4fba8319c483aa025a4e45"
1810
-"checksum glutin 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "42fb2de780307bd2bedbe013bc585659a683e7c6307d0baa878aec3da9250fc1"
1810
+"checksum glutin 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a70c5fe78efbd5a3b243a804ea1032053c584510f8822819f94cfb29b2100317"
1811
 "checksum httparse 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23801d98b42eed0318e5709b0527894ba7c3793d0236814618d6a9b6224152ff"
1811
 "checksum httparse 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23801d98b42eed0318e5709b0527894ba7c3793d0236814618d6a9b6224152ff"
1812
 "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e"
1812
 "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e"
1813
 "checksum hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)" = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7"
1813
 "checksum hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)" = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7"
1953
 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1953
 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1954
 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1954
 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1955
 "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767"
1955
 "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767"
1956
-"checksum winit 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bb6ea35de8bd722201914b28a33d503ee45b09fcf85fc4bbf574845e41f79e2"
1956
+"checksum winit 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9612edff5352d247ca263aa28e9a902ba80981cf4d3e88caf1833366ba9d354"
1957
 "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
1957
 "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
1958
 "checksum x11-dl 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "931d8584b49771143af0c422f372d8aef4280afd5920dad39b0a95a8e51df1e9"
1958
 "checksum x11-dl 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "931d8584b49771143af0c422f372d8aef4280afd5920dad39b0a95a8e51df1e9"
1959
 "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"
1959
 "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"

+ 1
- 1
Cargo.toml View File

16
 directories = "0.10"
16
 directories = "0.10"
17
 env_logger = "0.5.0-rc.2"
17
 env_logger = "0.5.0-rc.2"
18
 gl = "0.10"
18
 gl = "0.10"
19
-glutin = "0.16"
19
+glutin = "0.17"
20
 image = "0.19"
20
 image = "0.19"
21
 lazy_static = "1.0"
21
 lazy_static = "1.0"
22
 linked-hash-map = "0.5.0"
22
 linked-hash-map = "0.5.0"

+ 2
- 2
src/coord.rs View File

156
     }
156
     }
157
 }
157
 }
158
 
158
 
159
-/// A position on the screen in pixels. Top-left corner is (0.0, 0.0).
159
+/// A position on the screen in physical pixels. Top-left corner is (0.0, 0.0).
160
 #[derive(Copy, Clone, Debug)]
160
 #[derive(Copy, Clone, Debug)]
161
 pub struct ScreenCoord {
161
 pub struct ScreenCoord {
162
     pub x: f64,
162
     pub x: f64,
181
     }
181
     }
182
 }
182
 }
183
 
183
 
184
-/// A rectangle in screen coordinates.
184
+/// A rectangle in screen coordinates. Position and size are in physical pixels.
185
 #[derive(Copy, Clone, Debug)]
185
 #[derive(Copy, Clone, Debug)]
186
 pub struct ScreenRect {
186
 pub struct ScreenRect {
187
     pub x: f64,
187
     pub x: f64,

+ 49
- 29
src/main.rs View File

44
 
44
 
45
 use coord::{LatLonDeg, ScreenCoord};
45
 use coord::{LatLonDeg, ScreenCoord};
46
 use glutin::{ControlFlow, ElementState, Event, GlContext, MouseButton, MouseScrollDelta, VirtualKeyCode, WindowEvent};
46
 use glutin::{ControlFlow, ElementState, Event, GlContext, MouseButton, MouseScrollDelta, VirtualKeyCode, WindowEvent};
47
+use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition};
47
 use map_view_gl::MapViewGl;
48
 use map_view_gl::MapViewGl;
48
 use std::error::Error;
49
 use std::error::Error;
49
 use std::sync::mpsc;
50
 use std::sync::mpsc;
51
 use tile_source::TileSource;
52
 use tile_source::TileSource;
52
 
53
 
53
 
54
 
54
-#[derive(Copy, Clone, Debug, PartialEq, Eq)]
55
+#[derive(Copy, Clone, Debug, PartialEq)]
55
 enum Action {
56
 enum Action {
56
     Nothing,
57
     Nothing,
57
     Redraw,
58
     Redraw,
58
-    Resize(u32, u32),
59
+    Resize(LogicalSize),
59
     Close,
60
     Close,
60
 }
61
 }
61
 
62
 
63
     fn combine_with(&mut self, newer_action: Self) {
64
     fn combine_with(&mut self, newer_action: Self) {
64
         *self = match (*self, newer_action) {
65
         *self = match (*self, newer_action) {
65
             (Action::Close, _) | (_, Action::Close) => Action::Close,
66
             (Action::Close, _) | (_, Action::Close) => Action::Close,
66
-            (Action::Resize(..), Action::Resize(w, h)) => Action::Resize(w, h),
67
-            (Action::Resize(w, h), _) | (_, Action::Resize(w, h)) => Action::Resize(w, h),
67
+            (Action::Resize(..), Action::Resize(size)) => Action::Resize(size),
68
+            (Action::Resize(size), _) | (_, Action::Resize(size)) => Action::Resize(size),
68
             (Action::Redraw, _) | (_, Action::Redraw) => Action::Redraw,
69
             (Action::Redraw, _) | (_, Action::Redraw) => Action::Redraw,
69
             (Action::Nothing, Action::Nothing) => Action::Nothing,
70
             (Action::Nothing, Action::Nothing) => Action::Nothing,
70
         };
71
         };
73
 
74
 
74
 #[derive(Copy, Clone, Debug, PartialEq)]
75
 #[derive(Copy, Clone, Debug, PartialEq)]
75
 struct InputState {
76
 struct InputState {
76
-    mouse_position: (f64, f64),
77
+    mouse_position: LogicalPosition,
77
     mouse_pressed: bool,
78
     mouse_pressed: bool,
79
+    viewport_size: LogicalSize,
80
+    dpi_factor: f64,
78
 }
81
 }
79
 
82
 
80
 fn handle_event(
83
 fn handle_event(
101
                 input_state.mouse_pressed = false;
104
                 input_state.mouse_pressed = false;
102
                 Action::Nothing
105
                 Action::Nothing
103
             },
106
             },
104
-            WindowEvent::CursorMoved { position: (x, y), .. } => {
107
+            WindowEvent::CursorMoved { position: pos, .. } => {
105
                 if input_state.mouse_pressed {
108
                 if input_state.mouse_pressed {
106
                     map.move_pixel(
109
                     map.move_pixel(
107
-                        input_state.mouse_position.0 - x,
108
-                        input_state.mouse_position.1 - y,
110
+                        (input_state.mouse_position.x - pos.x) * input_state.dpi_factor,
111
+                        (input_state.mouse_position.y - pos.y) * input_state.dpi_factor,
109
                     );
112
                     );
110
-                    input_state.mouse_position = (x, y);
113
+                    input_state.mouse_position = pos;
111
                     Action::Redraw
114
                     Action::Redraw
112
                 } else {
115
                 } else {
113
-                    input_state.mouse_position = (x, y);
116
+                    input_state.mouse_position = pos;
114
                     Action::Nothing
117
                     Action::Nothing
115
                 }
118
                 }
116
             },
119
             },
117
             WindowEvent::MouseWheel { delta, modifiers, .. } => {
120
             WindowEvent::MouseWheel { delta, modifiers, .. } => {
118
-                let (dx, dy) = match delta {
121
+                let delta: PhysicalPosition = match delta {
119
                     MouseScrollDelta::LineDelta(dx, dy) => {
122
                     MouseScrollDelta::LineDelta(dx, dy) => {
120
                         // filter strange wheel events with huge values.
123
                         // filter strange wheel events with huge values.
121
                         // (maybe this is just a personal touchpad driver issue)
124
                         // (maybe this is just a personal touchpad driver issue)
122
                         if dx.abs() < 16.0 && dy.abs() < 16.0 {
125
                         if dx.abs() < 16.0 && dy.abs() < 16.0 {
123
                             //TODO find a sensible line height value (servo (the glutin port) uses 38)
126
                             //TODO find a sensible line height value (servo (the glutin port) uses 38)
124
-                            (dx, dy * 38.0)
127
+                            PhysicalPosition::new(
128
+                                f64::from(dx) * input_state.dpi_factor,
129
+                                f64::from(dy) * 38.0 * input_state.dpi_factor,
130
+                            )
125
                         } else {
131
                         } else {
126
-                            (0.0, 0.0)
132
+                            PhysicalPosition::new(0.0, 0.0)
127
                         }
133
                         }
128
                     },
134
                     },
129
-                    MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy),
135
+                    MouseScrollDelta::PixelDelta(size) => {
136
+                        size.to_physical(input_state.dpi_factor)
137
+                    }
130
                 };
138
                 };
131
 
139
 
132
                 //TODO add option for default mouse wheel behavior (scroll or zoom?)
140
                 //TODO add option for default mouse wheel behavior (scroll or zoom?)
133
                 //TODO add option to reverse scroll/zoom direction
141
                 //TODO add option to reverse scroll/zoom direction
134
 
142
 
135
                 if modifiers.ctrl {
143
                 if modifiers.ctrl {
136
-                    map.move_pixel(f64::from(-dx), f64::from(-dy));
144
+                    map.move_pixel(-delta.x, -delta.y);
137
                 } else {
145
                 } else {
138
                     map.zoom_at(
146
                     map.zoom_at(
139
                         ScreenCoord::new(
147
                         ScreenCoord::new(
140
-                            input_state.mouse_position.0,
141
-                            input_state.mouse_position.1,
148
+                            input_state.mouse_position.x * input_state.dpi_factor,
149
+                            input_state.mouse_position.y * input_state.dpi_factor,
142
                         ),
150
                         ),
143
-                        f64::from(dy) * (1.0 / 320.0),
151
+                        f64::from(delta.y) * (1.0 / 320.0),
144
                     );
152
                     );
145
                 }
153
                 }
146
                 Action::Redraw
154
                 Action::Redraw
210
             WindowEvent::Refresh => {
218
             WindowEvent::Refresh => {
211
                 Action::Redraw
219
                 Action::Redraw
212
             },
220
             },
213
-            WindowEvent::Resized(w, h) => {
214
-                Action::Resize(w, h)
221
+            WindowEvent::Resized(size) => {
222
+                input_state.viewport_size = size;
223
+                Action::Resize(size)
215
             },
224
             },
225
+            WindowEvent::HiDpiFactorChanged(dpi_factor) => {
226
+                input_state.dpi_factor = dpi_factor;
227
+                map.set_dpi_factor(dpi_factor);
228
+                Action::Resize(input_state.viewport_size)
229
+            }
216
             _ => Action::Nothing,
230
             _ => Action::Nothing,
217
         },
231
         },
218
         _ => Action::Nothing,
232
         _ => Action::Nothing,
258
     let _ = unsafe { gl_window.make_current() };
272
     let _ = unsafe { gl_window.make_current() };
259
     let mut cx = context::Context::from_gl_window(&gl_window);
273
     let mut cx = context::Context::from_gl_window(&gl_window);
260
 
274
 
275
+    let mut input_state = InputState {
276
+        mouse_position: LogicalPosition::new(0.0, 0.0),
277
+        mouse_pressed: false,
278
+        viewport_size: window.get_inner_size().unwrap(),
279
+        dpi_factor: window.get_hidpi_factor(),
280
+    };
281
+
261
     let mut map = {
282
     let mut map = {
262
         let proxy = events_loop.create_proxy();
283
         let proxy = events_loop.create_proxy();
263
 
284
 
264
         map_view_gl::MapViewGl::new(
285
         map_view_gl::MapViewGl::new(
265
             &mut cx,
286
             &mut cx,
266
-            window.get_inner_size().unwrap(),
287
+            input_state.viewport_size.to_physical(input_state.dpi_factor).into(),
288
+            input_state.dpi_factor,
267
             move || { proxy.wakeup().unwrap(); },
289
             move || { proxy.wakeup().unwrap(); },
268
             config.use_network(),
290
             config.use_network(),
269
             config.async(),
291
             config.async(),
274
         map.restore_session(session);
296
         map.restore_session(session);
275
     }
297
     }
276
 
298
 
277
-    let mut input_state = InputState {
278
-        mouse_position: (0.0, 0.0),
279
-        mouse_pressed: false,
280
-    };
281
-
282
     let (marker_tx, marker_rx) = mpsc::channel();
299
     let (marker_tx, marker_rx) = mpsc::channel();
283
     if let (Some(path), Some(pattern)) = (config.pbf_path(), config.search_pattern()) {
300
     if let (Some(path), Some(pattern)) = (config.pbf_path(), config.search_pattern()) {
284
         let proxy = events_loop.create_proxy();
301
         let proxy = events_loop.create_proxy();
361
             }
378
             }
362
         }
379
         }
363
 
380
 
364
-        if let Action::Resize(w, h) = action {
365
-            gl_window.resize(w, h);
366
-            map.set_viewport_size(&mut cx, w, h);
381
+        if let Action::Resize(size) = action {
382
+            let phys_size = size.to_physical(input_state.dpi_factor);
383
+            gl_window.resize(phys_size);
384
+
385
+            let phys_size: (u32, u32) = phys_size.into();
386
+            map.set_viewport_size(&mut cx, phys_size.0, phys_size.1);
367
         }
387
         }
368
 
388
 
369
         let redraw = match action {
389
         let redraw = match action {

+ 16
- 2
src/map_view_gl.rs View File

4
 use map_view::MapView;
4
 use map_view::MapView;
5
 use marker_layer::MarkerLayer;
5
 use marker_layer::MarkerLayer;
6
 use mercator_view::MercatorView;
6
 use mercator_view::MercatorView;
7
-use orthografic_view::OrthograficView;
8
 use session::Session;
7
 use session::Session;
9
 use texture::{Texture, TextureFormat};
8
 use texture::{Texture, TextureFormat};
10
 use tile_atlas::TileAtlas;
9
 use tile_atlas::TileAtlas;
19
 #[derive(Debug)]
18
 #[derive(Debug)]
20
 pub struct MapViewGl {
19
 pub struct MapViewGl {
21
     map_view: MapView,
20
     map_view: MapView,
21
+    /// Size in physical pixels
22
     viewport_size: (u32, u32),
22
     viewport_size: (u32, u32),
23
+    dpi_factor: f64,
23
     tile_cache: TileCache,
24
     tile_cache: TileCache,
24
     tile_atlas: TileAtlas,
25
     tile_atlas: TileAtlas,
25
     tile_layer: TileLayer,
26
     tile_layer: TileLayer,
49
     pub fn new<F>(
50
     pub fn new<F>(
50
         cx: &mut Context,
51
         cx: &mut Context,
51
         initial_size: (u32, u32),
52
         initial_size: (u32, u32),
53
+        dpi_factor: f64,
52
         update_func: F,
54
         update_func: F,
53
         use_network: bool,
55
         use_network: bool,
54
         use_async: bool,
56
         use_async: bool,
91
         MapViewGl {
93
         MapViewGl {
92
             map_view,
94
             map_view,
93
             viewport_size: initial_size,
95
             viewport_size: initial_size,
96
+            dpi_factor,
94
             tile_cache: TileCache::new(move |_tile| update_func(), use_network),
97
             tile_cache: TileCache::new(move |_tile| update_func(), use_network),
95
             tile_atlas,
98
             tile_atlas,
96
             tile_layer,
99
             tile_layer,
107
         cx.set_viewport(0, 0, width, height);
110
         cx.set_viewport(0, 0, width, height);
108
     }
111
     }
109
 
112
 
113
+    pub fn set_dpi_factor(&mut self, dpi_factor: f64) {
114
+        self.dpi_factor = dpi_factor;
115
+    }
116
+
110
     pub fn add_marker(&mut self, map_coord: MapCoord) {
117
     pub fn add_marker(&mut self, map_coord: MapCoord) {
111
         self.marker_layer.add_marker(map_coord);
118
         self.marker_layer.add_marker(map_coord);
112
     }
119
     }
158
         }
165
         }
159
 
166
 
160
         //TODO remove viewport_size parameter
167
         //TODO remove viewport_size parameter
161
-        self.marker_layer.draw(cx, &self.map_view, self.viewport_size, snap_to_pixel);
168
+        self.marker_layer.draw(
169
+            cx,
170
+            &self.map_view,
171
+            self.viewport_size,
172
+            self.dpi_factor,
173
+            snap_to_pixel,
174
+        );
162
     }
175
     }
163
 
176
 
164
     fn draw_ortho_tiles(&mut self, cx: &mut Context, source: &TileSource) {
177
     fn draw_ortho_tiles(&mut self, cx: &mut Context, source: &TileSource) {
238
         self.map_view.set_tile_zoom_offset(offset + delta_offset);
251
         self.map_view.set_tile_zoom_offset(offset + delta_offset);
239
     }
252
     }
240
 
253
 
254
+    //TODO Make sure to use physical pixel deltas
241
     pub fn move_pixel(&mut self, delta_x: f64, delta_y: f64) {
255
     pub fn move_pixel(&mut self, delta_x: f64, delta_y: f64) {
242
         //TODO implement for OrthograficView
256
         //TODO implement for OrthograficView
243
         MercatorView::move_pixel(&mut self.map_view, delta_x, delta_y);
257
         MercatorView::move_pixel(&mut self.map_view, delta_x, delta_y);

+ 4
- 2
src/marker_layer.rs View File

32
         ).unwrap();
32
         ).unwrap();
33
         check_gl_errors!(cx);
33
         check_gl_errors!(cx);
34
 
34
 
35
+        //TODO Create textures for higher DPI factors / use mipmaps
35
         let texture = {
36
         let texture = {
36
             let img = image::load_from_memory(
37
             let img = image::load_from_memory(
37
                 include_bytes!("../img/marker.png"),
38
                 include_bytes!("../img/marker.png"),
80
         cx: &mut Context,
81
         cx: &mut Context,
81
         map_view: &MapView,
82
         map_view: &MapView,
82
         viewport_size: (u32, u32),
83
         viewport_size: (u32, u32),
84
+        dpi_factor: f64,
83
         snap_to_pixel: bool
85
         snap_to_pixel: bool
84
     ) {
86
     ) {
85
         let mut vertex_data: Vec<f32> = vec![];
87
         let mut vertex_data: Vec<f32> = vec![];
86
 
88
 
87
-        let marker_size = vec2::<f64>(40.0, 50.0);
88
-        let marker_offset = vec2::<f64>(-20.0, -50.0);
89
+        let marker_size = vec2::<f64>(40.0, 50.0) * dpi_factor;
90
+        let marker_offset = vec2::<f64>(-20.0, -50.0) * dpi_factor;
89
 
91
 
90
         let scale_x = 2.0 / viewport_size.0 as f32;
92
         let scale_x = 2.0 / viewport_size.0 as f32;
91
         let scale_y = -2.0 / viewport_size.1 as f32;
93
         let scale_y = -2.0 / viewport_size.1 as f32;