Rename Rectangle::round to snap
Also use `ceil` instead of `round`. Closes #380.
This commit is contained in:
parent
b96d87ff69
commit
94af348846
5 changed files with 8 additions and 9 deletions
|
|
@ -126,15 +126,15 @@ impl Rectangle<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rounds the [`Rectangle`] to __unsigned__ integer coordinates.
|
/// Snaps the [`Rectangle`] to __unsigned__ integer coordinates.
|
||||||
///
|
///
|
||||||
/// [`Rectangle`]: struct.Rectangle.html
|
/// [`Rectangle`]: struct.Rectangle.html
|
||||||
pub fn round(self) -> Rectangle<u32> {
|
pub fn snap(self) -> Rectangle<u32> {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
x: self.x as u32,
|
x: self.x as u32,
|
||||||
y: self.y as u32,
|
y: self.y as u32,
|
||||||
width: (self.width + 0.5).round() as u32,
|
width: self.width.ceil() as u32,
|
||||||
height: (self.height + 0.5).round() as u32,
|
height: self.height.ceil() as u32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ impl Backend {
|
||||||
layer: &Layer<'_>,
|
layer: &Layer<'_>,
|
||||||
target_height: u32,
|
target_height: u32,
|
||||||
) {
|
) {
|
||||||
let mut bounds = (layer.bounds * scale_factor).round();
|
let mut bounds = (layer.bounds * scale_factor).snap();
|
||||||
bounds.height = bounds.height.min(target_height);
|
bounds.height = bounds.height.min(target_height);
|
||||||
|
|
||||||
if !layer.quads.is_empty() {
|
if !layer.quads.is_empty() {
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ impl Pipeline {
|
||||||
let transform =
|
let transform =
|
||||||
transformation * Transformation::translate(origin.x, origin.y);
|
transformation * Transformation::translate(origin.x, origin.y);
|
||||||
|
|
||||||
let clip_bounds = (*clip_bounds * scale_factor).round();
|
let clip_bounds = (*clip_bounds * scale_factor).snap();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
if self.current_transform != transform {
|
if self.current_transform != transform {
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ impl Backend {
|
||||||
target_width: u32,
|
target_width: u32,
|
||||||
target_height: u32,
|
target_height: u32,
|
||||||
) {
|
) {
|
||||||
let bounds = (layer.bounds * scale_factor).round();
|
let bounds = (layer.bounds * scale_factor).snap();
|
||||||
|
|
||||||
if !layer.quads.is_empty() {
|
if !layer.quads.is_empty() {
|
||||||
self.quad_pipeline.draw(
|
self.quad_pipeline.draw(
|
||||||
|
|
|
||||||
|
|
@ -326,8 +326,7 @@ impl Pipeline {
|
||||||
for (i, (vertex_offset, index_offset, indices)) in
|
for (i, (vertex_offset, index_offset, indices)) in
|
||||||
offsets.into_iter().enumerate()
|
offsets.into_iter().enumerate()
|
||||||
{
|
{
|
||||||
let clip_bounds =
|
let clip_bounds = (meshes[i].clip_bounds * scale_factor).snap();
|
||||||
(meshes[i].clip_bounds * scale_factor).round();
|
|
||||||
|
|
||||||
render_pass.set_scissor_rect(
|
render_pass.set_scissor_rect(
|
||||||
clip_bounds.x,
|
clip_bounds.x,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue