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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 }; | 1097 }; |
1098 | 1098 |
1099 MULTI_THREAD_TEST_F(LayerTreeHostTestSetVisible); | 1099 MULTI_THREAD_TEST_F(LayerTreeHostTestSetVisible); |
1100 | 1100 |
1101 class TestOpacityChangeLayerDelegate : public ContentLayerClient { | 1101 class TestOpacityChangeLayerDelegate : public ContentLayerClient { |
1102 public: | 1102 public: |
1103 TestOpacityChangeLayerDelegate() : test_layer_(0) {} | 1103 TestOpacityChangeLayerDelegate() : test_layer_(0) {} |
1104 | 1104 |
1105 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } | 1105 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } |
1106 | 1106 |
1107 void PaintContents( | 1107 void PaintContents(SkCanvas* canvas, |
1108 SkCanvas* canvas, | 1108 const gfx::Rect& clip, |
1109 const gfx::Rect& clip, | 1109 PaintingControlSetting picture_control) override { |
1110 ContentLayerClient::GraphicsContextStatus gc_status) override { | |
1111 // Set layer opacity to 0. | 1110 // Set layer opacity to 0. |
1112 if (test_layer_) | 1111 if (test_layer_) |
1113 test_layer_->SetOpacity(0.f); | 1112 test_layer_->SetOpacity(0.f); |
1114 } | 1113 } |
1115 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 1114 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
1116 const gfx::Rect& clip, | 1115 const gfx::Rect& clip, |
1117 GraphicsContextStatus gc_status) override { | 1116 PaintingControlSetting picture_control) override { |
1118 NOTIMPLEMENTED(); | 1117 NOTIMPLEMENTED(); |
1119 return DisplayItemList::Create(); | 1118 return DisplayItemList::Create(); |
1120 } | 1119 } |
1121 bool FillsBoundsCompletely() const override { return false; } | 1120 bool FillsBoundsCompletely() const override { return false; } |
1122 | 1121 |
1123 private: | 1122 private: |
1124 Layer* test_layer_; | 1123 Layer* test_layer_; |
1125 }; | 1124 }; |
1126 | 1125 |
1127 class ContentLayerWithUpdateTracking : public ContentLayer { | 1126 class ContentLayerWithUpdateTracking : public ContentLayer { |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 case 2: | 2058 case 2: |
2060 EndTest(); | 2059 EndTest(); |
2061 break; | 2060 break; |
2062 default: | 2061 default: |
2063 NOTREACHED(); | 2062 NOTREACHED(); |
2064 break; | 2063 break; |
2065 } | 2064 } |
2066 } | 2065 } |
2067 | 2066 |
2068 void AfterTest() override { | 2067 void AfterTest() override { |
2069 EXPECT_GE(3, num_will_begin_impl_frame_); | 2068 EXPECT_GE(num_will_begin_impl_frame_, 3); |
2070 EXPECT_EQ(2, num_send_begin_main_frame_); | 2069 EXPECT_EQ(2, num_send_begin_main_frame_); |
2071 } | 2070 } |
2072 | 2071 |
2073 private: | 2072 private: |
2074 int num_will_begin_impl_frame_; | 2073 int num_will_begin_impl_frame_; |
2075 int num_send_begin_main_frame_; | 2074 int num_send_begin_main_frame_; |
2076 }; | 2075 }; |
2077 | 2076 |
2078 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); | 2077 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); |
2079 | 2078 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted); | 2319 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted); |
2321 | 2320 |
2322 class LayerTreeHostTestLCDChange : public LayerTreeHostTest { | 2321 class LayerTreeHostTestLCDChange : public LayerTreeHostTest { |
2323 public: | 2322 public: |
2324 class PaintClient : public FakeContentLayerClient { | 2323 class PaintClient : public FakeContentLayerClient { |
2325 public: | 2324 public: |
2326 PaintClient() : paint_count_(0) {} | 2325 PaintClient() : paint_count_(0) {} |
2327 | 2326 |
2328 int paint_count() const { return paint_count_; } | 2327 int paint_count() const { return paint_count_; } |
2329 | 2328 |
2330 void PaintContents( | 2329 void PaintContents(SkCanvas* canvas, |
2331 SkCanvas* canvas, | 2330 const gfx::Rect& clip, |
2332 const gfx::Rect& clip, | 2331 PaintingControlSetting picture_control) override { |
2333 ContentLayerClient::GraphicsContextStatus gc_status) override { | 2332 FakeContentLayerClient::PaintContents(canvas, clip, picture_control); |
2334 FakeContentLayerClient::PaintContents(canvas, clip, gc_status); | |
2335 ++paint_count_; | 2333 ++paint_count_; |
2336 } | 2334 } |
2337 | 2335 |
2338 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 2336 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
2339 const gfx::Rect& clip, | 2337 const gfx::Rect& clip, |
2340 GraphicsContextStatus gc_status) override { | 2338 PaintingControlSetting picture_control) override { |
2341 NOTIMPLEMENTED(); | 2339 NOTIMPLEMENTED(); |
2342 return DisplayItemList::Create(); | 2340 return DisplayItemList::Create(); |
2343 } | 2341 } |
2344 | 2342 |
2345 bool FillsBoundsCompletely() const override { return false; } | 2343 bool FillsBoundsCompletely() const override { return false; } |
2346 | 2344 |
2347 private: | 2345 private: |
2348 int paint_count_; | 2346 int paint_count_; |
2349 }; | 2347 }; |
2350 | 2348 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 | 2596 |
2599 class LayerTreeHostTestChangeLayerPropertiesInPaintContents | 2597 class LayerTreeHostTestChangeLayerPropertiesInPaintContents |
2600 : public LayerTreeHostTest { | 2598 : public LayerTreeHostTest { |
2601 public: | 2599 public: |
2602 class SetBoundsClient : public ContentLayerClient { | 2600 class SetBoundsClient : public ContentLayerClient { |
2603 public: | 2601 public: |
2604 SetBoundsClient() : layer_(0) {} | 2602 SetBoundsClient() : layer_(0) {} |
2605 | 2603 |
2606 void set_layer(Layer* layer) { layer_ = layer; } | 2604 void set_layer(Layer* layer) { layer_ = layer; } |
2607 | 2605 |
2608 void PaintContents( | 2606 void PaintContents(SkCanvas* canvas, |
2609 SkCanvas* canvas, | 2607 const gfx::Rect& clip, |
2610 const gfx::Rect& clip, | 2608 PaintingControlSetting picture_control) override { |
2611 ContentLayerClient::GraphicsContextStatus gc_status) override { | |
2612 layer_->SetBounds(gfx::Size(2, 2)); | 2609 layer_->SetBounds(gfx::Size(2, 2)); |
2613 } | 2610 } |
2614 | 2611 |
2615 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 2612 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
2616 const gfx::Rect& clip, | 2613 const gfx::Rect& clip, |
2617 GraphicsContextStatus gc_status) override { | 2614 PaintingControlSetting picture_control) override { |
2618 NOTIMPLEMENTED(); | 2615 NOTIMPLEMENTED(); |
2619 return DisplayItemList::Create(); | 2616 return DisplayItemList::Create(); |
2620 } | 2617 } |
2621 | 2618 |
2622 bool FillsBoundsCompletely() const override { return false; } | 2619 bool FillsBoundsCompletely() const override { return false; } |
2623 | 2620 |
2624 private: | 2621 private: |
2625 Layer* layer_; | 2622 Layer* layer_; |
2626 }; | 2623 }; |
2627 | 2624 |
(...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5511 PostSetNeedsCommitToMainThread(); | 5508 PostSetNeedsCommitToMainThread(); |
5512 } | 5509 } |
5513 | 5510 |
5514 void BeginMainFrame(const BeginFrameArgs& args) override { | 5511 void BeginMainFrame(const BeginFrameArgs& args) override { |
5515 EXPECT_EQ(nullptr, layer_tree_host()->root_layer()); | 5512 EXPECT_EQ(nullptr, layer_tree_host()->root_layer()); |
5516 | 5513 |
5517 layer_tree_host()->ApplyScrollAndScale(&info_); | 5514 layer_tree_host()->ApplyScrollAndScale(&info_); |
5518 EndTest(); | 5515 EndTest(); |
5519 } | 5516 } |
5520 | 5517 |
5521 void ApplyViewportDeltas(const gfx::Vector2d& inner, | 5518 void ApplyViewportDeltas(const gfx::Vector2dF& inner, |
5522 const gfx::Vector2d& outer, | 5519 const gfx::Vector2dF& outer, |
5523 const gfx::Vector2dF& elastic_overscroll_delta, | 5520 const gfx::Vector2dF& elastic_overscroll_delta, |
5524 float scale_delta, | 5521 float scale_delta, |
5525 float top_controls_delta) override { | 5522 float top_controls_delta) override { |
5526 EXPECT_EQ(info_.page_scale_delta, scale_delta); | 5523 EXPECT_EQ(info_.page_scale_delta, scale_delta); |
5527 EXPECT_EQ(info_.top_controls_delta, top_controls_delta); | 5524 EXPECT_EQ(info_.top_controls_delta, top_controls_delta); |
5528 deltas_sent_to_client_ = true; | 5525 deltas_sent_to_client_ = true; |
5529 } | 5526 } |
5530 | 5527 |
5531 void ApplyViewportDeltas( | 5528 void ApplyViewportDeltas( |
5532 const gfx::Vector2d& scroll, | 5529 const gfx::Vector2d& scroll, |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6089 } | 6086 } |
6090 | 6087 |
6091 protected: | 6088 protected: |
6092 FakeContentLayerClient client_; | 6089 FakeContentLayerClient client_; |
6093 size_t notify_ready_to_activate_count_; | 6090 size_t notify_ready_to_activate_count_; |
6094 size_t scheduled_prepare_tiles_count_; | 6091 size_t scheduled_prepare_tiles_count_; |
6095 }; | 6092 }; |
6096 | 6093 |
6097 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); | 6094 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
6098 | 6095 |
| 6096 class LayerTreeHostTestFrameTimingRequestsSaveTimestamps |
| 6097 : public LayerTreeHostTest { |
| 6098 public: |
| 6099 LayerTreeHostTestFrameTimingRequestsSaveTimestamps() |
| 6100 : check_results_on_commit_(false) {} |
| 6101 |
| 6102 void SetupTree() override { |
| 6103 scoped_refptr<FakePictureLayer> root_layer = |
| 6104 FakePictureLayer::Create(&client_); |
| 6105 root_layer->SetBounds(gfx::Size(200, 200)); |
| 6106 root_layer->SetIsDrawable(true); |
| 6107 |
| 6108 scoped_refptr<FakePictureLayer> child_layer = |
| 6109 FakePictureLayer::Create(&client_); |
| 6110 child_layer->SetBounds(gfx::Size(1500, 1500)); |
| 6111 child_layer->SetIsDrawable(true); |
| 6112 |
| 6113 std::vector<FrameTimingRequest> requests; |
| 6114 requests.push_back(FrameTimingRequest(1, gfx::Rect(0, 0, 100, 100))); |
| 6115 requests.push_back(FrameTimingRequest(2, gfx::Rect(300, 0, 100, 100))); |
| 6116 child_layer->SetFrameTimingRequests(requests); |
| 6117 |
| 6118 root_layer->AddChild(child_layer); |
| 6119 layer_tree_host()->SetRootLayer(root_layer); |
| 6120 LayerTreeHostTest::SetupTree(); |
| 6121 } |
| 6122 |
| 6123 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 6124 |
| 6125 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 6126 if (!check_results_on_commit_) |
| 6127 return; |
| 6128 |
| 6129 // Since in reality, the events will be read by LayerTreeHost during commit, |
| 6130 // we check the requests here to ensure that they are correct at the next |
| 6131 // commit time (as opposed to checking in DrawLayers for instance). |
| 6132 // TODO(vmpstr): Change this to read things from the main thread when this |
| 6133 // information is propagated to the main thread (not yet implemented). |
| 6134 FrameTimingTracker* tracker = host_impl->frame_timing_tracker(); |
| 6135 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timing_set = |
| 6136 tracker->GroupCountsByRectId(); |
| 6137 EXPECT_EQ(1u, timing_set->size()); |
| 6138 auto rect_1_it = timing_set->find(1); |
| 6139 EXPECT_TRUE(rect_1_it != timing_set->end()); |
| 6140 const auto& timing_events = rect_1_it->second; |
| 6141 EXPECT_EQ(1u, timing_events.size()); |
| 6142 EXPECT_EQ(host_impl->active_tree()->source_frame_number(), |
| 6143 timing_events[0].frame_id); |
| 6144 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); |
| 6145 |
| 6146 EndTest(); |
| 6147 } |
| 6148 |
| 6149 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 6150 check_results_on_commit_ = true; |
| 6151 PostSetNeedsCommitToMainThread(); |
| 6152 } |
| 6153 |
| 6154 void AfterTest() override {} |
| 6155 |
| 6156 private: |
| 6157 FakeContentLayerClient client_; |
| 6158 bool check_results_on_commit_; |
| 6159 }; |
| 6160 |
| 6161 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps); |
| 6162 |
6099 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { | 6163 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { |
6100 public: | 6164 public: |
6101 LayerTreeHostTestActivationCausesPrepareTiles() | 6165 LayerTreeHostTestActivationCausesPrepareTiles() |
6102 : scheduled_prepare_tiles_count_(0) {} | 6166 : scheduled_prepare_tiles_count_(0) {} |
6103 | 6167 |
6104 void SetupTree() override { | 6168 void SetupTree() override { |
6105 client_.set_fill_with_nonsolid_color(true); | 6169 client_.set_fill_with_nonsolid_color(true); |
6106 scoped_refptr<FakePictureLayer> root_layer = | 6170 scoped_refptr<FakePictureLayer> root_layer = |
6107 FakePictureLayer::Create(&client_); | 6171 FakePictureLayer::Create(&client_); |
6108 root_layer->SetBounds(gfx::Size(150, 150)); | 6172 root_layer->SetBounds(gfx::Size(150, 150)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6171 | 6235 |
6172 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6236 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6173 | 6237 |
6174 private: | 6238 private: |
6175 bool did_commit_; | 6239 bool did_commit_; |
6176 }; | 6240 }; |
6177 | 6241 |
6178 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6242 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6179 | 6243 |
6180 } // namespace cc | 6244 } // namespace cc |
OLD | NEW |