Fix clip rect clamping

This commit is contained in:
Joonas Javanainen 2018-08-13 18:47:23 +03:00
parent 21d85afee0
commit 6a4286de11
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179
2 changed files with 6 additions and 6 deletions

View File

@ -218,8 +218,8 @@ impl<R: Resources> Renderer<R> {
self.bundle.slice.end = self.bundle.slice.start + cmd.elem_count;
self.bundle.data.scissor = Rect {
x: cmd.clip_rect.x.max(0.0).round() as u16,
y: cmd.clip_rect.y.max(0.0).round() as u16,
x: cmd.clip_rect.x.max(0.0).min(fb_width).round() as u16,
y: cmd.clip_rect.y.max(0.0).min(fb_height).round() as u16,
w: (cmd.clip_rect.z - cmd.clip_rect.x)
.abs()
.min(fb_width)

View File

@ -152,15 +152,15 @@ impl Renderer {
&DrawParameters {
blend: Blend::alpha_blending(),
scissor: Some(Rect {
left: cmd.clip_rect.x.max(0.0).round() as u32,
bottom: (fb_height - cmd.clip_rect.w).max(0.0).round() as u32,
left: cmd.clip_rect.x.max(0.0).min(fb_width).round() as u32,
bottom: (fb_height - cmd.clip_rect.w).max(0.0).min(fb_width).round() as u32,
width: (cmd.clip_rect.z - cmd.clip_rect.x)
.abs()
.max(fb_width)
.min(fb_width)
.round() as u32,
height: (cmd.clip_rect.w - cmd.clip_rect.y)
.abs()
.max(fb_height)
.min(fb_height)
.round() as u32,
}),
..DrawParameters::default()