diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-10-29 06:55:10 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-10-29 06:55:10 +0530 |
commit | 94ca87e7ddc07160b9205c0112b60b0a951f0742 (patch) | |
tree | 3715ca3c8d8e985cefe9b9c8d966fb3a64591214 /components/util/geometry.rs | |
parent | 9501564e0143f134297bc1fd339883f7f987c283 (diff) | |
parent | a7a58e47a0c9bed4355fb3ab5910de1ff2dfd0f5 (diff) | |
download | servo-94ca87e7ddc07160b9205c0112b60b0a951f0742.tar.gz servo-94ca87e7ddc07160b9205c0112b60b0a951f0742.zip |
Auto merge of #8244 - mrobinson:layer-size, r=pcwalton
Expand DisplayList layer bounds to whole pixels
Before passing these layers to the paint task, expand them to pixel
boundaries. This ensures that subpixel edges of the layer will not be
clipped away and helps prevent rounding issues with layer contents.
Fixes #8166.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8244)
<!-- Reviewable:end -->
Diffstat (limited to 'components/util/geometry.rs')
-rw-r--r-- | components/util/geometry.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/components/util/geometry.rs b/components/util/geometry.rs index c2f08f7cd8d..7b5f89dc53e 100644 --- a/components/util/geometry.rs +++ b/components/util/geometry.rs @@ -107,3 +107,20 @@ pub fn au_rect_to_f32_rect(rect: Rect<Au>) -> Rect<f32> { Rect::new(Point2D::new(rect.origin.x.to_f32_px(), rect.origin.y.to_f32_px()), Size2D::new(rect.size.width.to_f32_px(), rect.size.height.to_f32_px())) } + +pub trait ExpandToPixelBoundaries { + fn expand_to_px_boundaries(&self) -> Self; +} + +impl ExpandToPixelBoundaries for Rect<Au> { + fn expand_to_px_boundaries(&self) -> Rect<Au> { + let bottom_right = self.bottom_right(); + let bottom_right = Point2D::new(Au::from_px(bottom_right.x.ceil_to_px()), + Au::from_px(bottom_right.y.ceil_to_px())); + let new_origin = Point2D::new(Au::from_px(self.origin.x.to_px()), + Au::from_px(self.origin.y.to_px())); + Rect::new(new_origin, + Size2D::new(bottom_right.x - new_origin.x, + bottom_right.y - new_origin.y)) + } +} |