diff options
author | 2019-10-27 03:10:49 +0100 | |
---|---|---|
committer | 2019-10-27 03:10:49 +0100 | |
commit | 21eb2f692c687a675c54ae5e951556e28e7435eb (patch) | |
tree | bc11342e8f0a3efeeb4f84d455891feb75790eb8 | |
parent | e21890168f3db64fb6bb9aa5e1de974f5fad1c68 (diff) | |
download | iced-21eb2f692c687a675c54ae5e951556e28e7435eb.tar.gz iced-21eb2f692c687a675c54ae5e951556e28e7435eb.tar.bz2 iced-21eb2f692c687a675c54ae5e951556e28e7435eb.zip |
Implement clipping for quads
-rw-r--r-- | wgpu/src/quad.rs | 8 | ||||
-rw-r--r-- | wgpu/src/renderer.rs | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index adb294f0..6365e117 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -1,4 +1,5 @@ use crate::Transformation; +use iced_native::Rectangle; use std::mem; @@ -165,6 +166,7 @@ impl Pipeline { encoder: &mut wgpu::CommandEncoder, instances: &[Quad], transformation: Transformation, + bounds: Rectangle<u32>, target: &wgpu::TextureView, ) { let matrix: [f32; 16] = transformation.into(); @@ -227,6 +229,12 @@ impl Pipeline { 0, &[(&self.vertices, 0), (&self.instances, 0)], ); + render_pass.set_scissor_rect( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + ); render_pass.draw_indexed( 0..QUAD_INDICES.len() as u32, diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 5bd7be8d..ba140a66 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -251,7 +251,7 @@ impl Renderer { border_radius, } => { layer.quads.push(Quad { - position: [bounds.x, bounds.y], + position: [bounds.x, bounds.y - layer.y_offset as f32], scale: [bounds.width, bounds.height], color: match background { Background::Color(color) => color.into_linear(), @@ -304,6 +304,7 @@ impl Renderer { encoder, &layer.quads, transformation, + layer.bounds, target, ); |