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 crate::Transformation;
|
||||||
|
use iced_native::Rectangle;
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
|
@ -165,6 +166,7 @@ impl Pipeline {
|
||||||
encoder: &mut wgpu::CommandEncoder,
|
encoder: &mut wgpu::CommandEncoder,
|
||||||
instances: &[Quad],
|
instances: &[Quad],
|
||||||
transformation: Transformation,
|
transformation: Transformation,
|
||||||
|
bounds: Rectangle<u32>,
|
||||||
target: &wgpu::TextureView,
|
target: &wgpu::TextureView,
|
||||||
) {
|
) {
|
||||||
let matrix: [f32; 16] = transformation.into();
|
let matrix: [f32; 16] = transformation.into();
|
||||||
|
|
@ -227,6 +229,12 @@ impl Pipeline {
|
||||||
0,
|
0,
|
||||||
&[(&self.vertices, 0), (&self.instances, 0)],
|
&[(&self.vertices, 0), (&self.instances, 0)],
|
||||||
);
|
);
|
||||||
|
render_pass.set_scissor_rect(
|
||||||
|
bounds.x,
|
||||||
|
bounds.y,
|
||||||
|
bounds.width,
|
||||||
|
bounds.height,
|
||||||
|
);
|
||||||
|
|
||||||
render_pass.draw_indexed(
|
render_pass.draw_indexed(
|
||||||
0..QUAD_INDICES.len() as u32,
|
0..QUAD_INDICES.len() as u32,
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ impl Renderer {
|
||||||
border_radius,
|
border_radius,
|
||||||
} => {
|
} => {
|
||||||
layer.quads.push(Quad {
|
layer.quads.push(Quad {
|
||||||
position: [bounds.x, bounds.y],
|
position: [bounds.x, bounds.y - layer.y_offset as f32],
|
||||||
scale: [bounds.width, bounds.height],
|
scale: [bounds.width, bounds.height],
|
||||||
color: match background {
|
color: match background {
|
||||||
Background::Color(color) => color.into_linear(),
|
Background::Color(color) => color.into_linear(),
|
||||||
|
|
@ -304,6 +304,7 @@ impl Renderer {
|
||||||
encoder,
|
encoder,
|
||||||
&layer.quads,
|
&layer.quads,
|
||||||
transformation,
|
transformation,
|
||||||
|
layer.bounds,
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue