Index: cc/trees/layer_tree_host_common.cc |
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc |
index 6d75687201a55b640db73bb1d10ac125bdf63c5a..9a9650f520c0471828168bd4ef90810c180a66e1 100644 |
--- a/cc/trees/layer_tree_host_common.cc |
+++ b/cc/trees/layer_tree_host_common.cc |
@@ -17,6 +17,7 @@ |
#include "cc/trees/layer_sorter.h" |
#include "cc/trees/layer_tree_impl.h" |
#include "ui/gfx/geometry/rect_conversions.h" |
+#include "ui/gfx/geometry/vector2d_conversions.h" |
#include "ui/gfx/transform.h" |
namespace cc { |
@@ -1267,6 +1268,8 @@ struct SubtreeGlobals { |
float device_scale_factor; |
float page_scale_factor; |
const LayerType* page_scale_application_layer; |
+ gfx::Vector2dF elastic_overscroll; |
+ const LayerType* elastic_overscroll_application_layer; |
bool can_adjust_raster_scales; |
bool can_render_to_separate_surface; |
bool layers_always_allowed_lcd_text; |
@@ -1418,6 +1421,14 @@ static LayerImplList* GetLayerListForSorting(LayerImplList* layer_list) { |
return layer_list; |
} |
+static inline gfx::Vector2d BoundsDelta(Layer* layer) { |
+ return gfx::Vector2d(); |
+} |
+ |
+static inline gfx::Vector2d BoundsDelta(LayerImpl* layer) { |
+ return gfx::ToCeiledVector2d(layer->bounds_delta()); |
+} |
+ |
template <typename LayerType, typename GetIndexAndCountType> |
static void SortLayerListContributions( |
const LayerType& parent, |
@@ -1806,8 +1817,6 @@ static void CalculateDrawPropertiesInternal( |
layer->contents_opaque(); |
} |
- gfx::Rect content_rect(layer->content_bounds()); |
- |
// full_hierarchy_matrix is the matrix that transforms objects between screen |
// space (except projection matrix) and the most recent RenderSurfaceImpl's |
// space. next_hierarchy_matrix will only change if this layer uses a new |
@@ -2044,8 +2053,22 @@ static void CalculateDrawPropertiesInternal( |
if (adjust_text_aa) |
layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; |
- gfx::Rect rect_in_target_space = |
- MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); |
+ gfx::Size content_size_affected_by_delta(layer->content_bounds()); |
+ |
+ // Non-zero BoundsDelta imply the contents_scale of 1.0 |
+ // because BoundsDela is only set on Android where |
+ // ContentScalingLayer is never used. |
+ DCHECK_IMPLIES(!BoundsDelta(layer).IsZero(), |
+ (layer->contents_scale_x() == 1.0 && |
+ layer->contents_scale_y() == 1.0)); |
+ |
+ // Thus we can omit contents scale in the following calculation. |
+ gfx::Vector2d bounds_delta = BoundsDelta(layer); |
+ content_size_affected_by_delta.Enlarge(bounds_delta.x(), bounds_delta.y()); |
+ |
+ gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
+ layer->draw_transform(), |
+ gfx::Rect(content_size_affected_by_delta)); |
if (LayerClipsSubtree(layer)) { |
layer_or_ancestor_clips_descendants = true; |
@@ -2100,6 +2123,10 @@ static void CalculateDrawPropertiesInternal( |
globals.page_scale_factor); |
data_for_children.in_subtree_of_page_scale_application_layer = true; |
} |
+ if (layer == globals.elastic_overscroll_application_layer) { |
+ data_for_children.parent_matrix.Translate(globals.elastic_overscroll.x(), |
+ globals.elastic_overscroll.y()); |
+ } |
// Flatten to 2D if the layer doesn't preserve 3D. |
if (layer->should_flatten_transform()) |
@@ -2378,6 +2405,9 @@ static void ProcessCalcDrawPropsInputs( |
inputs.device_scale_factor * device_transform_scale; |
globals->page_scale_factor = inputs.page_scale_factor; |
globals->page_scale_application_layer = inputs.page_scale_application_layer; |
+ globals->elastic_overscroll = inputs.elastic_overscroll; |
+ globals->elastic_overscroll_application_layer = |
+ inputs.elastic_overscroll_application_layer; |
globals->can_render_to_separate_surface = |
inputs.can_render_to_separate_surface; |
globals->can_adjust_raster_scales = inputs.can_adjust_raster_scales; |