OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "cc/debug/lap_timer.h" | 9 #include "cc/debug/lap_timer.h" |
10 #include "cc/layers/layer_iterator.h" | 10 #include "cc/layers/layer_iterator.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 static const int kWarmupRuns = 5; | 28 static const int kWarmupRuns = 5; |
29 static const int kTimeCheckInterval = 10; | 29 static const int kTimeCheckInterval = 10; |
30 | 30 |
31 class OcclusionTrackerPerfTest : public testing::Test { | 31 class OcclusionTrackerPerfTest : public testing::Test { |
32 public: | 32 public: |
33 OcclusionTrackerPerfTest() | 33 OcclusionTrackerPerfTest() |
34 : timer_(kWarmupRuns, | 34 : timer_(kWarmupRuns, |
35 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 35 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
36 kTimeCheckInterval), | 36 kTimeCheckInterval), |
37 proxy_(base::ThreadTaskRunnerHandle::Get(), nullptr), | 37 proxy_(base::ThreadTaskRunnerHandle::Get(), nullptr), |
38 impl_(&proxy_), | 38 impl_(&proxy_) {} |
39 output_surface_(FakeOutputSurface::Create3d()) {} | |
40 void CreateHost() { | 39 void CreateHost() { |
41 LayerTreeSettings settings; | 40 LayerTreeSettings settings; |
42 host_impl_ = LayerTreeHostImpl::Create(settings, &client_, &proxy_, &stats_, | 41 host_impl_ = LayerTreeHostImpl::Create(settings, &client_, &proxy_, &stats_, |
43 &shared_bitmap_manager_, nullptr, | 42 &shared_bitmap_manager_, nullptr, |
44 &task_graph_runner_, 1); | 43 &task_graph_runner_, 1); |
45 host_impl_->InitializeRenderer(output_surface_.get()); | 44 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d()); |
46 | 45 |
47 scoped_ptr<LayerImpl> root_layer = LayerImpl::Create(active_tree(), 1); | 46 scoped_ptr<LayerImpl> root_layer = LayerImpl::Create(active_tree(), 1); |
48 root_layer->SetHasRenderSurface(true); | 47 root_layer->SetHasRenderSurface(true); |
49 active_tree()->SetRootLayer(root_layer.Pass()); | 48 active_tree()->SetRootLayer(root_layer.Pass()); |
50 } | 49 } |
51 | 50 |
52 LayerTreeImpl* active_tree() { return host_impl_->active_tree(); } | 51 LayerTreeImpl* active_tree() { return host_impl_->active_tree(); } |
53 | 52 |
54 void SetTestName(const std::string& name) { test_name_ = name; } | 53 void SetTestName(const std::string& name) { test_name_ = name; } |
55 | 54 |
56 void PrintResults() { | 55 void PrintResults() { |
57 CHECK(!test_name_.empty()) << "Must SetTestName() before AfterTest()."; | 56 CHECK(!test_name_.empty()) << "Must SetTestName() before AfterTest()."; |
58 perf_test::PrintResult("occlusion_tracker_time", | 57 perf_test::PrintResult("occlusion_tracker_time", |
59 "", | 58 "", |
60 test_name_, | 59 test_name_, |
61 1000 * timer_.MsPerLap(), | 60 1000 * timer_.MsPerLap(), |
62 "us", | 61 "us", |
63 true); | 62 true); |
64 } | 63 } |
65 | 64 |
66 protected: | 65 protected: |
67 LapTimer timer_; | 66 LapTimer timer_; |
68 std::string test_name_; | 67 std::string test_name_; |
69 FakeLayerTreeHostImplClient client_; | 68 FakeLayerTreeHostImplClient client_; |
70 FakeProxy proxy_; | 69 FakeProxy proxy_; |
71 DebugScopedSetImplThread impl_; | 70 DebugScopedSetImplThread impl_; |
72 FakeRenderingStatsInstrumentation stats_; | 71 FakeRenderingStatsInstrumentation stats_; |
73 TestSharedBitmapManager shared_bitmap_manager_; | 72 TestSharedBitmapManager shared_bitmap_manager_; |
74 TestTaskGraphRunner task_graph_runner_; | 73 TestTaskGraphRunner task_graph_runner_; |
75 scoped_ptr<OutputSurface> output_surface_; | |
76 scoped_ptr<LayerTreeHostImpl> host_impl_; | 74 scoped_ptr<LayerTreeHostImpl> host_impl_; |
77 }; | 75 }; |
78 | 76 |
79 TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { | 77 TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { |
80 SetTestName("unoccluded_content_rect_fully_occluded"); | 78 SetTestName("unoccluded_content_rect_fully_occluded"); |
81 | 79 |
82 gfx::Rect viewport_rect(768, 1038); | 80 gfx::Rect viewport_rect(768, 1038); |
83 OcclusionTracker tracker(viewport_rect); | 81 OcclusionTracker tracker(viewport_rect); |
84 | 82 |
85 CreateHost(); | 83 CreateHost(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_EQ(active_tree()->root_layer(), next.current_layer); | 204 EXPECT_EQ(active_tree()->root_layer(), next.current_layer); |
207 | 205 |
208 ++begin; | 206 ++begin; |
209 EXPECT_EQ(end, begin); | 207 EXPECT_EQ(end, begin); |
210 | 208 |
211 PrintResults(); | 209 PrintResults(); |
212 } | 210 } |
213 | 211 |
214 } // namespace | 212 } // namespace |
215 } // namespace cc | 213 } // namespace cc |
OLD | NEW |