mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Account for RenderLayer position when optimizing display list
The page_rect passed to DisplayListOptimizer is relative to the RenderLayer origin, but the display list components are relative to the page origin. Before passing the page rect to the display list, we translate it by the RenderLayer position.
This commit is contained in:
parent
479d8567d1
commit
ec29723f2b
4 changed files with 24 additions and 7 deletions
|
@ -13,6 +13,7 @@ use render_context::RenderContext;
|
||||||
use azure::azure_hl::{B8G8R8A8, Color, DrawTarget, StolenGLResources};
|
use azure::azure_hl::{B8G8R8A8, Color, DrawTarget, StolenGLResources};
|
||||||
use azure::AzFloat;
|
use azure::AzFloat;
|
||||||
use geom::matrix2d::Matrix2D;
|
use geom::matrix2d::Matrix2D;
|
||||||
|
use geom::point::Point2D;
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
use layers::platform::surface::{NativePaintingGraphicsContext, NativeSurface};
|
use layers::platform::surface::{NativePaintingGraphicsContext, NativeSurface};
|
||||||
|
@ -299,8 +300,15 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
|
|
||||||
// Divide up the layer into tiles.
|
// Divide up the layer into tiles.
|
||||||
for tile in tiles.iter() {
|
for tile in tiles.iter() {
|
||||||
|
// page_rect is in coordinates relative to the layer origin, but all display list
|
||||||
|
// components are relative to the page origin. We make page_rect relative to
|
||||||
|
// the page origin before passing it to the optimizer.
|
||||||
|
let page_rect =
|
||||||
|
tile.page_rect.translate(&Point2D(render_layer.position.origin.x as f32,
|
||||||
|
render_layer.position.origin.y as f32));
|
||||||
|
let page_rect_au = geometry::f32_rect_to_au_rect(page_rect);
|
||||||
|
|
||||||
// Optimize the display list for this tile.
|
// Optimize the display list for this tile.
|
||||||
let page_rect_au = geometry::f32_rect_to_au_rect(tile.page_rect);
|
|
||||||
let optimizer = DisplayListOptimizer::new(render_layer.display_list.clone(),
|
let optimizer = DisplayListOptimizer::new(render_layer.display_list.clone(),
|
||||||
page_rect_au);
|
page_rect_au);
|
||||||
let display_list = optimizer.optimize();
|
let display_list = optimizer.optimize();
|
||||||
|
@ -339,10 +347,8 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
// Apply the translation to render the tile we want.
|
// Apply the translation to render the tile we want.
|
||||||
let matrix: Matrix2D<AzFloat> = Matrix2D::identity();
|
let matrix: Matrix2D<AzFloat> = Matrix2D::identity();
|
||||||
let matrix = matrix.scale(scale as AzFloat, scale as AzFloat);
|
let matrix = matrix.scale(scale as AzFloat, scale as AzFloat);
|
||||||
let matrix = matrix.translate(-(tile.page_rect.origin.x) as AzFloat,
|
let matrix = matrix.translate(-page_rect.origin.x as AzFloat,
|
||||||
-(tile.page_rect.origin.y) as AzFloat);
|
-page_rect.origin.y as AzFloat);
|
||||||
let matrix = matrix.translate(-(render_layer.position.origin.x as AzFloat),
|
|
||||||
-(render_layer.position.origin.y as AzFloat));
|
|
||||||
|
|
||||||
ctx.draw_target.set_transform(&matrix);
|
ctx.draw_target.set_transform(&matrix);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@
|
||||||
# == position_fixed_a.html position_fixed_b.html
|
# == position_fixed_a.html position_fixed_b.html
|
||||||
# == position_fixed_simple_a.html position_fixed_simple_b.html
|
# == position_fixed_simple_a.html position_fixed_simple_b.html
|
||||||
# == position_fixed_static_y_a.html position_fixed_static_y_b.html
|
# == position_fixed_static_y_a.html position_fixed_static_y_b.html
|
||||||
|
== position_fixed_background_color_a.html position_fixed_background_color_b.html
|
||||||
|
== position_fixed_overflow_a.html position_fixed_overflow_b.html
|
||||||
|
== position_fixed_tile_edge.html position_fixed_tile_edge_ref.html
|
||||||
== position_relative_a.html position_relative_b.html
|
== position_relative_a.html position_relative_b.html
|
||||||
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
|
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
|
||||||
== background_none_a.html background_none_b.html
|
== background_none_a.html background_none_b.html
|
||||||
|
@ -85,8 +88,6 @@ flaky_cpu == linebreak_simple_a.html linebreak_simple_b.html
|
||||||
== overflow_auto.html overflow_simple_b.html
|
== overflow_auto.html overflow_simple_b.html
|
||||||
== overflow_scroll.html overflow_simple_b.html
|
== overflow_scroll.html overflow_simple_b.html
|
||||||
== overflow_simple_a.html overflow_simple_b.html
|
== overflow_simple_a.html overflow_simple_b.html
|
||||||
== position_fixed_background_color_a.html position_fixed_background_color_b.html
|
|
||||||
== position_fixed_overflow_a.html position_fixed_overflow_b.html
|
|
||||||
== noscript.html noscript_ref.html
|
== noscript.html noscript_ref.html
|
||||||
== pseudo_inherit.html pseudo_inherit_ref.html
|
== pseudo_inherit.html pseudo_inherit_ref.html
|
||||||
experimental == vertical-lr-blocks.html vertical-lr-blocks_ref.html
|
experimental == vertical-lr-blocks.html vertical-lr-blocks_ref.html
|
||||||
|
|
5
tests/ref/position_fixed_tile_edge.html
Normal file
5
tests/ref/position_fixed_tile_edge.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<div style="background: green; position: fixed; top: 0px; left: 512px; width: 20px; height: 20px;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
5
tests/ref/position_fixed_tile_edge_ref.html
Normal file
5
tests/ref/position_fixed_tile_edge_ref.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<div style="background: green; position: absolute; top: 0px; left: 512px; width: 20px; height: 20px;"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue