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 6102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6113 } | 6113 } |
6114 | 6114 |
6115 protected: | 6115 protected: |
6116 FakeContentLayerClient client_; | 6116 FakeContentLayerClient client_; |
6117 size_t notify_ready_to_activate_count_; | 6117 size_t notify_ready_to_activate_count_; |
6118 size_t scheduled_prepare_tiles_count_; | 6118 size_t scheduled_prepare_tiles_count_; |
6119 }; | 6119 }; |
6120 | 6120 |
6121 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); | 6121 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
6122 | 6122 |
| 6123 class LayerTreeHostTestFrameTimingRequestsSaveTimestamps |
| 6124 : public LayerTreeHostTest { |
| 6125 public: |
| 6126 LayerTreeHostTestFrameTimingRequestsSaveTimestamps() |
| 6127 : check_results_on_commit_(false) {} |
| 6128 |
| 6129 void SetupTree() override { |
| 6130 scoped_refptr<FakePictureLayer> root_layer = |
| 6131 FakePictureLayer::Create(&client_); |
| 6132 root_layer->SetBounds(gfx::Size(200, 200)); |
| 6133 root_layer->SetIsDrawable(true); |
| 6134 |
| 6135 scoped_refptr<FakePictureLayer> child_layer = |
| 6136 FakePictureLayer::Create(&client_); |
| 6137 child_layer->SetBounds(gfx::Size(1500, 1500)); |
| 6138 child_layer->SetIsDrawable(true); |
| 6139 |
| 6140 std::vector<FrameTimingRequest> requests; |
| 6141 requests.push_back(FrameTimingRequest(1, gfx::Rect(0, 0, 100, 100))); |
| 6142 requests.push_back(FrameTimingRequest(2, gfx::Rect(300, 0, 100, 100))); |
| 6143 child_layer->SetFrameTimingRequests(requests); |
| 6144 |
| 6145 root_layer->AddChild(child_layer); |
| 6146 layer_tree_host()->SetRootLayer(root_layer); |
| 6147 LayerTreeHostTest::SetupTree(); |
| 6148 } |
| 6149 |
| 6150 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 6151 |
| 6152 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 6153 if (!check_results_on_commit_) |
| 6154 return; |
| 6155 |
| 6156 // Since in reality, the events will be read by LayerTreeHost during commit, |
| 6157 // we check the requests here to ensure that they are correct at the next |
| 6158 // commit time (as opposed to checking in DrawLayers for instance). |
| 6159 // TODO(vmpstr): Change this to read things from the main thread when this |
| 6160 // information is propagated to the main thread (not yet implemented). |
| 6161 FrameTimingTracker* tracker = host_impl->frame_timing_tracker(); |
| 6162 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timing_set = |
| 6163 tracker->GroupCountsByRectId(); |
| 6164 EXPECT_EQ(1u, timing_set->size()); |
| 6165 auto rect_1_it = timing_set->find(1); |
| 6166 EXPECT_TRUE(rect_1_it != timing_set->end()); |
| 6167 const auto& timing_events = rect_1_it->second; |
| 6168 EXPECT_EQ(1u, timing_events.size()); |
| 6169 EXPECT_EQ(host_impl->active_tree()->source_frame_number(), |
| 6170 timing_events[0].frame_id); |
| 6171 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); |
| 6172 |
| 6173 EndTest(); |
| 6174 } |
| 6175 |
| 6176 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 6177 check_results_on_commit_ = true; |
| 6178 PostSetNeedsCommitToMainThread(); |
| 6179 } |
| 6180 |
| 6181 void AfterTest() override {} |
| 6182 |
| 6183 private: |
| 6184 FakeContentLayerClient client_; |
| 6185 bool check_results_on_commit_; |
| 6186 }; |
| 6187 |
| 6188 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps); |
| 6189 |
6123 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { | 6190 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { |
6124 public: | 6191 public: |
6125 LayerTreeHostTestActivationCausesPrepareTiles() | 6192 LayerTreeHostTestActivationCausesPrepareTiles() |
6126 : scheduled_prepare_tiles_count_(0) {} | 6193 : scheduled_prepare_tiles_count_(0) {} |
6127 | 6194 |
6128 void SetupTree() override { | 6195 void SetupTree() override { |
6129 client_.set_fill_with_nonsolid_color(true); | 6196 client_.set_fill_with_nonsolid_color(true); |
6130 scoped_refptr<FakePictureLayer> root_layer = | 6197 scoped_refptr<FakePictureLayer> root_layer = |
6131 FakePictureLayer::Create(&client_); | 6198 FakePictureLayer::Create(&client_); |
6132 root_layer->SetBounds(gfx::Size(150, 150)); | 6199 root_layer->SetBounds(gfx::Size(150, 150)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6195 | 6262 |
6196 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6263 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6197 | 6264 |
6198 private: | 6265 private: |
6199 bool did_commit_; | 6266 bool did_commit_; |
6200 }; | 6267 }; |
6201 | 6268 |
6202 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6269 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6203 | 6270 |
6204 } // namespace cc | 6271 } // namespace cc |
OLD | NEW |