Chromium Code Reviews| 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, | |
|
danakj
2015/02/02 23:57:29
Then it would be even better if you did this in Di
vmpstr
2015/02/03 00:10:41
DidCommit doesn't have a host_impl... I think this
danakj
2015/02/03 00:21:28
Poking LTHI in DidCommit would be unthreadsafe. So
vmpstr
2015/02/03 00:26:08
Done.
| |
| 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 FrameTimingTracker* tracker = host_impl->frame_timing_tracker(); | |
| 6160 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timing_set = | |
| 6161 tracker->GroupCountsByRectId(); | |
| 6162 EXPECT_EQ(1u, timing_set->size()); | |
| 6163 auto rect_1_it = timing_set->find(1); | |
|
danakj
2015/02/02 23:57:29
const auto&?
vmpstr
2015/02/03 00:10:41
We typically do iterators by value. I can make an
danakj
2015/02/03 00:21:28
Hm.. ya okay nvm!
| |
| 6164 EXPECT_TRUE(rect_1_it != timing_set->end()); | |
| 6165 const auto& timing_events = rect_1_it->second; | |
| 6166 EXPECT_EQ(1u, timing_events.size()); | |
| 6167 EXPECT_EQ(host_impl->active_tree()->source_frame_number(), | |
| 6168 timing_events[0].frame_id); | |
| 6169 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); | |
| 6170 | |
| 6171 EndTest(); | |
| 6172 } | |
| 6173 | |
| 6174 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | |
| 6175 check_results_on_commit_ = true; | |
| 6176 PostSetNeedsCommitToMainThread(); | |
| 6177 } | |
| 6178 | |
| 6179 void AfterTest() override {} | |
| 6180 | |
| 6181 private: | |
| 6182 FakeContentLayerClient client_; | |
| 6183 bool check_results_on_commit_; | |
| 6184 }; | |
| 6185 | |
| 6186 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps); | |
| 6187 | |
| 6123 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { | 6188 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { |
| 6124 public: | 6189 public: |
| 6125 LayerTreeHostTestActivationCausesPrepareTiles() | 6190 LayerTreeHostTestActivationCausesPrepareTiles() |
| 6126 : scheduled_prepare_tiles_count_(0) {} | 6191 : scheduled_prepare_tiles_count_(0) {} |
| 6127 | 6192 |
| 6128 void SetupTree() override { | 6193 void SetupTree() override { |
| 6129 client_.set_fill_with_nonsolid_color(true); | 6194 client_.set_fill_with_nonsolid_color(true); |
| 6130 scoped_refptr<FakePictureLayer> root_layer = | 6195 scoped_refptr<FakePictureLayer> root_layer = |
| 6131 FakePictureLayer::Create(&client_); | 6196 FakePictureLayer::Create(&client_); |
| 6132 root_layer->SetBounds(gfx::Size(150, 150)); | 6197 root_layer->SetBounds(gfx::Size(150, 150)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6195 | 6260 |
| 6196 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6261 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
| 6197 | 6262 |
| 6198 private: | 6263 private: |
| 6199 bool did_commit_; | 6264 bool did_commit_; |
| 6200 }; | 6265 }; |
| 6201 | 6266 |
| 6202 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6267 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
| 6203 | 6268 |
| 6204 } // namespace cc | 6269 } // namespace cc |
| OLD | NEW |