From 99cccb219389eb78f5019a3899c9746eae835e0d Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Wed, 7 Oct 2015 16:42:17 +0200 Subject: [PATCH] Snap to screen pixels instead of px --- components/gfx/display_list/mod.rs | 10 ++++++---- tests/ref/basic.list | 1 + tests/ref/pixel_snapping_position_a.html | 20 ++++++++++++++++++++ tests/ref/pixel_snapping_position_ref.html | 19 +++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 tests/ref/pixel_snapping_position_a.html create mode 100644 tests/ref/pixel_snapping_position_ref.html diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index c7053472b69..90e008a2dca 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -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)); @@ -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, @@ -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, diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 98488fd5239..f70c33ebe68 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -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 diff --git a/tests/ref/pixel_snapping_position_a.html b/tests/ref/pixel_snapping_position_a.html new file mode 100644 index 00000000000..a62dd36bbb4 --- /dev/null +++ b/tests/ref/pixel_snapping_position_a.html @@ -0,0 +1,20 @@ + + + + + Pixel snapping position test + + + +
+ + diff --git a/tests/ref/pixel_snapping_position_ref.html b/tests/ref/pixel_snapping_position_ref.html new file mode 100644 index 00000000000..58e3e4eddb0 --- /dev/null +++ b/tests/ref/pixel_snapping_position_ref.html @@ -0,0 +1,19 @@ + + + + + Pixel snapping position reference + + + +
+ +