Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap to screen pixels instead of px #7909

Merged
merged 1 commit into from Oct 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions components/gfx/display_list/mod.rs
Expand Up @@ -279,6 +279,8 @@ impl DisplayList {
layer_kind: paint_context.layer_kind,
};

let pixels_per_px = paint_subcontext.screen_pixels_per_px();

if opts::get().dump_display_list_optimized {
self.print(format!("Optimized display list. Tile bounds: {:?}",
paint_context.page_rect));
Expand Down Expand Up @@ -306,11 +308,11 @@ impl DisplayList {
transform.translate(positioned_kid.bounds
.origin
.x
.to_nearest_px() as AzFloat,
.to_nearest_pixel(pixels_per_px) as AzFloat,
positioned_kid.bounds
.origin
.y
.to_nearest_px() as AzFloat,
.to_nearest_pixel(pixels_per_px) as AzFloat,
0.0);
positioned_kid.optimize_and_draw_into_context(&mut paint_subcontext,
&new_transform,
Expand Down Expand Up @@ -348,11 +350,11 @@ impl DisplayList {
transform.translate(positioned_kid.bounds
.origin
.x
.to_nearest_px() as AzFloat,
.to_nearest_pixel(pixels_per_px) as AzFloat,
positioned_kid.bounds
.origin
.y
.to_nearest_px() as AzFloat,
.to_nearest_pixel(pixels_per_px) as AzFloat,
0.0);
positioned_kid.optimize_and_draw_into_context(&mut paint_subcontext,
&new_transform,
Expand Down
1 change: 1 addition & 0 deletions tests/ref/basic.list
Expand Up @@ -292,6 +292,7 @@ flaky_cpu == linebreak_simple_a.html linebreak_simple_b.html
== percentage_height_root.html percentage_height_root_ref.html
== percentage_width_inline_block_a.html percentage_width_inline_block_ref.html
resolution=300x300,device-pixel-ratio=2 != pixel_snapping_border_a.html pixel_snapping_border_ref.html
resolution=300x300,device-pixel-ratio=2 != pixel_snapping_position_a.html pixel_snapping_position_ref.html
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
== position_abs_cb_with_non_cb_kid_a.html position_abs_cb_with_non_cb_kid_b.html
== position_abs_height_width_a.html position_abs_height_width_b.html
Expand Down
20 changes: 20 additions & 0 deletions tests/ref/pixel_snapping_position_a.html
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Pixel snapping position test</title>
<style>
div {
position: absolute;
height: 100px;
width: 100px;
top: 11.5px;
background: red;
transform: scale(1);
}
</style>
</head>
<body>
<div></div>
</body>
</html>
19 changes: 19 additions & 0 deletions tests/ref/pixel_snapping_position_ref.html
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Pixel snapping position reference</title>
<style>
div {
position: absolute;
height: 100px;
width: 100px;
top: 12px;
background: red;
}
</style>
</head>
<body>
<div></div>
</body>
</html>