diff options
author | 2022-11-29 20:28:06 +0100 | |
---|---|---|
committer | 2022-11-29 20:28:06 +0100 | |
commit | 67420cb1e4ac8f7819ee5775c52676c6b7b58718 (patch) | |
tree | fa9aa515b2d49d9c8b1a47febe4410c603b62d64 /glow | |
parent | 8d67e21d48dcefbbb675cfad07849607ce0fe1b7 (diff) | |
parent | efc00b2f412865b975088002cbe3c927ef662e10 (diff) | |
download | iced-67420cb1e4ac8f7819ee5775c52676c6b7b58718.tar.gz iced-67420cb1e4ac8f7819ee5775c52676c6b7b58718.tar.bz2 iced-67420cb1e4ac8f7819ee5775c52676c6b7b58718.zip |
Merge pull request #1557 from wash2/fix/glow-image-scissor
fix: scissor layer bounds for images when using glow
Diffstat (limited to 'glow')
-rw-r--r-- | glow/src/backend.rs | 10 | ||||
-rw-r--r-- | glow/src/image.rs | 13 |
2 files changed, 21 insertions, 2 deletions
diff --git a/glow/src/backend.rs b/glow/src/backend.rs index 1a41d540..416c3b94 100644 --- a/glow/src/backend.rs +++ b/glow/src/backend.rs @@ -128,8 +128,14 @@ impl Backend { let scaled = transformation * Transformation::scale(scale_factor, scale_factor); - self.image_pipeline - .draw(gl, scaled, scale_factor, &layer.images); + self.image_pipeline.draw( + gl, + target_height, + scaled, + scale_factor, + &layer.images, + bounds, + ); } if !layer.text.is_empty() { diff --git a/glow/src/image.rs b/glow/src/image.rs index f906cd4c..955fd1ab 100644 --- a/glow/src/image.rs +++ b/glow/src/image.rs @@ -14,6 +14,7 @@ use iced_graphics::image::raster; use iced_graphics::image::vector; use iced_graphics::layer; +use iced_graphics::Rectangle; use iced_graphics::Size; use glow::HasContext; @@ -141,14 +142,17 @@ impl Pipeline { pub fn draw( &mut self, mut gl: &glow::Context, + target_height: u32, transformation: Transformation, _scale_factor: f32, images: &[layer::Image], + layer_bounds: Rectangle<u32>, ) { unsafe { gl.use_program(Some(self.program)); gl.bind_vertex_array(Some(self.vertex_array)); gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vertex_buffer)); + gl.enable(glow::SCISSOR_TEST); } #[cfg(feature = "image")] @@ -187,6 +191,14 @@ impl Pipeline { }; unsafe { + gl.scissor( + layer_bounds.x as i32, + (target_height - (layer_bounds.y + layer_bounds.height)) + as i32, + layer_bounds.width as i32, + layer_bounds.height as i32, + ); + if let Some(storage::Entry { texture, .. }) = entry { gl.bind_texture(glow::TEXTURE_2D, Some(*texture)) } else { @@ -213,6 +225,7 @@ impl Pipeline { gl.bind_buffer(glow::ARRAY_BUFFER, None); gl.bind_vertex_array(None); gl.use_program(None); + gl.disable(glow::SCISSOR_TEST); } } |