Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 216973006: Fix fixed-pos jitter related to physical pixel snapping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Group code together with contents scale as before Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] 1511 // LT = Tr[origin] * Tr[origin2anchor] * M[layer]
1512 combined_transform.PreconcatTransform(layer->transform()); 1512 combined_transform.PreconcatTransform(layer->transform());
1513 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] 1513 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin]
1514 combined_transform.Translate3d(-anchor_point.x() * bounds.width(), 1514 combined_transform.Translate3d(-anchor_point.x() * bounds.width(),
1515 -anchor_point.y() * bounds.height(), 1515 -anchor_point.y() * bounds.height(),
1516 -layer->anchor_point_z()); 1516 -layer->anchor_point_z());
1517 } else { 1517 } else {
1518 combined_transform.Translate(position.x(), position.y()); 1518 combined_transform.Translate(position.x(), position.y());
1519 } 1519 }
1520 1520
1521 gfx::Vector2dF effective_scroll_delta = GetEffectiveScrollDelta(layer);
1522 if (!animating_transform_to_target && layer->scrollable() &&
1523 combined_transform.IsScaleOrTranslation()) {
1524 // Align the scrollable layer's position to screen space pixels to avoid
1525 // blurriness. To avoid side-effects, do this only if the transform is
1526 // simple.
1527 gfx::Vector2dF previous_translation = combined_transform.To2dTranslation();
1528 RoundTranslationComponents(&combined_transform);
1529 gfx::Vector2dF current_translation = combined_transform.To2dTranslation();
1530
1531 // This rounding changes the scroll delta, and so must be included
1532 // in the scroll compensation matrix.
1533 effective_scroll_delta -= current_translation - previous_translation;
1534 }
1535
1536 // Apply adjustment from position constraints.
1537 ApplyPositionAdjustment(layer, data_from_ancestor.fixed_container,
1538 data_from_ancestor.scroll_compensation_matrix, &combined_transform);
1539
1540 // Compute the 2d scale components of the transform hierarchy up to the target 1521 // Compute the 2d scale components of the transform hierarchy up to the target
1541 // surface. From there, we can decide on a contents scale for the layer. 1522 // surface. From there, we can decide on a contents scale for the layer.
1542 float layer_scale_factors = globals.device_scale_factor; 1523 float layer_scale_factors = globals.device_scale_factor;
1543 if (data_from_ancestor.in_subtree_of_page_scale_application_layer) 1524 if (data_from_ancestor.in_subtree_of_page_scale_application_layer)
1544 layer_scale_factors *= globals.page_scale_factor; 1525 layer_scale_factors *= globals.page_scale_factor;
1545 gfx::Vector2dF combined_transform_scales = 1526 gfx::Vector2dF combined_transform_scales =
1546 MathUtil::ComputeTransform2dScaleComponents( 1527 MathUtil::ComputeTransform2dScaleComponents(
1547 combined_transform, 1528 combined_transform,
1548 layer_scale_factors); 1529 layer_scale_factors);
1549 1530
1550 float ideal_contents_scale = 1531 float ideal_contents_scale =
1551 globals.can_adjust_raster_scales 1532 globals.can_adjust_raster_scales
1552 ? std::max(combined_transform_scales.x(), 1533 ? std::max(combined_transform_scales.x(),
1553 combined_transform_scales.y()) 1534 combined_transform_scales.y())
1554 : layer_scale_factors; 1535 : layer_scale_factors;
1555 UpdateLayerContentsScale( 1536 UpdateLayerContentsScale(
1556 layer, 1537 layer,
1557 globals.can_adjust_raster_scales, 1538 globals.can_adjust_raster_scales,
1558 ideal_contents_scale, 1539 ideal_contents_scale,
1559 globals.device_scale_factor, 1540 globals.device_scale_factor,
1560 data_from_ancestor.in_subtree_of_page_scale_application_layer ? 1541 data_from_ancestor.in_subtree_of_page_scale_application_layer ?
1561 globals.page_scale_factor : 1.f, 1542 globals.page_scale_factor : 1.f,
1562 animating_transform_to_screen); 1543 animating_transform_to_screen);
1563 1544
1545 gfx::Vector2dF effective_scroll_delta = GetEffectiveScrollDelta(layer);
1546 if (!animating_transform_to_target && layer->scrollable() &&
1547 combined_transform.IsScaleOrTranslation()) {
1548 // Align the scrollable layer's position to screen space pixels to avoid
1549 // blurriness. To avoid side-effects, do this only if the transform is
1550 // simple.
1551 gfx::Vector2dF previous_translation = combined_transform.To2dTranslation();
1552 RoundTranslationComponents(&combined_transform);
1553 gfx::Vector2dF current_translation = combined_transform.To2dTranslation();
1554
1555 // This rounding changes the scroll delta, and so must be included
1556 // in the scroll compensation matrix.
enne (OOO) 2014/03/31 22:45:22 Can you also mention why you're scaling the offset
aelias_OOO_until_Jul13 2014/04/01 06:24:20 Added a longer comment.
1557 effective_scroll_delta -=
1558 gfx::ScaleVector2d(current_translation - previous_translation,
1559 1 / combined_transform_scales.x(),
enne (OOO) 2014/03/31 22:45:22 style nit: 1.f
aelias_OOO_until_Jul13 2014/04/01 06:24:20 Done.
1560 1 / combined_transform_scales.y());
1561 }
1562
1563 // Apply adjustment from position constraints.
1564 ApplyPositionAdjustment(layer,
1565 data_from_ancestor.fixed_container,
1566 data_from_ancestor.scroll_compensation_matrix,
1567 &combined_transform);
1568
1564 // The draw_transform that gets computed below is effectively the layer's 1569 // The draw_transform that gets computed below is effectively the layer's
1565 // draw_transform, unless the layer itself creates a render_surface. In that 1570 // draw_transform, unless the layer itself creates a render_surface. In that
1566 // case, the render_surface re-parents the transforms. 1571 // case, the render_surface re-parents the transforms.
1567 layer_draw_properties.target_space_transform = combined_transform; 1572 layer_draw_properties.target_space_transform = combined_transform;
1568 // M[draw] = M[parent] * LT * S[layer2content] 1573 // M[draw] = M[parent] * LT * S[layer2content]
1569 layer_draw_properties.target_space_transform.Scale( 1574 layer_draw_properties.target_space_transform.Scale(
1570 SK_MScalar1 / layer->contents_scale_x(), 1575 SK_MScalar1 / layer->contents_scale_x(),
1571 SK_MScalar1 / layer->contents_scale_y()); 1576 SK_MScalar1 / layer->contents_scale_y());
1572 1577
1573 // The layer's screen_space_transform represents the transform between root 1578 // The layer's screen_space_transform represents the transform between root
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 // At this point, we think the point does hit the touch event handler region 2402 // At this point, we think the point does hit the touch event handler region
2398 // on the layer, but we need to walk up the parents to ensure that the layer 2403 // on the layer, but we need to walk up the parents to ensure that the layer
2399 // was not clipped in such a way that the hit point actually should not hit 2404 // was not clipped in such a way that the hit point actually should not hit
2400 // the layer. 2405 // the layer.
2401 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2406 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2402 return false; 2407 return false;
2403 2408
2404 return true; 2409 return true;
2405 } 2410 }
2406 } // namespace cc 2411 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698