diff options
author | Dana Jansens <danakj@google.com> | 2015-06-17 18:33:14 -0700 |
---|---|---|
committer | Dana Jansens <danakj@google.com> | 2015-06-18 01:34:04 +0000 |
commit | c46d374132867eceba26a27e346353086436ee03 (patch) | |
tree | 3194cd20a23c9c4ae005657be429c59b94deec48 /cc/trees | |
parent | c38dbd49c2f0ccc9b684c5bbcf6be41bca8ea8ae (diff) | |
download | chromium_src-c46d374132867eceba26a27e346353086436ee03.zip chromium_src-c46d374132867eceba26a27e346353086436ee03.tar.gz chromium_src-c46d374132867eceba26a27e346353086436ee03.tar.bz2 |
cc: Remove the layer content_bounds() and use bounds() instead.
And remove the content_bounds from DrawProperties.
They are always equal now (outside of some legacy tests).
R=enne@chromium.org, enne, vmpstr
BUG=413479
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1179133004.
Cr-Commit-Position: refs/heads/master@{#334979}
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 133 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_perftest.cc | 6 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 31 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 3 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 52 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 10 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl_unittest.cc | 187 |
7 files changed, 57 insertions, 365 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 5f081b4..b57177b 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -377,7 +377,7 @@ static gfx::Rect CalculateVisibleContentRect( DCHECK(layer->render_target()); // Nothing is visible if the layer bounds are empty. - if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || + if (!layer->DrawsContent() || layer->bounds().IsEmpty() || layer->drawable_content_rect().IsEmpty()) return gfx::Rect(); @@ -403,10 +403,8 @@ static gfx::Rect CalculateVisibleContentRect( return gfx::Rect(); return CalculateVisibleRectWithCachedLayerRect( - visible_rect_in_target_surface_space, - gfx::Rect(layer->content_bounds()), - layer_rect_in_target_space, - layer->draw_transform()); + visible_rect_in_target_surface_space, gfx::Rect(layer->bounds()), + layer_rect_in_target_space, layer->draw_transform()); } static inline bool TransformToParentIsKnown(LayerImpl* layer) { return true; } @@ -925,94 +923,6 @@ static inline void UpdateLayerScaleDrawProperties( layer->draw_properties().device_scale_factor = device_scale_factor; } -static inline void CalculateContentsScale(LayerImpl* layer, - float contents_scale) { - // LayerImpl has all of its content scales and bounds pushed from the Main - // thread during commit and just uses those values as-is. -} - -static inline void CalculateContentsScale(Layer* layer, float contents_scale) { - layer->CalculateContentsScale(contents_scale, - &layer->draw_properties().contents_scale_x, - &layer->draw_properties().contents_scale_y, - &layer->draw_properties().content_bounds); - - Layer* mask_layer = layer->mask_layer(); - if (mask_layer) { - mask_layer->CalculateContentsScale( - contents_scale, - &mask_layer->draw_properties().contents_scale_x, - &mask_layer->draw_properties().contents_scale_y, - &mask_layer->draw_properties().content_bounds); - } - - Layer* replica_mask_layer = - layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; - if (replica_mask_layer) { - replica_mask_layer->CalculateContentsScale( - contents_scale, - &replica_mask_layer->draw_properties().contents_scale_x, - &replica_mask_layer->draw_properties().contents_scale_y, - &replica_mask_layer->draw_properties().content_bounds); - } -} - -static inline void UpdateLayerContentsScale( - LayerImpl* layer, - bool can_adjust_raster_scale, - float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - bool animating_transform_to_screen) { - CalculateContentsScale(layer, ideal_contents_scale); -} - -static inline void UpdateLayerContentsScale( - Layer* layer, - bool can_adjust_raster_scale, - float ideal_contents_scale, - float device_scale_factor, - float page_scale_factor, - bool animating_transform_to_screen) { - if (can_adjust_raster_scale) { - float ideal_raster_scale = - ideal_contents_scale / (device_scale_factor * page_scale_factor); - - bool need_to_set_raster_scale = layer->raster_scale_is_unknown(); - - // If we've previously saved a raster_scale but the ideal changes, things - // are unpredictable and we should just use 1. - if (!need_to_set_raster_scale && layer->raster_scale() != 1.f && - ideal_raster_scale != layer->raster_scale()) { - ideal_raster_scale = 1.f; - need_to_set_raster_scale = true; - } - - if (need_to_set_raster_scale) { - bool use_and_save_ideal_scale = - ideal_raster_scale >= 1.f && !animating_transform_to_screen; - if (use_and_save_ideal_scale) - layer->set_raster_scale(ideal_raster_scale); - } - } - - float raster_scale = 1.f; - if (!layer->raster_scale_is_unknown()) - raster_scale = layer->raster_scale(); - - gfx::Size old_content_bounds = layer->content_bounds(); - float old_contents_scale_x = layer->contents_scale_x(); - float old_contents_scale_y = layer->contents_scale_y(); - - float contents_scale = raster_scale * device_scale_factor * page_scale_factor; - CalculateContentsScale(layer, contents_scale); - - if (layer->content_bounds() != old_content_bounds || - layer->contents_scale_x() != old_contents_scale_x || - layer->contents_scale_y() != old_contents_scale_y) - layer->SetNeedsPushProperties(); -} - static inline void CalculateAnimationContentsScale( Layer* layer, bool ancestor_is_animating_scale, @@ -1529,14 +1439,6 @@ 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, @@ -1849,13 +1751,6 @@ static void CalculateDrawPropertiesInternal( ? std::max(combined_transform_scales.x(), combined_transform_scales.y()) : layer_scale_factors; - UpdateLayerContentsScale(layer, globals.can_adjust_raster_scales, - ideal_contents_scale, globals.device_scale_factor, - data_from_ancestor.in_subtree_of_page_scale_layer - ? globals.page_scale_factor - : 1.f, - animating_transform_to_screen); - UpdateLayerScaleDrawProperties( layer, ideal_contents_scale, combined_maximum_animation_contents_scale, combined_starting_animation_contents_scale, @@ -2031,7 +1926,7 @@ static void CalculateDrawPropertiesInternal( layer->mask_layer()->draw_properties(); mask_layer_draw_properties.render_target = layer; mask_layer_draw_properties.visible_content_rect = - gfx::Rect(layer->content_bounds()); + gfx::Rect(layer->bounds()); } if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { @@ -2039,7 +1934,7 @@ static void CalculateDrawPropertiesInternal( layer->replica_layer()->mask_layer()->draw_properties(); replica_mask_draw_properties.render_target = layer; replica_mask_draw_properties.visible_content_rect = - gfx::Rect(layer->content_bounds()); + gfx::Rect(layer->bounds()); } // Ignore occlusion from outside the surface when surface contents need to @@ -2157,22 +2052,10 @@ static void CalculateDrawPropertiesInternal( layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; - 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()); - + // The layer bounds() includes the layer's bounds_delta() which we want + // for the clip rect. gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( - layer->draw_transform(), - gfx::Rect(content_size_affected_by_delta)); + layer->draw_transform(), gfx::Rect(layer->bounds())); if (LayerClipsSubtree(layer)) { layer_or_ancestor_clips_descendants = true; diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc index 08e5404..e42d87e 100644 --- a/cc/trees/layer_tree_host_common_perftest.cc +++ b/cc/trees/layer_tree_host_common_perftest.cc @@ -154,10 +154,8 @@ class BspTreePerfTest : public CalcDrawPropsTest { for (LayerImplList::iterator it = base_list.begin(); it != base_list.end(); ++it) { DrawPolygon* draw_polygon = - new DrawPolygon(NULL, - gfx::RectF((*it)->content_bounds()), - (*it)->draw_transform(), - polygon_counter++); + new DrawPolygon(NULL, gfx::RectF((*it)->bounds()), + (*it)->draw_transform(), polygon_counter++); polygon_list.push_back(scoped_ptr<DrawPolygon>(draw_polygon)); } diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 55fa3bf..2fc2f6e 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -4111,13 +4111,13 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { // The animating layers should have a visible content rect that represents the // area of the front face that is within the viewport. EXPECT_EQ(animating_child->visible_content_rect(), - gfx::Rect(animating_child->content_bounds())); + gfx::Rect(animating_child->bounds())); EXPECT_EQ(animating_surface->visible_content_rect(), - gfx::Rect(animating_surface->content_bounds())); + gfx::Rect(animating_surface->bounds())); // And layers in the subtree of the animating layer should have valid visible // content rects also. EXPECT_EQ(child_of_animating_surface->visible_content_rect(), - gfx::Rect(child_of_animating_surface->content_bounds())); + gfx::Rect(child_of_animating_surface->bounds())); } TEST_F(LayerTreeHostCommonTest, @@ -4302,12 +4302,12 @@ TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) { parent->draw_transform()); // Verify results of transformed parent rects - gfx::RectF parent_content_bounds(parent->content_bounds()); + gfx::RectF parent_bounds(parent->bounds()); gfx::RectF parent_draw_rect = - MathUtil::MapClippedRect(parent->draw_transform(), parent_content_bounds); - gfx::RectF parent_screen_space_rect = MathUtil::MapClippedRect( - parent->screen_space_transform(), parent_content_bounds); + MathUtil::MapClippedRect(parent->draw_transform(), parent_bounds); + gfx::RectF parent_screen_space_rect = + MathUtil::MapClippedRect(parent->screen_space_transform(), parent_bounds); gfx::RectF expected_parent_draw_rect(parent->bounds()); expected_parent_draw_rect.Scale(device_scale_factor); @@ -4330,17 +4330,17 @@ TEST_F(LayerTreeHostCommonTest, LayerTransformsInHighDPI) { // Verify results of transformed child and child_empty rects. They should // match. - gfx::RectF child_content_bounds(child->content_bounds()); + gfx::RectF child_bounds(child->bounds()); gfx::RectF child_draw_rect = - MathUtil::MapClippedRect(child->draw_transform(), child_content_bounds); - gfx::RectF child_screen_space_rect = MathUtil::MapClippedRect( - child->screen_space_transform(), child_content_bounds); + MathUtil::MapClippedRect(child->draw_transform(), child_bounds); + gfx::RectF child_screen_space_rect = + MathUtil::MapClippedRect(child->screen_space_transform(), child_bounds); - gfx::RectF child_empty_draw_rect = MathUtil::MapClippedRect( - child_empty->draw_transform(), child_content_bounds); + gfx::RectF child_empty_draw_rect = + MathUtil::MapClippedRect(child_empty->draw_transform(), child_bounds); gfx::RectF child_empty_screen_space_rect = MathUtil::MapClippedRect( - child_empty->screen_space_transform(), child_content_bounds); + child_empty->screen_space_transform(), child_bounds); gfx::RectF expected_child_draw_rect(child->position(), child->bounds()); expected_child_draw_rect.Scale(device_scale_factor); @@ -4692,8 +4692,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) { duplicate_child_non_owner->screen_space_transform()); EXPECT_EQ(child->drawable_content_rect(), duplicate_child_non_owner->drawable_content_rect()); - EXPECT_EQ(child->content_bounds(), - duplicate_child_non_owner->content_bounds()); + EXPECT_EQ(child->bounds(), duplicate_child_non_owner->bounds()); gfx::Transform expected_render_surface_draw_transform; expected_render_surface_draw_transform.Translate( diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index f29f3da..2260925 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2879,8 +2879,7 @@ float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( if (!layer_impl) return std::numeric_limits<float>::max(); - gfx::Rect layer_impl_bounds( - layer_impl->content_bounds()); + gfx::Rect layer_impl_bounds(layer_impl->bounds()); gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( layer_impl->screen_space_transform(), diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index e814e70..0dfcd01 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -3932,7 +3932,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { scoped_ptr<LayerImpl> clip_layer = LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); scoped_ptr<LayerImpl> child = CreateScrollableLayer( - child_layer_id, scroll_layer->content_bounds(), clip_layer.get()); + child_layer_id, scroll_layer->bounds(), clip_layer.get()); gfx::Transform rotate_transform; rotate_transform.Translate(-50.0, -50.0); rotate_transform.Rotate(child_layer_angle); @@ -4727,7 +4727,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Opaque layer, drawn without blending. layer1->SetContentsOpaque(true); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4736,7 +4736,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Layer with translucent content and painting, so drawn with blending. layer1->SetContentsOpaque(false); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4746,7 +4746,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(0.5f); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4756,7 +4756,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(0.5f); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4774,11 +4774,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(true); layer2->SetOpacity(1.f); layer2->SetExpectation(false, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4789,9 +4789,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Child layer with opaque content, drawn without blending. layer1->SetContentsOpaque(false); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetExpectation(false, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4803,9 +4803,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Child layer with opaque content, drawn without blending. layer1->SetContentsOpaque(true); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetExpectation(false, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4821,9 +4821,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetOpacity(0.5f); layer1->SetHasRenderSurface(true); layer1->SetExpectation(false, true); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetExpectation(false, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( host_impl_->active_tree()->root_layer()); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -4838,11 +4838,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(true); layer2->SetOpacity(0.5f); layer2->SetExpectation(true, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4853,11 +4853,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(false); layer2->SetOpacity(1.f); layer2->SetExpectation(true, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4869,11 +4869,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(true); layer2->SetOpacity(1.f); layer2->SetExpectation(false, false); - layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4886,7 +4886,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4898,7 +4898,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4910,7 +4910,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -4923,7 +4923,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(false, false); - layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); EXPECT_TRUE(layer1->quads_appended()); @@ -5354,7 +5354,7 @@ class FakeLayerWithQuads : public LayerImpl { PopulateSharedQuadState(shared_quad_state); SkColor gray = SkColorSetRGB(100, 100, 100); - gfx::Rect quad_rect(content_bounds()); + gfx::Rect quad_rect(bounds()); gfx::Rect visible_quad_rect(quad_rect); SolidColorDrawQuad* my_quad = render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); @@ -5820,12 +5820,12 @@ class LayerTreeHostImplTestWithDelegatingRenderer ASSERT_EQ(2u, root_render_pass->quad_list.size()); LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; - gfx::RectF expected_child_visible_rect(child->content_bounds()); + gfx::RectF expected_child_visible_rect(child->bounds()); EXPECT_EQ(expected_child_visible_rect, root_render_pass->quad_list.front()->visible_rect); LayerImpl* root = host_impl_->active_tree()->root_layer(); - gfx::RectF expected_root_visible_rect(root->content_bounds()); + gfx::RectF expected_root_visible_rect(root->bounds()); EXPECT_EQ(expected_root_visible_rect, root_render_pass->quad_list.ElementAt(1)->visible_rect); } diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 9efb89c..ce3c3e06 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -503,7 +503,7 @@ gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { return gfx::Rect(); LayerImpl* layer = root_scroll_layer->children()[0]; return MathUtil::MapEnclosingClippedRect(layer->screen_space_transform(), - gfx::Rect(layer->content_bounds())); + gfx::Rect(layer->bounds())); } void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { @@ -1334,10 +1334,8 @@ static bool PointIsClippedBySurfaceOrClipRect( return true; if (LayerClipsSubtree(layer) && - !PointHitsRect(screen_space_point, - layer->screen_space_transform(), - gfx::Rect(layer->content_bounds()), - NULL)) + !PointHitsRect(screen_space_point, layer->screen_space_transform(), + gfx::Rect(layer->bounds()), NULL)) return true; } @@ -1349,7 +1347,7 @@ static bool PointIsClippedBySurfaceOrClipRect( static bool PointHitsLayer(const LayerImpl* layer, const gfx::PointF& screen_space_point, float* distance_to_intersection) { - gfx::RectF content_rect(layer->content_bounds()); + gfx::RectF content_rect(layer->bounds()); if (!PointHitsRect(screen_space_point, layer->screen_space_transform(), content_rect, diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 11ce4bc..4811893 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -380,87 +380,6 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { EXPECT_EQ(12345, result_layer->id()); } -TEST_F(LayerTreeImplTest, HitTestingForSingleLayerWithScaledContents) { - // A layer's visible content rect is actually in the layer's content space. - // The screen space transform converts from the layer's origin space to screen - // space. This test makes sure that hit testing works correctly accounts for - // the contents scale. A contents scale that is not 1 effectively forces a - // non-identity transform between layer's content space and layer's origin - // space. The hit testing code must take this into account. - // - // To test this, the layer is positioned at (25, 25), and is size (50, 50). If - // contents scale is ignored, then hit testing will mis-interpret the visible - // content rect as being larger than the actual bounds of the layer. - // - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - - gfx::Transform identity_matrix; - gfx::Point3F transform_origin; - - SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, - gfx::PointF(), gfx::Size(100, 100), true, false, - true); - { - gfx::PointF position(25.f, 25.f); - gfx::Size bounds(50, 50); - scoped_ptr<LayerImpl> test_layer = - LayerImpl::Create(host_impl().active_tree(), 12345); - SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, - transform_origin, position, bounds, true, - false, false); - - // override content bounds and contents scale - test_layer->SetContentBounds(gfx::Size(100, 100)); - test_layer->SetContentsScale(2, 2); - - test_layer->SetDrawsContent(true); - root->AddChild(test_layer.Pass()); - } - - host_impl().SetViewportSize(root->bounds()); - host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); - - // Sanity check the scenario we just created. - // The visible content rect for test_layer is actually 100x100, even though - // its layout size is 50x50, positioned at 25x25. - LayerImpl* test_layer = - host_impl().active_tree()->root_layer()->children()[0]; - EXPECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); - ASSERT_EQ(1u, RenderSurfaceLayerList().size()); - ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); - - // Hit testing for a point outside the layer should return a null pointer (the - // root layer does not draw content, so it will not be hit tested either). - gfx::Point test_point(101, 101); - LayerImpl* result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - EXPECT_FALSE(result_layer); - - test_point = gfx::Point(24, 24); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - EXPECT_FALSE(result_layer); - - test_point = gfx::Point(76, 76); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - EXPECT_FALSE(result_layer); - - // Hit testing for a point inside should return the test layer. - test_point = gfx::Point(26, 26); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - ASSERT_TRUE(result_layer); - EXPECT_EQ(12345, result_layer->id()); - - test_point = gfx::Point(74, 74); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - ASSERT_TRUE(result_layer); - EXPECT_EQ(12345, result_layer->id()); -} - TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { // Test that hit-testing will only work for the visible portion of a layer, // and not the entire layer bounds. Here we just test the simple axis-aligned @@ -1500,110 +1419,6 @@ TEST_F(LayerTreeImplTest, } TEST_F(LayerTreeImplTest, - HitCheckingTouchHandlerRegionsForSingleLayerWithScaledContents) { - // A layer's visible content rect is actually in the layer's content space. - // The screen space transform converts from the layer's origin space to screen - // space. This test makes sure that hit testing works correctly accounts for - // the contents scale. A contents scale that is not 1 effectively forces a - // non-identity transform between layer's content space and layer's origin - // space. The hit testing code must take this into account. - // - // To test this, the layer is positioned at (25, 25), and is size (50, 50). If - // contents scale is ignored, then hit checking will mis-interpret the visible - // content rect as being larger than the actual bounds of the layer. - // - scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - - gfx::Transform identity_matrix; - gfx::Point3F transform_origin; - - SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, - gfx::PointF(), gfx::Size(100, 100), true, false, - true); - { - Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); - gfx::PointF position(25.f, 25.f); - gfx::Size bounds(50, 50); - scoped_ptr<LayerImpl> test_layer = - LayerImpl::Create(host_impl().active_tree(), 12345); - SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, - transform_origin, position, bounds, true, - false, false); - - // override content bounds and contents scale - test_layer->SetContentBounds(gfx::Size(100, 100)); - test_layer->SetContentsScale(2, 2); - - test_layer->SetDrawsContent(true); - test_layer->SetTouchEventHandlerRegion(touch_handler_region); - root->AddChild(test_layer.Pass()); - } - - host_impl().SetViewportSize(root->bounds()); - host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); - - // Sanity check the scenario we just created. - // The visible content rect for test_layer is actually 100x100, even though - // its layout size is 50x50, positioned at 25x25. - LayerImpl* test_layer = - host_impl().active_tree()->root_layer()->children()[0]; - EXPECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); - ASSERT_EQ(1u, RenderSurfaceLayerList().size()); - ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); - - // Hit checking for a point outside the layer should return a null pointer - // (the root layer does not draw content, so it will not be tested either). - gfx::Point test_point(76, 76); - LayerImpl* result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point); - EXPECT_FALSE(result_layer); - - // Hit checking for a point inside the layer, but outside the touch handler - // region should return a null pointer. - test_point = gfx::Point(26, 26); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point); - EXPECT_FALSE(result_layer); - - test_point = gfx::Point(34, 34); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point); - EXPECT_FALSE(result_layer); - - test_point = gfx::Point(65, 65); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point); - EXPECT_FALSE(result_layer); - - test_point = gfx::Point(74, 74); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point); - EXPECT_FALSE(result_layer); - - // Hit checking for a point inside the touch event handler region should - // return the root layer. - test_point = gfx::Point(35, 35); - 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); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( - test_point); - ASSERT_TRUE(result_layer); - EXPECT_EQ(12345, result_layer->id()); -} - -TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { // The layer's device_scale_factor and page_scale_factor should scale the // content rect and we should be able to hit the touch handler region by @@ -1655,7 +1470,7 @@ TEST_F(LayerTreeImplTest, ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); // Check whether the child layer fits into the root after scaled. - EXPECT_EQ(gfx::Rect(test_layer->content_bounds()), + EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_content_rect()); // Hit checking for a point outside the layer should return a null pointer |