diff options
author | Paul Rouget <me@paulrouget.com> | 2018-03-20 19:38:03 +0800 |
---|---|---|
committer | Paul Rouget <me@paulrouget.com> | 2018-03-22 08:07:43 +0100 |
commit | abea15d4190b9b25736ee619e2415b1098baccab (patch) | |
tree | d5617bc7a534174dc1c47c49867047eb954b2f66 | |
parent | aa72b8783dd6d5122d48a03d5583ffef8463e3a4 (diff) | |
download | servo-abea15d4190b9b25736ee619e2415b1098baccab.tar.gz servo-abea15d4190b9b25736ee619e2415b1098baccab.zip |
Use the --device-pixel-ratio in opt instead of /components/servo/
-rw-r--r-- | components/servo/lib.rs | 12 | ||||
-rw-r--r-- | ports/servo/glutin_app/window.rs | 14 |
2 files changed, 13 insertions, 13 deletions
diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 0baf5be6f6f..d557cb3e591 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -160,16 +160,6 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static { let coordinates = window.get_coordinates(); let (mut webrender, webrender_api_sender) = { - let device_pixel_ratio = match opts.device_pixels_per_px { - Some(device_pixels_per_px) => device_pixels_per_px, - None => match opts.output_file { - Some(_) => 1.0, - // TODO(gw): Duplicates device_pixels_per_screen_px from compositor. - // Tidy up! - None => coordinates.hidpi_factor.get(), - } - }; - let renderer_kind = if opts::get().should_use_osmesa() { RendererKind::OSMesa } else { @@ -190,7 +180,7 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static { let render_notifier = Box::new(RenderNotifier::new(compositor_proxy.clone())); webrender::Renderer::new(window.gl(), render_notifier, webrender::RendererOptions { - device_pixel_ratio: device_pixel_ratio, + device_pixel_ratio: coordinates.hidpi_factor.get(), resource_override_path: Some(resource_path), enable_aa: opts.enable_text_antialiasing, debug_flags: debug_flags, diff --git a/ports/servo/glutin_app/window.rs b/ports/servo/glutin_app/window.rs index 7fb77d27273..624ed0d5f1f 100644 --- a/ports/servo/glutin_app/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -601,8 +601,18 @@ impl Window { self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event)); } - #[cfg(not(target_os = "windows"))] fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { + match opts::get().device_pixels_per_px { + Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px), + None => match opts::get().output_file { + Some(_) => TypedScale::new(1.0), + None => self.platform_hidpi_factor() + } + } + } + + #[cfg(not(target_os = "windows"))] + fn platform_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { match self.kind { WindowKind::Window(ref window, ..) => { TypedScale::new(window.hidpi_factor()) @@ -614,7 +624,7 @@ impl Window { } #[cfg(target_os = "windows")] - fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { + fn platform_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { let hdc = unsafe { user32::GetDC(::std::ptr::null_mut()) }; let ppi = unsafe { gdi32::GetDeviceCaps(hdc, winapi::wingdi::LOGPIXELSY) }; TypedScale::new(ppi as f32 / 96.0) |