Implement clipping for images

This commit is contained in:
Héctor Ramón Jiménez 2019-10-27 02:29:23 +01:00
parent 63c10b67ab
commit 0a0aa3edd9
3 changed files with 48 additions and 19 deletions

View file

@ -1,4 +1,5 @@
use crate::Transformation;
use iced_native::Rectangle;
use std::cell::RefCell;
use std::collections::HashMap;
@ -218,6 +219,7 @@ impl Pipeline {
encoder: &mut wgpu::CommandEncoder,
instances: &[Image],
transformation: Transformation,
bounds: Rectangle<u32>,
target: &wgpu::TextureView,
) {
let matrix: [f32; 16] = transformation.into();
@ -291,6 +293,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,