OLD | NEW |
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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 6122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6133 LayerImpl* scroll_layer = | 6133 LayerImpl* scroll_layer = |
6134 host_impl_->active_tree()->LayerById(scroll_layer_id); | 6134 host_impl_->active_tree()->LayerById(scroll_layer_id); |
6135 scroll_layer->SetDrawsContent(true); | 6135 scroll_layer->SetDrawsContent(true); |
6136 | 6136 |
6137 int occluder_layer_id = 6; | 6137 int occluder_layer_id = 6; |
6138 scoped_ptr<LayerImpl> occluder_layer = | 6138 scoped_ptr<LayerImpl> occluder_layer = |
6139 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 6139 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
6140 occluder_layer->SetDrawsContent(true); | 6140 occluder_layer->SetDrawsContent(true); |
6141 occluder_layer->SetBounds(content_size); | 6141 occluder_layer->SetBounds(content_size); |
6142 occluder_layer->SetContentBounds(content_size); | 6142 occluder_layer->SetContentBounds(content_size); |
6143 occluder_layer->SetPosition(gfx::PointF()); | 6143 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); |
6144 occluder_layer->SetAnchorPoint(gfx::PointF()); | 6144 occluder_layer->SetAnchorPoint(gfx::PointF()); |
6145 | 6145 |
6146 int child_scroll_clip_layer_id = 7; | 6146 int child_scroll_clip_layer_id = 7; |
6147 scoped_ptr<LayerImpl> child_scroll_clip = | 6147 scoped_ptr<LayerImpl> child_scroll_clip = |
6148 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); | 6148 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); |
6149 | 6149 |
6150 int child_scroll_layer_id = 8; | 6150 int child_scroll_layer_id = 8; |
6151 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 6151 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
6152 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 6152 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
6153 | 6153 |
6154 child_scroll->SetDrawsContent(false); | 6154 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
6155 | 6155 |
6156 child_scroll->AddChild(occluder_layer.Pass()); | 6156 child_scroll->AddChild(occluder_layer.Pass()); |
6157 scroll_layer->AddChild(child_scroll.Pass()); | 6157 scroll_layer->AddChild(child_scroll.Pass()); |
6158 | 6158 |
6159 DrawFrame(); | 6159 DrawFrame(); |
6160 | 6160 |
6161 EXPECT_EQ(InputHandler::ScrollUnknown, | 6161 EXPECT_EQ(InputHandler::ScrollUnknown, |
6162 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 6162 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
6163 } | 6163 } |
6164 | 6164 |
| 6165 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) { |
| 6166 gfx::Size content_size(100, 100); |
| 6167 SetupScrollAndContentsLayers(content_size); |
| 6168 |
| 6169 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
| 6170 |
| 6171 int scroll_layer_id = 2; |
| 6172 LayerImpl* scroll_layer = |
| 6173 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 6174 |
| 6175 int child_scroll_layer_id = 7; |
| 6176 scoped_ptr<LayerImpl> child_scroll = |
| 6177 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
| 6178 child_scroll->SetDrawsContent(false); |
| 6179 |
| 6180 scroll_layer->AddChild(child_scroll.Pass()); |
| 6181 |
| 6182 DrawFrame(); |
| 6183 |
| 6184 // We should not have scrolled |child_scroll| even though we technically "hit" |
| 6185 // it. The reason for this is that if the scrolling the scroll would not move |
| 6186 // any layer that is a drawn RSLL member, then we can ignore the hit. |
| 6187 // |
| 6188 // Why ScrollStarted? In this case, it's because we've bubbled out and started |
| 6189 // overscrolling the inner viewport. |
| 6190 EXPECT_EQ(InputHandler::ScrollStarted, |
| 6191 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 6192 |
| 6193 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); |
| 6194 } |
| 6195 |
| 6196 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { |
| 6197 // This test case is very similar to the one above with one key difference: |
| 6198 // the invisible scroller has a scroll child that is indeed draw contents. |
| 6199 // If we attempt to initiate a gesture scroll off of the visible scroll child |
| 6200 // we should still start the scroll child. |
| 6201 gfx::Size content_size(100, 100); |
| 6202 SetupScrollAndContentsLayers(content_size); |
| 6203 |
| 6204 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
| 6205 |
| 6206 int scroll_layer_id = 2; |
| 6207 LayerImpl* scroll_layer = |
| 6208 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 6209 |
| 6210 int scroll_child_id = 6; |
| 6211 scoped_ptr<LayerImpl> scroll_child = |
| 6212 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); |
| 6213 scroll_child->SetDrawsContent(true); |
| 6214 scroll_child->SetBounds(content_size); |
| 6215 scroll_child->SetContentBounds(content_size); |
| 6216 // Move the scroll child so it's not hit by our test point. |
| 6217 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 6218 scroll_child->SetAnchorPoint(gfx::PointF()); |
| 6219 |
| 6220 int invisible_scroll_layer_id = 7; |
| 6221 scoped_ptr<LayerImpl> invisible_scroll = |
| 6222 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); |
| 6223 invisible_scroll->SetDrawsContent(false); |
| 6224 |
| 6225 int container_id = 8; |
| 6226 scoped_ptr<LayerImpl> container = |
| 6227 LayerImpl::Create(host_impl_->active_tree(), container_id); |
| 6228 |
| 6229 scoped_ptr<std::set<LayerImpl*> > scroll_children(new std::set<LayerImpl*>()); |
| 6230 scroll_children->insert(scroll_child.get()); |
| 6231 invisible_scroll->SetScrollChildren(scroll_children.release()); |
| 6232 |
| 6233 scroll_child->SetScrollParent(invisible_scroll.get()); |
| 6234 |
| 6235 container->AddChild(invisible_scroll.Pass()); |
| 6236 container->AddChild(scroll_child.Pass()); |
| 6237 |
| 6238 scroll_layer->AddChild(container.Pass()); |
| 6239 |
| 6240 DrawFrame(); |
| 6241 |
| 6242 // We should not have scrolled |child_scroll| even though we technically "hit" |
| 6243 // it. The reason for this is that if the scrolling the scroll would not move |
| 6244 // any layer that is a drawn RSLL member, then we can ignore the hit. |
| 6245 // |
| 6246 // Why ScrollStarted? In this case, it's because we've bubbled out and started |
| 6247 // overscrolling the inner viewport. |
| 6248 EXPECT_EQ(InputHandler::ScrollStarted, |
| 6249 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 6250 |
| 6251 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
| 6252 } |
| 6253 |
6165 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 6254 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
6166 // to CompositorFrameMetadata after SwapBuffers(); | 6255 // to CompositorFrameMetadata after SwapBuffers(); |
6167 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 6256 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
6168 scoped_ptr<SolidColorLayerImpl> root = | 6257 scoped_ptr<SolidColorLayerImpl> root = |
6169 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6258 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
6170 root->SetAnchorPoint(gfx::PointF()); | 6259 root->SetAnchorPoint(gfx::PointF()); |
6171 root->SetPosition(gfx::PointF()); | 6260 root->SetPosition(gfx::PointF()); |
6172 root->SetBounds(gfx::Size(10, 10)); | 6261 root->SetBounds(gfx::Size(10, 10)); |
6173 root->SetContentBounds(gfx::Size(10, 10)); | 6262 root->SetContentBounds(gfx::Size(10, 10)); |
6174 root->SetDrawsContent(true); | 6263 root->SetDrawsContent(true); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6541 FakePictureLayerImpl* active_mask_content = | 6630 FakePictureLayerImpl* active_mask_content = |
6542 static_cast<FakePictureLayerImpl*>( | 6631 static_cast<FakePictureLayerImpl*>( |
6543 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); | 6632 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); |
6544 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); | 6633 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); |
6545 | 6634 |
6546 ASSERT_TRUE(!r2.IsEmpty()); | 6635 ASSERT_TRUE(!r2.IsEmpty()); |
6547 } | 6636 } |
6548 | 6637 |
6549 } // namespace | 6638 } // namespace |
6550 } // namespace cc | 6639 } // namespace cc |
OLD | NEW |