summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/trees/draw_property_utils.cc68
-rw-r--r--cc/trees/draw_property_utils.h8
-rw-r--r--cc/trees/layer_tree_host_common.cc7
-rw-r--r--cc/trees/layer_tree_impl_unittest.cc28
-rw-r--r--cc/trees/property_tree_builder.cc3
5 files changed, 81 insertions, 33 deletions
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index 0b5194e..1554142 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -29,9 +29,13 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
const bool is_unclipped =
clip_node->data.resets_clip && !clip_node->data.applies_local_clip;
+ // When both the layer and the target are unclipped, the entire layer
+ // content rect is visible.
+ const bool fully_visible = !clip_node->data.layers_are_clipped &&
+ !clip_node->data.target_is_clipped;
const TransformNode* transform_node =
transform_tree.Node(layer->transform_tree_index());
- if (!is_unclipped) {
+ if (!is_unclipped && !fully_visible) {
const TransformNode* target_node =
transform_tree.Node(transform_node->data.content_target_id);
@@ -41,16 +45,6 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
gfx::Rect combined_clip_rect_in_target_space;
bool success = true;
- gfx::Rect layer_content_rect = gfx::Rect(layer_bounds);
- // When both the layer and the target are unclipped, the entire layer
- // content rect is visible.
- if (!clip_node->data.layers_are_clipped &&
- !clip_node->data.target_is_clipped) {
- layer->set_visible_rect_from_property_trees(layer_content_rect);
- layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect());
- continue;
- }
-
if (clip_node->data.target_id != target_node->id) {
// In this case, layer has a clip parent (or shares the target with an
// ancestor layer that has clip parent) and the clip parent's target is
@@ -104,6 +98,7 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
content_to_target.Translate(layer->offset_to_transform_parent().x(),
layer->offset_to_transform_parent().y());
+ gfx::Rect layer_content_rect = gfx::Rect(layer_bounds);
gfx::Rect layer_content_bounds_in_target_space =
MathUtil::MapEnclosingClippedRect(content_to_target,
layer_content_rect);
@@ -155,8 +150,9 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
layer->set_visible_rect_from_property_trees(visible_rect);
} else {
layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds));
- layer->set_clip_rect_in_target_space_from_property_trees(
- gfx::Rect(layer_bounds));
+ // As the layer is unclipped, the clip rect in target space of this layer
+ // is not used. So, we set it to an empty rect.
+ layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect());
}
}
}
@@ -916,7 +912,9 @@ template <typename LayerType>
void UpdatePageScaleFactorInPropertyTreesInternal(
PropertyTrees* property_trees,
const LayerType* page_scale_layer,
- float page_scale_factor) {
+ float page_scale_factor,
+ float device_scale_factor,
+ gfx::Transform device_transform) {
if (property_trees->transform_tree.page_scale_factor() == page_scale_factor)
return;
@@ -931,24 +929,42 @@ void UpdatePageScaleFactorInPropertyTreesInternal(
DCHECK_EQ(page_scale_layer->transform_origin().ToString(),
gfx::Point3F().ToString());
- node->data.post_local_scale_factor = page_scale_factor;
+ if (!page_scale_layer->parent()) {
+ // When the page scale layer is also the root layer, the node should also
+ // store the combined scale factor and not just the page scale factor.
+ float post_local_scale_factor = page_scale_factor * device_scale_factor;
+ node->data.post_local_scale_factor = post_local_scale_factor;
+ node->data.post_local = device_transform;
+ node->data.post_local.Scale(post_local_scale_factor,
+ post_local_scale_factor);
+ } else {
+ node->data.post_local_scale_factor = page_scale_factor;
+ node->data.update_post_local_transform(gfx::PointF(), gfx::Point3F());
+ }
node->data.needs_local_transform_update = true;
- node->data.update_post_local_transform(gfx::PointF(), gfx::Point3F());
property_trees->transform_tree.set_needs_update(true);
}
-void UpdatePageScaleFactorInPropertyTrees(PropertyTrees* property_trees,
- const LayerImpl* page_scale_layer,
- float page_scale_factor) {
- UpdatePageScaleFactorInPropertyTreesInternal(property_trees, page_scale_layer,
- page_scale_factor);
+void UpdatePageScaleFactorInPropertyTrees(
+ PropertyTrees* property_trees,
+ const LayerImpl* page_scale_layer,
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Transform device_transform) {
+ UpdatePageScaleFactorInPropertyTreesInternal(
+ property_trees, page_scale_layer, page_scale_factor, device_scale_factor,
+ device_transform);
}
-void UpdatePageScaleFactorInPropertyTrees(PropertyTrees* property_trees,
- const Layer* page_scale_layer,
- float page_scale_factor) {
- UpdatePageScaleFactorInPropertyTreesInternal(property_trees, page_scale_layer,
- page_scale_factor);
+void UpdatePageScaleFactorInPropertyTrees(
+ PropertyTrees* property_trees,
+ const Layer* page_scale_layer,
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Transform device_transform) {
+ UpdatePageScaleFactorInPropertyTreesInternal(
+ property_trees, page_scale_layer, page_scale_factor, device_scale_factor,
+ device_transform);
}
} // namespace cc
diff --git a/cc/trees/draw_property_utils.h b/cc/trees/draw_property_utils.h
index ce657c7..2200959 100644
--- a/cc/trees/draw_property_utils.h
+++ b/cc/trees/draw_property_utils.h
@@ -106,12 +106,16 @@ ScreenSpaceTransformFromPropertyTrees(const LayerImpl* layer,
void CC_EXPORT
UpdatePageScaleFactorInPropertyTrees(PropertyTrees* property_trees,
const LayerImpl* page_scale_layer,
- float page_scale_factor);
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Transform device_transform);
void CC_EXPORT
UpdatePageScaleFactorInPropertyTrees(PropertyTrees* property_trees,
const Layer* page_scale_layer,
- float page_scale_factor);
+ float page_scale_factor,
+ float device_scale_factor,
+ const gfx::Transform device_transform);
} // namespace cc
#endif // CC_TREES_DRAW_PROPERTY_UTILS_H_
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 21054ff..ac25fbb 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -2713,9 +2713,10 @@ void CalculateDrawPropertiesAndVerify(
// active tree immediately affect the pending tree, so instead of
// trying to update property trees whenever page scale changes, we
// update their page scale before using them.
- UpdatePageScaleFactorInPropertyTrees(inputs->property_trees,
- inputs->page_scale_layer,
- inputs->page_scale_factor);
+ UpdatePageScaleFactorInPropertyTrees(
+ inputs->property_trees, inputs->page_scale_layer,
+ inputs->page_scale_factor, inputs->device_scale_factor,
+ inputs->device_transform);
ComputeVisibleRectsUsingPropertyTrees(
inputs->root_layer, inputs->property_trees, &update_layer_list);
break;
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc
index 77e0749..dbe7205 100644
--- a/cc/trees/layer_tree_impl_unittest.cc
+++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -1496,13 +1496,14 @@ TEST_F(LayerTreeImplTest,
float device_scale_factor = 3.f;
float page_scale_factor = 5.f;
+ float max_page_scale_factor = 10.f;
gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
root->bounds(), device_scale_factor * page_scale_factor);
host_impl().SetViewportSize(scaled_bounds_for_root);
host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
host_impl().active_tree()->PushPageScaleFromMainThread(
- page_scale_factor, page_scale_factor, page_scale_factor);
+ page_scale_factor, page_scale_factor, max_page_scale_factor);
host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
host_impl().active_tree()->SetRootLayer(root.Pass());
host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1,
@@ -1583,6 +1584,31 @@ TEST_F(LayerTreeImplTest,
test_point);
ASSERT_TRUE(result_layer);
EXPECT_EQ(12345, result_layer->id());
+
+ // Check update of page scale factor on the active tree when page scale layer
+ // is also the root layer.
+ page_scale_factor *= 1.5f;
+ host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
+ EXPECT_EQ(host_impl().active_tree()->root_layer(),
+ host_impl().active_tree()->PageScaleLayer());
+
+ test_point = gfx::Point(35, 35);
+ test_point =
+ gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor);
+ result_layer =
+ host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
+ test_point);
+ ASSERT_TRUE(result_layer);
+ EXPECT_EQ(12345, result_layer->id());
+
+ test_point = gfx::Point(64, 64);
+ test_point =
+ gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor);
+ result_layer =
+ host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
+ test_point);
+ ASSERT_TRUE(result_layer);
+ EXPECT_EQ(12345, result_layer->id());
}
TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) {
diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc
index 3000621..0a7fa29 100644
--- a/cc/trees/property_tree_builder.cc
+++ b/cc/trees/property_tree_builder.cc
@@ -542,7 +542,8 @@ void BuildPropertyTreesTopLevelInternal(
PropertyTrees* property_trees) {
if (!property_trees->needs_rebuild) {
UpdatePageScaleFactorInPropertyTrees(property_trees, page_scale_layer,
- page_scale_factor);
+ page_scale_factor, device_scale_factor,
+ device_transform);
return;
}