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 client_.set_fill_with_nonsolid_color(true); |
| 6131 scoped_refptr<FakePictureLayer> root_layer = |
| 6132 FakePictureLayer::Create(&client_); |
| 6133 root_layer->SetBounds(gfx::Size(1500, 1500)); |
| 6134 root_layer->SetIsDrawable(true); |
| 6135 |
| 6136 std::vector<FrameTimingRequest> requests; |
| 6137 requests.push_back(FrameTimingRequest(1, gfx::Rect(0, 0, 100, 100))); |
| 6138 requests.push_back(FrameTimingRequest(2, gfx::Rect(300, 0, 100, 100))); |
| 6139 root_layer->SetFrameTimingRequests(requests); |
| 6140 |
| 6141 layer_tree_host()->SetRootLayer(root_layer); |
| 6142 LayerTreeHostTest::SetupTree(); |
| 6143 } |
| 6144 |
| 6145 void BeginTest() override { |
| 6146 layer_tree_host()->SetViewportSize(gfx::Size(16, 16)); |
| 6147 PostSetNeedsCommitToMainThread(); |
| 6148 } |
| 6149 |
| 6150 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
| 6151 if (!check_results_on_commit_) |
| 6152 return; |
| 6153 |
| 6154 FrameTimingTracker* tracker = host_impl->frame_timing_tracker(); |
| 6155 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timing_set = |
| 6156 tracker->GroupCountsByRectId(); |
| 6157 EXPECT_EQ(1u, timing_set->size()); |
| 6158 auto rect_1_it = timing_set->find(1); |
| 6159 EXPECT_TRUE(rect_1_it != timing_set->end()); |
| 6160 const auto& timing_events = rect_1_it->second; |
| 6161 EXPECT_EQ(1u, timing_events.size()); |
| 6162 EXPECT_EQ(host_impl->active_tree()->source_frame_number(), |
| 6163 timing_events[0].frame_id); |
| 6164 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); |
| 6165 |
| 6166 EndTest(); |
| 6167 } |
| 6168 |
| 6169 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 6170 check_results_on_commit_ = true; |
| 6171 PostSetNeedsCommitToMainThread(); |
| 6172 } |
| 6173 |
| 6174 void AfterTest() override {} |
| 6175 |
| 6176 private: |
| 6177 FakeContentLayerClient client_; |
| 6178 bool check_results_on_commit_; |
| 6179 }; |
| 6180 |
| 6181 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps); |
| 6182 |
6123 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { | 6183 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { |
6124 public: | 6184 public: |
6125 LayerTreeHostTestActivationCausesPrepareTiles() | 6185 LayerTreeHostTestActivationCausesPrepareTiles() |
6126 : scheduled_prepare_tiles_count_(0) {} | 6186 : scheduled_prepare_tiles_count_(0) {} |
6127 | 6187 |
6128 void SetupTree() override { | 6188 void SetupTree() override { |
6129 client_.set_fill_with_nonsolid_color(true); | 6189 client_.set_fill_with_nonsolid_color(true); |
6130 scoped_refptr<FakePictureLayer> root_layer = | 6190 scoped_refptr<FakePictureLayer> root_layer = |
6131 FakePictureLayer::Create(&client_); | 6191 FakePictureLayer::Create(&client_); |
6132 root_layer->SetBounds(gfx::Size(150, 150)); | 6192 root_layer->SetBounds(gfx::Size(150, 150)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6195 | 6255 |
6196 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6256 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6197 | 6257 |
6198 private: | 6258 private: |
6199 bool did_commit_; | 6259 bool did_commit_; |
6200 }; | 6260 }; |
6201 | 6261 |
6202 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6262 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6203 | 6263 |
6204 } // namespace cc | 6264 } // namespace cc |
OLD | NEW |