Implement clipping for quads
This commit is contained in:
parent
e21890168f
commit
21eb2f692c
2 changed files with 10 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue