From 631cc493c1313fd83b1eebd09d9edf7e6332b868 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Fri, 6 Dec 2019 10:29:24 -0800 Subject: [PATCH] hack around mac dpi minimap issue --- ezgui/src/drawing.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ezgui/src/drawing.rs b/ezgui/src/drawing.rs index 763f45027c..4632c63402 100644 --- a/ezgui/src/drawing.rs +++ b/ezgui/src/drawing.rs @@ -209,13 +209,18 @@ impl<'a> GfxCtx<'a> { } pub fn redraw_clipped(&mut self, obj: &Drawable, rect: &ScreenRectangle) { + // We have to multiply by the DPI factor for the scissor test. But on the one Mac I've used + // to test, it reports a factor of 1, which isn't true. Hardcode it to 2 until I observe + // second Mac that differs. >_< + let factor = if cfg!(target_os = "macos") { 2.0 } else { 1.0 }; + let mut params = self.params.clone(); params.scissor = Some(glium::Rect { - left: rect.x1 as u32, + left: (factor * rect.x1) as u32, // Y-inversion - bottom: (self.canvas.window_height - rect.y2) as u32, - width: (rect.x2 - rect.x1) as u32, - height: (rect.y2 - rect.y1) as u32, + bottom: (factor * (self.canvas.window_height - rect.y2)) as u32, + width: (factor * (rect.x2 - rect.x1)) as u32, + height: (factor * (rect.y2 - rect.y1)) as u32, }); self.target .draw(