fix hidpi issue ONCE AND FOR ALL. tested successfully on linux and

windows. [rebuild]
This commit is contained in:
Dustin Carlino 2020-01-16 10:38:01 -08:00
parent e4959892d7
commit aff092776e
2 changed files with 8 additions and 7 deletions

View File

@ -208,14 +208,15 @@ impl<'a> GfxCtx<'a> {
// TODO Stateful API :(
pub fn enable_clipping(&mut self, rect: ScreenRectangle) {
assert!(self.params.scissor.is_none());
// This is a bit weird, but the ScreenRectangle and window dims are already scaled up, so
// here, we actually have to scale down!
// The scissor rectangle has to be in device coordinates, so you would think some transform
// by self.canvas.hidpi_factor has to happen here. But actually, window dimensions and the
// rectangle passed in are already scaled up. So don't do anything here!
self.params.scissor = Some(glium::Rect {
left: (rect.x1 / self.canvas.hidpi_factor) as u32,
left: rect.x1 as u32,
// Y-inversion
bottom: ((self.canvas.window_height - rect.y2) / self.canvas.hidpi_factor) as u32,
width: ((rect.x2 - rect.x1) / self.canvas.hidpi_factor) as u32,
height: ((rect.y2 - rect.y1) / self.canvas.hidpi_factor) as u32,
bottom: (self.canvas.window_height - rect.y2) as u32,
width: (rect.x2 - rect.x1) as u32,
height: (rect.y2 - rect.y1) as u32,
});
}

View File

@ -20,7 +20,7 @@ impl ScreenPt {
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct ScreenRectangle {
pub x1: f64,
pub y1: f64,