Implement text clipping (caching still broken)

This commit is contained in:
Héctor Ramón Jiménez 2019-10-28 04:28:21 +01:00
parent 35e94f5a32
commit 2b23e0986c
5 changed files with 18 additions and 29 deletions

View file

@ -9,9 +9,9 @@ repository = "https://github.com/hecrj/iced"
[dependencies]
iced_native = { version = "0.1.0-alpha", path = "../native" }
wgpu = { version = "0.3", git = "https://github.com/gfx-rs/wgpu-rs", rev = "cb25914b95b58fee0dc139b400867e7a731d98f4" }
wgpu_glyph = { version = "0.4", git = "https://github.com/hecrj/wgpu_glyph", rev = "48daa98f5f785963838b4345e86ac40eac095ba9" }
raw-window-handle = "0.1"
wgpu = { version = "0.3", git = "https://github.com/gfx-rs/wgpu-rs", rev = "ed2c67f762970d0099c1e6c6e078fb645afbf964" }
wgpu_glyph = { version = "0.4", git = "https://github.com/hecrj/wgpu_glyph", rev = "954ac865ca1b7f6b97bf403f8c6174a7120e667c" }
raw-window-handle = "0.3"
image = "0.22"
nalgebra = "0.18"
log = "0.4"

View file

@ -75,7 +75,7 @@ impl Renderer {
extensions: Extensions {
anisotropic_filtering: false,
},
limits: Limits { max_bind_groups: 1 },
limits: Limits { max_bind_groups: 2 },
});
let surface = Surface::create(window);
@ -162,17 +162,6 @@ impl Renderer {
self.draw_primitive(primitive, &mut layer);
self.flush(target.transformation, &layer, &mut encoder, &frame.view);
self.glyph_brush
.borrow_mut()
.draw_queued(
&mut self.device,
&mut encoder,
&frame.view,
u32::from(target.width),
u32::from(target.height),
)
.expect("Draw text");
self.queue.submit(&[encoder.finish()]);
*mouse_cursor
@ -331,11 +320,17 @@ impl Renderer {
}
glyph_brush
.draw_queued_with_transform(
.draw_queued_with_transform_and_scissoring(
&mut self.device,
encoder,
target,
translated.into(),
wgpu_glyph::Region {
x: layer.bounds.x,
y: layer.bounds.y,
width: layer.bounds.width,
height: layer.bounds.height,
},
)
.expect("Draw text");
}