Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: cc/trees/occlusion_tracker_perftest.cc

Issue 165413002: cc: Add an occlusion perf test with more than 1 opaque layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: perftest-morelayers: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/time/time.h" 7 #include "base/time/time.h"
8 #include "cc/layers/layer_iterator.h" 8 #include "cc/layers/layer_iterator.h"
9 #include "cc/layers/solid_color_layer_impl.h" 9 #include "cc/layers/solid_color_layer_impl.h"
10 #include "cc/test/fake_layer_tree_host_impl_client.h" 10 #include "cc/test/fake_layer_tree_host_impl_client.h"
11 #include "cc/test/fake_output_surface.h" 11 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/fake_proxy.h" 12 #include "cc/test/fake_proxy.h"
13 #include "cc/test/fake_rendering_stats_instrumentation.h" 13 #include "cc/test/fake_rendering_stats_instrumentation.h"
14 #include "cc/test/lap_timer.h" 14 #include "cc/test/lap_timer.h"
15 #include "cc/trees/layer_tree_host_impl.h" 15 #include "cc/trees/layer_tree_host_impl.h"
16 #include "cc/trees/layer_tree_impl.h" 16 #include "cc/trees/layer_tree_impl.h"
17 #include "cc/trees/single_thread_proxy.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/perf/perf_test.h" 19 #include "testing/perf/perf_test.h"
19 20
20 namespace cc { 21 namespace cc {
21 namespace { 22 namespace {
22 23
23 static const int kTimeLimitMillis = 2000; 24 static const int kTimeLimitMillis = 2000;
24 static const int kWarmupRuns = 5; 25 static const int kWarmupRuns = 5;
25 static const int kTimeCheckInterval = 10; 26 static const int kTimeCheckInterval = 10;
26 27
(...skipping 30 matching lines...) Expand all
57 58
58 protected: 59 protected:
59 LapTimer timer_; 60 LapTimer timer_;
60 std::string test_name_; 61 std::string test_name_;
61 FakeLayerTreeHostImplClient client_; 62 FakeLayerTreeHostImplClient client_;
62 FakeProxy proxy_; 63 FakeProxy proxy_;
63 FakeRenderingStatsInstrumentation stats_; 64 FakeRenderingStatsInstrumentation stats_;
64 scoped_ptr<LayerTreeHostImpl> host_impl_; 65 scoped_ptr<LayerTreeHostImpl> host_impl_;
65 }; 66 };
66 67
67 // Simulates a page with several large, transformed and animated layers.
68 TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { 68 TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
69 SetTestName("unoccluded_content_rect_fully_occluded"); 69 SetTestName("unoccluded_content_rect_fully_occluded");
70 70
71 gfx::Rect viewport_rect(768, 1038); 71 gfx::Rect viewport_rect(768, 1038);
72 OcclusionTrackerBase<LayerImpl, LayerImpl::RenderSurfaceType> tracker( 72 OcclusionTrackerBase<LayerImpl, LayerImpl::RenderSurfaceType> tracker(
73 viewport_rect, false); 73 viewport_rect, false);
74 74
75 DebugScopedSetImplThread impl(&proxy_);
enne (OOO) 2014/02/13 23:55:07 Should the occlusion tracker test do this?
danakj 2014/02/14 00:00:53 Sure, done.
76
75 CreateHost(); 77 CreateHost();
76 host_impl_->SetViewportSize(viewport_rect.size()); 78 host_impl_->SetViewportSize(viewport_rect.size());
77 79
78 scoped_ptr<SolidColorLayerImpl> opaque_layer = 80 scoped_ptr<SolidColorLayerImpl> opaque_layer =
79 SolidColorLayerImpl::Create(active_tree(), 2); 81 SolidColorLayerImpl::Create(active_tree(), 2);
80 opaque_layer->SetBackgroundColor(SK_ColorRED); 82 opaque_layer->SetBackgroundColor(SK_ColorRED);
81 opaque_layer->SetContentsOpaque(true); 83 opaque_layer->SetContentsOpaque(true);
82 opaque_layer->SetDrawsContent(true); 84 opaque_layer->SetDrawsContent(true);
83 opaque_layer->SetBounds(viewport_rect.size()); 85 opaque_layer->SetBounds(viewport_rect.size());
84 opaque_layer->SetContentBounds(viewport_rect.size()); 86 opaque_layer->SetContentBounds(viewport_rect.size());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ++begin; 132 ++begin;
131 LayerIteratorPosition<LayerImpl> next = begin; 133 LayerIteratorPosition<LayerImpl> next = begin;
132 EXPECT_EQ(active_tree()->root_layer(), next.current_layer); 134 EXPECT_EQ(active_tree()->root_layer(), next.current_layer);
133 135
134 ++begin; 136 ++begin;
135 EXPECT_EQ(end, begin); 137 EXPECT_EQ(end, begin);
136 138
137 PrintResults(); 139 PrintResults();
138 } 140 }
139 141
142 TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) {
143 static const int kNumOpaqueLayers = 10;
144 SetTestName("unoccluded_content_rect_10_opaque_layers");
145
146 gfx::Rect viewport_rect(768, 1038);
147 OcclusionTrackerBase<LayerImpl, LayerImpl::RenderSurfaceType> tracker(
148 viewport_rect, false);
149
150 DebugScopedSetImplThread impl(&proxy_);
151
152 CreateHost();
153 host_impl_->SetViewportSize(viewport_rect.size());
154
155 for (int i = 0; i < kNumOpaqueLayers; ++i) {
156 scoped_ptr<SolidColorLayerImpl> opaque_layer =
157 SolidColorLayerImpl::Create(active_tree(), 2 + i);
158 opaque_layer->SetBackgroundColor(SK_ColorRED);
159 opaque_layer->SetContentsOpaque(true);
160 opaque_layer->SetDrawsContent(true);
161 opaque_layer->SetBounds(
162 gfx::Size(viewport_rect.width() / 2, viewport_rect.height() / 2));
163 opaque_layer->SetContentBounds(
164 gfx::Size(viewport_rect.width() / 2, viewport_rect.height() / 2));
165 opaque_layer->SetPosition(gfx::Point(i, i));
166 active_tree()->root_layer()->AddChild(opaque_layer.PassAs<LayerImpl>());
167 }
168
169 active_tree()->UpdateDrawProperties();
170 const LayerImplList& rsll = active_tree()->RenderSurfaceLayerList();
171 ASSERT_EQ(1u, rsll.size());
172 EXPECT_EQ(static_cast<size_t>(kNumOpaqueLayers),
173 rsll[0]->render_surface()->layer_list().size());
174
175 typedef LayerIterator<LayerImpl,
enne (OOO) 2014/02/13 23:55:07 This seems like baking in logic from the occlusion
danakj 2014/02/14 00:00:53 This is the tree walk in LayerTreeHostImpl. Then I
enne (OOO) 2014/02/14 00:03:38 Hrm, ok. Do you think it'd be worth leaving a com
danakj 2014/02/14 00:05:29 Not really, because this is just how we walk a lay
enne (OOO) 2014/02/14 00:07:18 Ok ok.
176 LayerImpl::LayerListType,
177 LayerImpl::RenderSurfaceType,
178 LayerIteratorActions::FrontToBack> IteratorType;
179 IteratorType begin = IteratorType::Begin(&rsll);
180 IteratorType end = IteratorType::End(&rsll);
181
182 // The opaque_layers add occlusion.
183 for (int i = 0; i < kNumOpaqueLayers - 1; ++i) {
184 LayerIteratorPosition<LayerImpl> pos = begin;
185 tracker.EnterLayer(pos);
186 tracker.LeaveLayer(pos);
187 ++begin;
188 }
189 LayerIteratorPosition<LayerImpl> pos = begin;
190 tracker.EnterLayer(pos);
191 tracker.LeaveLayer(pos);
192
193 gfx::Transform transform_to_target;
194 transform_to_target.Translate(0, 96);
195 bool impl_draw_transform_is_unknown = false;
196
197 do {
198 for (int x = 0; x < viewport_rect.width(); x += 256) {
199 for (int y = 0; y < viewport_rect.height(); y += 256) {
200 gfx::Rect query_content_rect(x, y, 256, 256);
201 gfx::Rect unoccluded =
202 tracker.UnoccludedContentRect(pos.target_render_surface_layer,
203 query_content_rect,
204 transform_to_target,
205 impl_draw_transform_is_unknown);
206 }
207 }
208
209 timer_.NextLap();
210 } while (!timer_.HasTimeLimitExpired());
211
212 ++begin;
213 LayerIteratorPosition<LayerImpl> next = begin;
214 EXPECT_EQ(active_tree()->root_layer(), next.current_layer);
215
216 ++begin;
217 EXPECT_EQ(end, begin);
218
219 PrintResults();
220 }
221
140 } // namespace 222 } // namespace
141 } // namespace cc 223 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698