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

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

Issue 628443002: replace OVERRIDE and FINAL with override and final in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 namespace { 68 namespace {
69 69
70 class LayerTreeHostTest : public LayerTreeTest {}; 70 class LayerTreeHostTest : public LayerTreeTest {};
71 71
72 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 72 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1
73 // draw with frame 0. 73 // draw with frame 0.
74 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { 74 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
75 public: 75 public:
76 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {} 76 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {}
77 77
78 virtual void BeginTest() OVERRIDE { 78 virtual void BeginTest() override {
79 PostSetNeedsCommitToMainThread(); 79 PostSetNeedsCommitToMainThread();
80 PostSetNeedsCommitToMainThread(); 80 PostSetNeedsCommitToMainThread();
81 } 81 }
82 82
83 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 83 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
84 num_draws_++; 84 num_draws_++;
85 if (!impl->active_tree()->source_frame_number()) 85 if (!impl->active_tree()->source_frame_number())
86 EndTest(); 86 EndTest();
87 } 87 }
88 88
89 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 89 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
90 num_commits_++; 90 num_commits_++;
91 } 91 }
92 92
93 virtual void AfterTest() OVERRIDE { 93 virtual void AfterTest() override {
94 EXPECT_LE(1, num_commits_); 94 EXPECT_LE(1, num_commits_);
95 EXPECT_LE(1, num_draws_); 95 EXPECT_LE(1, num_draws_);
96 } 96 }
97 97
98 private: 98 private:
99 int num_commits_; 99 int num_commits_;
100 int num_draws_; 100 int num_draws_;
101 }; 101 };
102 102
103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); 103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1);
104 104
105 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that 105 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that
106 // first committed frame draws should lead to another commit. 106 // first committed frame draws should lead to another commit.
107 class LayerTreeHostTestSetNeedsCommit2 : public LayerTreeHostTest { 107 class LayerTreeHostTestSetNeedsCommit2 : public LayerTreeHostTest {
108 public: 108 public:
109 LayerTreeHostTestSetNeedsCommit2() : num_commits_(0), num_draws_(0) {} 109 LayerTreeHostTestSetNeedsCommit2() : num_commits_(0), num_draws_(0) {}
110 110
111 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 111 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
112 112
113 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 113 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
114 ++num_draws_; 114 ++num_draws_;
115 } 115 }
116 116
117 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 117 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
118 ++num_commits_; 118 ++num_commits_;
119 switch (num_commits_) { 119 switch (num_commits_) {
120 case 1: 120 case 1:
121 PostSetNeedsCommitToMainThread(); 121 PostSetNeedsCommitToMainThread();
122 break; 122 break;
123 case 2: 123 case 2:
124 EndTest(); 124 EndTest();
125 break; 125 break;
126 default: 126 default:
127 NOTREACHED(); 127 NOTREACHED();
128 } 128 }
129 } 129 }
130 130
131 virtual void AfterTest() OVERRIDE { 131 virtual void AfterTest() override {
132 EXPECT_EQ(2, num_commits_); 132 EXPECT_EQ(2, num_commits_);
133 EXPECT_LE(1, num_draws_); 133 EXPECT_LE(1, num_draws_);
134 } 134 }
135 135
136 private: 136 private:
137 int num_commits_; 137 int num_commits_;
138 int num_draws_; 138 int num_draws_;
139 }; 139 };
140 140
141 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2); 141 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2);
142 142
143 // Verify that we pass property values in PushPropertiesTo. 143 // Verify that we pass property values in PushPropertiesTo.
144 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest { 144 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
145 protected: 145 protected:
146 virtual void SetupTree() OVERRIDE { 146 virtual void SetupTree() override {
147 scoped_refptr<Layer> root = Layer::Create(); 147 scoped_refptr<Layer> root = Layer::Create();
148 root->SetBounds(gfx::Size(10, 10)); 148 root->SetBounds(gfx::Size(10, 10));
149 layer_tree_host()->SetRootLayer(root); 149 layer_tree_host()->SetRootLayer(root);
150 LayerTreeHostTest::SetupTree(); 150 LayerTreeHostTest::SetupTree();
151 } 151 }
152 152
153 enum Properties { 153 enum Properties {
154 STARTUP, 154 STARTUP,
155 BOUNDS, 155 BOUNDS,
156 HIDE_LAYER_AND_SUBTREE, 156 HIDE_LAYER_AND_SUBTREE,
157 DRAWS_CONTENT, 157 DRAWS_CONTENT,
158 DONE, 158 DONE,
159 }; 159 };
160 160
161 virtual void BeginTest() OVERRIDE { 161 virtual void BeginTest() override {
162 index_ = STARTUP; 162 index_ = STARTUP;
163 PostSetNeedsCommitToMainThread(); 163 PostSetNeedsCommitToMainThread();
164 } 164 }
165 165
166 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 166 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
167 VerifyAfterValues(impl->active_tree()->root_layer()); 167 VerifyAfterValues(impl->active_tree()->root_layer());
168 } 168 }
169 169
170 virtual void DidCommitAndDrawFrame() OVERRIDE { 170 virtual void DidCommitAndDrawFrame() override {
171 SetBeforeValues(layer_tree_host()->root_layer()); 171 SetBeforeValues(layer_tree_host()->root_layer());
172 VerifyBeforeValues(layer_tree_host()->root_layer()); 172 VerifyBeforeValues(layer_tree_host()->root_layer());
173 173
174 ++index_; 174 ++index_;
175 if (index_ == DONE) { 175 if (index_ == DONE) {
176 EndTest(); 176 EndTest();
177 return; 177 return;
178 } 178 }
179 179
180 SetAfterValues(layer_tree_host()->root_layer()); 180 SetAfterValues(layer_tree_host()->root_layer());
181 } 181 }
182 182
183 virtual void AfterTest() OVERRIDE {} 183 virtual void AfterTest() override {}
184 184
185 void VerifyBeforeValues(Layer* layer) { 185 void VerifyBeforeValues(Layer* layer) {
186 EXPECT_EQ(gfx::Size(10, 10).ToString(), layer->bounds().ToString()); 186 EXPECT_EQ(gfx::Size(10, 10).ToString(), layer->bounds().ToString());
187 EXPECT_FALSE(layer->hide_layer_and_subtree()); 187 EXPECT_FALSE(layer->hide_layer_and_subtree());
188 EXPECT_FALSE(layer->DrawsContent()); 188 EXPECT_FALSE(layer->DrawsContent());
189 } 189 }
190 190
191 void SetBeforeValues(Layer* layer) { 191 void SetBeforeValues(Layer* layer) {
192 layer->SetBounds(gfx::Size(10, 10)); 192 layer->SetBounds(gfx::Size(10, 10));
193 layer->SetHideLayerAndSubtree(false); 193 layer->SetHideLayerAndSubtree(false);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 }; 232 };
233 233
234 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo); 234 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo);
235 235
236 // 1 setNeedsRedraw after the first commit has completed should lead to 1 236 // 1 setNeedsRedraw after the first commit has completed should lead to 1
237 // additional draw. 237 // additional draw.
238 class LayerTreeHostTestSetNeedsRedraw : public LayerTreeHostTest { 238 class LayerTreeHostTestSetNeedsRedraw : public LayerTreeHostTest {
239 public: 239 public:
240 LayerTreeHostTestSetNeedsRedraw() : num_commits_(0), num_draws_(0) {} 240 LayerTreeHostTestSetNeedsRedraw() : num_commits_(0), num_draws_(0) {}
241 241
242 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 242 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
243 243
244 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 244 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
245 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); 245 EXPECT_EQ(0, impl->active_tree()->source_frame_number());
246 if (!num_draws_) { 246 if (!num_draws_) {
247 // Redraw again to verify that the second redraw doesn't commit. 247 // Redraw again to verify that the second redraw doesn't commit.
248 PostSetNeedsRedrawToMainThread(); 248 PostSetNeedsRedrawToMainThread();
249 } else { 249 } else {
250 EndTest(); 250 EndTest();
251 } 251 }
252 num_draws_++; 252 num_draws_++;
253 } 253 }
254 254
255 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 255 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
256 EXPECT_EQ(0, num_draws_); 256 EXPECT_EQ(0, num_draws_);
257 num_commits_++; 257 num_commits_++;
258 } 258 }
259 259
260 virtual void AfterTest() OVERRIDE { 260 virtual void AfterTest() override {
261 EXPECT_GE(2, num_draws_); 261 EXPECT_GE(2, num_draws_);
262 EXPECT_EQ(1, num_commits_); 262 EXPECT_EQ(1, num_commits_);
263 } 263 }
264 264
265 private: 265 private:
266 int num_commits_; 266 int num_commits_;
267 int num_draws_; 267 int num_draws_;
268 }; 268 };
269 269
270 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw); 270 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw);
271 271
272 // After setNeedsRedrawRect(invalid_rect) the final damage_rect 272 // After setNeedsRedrawRect(invalid_rect) the final damage_rect
273 // must contain invalid_rect. 273 // must contain invalid_rect.
274 class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { 274 class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest {
275 public: 275 public:
276 LayerTreeHostTestSetNeedsRedrawRect() 276 LayerTreeHostTestSetNeedsRedrawRect()
277 : num_draws_(0), 277 : num_draws_(0),
278 bounds_(50, 50), 278 bounds_(50, 50),
279 invalid_rect_(10, 10, 20, 20), 279 invalid_rect_(10, 10, 20, 20),
280 root_layer_(ContentLayer::Create(&client_)) {} 280 root_layer_(ContentLayer::Create(&client_)) {}
281 281
282 virtual void BeginTest() OVERRIDE { 282 virtual void BeginTest() override {
283 root_layer_->SetIsDrawable(true); 283 root_layer_->SetIsDrawable(true);
284 root_layer_->SetBounds(bounds_); 284 root_layer_->SetBounds(bounds_);
285 layer_tree_host()->SetRootLayer(root_layer_); 285 layer_tree_host()->SetRootLayer(root_layer_);
286 layer_tree_host()->SetViewportSize(bounds_); 286 layer_tree_host()->SetViewportSize(bounds_);
287 PostSetNeedsCommitToMainThread(); 287 PostSetNeedsCommitToMainThread();
288 } 288 }
289 289
290 virtual DrawResult PrepareToDrawOnThread( 290 virtual DrawResult PrepareToDrawOnThread(
291 LayerTreeHostImpl* host_impl, 291 LayerTreeHostImpl* host_impl,
292 LayerTreeHostImpl::FrameData* frame_data, 292 LayerTreeHostImpl::FrameData* frame_data,
293 DrawResult draw_result) OVERRIDE { 293 DrawResult draw_result) override {
294 EXPECT_EQ(DRAW_SUCCESS, draw_result); 294 EXPECT_EQ(DRAW_SUCCESS, draw_result);
295 295
296 gfx::RectF root_damage_rect; 296 gfx::RectF root_damage_rect;
297 if (!frame_data->render_passes.empty()) 297 if (!frame_data->render_passes.empty())
298 root_damage_rect = frame_data->render_passes.back()->damage_rect; 298 root_damage_rect = frame_data->render_passes.back()->damage_rect;
299 299
300 if (!num_draws_) { 300 if (!num_draws_) {
301 // If this is the first frame, expect full frame damage. 301 // If this is the first frame, expect full frame damage.
302 EXPECT_RECT_EQ(root_damage_rect, gfx::Rect(bounds_)); 302 EXPECT_RECT_EQ(root_damage_rect, gfx::Rect(bounds_));
303 } else { 303 } else {
304 // Check that invalid_rect_ is indeed repainted. 304 // Check that invalid_rect_ is indeed repainted.
305 EXPECT_TRUE(root_damage_rect.Contains(invalid_rect_)); 305 EXPECT_TRUE(root_damage_rect.Contains(invalid_rect_));
306 } 306 }
307 307
308 return draw_result; 308 return draw_result;
309 } 309 }
310 310
311 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 311 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
312 if (!num_draws_) { 312 if (!num_draws_) {
313 PostSetNeedsRedrawRectToMainThread(invalid_rect_); 313 PostSetNeedsRedrawRectToMainThread(invalid_rect_);
314 } else { 314 } else {
315 EndTest(); 315 EndTest();
316 } 316 }
317 num_draws_++; 317 num_draws_++;
318 } 318 }
319 319
320 virtual void AfterTest() OVERRIDE { EXPECT_EQ(2, num_draws_); } 320 virtual void AfterTest() override { EXPECT_EQ(2, num_draws_); }
321 321
322 private: 322 private:
323 int num_draws_; 323 int num_draws_;
324 const gfx::Size bounds_; 324 const gfx::Size bounds_;
325 const gfx::Rect invalid_rect_; 325 const gfx::Rect invalid_rect_;
326 FakeContentLayerClient client_; 326 FakeContentLayerClient client_;
327 scoped_refptr<ContentLayer> root_layer_; 327 scoped_refptr<ContentLayer> root_layer_;
328 }; 328 };
329 329
330 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); 330 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect);
331 331
332 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { 332 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
333 public: 333 public:
334 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 334 virtual void InitializeSettings(LayerTreeSettings* settings) override {
335 settings->layer_transforms_should_scale_layer_contents = true; 335 settings->layer_transforms_should_scale_layer_contents = true;
336 } 336 }
337 337
338 virtual void SetupTree() OVERRIDE { 338 virtual void SetupTree() override {
339 root_layer_ = Layer::Create(); 339 root_layer_ = Layer::Create();
340 root_layer_->SetBounds(gfx::Size(10, 20)); 340 root_layer_->SetBounds(gfx::Size(10, 20));
341 341
342 scaled_layer_ = FakeContentLayer::Create(&client_); 342 scaled_layer_ = FakeContentLayer::Create(&client_);
343 scaled_layer_->SetBounds(gfx::Size(1, 1)); 343 scaled_layer_->SetBounds(gfx::Size(1, 1));
344 root_layer_->AddChild(scaled_layer_); 344 root_layer_->AddChild(scaled_layer_);
345 345
346 layer_tree_host()->SetRootLayer(root_layer_); 346 layer_tree_host()->SetRootLayer(root_layer_);
347 LayerTreeHostTest::SetupTree(); 347 LayerTreeHostTest::SetupTree();
348 } 348 }
349 349
350 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 350 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
351 351
352 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 352 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
353 if (host_impl->active_tree()->source_frame_number() == 1) 353 if (host_impl->active_tree()->source_frame_number() == 1)
354 EndTest(); 354 EndTest();
355 } 355 }
356 356
357 virtual void DidCommit() OVERRIDE { 357 virtual void DidCommit() override {
358 switch (layer_tree_host()->source_frame_number()) { 358 switch (layer_tree_host()->source_frame_number()) {
359 case 1: 359 case 1:
360 // Changing the device scale factor causes a commit. It also changes 360 // Changing the device scale factor causes a commit. It also changes
361 // the content bounds of |scaled_layer_|, which should not generate 361 // the content bounds of |scaled_layer_|, which should not generate
362 // a second commit as a result. 362 // a second commit as a result.
363 layer_tree_host()->SetDeviceScaleFactor(4.f); 363 layer_tree_host()->SetDeviceScaleFactor(4.f);
364 break; 364 break;
365 default: 365 default:
366 // No extra commits. 366 // No extra commits.
367 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); 367 EXPECT_EQ(2, layer_tree_host()->source_frame_number());
368 } 368 }
369 } 369 }
370 370
371 virtual void AfterTest() OVERRIDE { 371 virtual void AfterTest() override {
372 EXPECT_EQ(gfx::Size(4, 4).ToString(), 372 EXPECT_EQ(gfx::Size(4, 4).ToString(),
373 scaled_layer_->content_bounds().ToString()); 373 scaled_layer_->content_bounds().ToString());
374 } 374 }
375 375
376 private: 376 private:
377 FakeContentLayerClient client_; 377 FakeContentLayerClient client_;
378 scoped_refptr<Layer> root_layer_; 378 scoped_refptr<Layer> root_layer_;
379 scoped_refptr<FakeContentLayer> scaled_layer_; 379 scoped_refptr<FakeContentLayer> scaled_layer_;
380 }; 380 };
381 381
382 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); 382 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate);
383 383
384 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate 384 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate
385 : public LayerTreeHostTest { 385 : public LayerTreeHostTest {
386 public: 386 public:
387 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 387 virtual void InitializeSettings(LayerTreeSettings* settings) override {
388 settings->layer_transforms_should_scale_layer_contents = true; 388 settings->layer_transforms_should_scale_layer_contents = true;
389 } 389 }
390 390
391 virtual void SetupTree() OVERRIDE { 391 virtual void SetupTree() override {
392 root_layer_ = Layer::Create(); 392 root_layer_ = Layer::Create();
393 root_layer_->SetBounds(gfx::Size(10, 20)); 393 root_layer_->SetBounds(gfx::Size(10, 20));
394 394
395 bool paint_scrollbar = true; 395 bool paint_scrollbar = true;
396 bool has_thumb = false; 396 bool has_thumb = false;
397 scrollbar_ = FakePaintedScrollbarLayer::Create( 397 scrollbar_ = FakePaintedScrollbarLayer::Create(
398 paint_scrollbar, has_thumb, root_layer_->id()); 398 paint_scrollbar, has_thumb, root_layer_->id());
399 scrollbar_->SetPosition(gfx::Point(0, 10)); 399 scrollbar_->SetPosition(gfx::Point(0, 10));
400 scrollbar_->SetBounds(gfx::Size(10, 10)); 400 scrollbar_->SetBounds(gfx::Size(10, 10));
401 401
402 root_layer_->AddChild(scrollbar_); 402 root_layer_->AddChild(scrollbar_);
403 403
404 layer_tree_host()->SetRootLayer(root_layer_); 404 layer_tree_host()->SetRootLayer(root_layer_);
405 LayerTreeHostTest::SetupTree(); 405 LayerTreeHostTest::SetupTree();
406 } 406 }
407 407
408 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 408 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
409 409
410 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 410 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
411 if (host_impl->active_tree()->source_frame_number() == 1) 411 if (host_impl->active_tree()->source_frame_number() == 1)
412 EndTest(); 412 EndTest();
413 } 413 }
414 414
415 virtual void DidCommit() OVERRIDE { 415 virtual void DidCommit() override {
416 switch (layer_tree_host()->source_frame_number()) { 416 switch (layer_tree_host()->source_frame_number()) {
417 case 1: 417 case 1:
418 // Changing the device scale factor causes a commit. It also changes 418 // Changing the device scale factor causes a commit. It also changes
419 // the content bounds of |scrollbar_|, which should not generate 419 // the content bounds of |scrollbar_|, which should not generate
420 // a second commit as a result. 420 // a second commit as a result.
421 layer_tree_host()->SetDeviceScaleFactor(4.f); 421 layer_tree_host()->SetDeviceScaleFactor(4.f);
422 break; 422 break;
423 default: 423 default:
424 // No extra commits. 424 // No extra commits.
425 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); 425 EXPECT_EQ(2, layer_tree_host()->source_frame_number());
426 } 426 }
427 } 427 }
428 428
429 virtual void AfterTest() OVERRIDE { 429 virtual void AfterTest() override {
430 EXPECT_EQ(gfx::Size(40, 40).ToString(), 430 EXPECT_EQ(gfx::Size(40, 40).ToString(),
431 scrollbar_->content_bounds().ToString()); 431 scrollbar_->content_bounds().ToString());
432 } 432 }
433 433
434 private: 434 private:
435 FakeContentLayerClient client_; 435 FakeContentLayerClient client_;
436 scoped_refptr<Layer> root_layer_; 436 scoped_refptr<Layer> root_layer_;
437 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; 437 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_;
438 }; 438 };
439 439
440 SINGLE_AND_MULTI_THREAD_TEST_F( 440 SINGLE_AND_MULTI_THREAD_TEST_F(
441 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); 441 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate);
442 442
443 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { 443 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
444 public: 444 public:
445 LayerTreeHostTestSetNextCommitForcesRedraw() 445 LayerTreeHostTestSetNextCommitForcesRedraw()
446 : num_draws_(0), 446 : num_draws_(0),
447 bounds_(50, 50), 447 bounds_(50, 50),
448 invalid_rect_(10, 10, 20, 20), 448 invalid_rect_(10, 10, 20, 20),
449 root_layer_(ContentLayer::Create(&client_)) {} 449 root_layer_(ContentLayer::Create(&client_)) {}
450 450
451 virtual void BeginTest() OVERRIDE { 451 virtual void BeginTest() override {
452 root_layer_->SetIsDrawable(true); 452 root_layer_->SetIsDrawable(true);
453 root_layer_->SetBounds(bounds_); 453 root_layer_->SetBounds(bounds_);
454 layer_tree_host()->SetRootLayer(root_layer_); 454 layer_tree_host()->SetRootLayer(root_layer_);
455 layer_tree_host()->SetViewportSize(bounds_); 455 layer_tree_host()->SetViewportSize(bounds_);
456 PostSetNeedsCommitToMainThread(); 456 PostSetNeedsCommitToMainThread();
457 } 457 }
458 458
459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
460 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) 460 if (num_draws_ == 3 && host_impl->settings().impl_side_painting)
461 host_impl->SetNeedsRedrawRect(invalid_rect_); 461 host_impl->SetNeedsRedrawRect(invalid_rect_);
462 } 462 }
463 463
464 virtual DrawResult PrepareToDrawOnThread( 464 virtual DrawResult PrepareToDrawOnThread(
465 LayerTreeHostImpl* host_impl, 465 LayerTreeHostImpl* host_impl,
466 LayerTreeHostImpl::FrameData* frame_data, 466 LayerTreeHostImpl::FrameData* frame_data,
467 DrawResult draw_result) OVERRIDE { 467 DrawResult draw_result) override {
468 EXPECT_EQ(DRAW_SUCCESS, draw_result); 468 EXPECT_EQ(DRAW_SUCCESS, draw_result);
469 469
470 gfx::RectF root_damage_rect; 470 gfx::RectF root_damage_rect;
471 if (!frame_data->render_passes.empty()) 471 if (!frame_data->render_passes.empty())
472 root_damage_rect = frame_data->render_passes.back()->damage_rect; 472 root_damage_rect = frame_data->render_passes.back()->damage_rect;
473 473
474 switch (num_draws_) { 474 switch (num_draws_) {
475 case 0: 475 case 0:
476 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); 476 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect);
477 break; 477 break;
478 case 1: 478 case 1:
479 case 2: 479 case 2:
480 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect); 480 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect);
481 break; 481 break;
482 case 3: 482 case 3:
483 EXPECT_RECT_EQ(invalid_rect_, root_damage_rect); 483 EXPECT_RECT_EQ(invalid_rect_, root_damage_rect);
484 break; 484 break;
485 case 4: 485 case 4:
486 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); 486 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect);
487 break; 487 break;
488 default: 488 default:
489 NOTREACHED(); 489 NOTREACHED();
490 } 490 }
491 491
492 return draw_result; 492 return draw_result;
493 } 493 }
494 494
495 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 495 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
496 switch (num_draws_) { 496 switch (num_draws_) {
497 case 0: 497 case 0:
498 case 1: 498 case 1:
499 // Cycle through a couple of empty commits to ensure we're observing the 499 // Cycle through a couple of empty commits to ensure we're observing the
500 // right behavior 500 // right behavior
501 PostSetNeedsCommitToMainThread(); 501 PostSetNeedsCommitToMainThread();
502 break; 502 break;
503 case 2: 503 case 2:
504 // Should force full frame damage on the next commit 504 // Should force full frame damage on the next commit
505 PostSetNextCommitForcesRedrawToMainThread(); 505 PostSetNextCommitForcesRedrawToMainThread();
506 PostSetNeedsCommitToMainThread(); 506 PostSetNeedsCommitToMainThread();
507 if (host_impl->settings().impl_side_painting) 507 if (host_impl->settings().impl_side_painting)
508 host_impl->BlockNotifyReadyToActivateForTesting(true); 508 host_impl->BlockNotifyReadyToActivateForTesting(true);
509 else 509 else
510 num_draws_++; 510 num_draws_++;
511 break; 511 break;
512 case 3: 512 case 3:
513 host_impl->BlockNotifyReadyToActivateForTesting(false); 513 host_impl->BlockNotifyReadyToActivateForTesting(false);
514 break; 514 break;
515 default: 515 default:
516 EndTest(); 516 EndTest();
517 break; 517 break;
518 } 518 }
519 num_draws_++; 519 num_draws_++;
520 } 520 }
521 521
522 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } 522 virtual void AfterTest() override { EXPECT_EQ(5, num_draws_); }
523 523
524 private: 524 private:
525 int num_draws_; 525 int num_draws_;
526 const gfx::Size bounds_; 526 const gfx::Size bounds_;
527 const gfx::Rect invalid_rect_; 527 const gfx::Rect invalid_rect_;
528 FakeContentLayerClient client_; 528 FakeContentLayerClient client_;
529 scoped_refptr<ContentLayer> root_layer_; 529 scoped_refptr<ContentLayer> root_layer_;
530 }; 530 };
531 531
532 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); 532 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw);
533 533
534 // Tests that if a layer is not drawn because of some reason in the parent then 534 // Tests that if a layer is not drawn because of some reason in the parent then
535 // its damage is preserved until the next time it is drawn. 535 // its damage is preserved until the next time it is drawn.
536 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { 536 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
537 public: 537 public:
538 LayerTreeHostTestUndrawnLayersDamageLater() 538 LayerTreeHostTestUndrawnLayersDamageLater()
539 : root_layer_(ContentLayer::Create(&client_)) {} 539 : root_layer_(ContentLayer::Create(&client_)) {}
540 540
541 virtual void SetupTree() OVERRIDE { 541 virtual void SetupTree() override {
542 root_layer_->SetIsDrawable(true); 542 root_layer_->SetIsDrawable(true);
543 root_layer_->SetBounds(gfx::Size(50, 50)); 543 root_layer_->SetBounds(gfx::Size(50, 50));
544 layer_tree_host()->SetRootLayer(root_layer_); 544 layer_tree_host()->SetRootLayer(root_layer_);
545 545
546 // The initially transparent layer has a larger child layer, which is 546 // The initially transparent layer has a larger child layer, which is
547 // not initially drawn because of the this (parent) layer. 547 // not initially drawn because of the this (parent) layer.
548 parent_layer_ = FakeContentLayer::Create(&client_); 548 parent_layer_ = FakeContentLayer::Create(&client_);
549 parent_layer_->SetBounds(gfx::Size(15, 15)); 549 parent_layer_->SetBounds(gfx::Size(15, 15));
550 parent_layer_->SetOpacity(0.0f); 550 parent_layer_->SetOpacity(0.0f);
551 root_layer_->AddChild(parent_layer_); 551 root_layer_->AddChild(parent_layer_);
552 552
553 child_layer_ = FakeContentLayer::Create(&client_); 553 child_layer_ = FakeContentLayer::Create(&client_);
554 child_layer_->SetBounds(gfx::Size(25, 25)); 554 child_layer_->SetBounds(gfx::Size(25, 25));
555 parent_layer_->AddChild(child_layer_); 555 parent_layer_->AddChild(child_layer_);
556 556
557 LayerTreeHostTest::SetupTree(); 557 LayerTreeHostTest::SetupTree();
558 } 558 }
559 559
560 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 560 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
561 561
562 virtual DrawResult PrepareToDrawOnThread( 562 virtual DrawResult PrepareToDrawOnThread(
563 LayerTreeHostImpl* host_impl, 563 LayerTreeHostImpl* host_impl,
564 LayerTreeHostImpl::FrameData* frame_data, 564 LayerTreeHostImpl::FrameData* frame_data,
565 DrawResult draw_result) OVERRIDE { 565 DrawResult draw_result) override {
566 EXPECT_EQ(DRAW_SUCCESS, draw_result); 566 EXPECT_EQ(DRAW_SUCCESS, draw_result);
567 567
568 gfx::RectF root_damage_rect; 568 gfx::RectF root_damage_rect;
569 if (!frame_data->render_passes.empty()) 569 if (!frame_data->render_passes.empty())
570 root_damage_rect = frame_data->render_passes.back()->damage_rect; 570 root_damage_rect = frame_data->render_passes.back()->damage_rect;
571 571
572 // The first time, the whole view needs be drawn. 572 // The first time, the whole view needs be drawn.
573 // Afterwards, just the opacity of surface_layer1 is changed a few times, 573 // Afterwards, just the opacity of surface_layer1 is changed a few times,
574 // and each damage should be the bounding box of it and its child. If this 574 // and each damage should be the bounding box of it and its child. If this
575 // was working improperly, the damage might not include its childs bounding 575 // was working improperly, the damage might not include its childs bounding
576 // box. 576 // box.
577 switch (host_impl->active_tree()->source_frame_number()) { 577 switch (host_impl->active_tree()->source_frame_number()) {
578 case 0: 578 case 0:
579 EXPECT_RECT_EQ(gfx::Rect(root_layer_->bounds()), root_damage_rect); 579 EXPECT_RECT_EQ(gfx::Rect(root_layer_->bounds()), root_damage_rect);
580 break; 580 break;
581 case 1: 581 case 1:
582 case 2: 582 case 2:
583 case 3: 583 case 3:
584 EXPECT_RECT_EQ(gfx::Rect(child_layer_->bounds()), root_damage_rect); 584 EXPECT_RECT_EQ(gfx::Rect(child_layer_->bounds()), root_damage_rect);
585 break; 585 break;
586 default: 586 default:
587 NOTREACHED(); 587 NOTREACHED();
588 } 588 }
589 589
590 return draw_result; 590 return draw_result;
591 } 591 }
592 592
593 virtual void DidCommitAndDrawFrame() OVERRIDE { 593 virtual void DidCommitAndDrawFrame() override {
594 switch (layer_tree_host()->source_frame_number()) { 594 switch (layer_tree_host()->source_frame_number()) {
595 case 1: 595 case 1:
596 // Test not owning the surface. 596 // Test not owning the surface.
597 parent_layer_->SetOpacity(1.0f); 597 parent_layer_->SetOpacity(1.0f);
598 break; 598 break;
599 case 2: 599 case 2:
600 parent_layer_->SetOpacity(0.0f); 600 parent_layer_->SetOpacity(0.0f);
601 break; 601 break;
602 case 3: 602 case 3:
603 // Test owning the surface. 603 // Test owning the surface.
604 parent_layer_->SetOpacity(0.5f); 604 parent_layer_->SetOpacity(0.5f);
605 parent_layer_->SetForceRenderSurface(true); 605 parent_layer_->SetForceRenderSurface(true);
606 break; 606 break;
607 case 4: 607 case 4:
608 EndTest(); 608 EndTest();
609 break; 609 break;
610 default: 610 default:
611 NOTREACHED(); 611 NOTREACHED();
612 } 612 }
613 } 613 }
614 614
615 virtual void AfterTest() OVERRIDE {} 615 virtual void AfterTest() override {}
616 616
617 private: 617 private:
618 FakeContentLayerClient client_; 618 FakeContentLayerClient client_;
619 scoped_refptr<ContentLayer> root_layer_; 619 scoped_refptr<ContentLayer> root_layer_;
620 scoped_refptr<FakeContentLayer> parent_layer_; 620 scoped_refptr<FakeContentLayer> parent_layer_;
621 scoped_refptr<FakeContentLayer> child_layer_; 621 scoped_refptr<FakeContentLayer> child_layer_;
622 }; 622 };
623 623
624 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); 624 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater);
625 625
626 // Tests that if a layer is not drawn because of some reason in the parent, 626 // Tests that if a layer is not drawn because of some reason in the parent,
627 // causing its content bounds to not be computed, then when it is later drawn, 627 // causing its content bounds to not be computed, then when it is later drawn,
628 // its content bounds get pushed. 628 // its content bounds get pushed.
629 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater 629 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater
630 : public LayerTreeHostTest { 630 : public LayerTreeHostTest {
631 public: 631 public:
632 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() 632 LayerTreeHostTestUndrawnLayersPushContentBoundsLater()
633 : root_layer_(Layer::Create()) {} 633 : root_layer_(Layer::Create()) {}
634 634
635 virtual void SetupTree() OVERRIDE { 635 virtual void SetupTree() override {
636 root_layer_->SetIsDrawable(true); 636 root_layer_->SetIsDrawable(true);
637 root_layer_->SetBounds(gfx::Size(20, 20)); 637 root_layer_->SetBounds(gfx::Size(20, 20));
638 layer_tree_host()->SetRootLayer(root_layer_); 638 layer_tree_host()->SetRootLayer(root_layer_);
639 639
640 parent_layer_ = Layer::Create(); 640 parent_layer_ = Layer::Create();
641 parent_layer_->SetBounds(gfx::Size(20, 20)); 641 parent_layer_->SetBounds(gfx::Size(20, 20));
642 parent_layer_->SetOpacity(0.0f); 642 parent_layer_->SetOpacity(0.0f);
643 root_layer_->AddChild(parent_layer_); 643 root_layer_->AddChild(parent_layer_);
644 644
645 child_layer_ = Layer::Create(); 645 child_layer_ = Layer::Create();
646 child_layer_->SetBounds(gfx::Size(15, 15)); 646 child_layer_->SetBounds(gfx::Size(15, 15));
647 parent_layer_->AddChild(child_layer_); 647 parent_layer_->AddChild(child_layer_);
648 648
649 LayerTreeHostTest::SetupTree(); 649 LayerTreeHostTest::SetupTree();
650 } 650 }
651 651
652 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 652 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
653 653
654 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 654 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
655 LayerImpl* root = host_impl->active_tree()->root_layer(); 655 LayerImpl* root = host_impl->active_tree()->root_layer();
656 LayerImpl* parent = root->children()[0]; 656 LayerImpl* parent = root->children()[0];
657 LayerImpl* child = parent->children()[0]; 657 LayerImpl* child = parent->children()[0];
658 658
659 switch (host_impl->active_tree()->source_frame_number()) { 659 switch (host_impl->active_tree()->source_frame_number()) {
660 case 0: 660 case 0:
661 EXPECT_EQ(0.f, parent->opacity()); 661 EXPECT_EQ(0.f, parent->opacity());
662 EXPECT_EQ(gfx::SizeF(), child->content_bounds()); 662 EXPECT_EQ(gfx::SizeF(), child->content_bounds());
663 break; 663 break;
664 case 1: 664 case 1:
665 EXPECT_EQ(1.f, parent->opacity()); 665 EXPECT_EQ(1.f, parent->opacity());
666 EXPECT_EQ(gfx::SizeF(15.f, 15.f), child->content_bounds()); 666 EXPECT_EQ(gfx::SizeF(15.f, 15.f), child->content_bounds());
667 EndTest(); 667 EndTest();
668 break; 668 break;
669 default: 669 default:
670 NOTREACHED(); 670 NOTREACHED();
671 } 671 }
672 } 672 }
673 673
674 virtual void DidCommit() OVERRIDE { 674 virtual void DidCommit() override {
675 switch (layer_tree_host()->source_frame_number()) { 675 switch (layer_tree_host()->source_frame_number()) {
676 case 1: 676 case 1:
677 parent_layer_->SetOpacity(1.0f); 677 parent_layer_->SetOpacity(1.0f);
678 break; 678 break;
679 case 2: 679 case 2:
680 break; 680 break;
681 default: 681 default:
682 NOTREACHED(); 682 NOTREACHED();
683 } 683 }
684 } 684 }
685 685
686 virtual void AfterTest() OVERRIDE {} 686 virtual void AfterTest() override {}
687 687
688 private: 688 private:
689 scoped_refptr<Layer> root_layer_; 689 scoped_refptr<Layer> root_layer_;
690 scoped_refptr<Layer> parent_layer_; 690 scoped_refptr<Layer> parent_layer_;
691 scoped_refptr<Layer> child_layer_; 691 scoped_refptr<Layer> child_layer_;
692 }; 692 };
693 693
694 SINGLE_AND_MULTI_THREAD_TEST_F( 694 SINGLE_AND_MULTI_THREAD_TEST_F(
695 LayerTreeHostTestUndrawnLayersPushContentBoundsLater); 695 LayerTreeHostTestUndrawnLayersPushContentBoundsLater);
696 696
697 // This test verifies that properties on the layer tree host are commited 697 // This test verifies that properties on the layer tree host are commited
698 // to the impl side. 698 // to the impl side.
699 class LayerTreeHostTestCommit : public LayerTreeHostTest { 699 class LayerTreeHostTestCommit : public LayerTreeHostTest {
700 public: 700 public:
701 LayerTreeHostTestCommit() {} 701 LayerTreeHostTestCommit() {}
702 702
703 virtual void BeginTest() OVERRIDE { 703 virtual void BeginTest() override {
704 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 704 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
705 layer_tree_host()->set_background_color(SK_ColorGRAY); 705 layer_tree_host()->set_background_color(SK_ColorGRAY);
706 706
707 PostSetNeedsCommitToMainThread(); 707 PostSetNeedsCommitToMainThread();
708 } 708 }
709 709
710 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 710 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
711 EXPECT_EQ(gfx::Size(20, 20), impl->DrawViewportSize()); 711 EXPECT_EQ(gfx::Size(20, 20), impl->DrawViewportSize());
712 EXPECT_EQ(SK_ColorGRAY, impl->active_tree()->background_color()); 712 EXPECT_EQ(SK_ColorGRAY, impl->active_tree()->background_color());
713 713
714 EndTest(); 714 EndTest();
715 } 715 }
716 716
717 virtual void AfterTest() OVERRIDE {} 717 virtual void AfterTest() override {}
718 }; 718 };
719 719
720 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); 720 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
721 721
722 // This test verifies that LayerTreeHostImpl's current frame time gets 722 // This test verifies that LayerTreeHostImpl's current frame time gets
723 // updated in consecutive frames when it doesn't draw due to tree 723 // updated in consecutive frames when it doesn't draw due to tree
724 // activation failure. 724 // activation failure.
725 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails 725 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
726 : public LayerTreeHostTest { 726 : public LayerTreeHostTest {
727 public: 727 public:
728 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() 728 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
729 : frame_count_with_pending_tree_(0) {} 729 : frame_count_with_pending_tree_(0) {}
730 730
731 virtual void BeginTest() OVERRIDE { 731 virtual void BeginTest() override {
732 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 732 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
733 layer_tree_host()->set_background_color(SK_ColorGRAY); 733 layer_tree_host()->set_background_color(SK_ColorGRAY);
734 734
735 PostSetNeedsCommitToMainThread(); 735 PostSetNeedsCommitToMainThread();
736 } 736 }
737 737
738 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { 738 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
739 EXPECT_EQ(frame_count_with_pending_tree_, 0); 739 EXPECT_EQ(frame_count_with_pending_tree_, 0);
740 impl->BlockNotifyReadyToActivateForTesting(true); 740 impl->BlockNotifyReadyToActivateForTesting(true);
741 } 741 }
742 742
743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, 743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
744 const BeginFrameArgs& args) OVERRIDE { 744 const BeginFrameArgs& args) override {
745 if (impl->pending_tree()) 745 if (impl->pending_tree())
746 frame_count_with_pending_tree_++; 746 frame_count_with_pending_tree_++;
747 747
748 if (frame_count_with_pending_tree_ == 1) { 748 if (frame_count_with_pending_tree_ == 1) {
749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); 749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0);
750 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; 750 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time;
751 } else if (frame_count_with_pending_tree_ == 2) { 751 } else if (frame_count_with_pending_tree_ == 2) {
752 impl->BlockNotifyReadyToActivateForTesting(false); 752 impl->BlockNotifyReadyToActivateForTesting(false);
753 } 753 }
754 } 754 }
755 755
756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
757 if (frame_count_with_pending_tree_ > 1) { 757 if (frame_count_with_pending_tree_ > 1) {
758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); 758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0);
759 EXPECT_NE(first_frame_time_.ToInternalValue(), 759 EXPECT_NE(first_frame_time_.ToInternalValue(),
760 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); 760 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue());
761 EndTest(); 761 EndTest();
762 return; 762 return;
763 } 763 }
764 764
765 EXPECT_FALSE(impl->settings().impl_side_painting); 765 EXPECT_FALSE(impl->settings().impl_side_painting);
766 EndTest(); 766 EndTest();
767 } 767 }
768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
769 if (impl->settings().impl_side_painting) 769 if (impl->settings().impl_side_painting)
770 EXPECT_NE(frame_count_with_pending_tree_, 1); 770 EXPECT_NE(frame_count_with_pending_tree_, 1);
771 } 771 }
772 772
773 virtual void AfterTest() OVERRIDE {} 773 virtual void AfterTest() override {}
774 774
775 private: 775 private:
776 int frame_count_with_pending_tree_; 776 int frame_count_with_pending_tree_;
777 base::TimeTicks first_frame_time_; 777 base::TimeTicks first_frame_time_;
778 }; 778 };
779 779
780 SINGLE_AND_MULTI_THREAD_TEST_F( 780 SINGLE_AND_MULTI_THREAD_TEST_F(
781 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); 781 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
782 782
783 // This test verifies that LayerTreeHostImpl's current frame time gets 783 // This test verifies that LayerTreeHostImpl's current frame time gets
784 // updated in consecutive frames when it draws in each frame. 784 // updated in consecutive frames when it draws in each frame.
785 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { 785 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
786 public: 786 public:
787 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} 787 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {}
788 788
789 virtual void BeginTest() OVERRIDE { 789 virtual void BeginTest() override {
790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
791 layer_tree_host()->set_background_color(SK_ColorGRAY); 791 layer_tree_host()->set_background_color(SK_ColorGRAY);
792 792
793 PostSetNeedsCommitToMainThread(); 793 PostSetNeedsCommitToMainThread();
794 } 794 }
795 795
796 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 796 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
797 frame_++; 797 frame_++;
798 if (frame_ == 1) { 798 if (frame_ == 1) {
799 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; 799 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time;
800 impl->SetNeedsRedraw(); 800 impl->SetNeedsRedraw();
801 801
802 // Since we might use a low-resolution clock on Windows, we need to 802 // Since we might use a low-resolution clock on Windows, we need to
803 // make sure that the clock has incremented past first_frame_time_. 803 // make sure that the clock has incremented past first_frame_time_.
804 while (first_frame_time_ == gfx::FrameTime::Now()) { 804 while (first_frame_time_ == gfx::FrameTime::Now()) {
805 } 805 }
806 806
807 return; 807 return;
808 } 808 }
809 809
810 EXPECT_NE(first_frame_time_, impl->CurrentBeginFrameArgs().frame_time); 810 EXPECT_NE(first_frame_time_, impl->CurrentBeginFrameArgs().frame_time);
811 EndTest(); 811 EndTest();
812 } 812 }
813 813
814 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 814 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
815 // Ensure there isn't a commit between the two draws, to ensure that a 815 // Ensure there isn't a commit between the two draws, to ensure that a
816 // commit isn't required for updating the current frame time. We can 816 // commit isn't required for updating the current frame time. We can
817 // only check for this in the multi-threaded case, since in the single- 817 // only check for this in the multi-threaded case, since in the single-
818 // threaded case there will always be a commit between consecutive draws. 818 // threaded case there will always be a commit between consecutive draws.
819 if (HasImplThread()) 819 if (HasImplThread())
820 EXPECT_EQ(0, frame_); 820 EXPECT_EQ(0, frame_);
821 } 821 }
822 822
823 virtual void AfterTest() OVERRIDE {} 823 virtual void AfterTest() override {}
824 824
825 private: 825 private:
826 int frame_; 826 int frame_;
827 base::TimeTicks first_frame_time_; 827 base::TimeTicks first_frame_time_;
828 }; 828 };
829 829
830 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFrameTimeUpdatesAfterDraw); 830 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFrameTimeUpdatesAfterDraw);
831 831
832 // Verifies that StartPageScaleAnimation events propagate correctly 832 // Verifies that StartPageScaleAnimation events propagate correctly
833 // from LayerTreeHost to LayerTreeHostImpl in the MT compositor. 833 // from LayerTreeHost to LayerTreeHostImpl in the MT compositor.
834 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { 834 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
835 public: 835 public:
836 LayerTreeHostTestStartPageScaleAnimation() {} 836 LayerTreeHostTestStartPageScaleAnimation() {}
837 837
838 virtual void SetupTree() OVERRIDE { 838 virtual void SetupTree() override {
839 LayerTreeHostTest::SetupTree(); 839 LayerTreeHostTest::SetupTree();
840 840
841 if (layer_tree_host()->settings().impl_side_painting) { 841 if (layer_tree_host()->settings().impl_side_painting) {
842 scoped_refptr<FakePictureLayer> layer = 842 scoped_refptr<FakePictureLayer> layer =
843 FakePictureLayer::Create(&client_); 843 FakePictureLayer::Create(&client_);
844 layer->set_always_update_resources(true); 844 layer->set_always_update_resources(true);
845 scroll_layer_ = layer; 845 scroll_layer_ = layer;
846 } else { 846 } else {
847 scroll_layer_ = FakeContentLayer::Create(&client_); 847 scroll_layer_ = FakeContentLayer::Create(&client_);
848 } 848 }
849 849
850 Layer* root_layer = layer_tree_host()->root_layer(); 850 Layer* root_layer = layer_tree_host()->root_layer();
851 scroll_layer_->SetScrollClipLayerId(root_layer->id()); 851 scroll_layer_->SetScrollClipLayerId(root_layer->id());
852 scroll_layer_->SetIsContainerForFixedPositionLayers(true); 852 scroll_layer_->SetIsContainerForFixedPositionLayers(true);
853 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), 853 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(),
854 2 * root_layer->bounds().height())); 854 2 * root_layer->bounds().height()));
855 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); 855 scroll_layer_->SetScrollOffset(gfx::ScrollOffset());
856 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 856 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
857 // This test requires the page_scale and inner viewport layers to be 857 // This test requires the page_scale and inner viewport layers to be
858 // identified. 858 // identified.
859 layer_tree_host()->RegisterViewportLayers( 859 layer_tree_host()->RegisterViewportLayers(
860 root_layer, scroll_layer_.get(), NULL); 860 root_layer, scroll_layer_.get(), NULL);
861 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); 861 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f);
862 } 862 }
863 863
864 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 864 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
865 865
866 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, 866 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
867 float scale, 867 float scale,
868 float) OVERRIDE { 868 float) override {
869 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); 869 gfx::ScrollOffset offset = scroll_layer_->scroll_offset();
870 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, 870 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset,
871 scroll_delta)); 871 scroll_delta));
872 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); 872 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
873 } 873 }
874 874
875 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 875 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
876 // We get one commit before the first draw, and the animation doesn't happen 876 // We get one commit before the first draw, and the animation doesn't happen
877 // until the second draw. 877 // until the second draw.
878 switch (impl->active_tree()->source_frame_number()) { 878 switch (impl->active_tree()->source_frame_number()) {
879 case 0: 879 case 0:
880 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); 880 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
881 // We'll start an animation when we get back to the main thread. 881 // We'll start an animation when we get back to the main thread.
882 break; 882 break;
883 case 1: 883 case 1:
884 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); 884 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
885 break; 885 break;
886 case 2: 886 case 2:
887 EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor()); 887 EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor());
888 EndTest(); 888 EndTest();
889 break; 889 break;
890 default: 890 default:
891 NOTREACHED(); 891 NOTREACHED();
892 } 892 }
893 } 893 }
894 894
895 virtual void DidCommitAndDrawFrame() OVERRIDE { 895 virtual void DidCommitAndDrawFrame() override {
896 switch (layer_tree_host()->source_frame_number()) { 896 switch (layer_tree_host()->source_frame_number()) {
897 case 1: 897 case 1:
898 layer_tree_host()->StartPageScaleAnimation( 898 layer_tree_host()->StartPageScaleAnimation(
899 gfx::Vector2d(), false, 1.25f, base::TimeDelta()); 899 gfx::Vector2d(), false, 1.25f, base::TimeDelta());
900 break; 900 break;
901 } 901 }
902 } 902 }
903 903
904 virtual void AfterTest() OVERRIDE {} 904 virtual void AfterTest() override {}
905 905
906 FakeContentLayerClient client_; 906 FakeContentLayerClient client_;
907 scoped_refptr<Layer> scroll_layer_; 907 scoped_refptr<Layer> scroll_layer_;
908 }; 908 };
909 909
910 MULTI_THREAD_TEST_F(LayerTreeHostTestStartPageScaleAnimation); 910 MULTI_THREAD_TEST_F(LayerTreeHostTestStartPageScaleAnimation);
911 911
912 class LayerTreeHostTestSetVisible : public LayerTreeHostTest { 912 class LayerTreeHostTestSetVisible : public LayerTreeHostTest {
913 public: 913 public:
914 LayerTreeHostTestSetVisible() : num_draws_(0) {} 914 LayerTreeHostTestSetVisible() : num_draws_(0) {}
915 915
916 virtual void BeginTest() OVERRIDE { 916 virtual void BeginTest() override {
917 PostSetNeedsCommitToMainThread(); 917 PostSetNeedsCommitToMainThread();
918 PostSetVisibleToMainThread(false); 918 PostSetVisibleToMainThread(false);
919 // This is suppressed while we're invisible. 919 // This is suppressed while we're invisible.
920 PostSetNeedsRedrawToMainThread(); 920 PostSetNeedsRedrawToMainThread();
921 // Triggers the redraw. 921 // Triggers the redraw.
922 PostSetVisibleToMainThread(true); 922 PostSetVisibleToMainThread(true);
923 } 923 }
924 924
925 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 925 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
926 EXPECT_TRUE(impl->visible()); 926 EXPECT_TRUE(impl->visible());
927 ++num_draws_; 927 ++num_draws_;
928 EndTest(); 928 EndTest();
929 } 929 }
930 930
931 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_draws_); } 931 virtual void AfterTest() override { EXPECT_EQ(1, num_draws_); }
932 932
933 private: 933 private:
934 int num_draws_; 934 int num_draws_;
935 }; 935 };
936 936
937 MULTI_THREAD_TEST_F(LayerTreeHostTestSetVisible); 937 MULTI_THREAD_TEST_F(LayerTreeHostTestSetVisible);
938 938
939 class TestOpacityChangeLayerDelegate : public ContentLayerClient { 939 class TestOpacityChangeLayerDelegate : public ContentLayerClient {
940 public: 940 public:
941 TestOpacityChangeLayerDelegate() : test_layer_(0) {} 941 TestOpacityChangeLayerDelegate() : test_layer_(0) {}
942 942
943 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } 943 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; }
944 944
945 virtual void PaintContents( 945 virtual void PaintContents(
946 SkCanvas* canvas, 946 SkCanvas* canvas,
947 const gfx::Rect& clip, 947 const gfx::Rect& clip,
948 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE { 948 ContentLayerClient::GraphicsContextStatus gc_status) override {
949 // Set layer opacity to 0. 949 // Set layer opacity to 0.
950 if (test_layer_) 950 if (test_layer_)
951 test_layer_->SetOpacity(0.f); 951 test_layer_->SetOpacity(0.f);
952 } 952 }
953 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} 953 virtual void DidChangeLayerCanUseLCDText() override {}
954 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } 954 virtual bool FillsBoundsCompletely() const override { return false; }
955 955
956 private: 956 private:
957 Layer* test_layer_; 957 Layer* test_layer_;
958 }; 958 };
959 959
960 class ContentLayerWithUpdateTracking : public ContentLayer { 960 class ContentLayerWithUpdateTracking : public ContentLayer {
961 public: 961 public:
962 static scoped_refptr<ContentLayerWithUpdateTracking> Create( 962 static scoped_refptr<ContentLayerWithUpdateTracking> Create(
963 ContentLayerClient* client) { 963 ContentLayerClient* client) {
964 return make_scoped_refptr(new ContentLayerWithUpdateTracking(client)); 964 return make_scoped_refptr(new ContentLayerWithUpdateTracking(client));
965 } 965 }
966 966
967 int PaintContentsCount() { return paint_contents_count_; } 967 int PaintContentsCount() { return paint_contents_count_; }
968 void ResetPaintContentsCount() { paint_contents_count_ = 0; } 968 void ResetPaintContentsCount() { paint_contents_count_ = 0; }
969 969
970 virtual bool Update(ResourceUpdateQueue* queue, 970 virtual bool Update(ResourceUpdateQueue* queue,
971 const OcclusionTracker<Layer>* occlusion) OVERRIDE { 971 const OcclusionTracker<Layer>* occlusion) override {
972 bool updated = ContentLayer::Update(queue, occlusion); 972 bool updated = ContentLayer::Update(queue, occlusion);
973 paint_contents_count_++; 973 paint_contents_count_++;
974 return updated; 974 return updated;
975 } 975 }
976 976
977 private: 977 private:
978 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) 978 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client)
979 : ContentLayer(client), paint_contents_count_(0) { 979 : ContentLayer(client), paint_contents_count_(0) {
980 SetBounds(gfx::Size(10, 10)); 980 SetBounds(gfx::Size(10, 10));
981 SetIsDrawable(true); 981 SetIsDrawable(true);
982 } 982 }
983 virtual ~ContentLayerWithUpdateTracking() {} 983 virtual ~ContentLayerWithUpdateTracking() {}
984 984
985 int paint_contents_count_; 985 int paint_contents_count_;
986 }; 986 };
987 987
988 // Layer opacity change during paint should not prevent compositor resources 988 // Layer opacity change during paint should not prevent compositor resources
989 // from being updated during commit. 989 // from being updated during commit.
990 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { 990 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest {
991 public: 991 public:
992 LayerTreeHostTestOpacityChange() 992 LayerTreeHostTestOpacityChange()
993 : test_opacity_change_delegate_(), 993 : test_opacity_change_delegate_(),
994 update_check_layer_(ContentLayerWithUpdateTracking::Create( 994 update_check_layer_(ContentLayerWithUpdateTracking::Create(
995 &test_opacity_change_delegate_)) { 995 &test_opacity_change_delegate_)) {
996 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); 996 test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get());
997 } 997 }
998 998
999 virtual void BeginTest() OVERRIDE { 999 virtual void BeginTest() override {
1000 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); 1000 layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
1001 layer_tree_host()->root_layer()->AddChild(update_check_layer_); 1001 layer_tree_host()->root_layer()->AddChild(update_check_layer_);
1002 1002
1003 PostSetNeedsCommitToMainThread(); 1003 PostSetNeedsCommitToMainThread();
1004 } 1004 }
1005 1005
1006 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1006 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
1007 EndTest(); 1007 EndTest();
1008 } 1008 }
1009 1009
1010 virtual void AfterTest() OVERRIDE { 1010 virtual void AfterTest() override {
1011 // Update() should have been called once. 1011 // Update() should have been called once.
1012 EXPECT_EQ(1, update_check_layer_->PaintContentsCount()); 1012 EXPECT_EQ(1, update_check_layer_->PaintContentsCount());
1013 } 1013 }
1014 1014
1015 private: 1015 private:
1016 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; 1016 TestOpacityChangeLayerDelegate test_opacity_change_delegate_;
1017 scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_; 1017 scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_;
1018 }; 1018 };
1019 1019
1020 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); 1020 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange);
1021 1021
1022 class NoScaleContentLayer : public ContentLayer { 1022 class NoScaleContentLayer : public ContentLayer {
1023 public: 1023 public:
1024 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { 1024 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) {
1025 return make_scoped_refptr(new NoScaleContentLayer(client)); 1025 return make_scoped_refptr(new NoScaleContentLayer(client));
1026 } 1026 }
1027 1027
1028 virtual void CalculateContentsScale(float ideal_contents_scale, 1028 virtual void CalculateContentsScale(float ideal_contents_scale,
1029 float* contents_scale_x, 1029 float* contents_scale_x,
1030 float* contents_scale_y, 1030 float* contents_scale_y,
1031 gfx::Size* contentBounds) OVERRIDE { 1031 gfx::Size* contentBounds) override {
1032 // Skip over the ContentLayer's method to the base Layer class. 1032 // Skip over the ContentLayer's method to the base Layer class.
1033 Layer::CalculateContentsScale(ideal_contents_scale, 1033 Layer::CalculateContentsScale(ideal_contents_scale,
1034 contents_scale_x, 1034 contents_scale_x,
1035 contents_scale_y, 1035 contents_scale_y,
1036 contentBounds); 1036 contentBounds);
1037 } 1037 }
1038 1038
1039 private: 1039 private:
1040 explicit NoScaleContentLayer(ContentLayerClient* client) 1040 explicit NoScaleContentLayer(ContentLayerClient* client)
1041 : ContentLayer(client) {} 1041 : ContentLayer(client) {}
1042 virtual ~NoScaleContentLayer() {} 1042 virtual ~NoScaleContentLayer() {}
1043 }; 1043 };
1044 1044
1045 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers 1045 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
1046 : public LayerTreeHostTest { 1046 : public LayerTreeHostTest {
1047 public: 1047 public:
1048 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() 1048 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers()
1049 : root_layer_(NoScaleContentLayer::Create(&client_)), 1049 : root_layer_(NoScaleContentLayer::Create(&client_)),
1050 child_layer_(ContentLayer::Create(&client_)) {} 1050 child_layer_(ContentLayer::Create(&client_)) {}
1051 1051
1052 virtual void BeginTest() OVERRIDE { 1052 virtual void BeginTest() override {
1053 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); 1053 layer_tree_host()->SetViewportSize(gfx::Size(60, 60));
1054 layer_tree_host()->SetDeviceScaleFactor(1.5); 1054 layer_tree_host()->SetDeviceScaleFactor(1.5);
1055 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); 1055 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size());
1056 1056
1057 root_layer_->AddChild(child_layer_); 1057 root_layer_->AddChild(child_layer_);
1058 1058
1059 root_layer_->SetIsDrawable(true); 1059 root_layer_->SetIsDrawable(true);
1060 root_layer_->SetBounds(gfx::Size(30, 30)); 1060 root_layer_->SetBounds(gfx::Size(30, 30));
1061 1061
1062 child_layer_->SetIsDrawable(true); 1062 child_layer_->SetIsDrawable(true);
1063 child_layer_->SetPosition(gfx::Point(2, 2)); 1063 child_layer_->SetPosition(gfx::Point(2, 2));
1064 child_layer_->SetBounds(gfx::Size(10, 10)); 1064 child_layer_->SetBounds(gfx::Size(10, 10));
1065 1065
1066 layer_tree_host()->SetRootLayer(root_layer_); 1066 layer_tree_host()->SetRootLayer(root_layer_);
1067 1067
1068 PostSetNeedsCommitToMainThread(); 1068 PostSetNeedsCommitToMainThread();
1069 } 1069 }
1070 1070
1071 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1071 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
1072 // Should only do one commit. 1072 // Should only do one commit.
1073 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); 1073 EXPECT_EQ(0, impl->active_tree()->source_frame_number());
1074 // Device scale factor should come over to impl. 1074 // Device scale factor should come over to impl.
1075 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f); 1075 EXPECT_NEAR(impl->device_scale_factor(), 1.5f, 0.00001f);
1076 1076
1077 // Both layers are on impl. 1077 // Both layers are on impl.
1078 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); 1078 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size());
1079 1079
1080 // Device viewport is scaled. 1080 // Device viewport is scaled.
1081 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); 1081 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 gfx::Transform child_draw_transform = child_screen_space_transform; 1127 gfx::Transform child_draw_transform = child_screen_space_transform;
1128 1128
1129 EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform, 1129 EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform,
1130 child->draw_transform()); 1130 child->draw_transform());
1131 EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform, 1131 EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform,
1132 child->screen_space_transform()); 1132 child->screen_space_transform());
1133 1133
1134 EndTest(); 1134 EndTest();
1135 } 1135 }
1136 1136
1137 virtual void AfterTest() OVERRIDE {} 1137 virtual void AfterTest() override {}
1138 1138
1139 private: 1139 private:
1140 FakeContentLayerClient client_; 1140 FakeContentLayerClient client_;
1141 scoped_refptr<NoScaleContentLayer> root_layer_; 1141 scoped_refptr<NoScaleContentLayer> root_layer_;
1142 scoped_refptr<ContentLayer> child_layer_; 1142 scoped_refptr<ContentLayer> child_layer_;
1143 }; 1143 };
1144 1144
1145 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); 1145 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers);
1146 1146
1147 // Verify atomicity of commits and reuse of textures. 1147 // Verify atomicity of commits and reuse of textures.
1148 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { 1148 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest {
1149 public: 1149 public:
1150 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 1150 virtual void InitializeSettings(LayerTreeSettings* settings) override {
1151 settings->texture_id_allocation_chunk_size = 1; 1151 settings->texture_id_allocation_chunk_size = 1;
1152 // Make sure partial texture updates are turned off. 1152 // Make sure partial texture updates are turned off.
1153 settings->max_partial_texture_updates = 0; 1153 settings->max_partial_texture_updates = 0;
1154 // Linear fade animator prevents scrollbars from drawing immediately. 1154 // Linear fade animator prevents scrollbars from drawing immediately.
1155 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; 1155 settings->scrollbar_animator = LayerTreeSettings::NoAnimator;
1156 } 1156 }
1157 1157
1158 virtual void SetupTree() OVERRIDE { 1158 virtual void SetupTree() override {
1159 layer_ = FakeContentLayer::Create(&client_); 1159 layer_ = FakeContentLayer::Create(&client_);
1160 layer_->SetBounds(gfx::Size(10, 20)); 1160 layer_->SetBounds(gfx::Size(10, 20));
1161 1161
1162 bool paint_scrollbar = true; 1162 bool paint_scrollbar = true;
1163 bool has_thumb = false; 1163 bool has_thumb = false;
1164 scrollbar_ = FakePaintedScrollbarLayer::Create( 1164 scrollbar_ = FakePaintedScrollbarLayer::Create(
1165 paint_scrollbar, has_thumb, layer_->id()); 1165 paint_scrollbar, has_thumb, layer_->id());
1166 scrollbar_->SetPosition(gfx::Point(0, 10)); 1166 scrollbar_->SetPosition(gfx::Point(0, 10));
1167 scrollbar_->SetBounds(gfx::Size(10, 10)); 1167 scrollbar_->SetBounds(gfx::Size(10, 10));
1168 1168
1169 layer_->AddChild(scrollbar_); 1169 layer_->AddChild(scrollbar_);
1170 1170
1171 layer_tree_host()->SetRootLayer(layer_); 1171 layer_tree_host()->SetRootLayer(layer_);
1172 LayerTreeHostTest::SetupTree(); 1172 LayerTreeHostTest::SetupTree();
1173 } 1173 }
1174 1174
1175 virtual void BeginTest() OVERRIDE { 1175 virtual void BeginTest() override {
1176 drew_frame_ = -1; 1176 drew_frame_ = -1;
1177 PostSetNeedsCommitToMainThread(); 1177 PostSetNeedsCommitToMainThread();
1178 } 1178 }
1179 1179
1180 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1180 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
1181 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); 1181 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates);
1182 1182
1183 TestWebGraphicsContext3D* context = TestContext(); 1183 TestWebGraphicsContext3D* context = TestContext();
1184 1184
1185 switch (impl->active_tree()->source_frame_number()) { 1185 switch (impl->active_tree()->source_frame_number()) {
1186 case 0: 1186 case 0:
1187 // Number of textures should be one for each layer 1187 // Number of textures should be one for each layer
1188 ASSERT_EQ(2u, context->NumTextures()); 1188 ASSERT_EQ(2u, context->NumTextures());
1189 // Number of textures used for commit should be one for each layer. 1189 // Number of textures used for commit should be one for each layer.
1190 EXPECT_EQ(2u, context->NumUsedTextures()); 1190 EXPECT_EQ(2u, context->NumUsedTextures());
(...skipping 20 matching lines...) Expand all
1211 break; 1211 break;
1212 case 2: 1212 case 2:
1213 EndTest(); 1213 EndTest();
1214 break; 1214 break;
1215 default: 1215 default:
1216 NOTREACHED(); 1216 NOTREACHED();
1217 break; 1217 break;
1218 } 1218 }
1219 } 1219 }
1220 1220
1221 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1221 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1222 TestWebGraphicsContext3D* context = TestContext(); 1222 TestWebGraphicsContext3D* context = TestContext();
1223 1223
1224 if (drew_frame_ == impl->active_tree()->source_frame_number()) { 1224 if (drew_frame_ == impl->active_tree()->source_frame_number()) {
1225 EXPECT_EQ(0u, context->NumUsedTextures()) << "For frame " << drew_frame_; 1225 EXPECT_EQ(0u, context->NumUsedTextures()) << "For frame " << drew_frame_;
1226 return; 1226 return;
1227 } 1227 }
1228 drew_frame_ = impl->active_tree()->source_frame_number(); 1228 drew_frame_ = impl->active_tree()->source_frame_number();
1229 1229
1230 // We draw/ship one texture each frame for each layer. 1230 // We draw/ship one texture each frame for each layer.
1231 EXPECT_EQ(2u, context->NumUsedTextures()); 1231 EXPECT_EQ(2u, context->NumUsedTextures());
1232 context->ResetUsedTextures(); 1232 context->ResetUsedTextures();
1233 1233
1234 if (!TestEnded()) 1234 if (!TestEnded())
1235 PostSetNeedsCommitToMainThread(); 1235 PostSetNeedsCommitToMainThread();
1236 } 1236 }
1237 1237
1238 virtual void Layout() OVERRIDE { 1238 virtual void Layout() override {
1239 layer_->SetNeedsDisplay(); 1239 layer_->SetNeedsDisplay();
1240 scrollbar_->SetNeedsDisplay(); 1240 scrollbar_->SetNeedsDisplay();
1241 } 1241 }
1242 1242
1243 virtual void AfterTest() OVERRIDE {} 1243 virtual void AfterTest() override {}
1244 1244
1245 protected: 1245 protected:
1246 FakeContentLayerClient client_; 1246 FakeContentLayerClient client_;
1247 scoped_refptr<FakeContentLayer> layer_; 1247 scoped_refptr<FakeContentLayer> layer_;
1248 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; 1248 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_;
1249 int drew_frame_; 1249 int drew_frame_;
1250 }; 1250 };
1251 1251
1252 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 1252 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
1253 LayerTreeHostTestDirectRendererAtomicCommit); 1253 LayerTreeHostTestDirectRendererAtomicCommit);
1254 1254
1255 class LayerTreeHostTestDelegatingRendererAtomicCommit 1255 class LayerTreeHostTestDelegatingRendererAtomicCommit
1256 : public LayerTreeHostTestDirectRendererAtomicCommit { 1256 : public LayerTreeHostTestDirectRendererAtomicCommit {
1257 public: 1257 public:
1258 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1258 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
1259 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); 1259 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates);
1260 1260
1261 TestWebGraphicsContext3D* context = TestContext(); 1261 TestWebGraphicsContext3D* context = TestContext();
1262 1262
1263 switch (impl->active_tree()->source_frame_number()) { 1263 switch (impl->active_tree()->source_frame_number()) {
1264 case 0: 1264 case 0:
1265 // Number of textures should be one for each layer 1265 // Number of textures should be one for each layer
1266 ASSERT_EQ(2u, context->NumTextures()); 1266 ASSERT_EQ(2u, context->NumTextures());
1267 // Number of textures used for commit should be one for each layer. 1267 // Number of textures used for commit should be one for each layer.
1268 EXPECT_EQ(2u, context->NumUsedTextures()); 1268 EXPECT_EQ(2u, context->NumUsedTextures());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 layer->SetTransform(transform); 1315 layer->SetTransform(transform);
1316 layer->SetTransformOrigin(transform_origin); 1316 layer->SetTransformOrigin(transform_origin);
1317 layer->SetPosition(position); 1317 layer->SetPosition(position);
1318 layer->SetBounds(bounds); 1318 layer->SetBounds(bounds);
1319 layer->SetContentsOpaque(opaque); 1319 layer->SetContentsOpaque(opaque);
1320 } 1320 }
1321 1321
1322 class LayerTreeHostTestAtomicCommitWithPartialUpdate 1322 class LayerTreeHostTestAtomicCommitWithPartialUpdate
1323 : public LayerTreeHostTest { 1323 : public LayerTreeHostTest {
1324 public: 1324 public:
1325 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 1325 virtual void InitializeSettings(LayerTreeSettings* settings) override {
1326 settings->texture_id_allocation_chunk_size = 1; 1326 settings->texture_id_allocation_chunk_size = 1;
1327 // Allow one partial texture update. 1327 // Allow one partial texture update.
1328 settings->max_partial_texture_updates = 1; 1328 settings->max_partial_texture_updates = 1;
1329 // No partial updates when impl side painting is enabled. 1329 // No partial updates when impl side painting is enabled.
1330 settings->impl_side_painting = false; 1330 settings->impl_side_painting = false;
1331 } 1331 }
1332 1332
1333 virtual void SetupTree() OVERRIDE { 1333 virtual void SetupTree() override {
1334 parent_ = FakeContentLayer::Create(&client_); 1334 parent_ = FakeContentLayer::Create(&client_);
1335 parent_->SetBounds(gfx::Size(10, 20)); 1335 parent_->SetBounds(gfx::Size(10, 20));
1336 1336
1337 child_ = FakeContentLayer::Create(&client_); 1337 child_ = FakeContentLayer::Create(&client_);
1338 child_->SetPosition(gfx::Point(0, 10)); 1338 child_->SetPosition(gfx::Point(0, 10));
1339 child_->SetBounds(gfx::Size(3, 10)); 1339 child_->SetBounds(gfx::Size(3, 10));
1340 1340
1341 parent_->AddChild(child_); 1341 parent_->AddChild(child_);
1342 1342
1343 layer_tree_host()->SetRootLayer(parent_); 1343 layer_tree_host()->SetRootLayer(parent_);
1344 LayerTreeHostTest::SetupTree(); 1344 LayerTreeHostTest::SetupTree();
1345 } 1345 }
1346 1346
1347 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1347 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1348 1348
1349 virtual void DidCommitAndDrawFrame() OVERRIDE { 1349 virtual void DidCommitAndDrawFrame() override {
1350 switch (layer_tree_host()->source_frame_number()) { 1350 switch (layer_tree_host()->source_frame_number()) {
1351 case 1: 1351 case 1:
1352 parent_->SetNeedsDisplay(); 1352 parent_->SetNeedsDisplay();
1353 child_->SetNeedsDisplay(); 1353 child_->SetNeedsDisplay();
1354 break; 1354 break;
1355 case 2: 1355 case 2:
1356 // Damage part of layers. 1356 // Damage part of layers.
1357 parent_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); 1357 parent_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f));
1358 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); 1358 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f));
1359 break; 1359 break;
1360 case 3: 1360 case 3:
1361 child_->SetNeedsDisplay(); 1361 child_->SetNeedsDisplay();
1362 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); 1362 layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
1363 break; 1363 break;
1364 case 4: 1364 case 4:
1365 layer_tree_host()->SetViewportSize(gfx::Size(10, 20)); 1365 layer_tree_host()->SetViewportSize(gfx::Size(10, 20));
1366 break; 1366 break;
1367 case 5: 1367 case 5:
1368 EndTest(); 1368 EndTest();
1369 break; 1369 break;
1370 default: 1370 default:
1371 NOTREACHED() << layer_tree_host()->source_frame_number(); 1371 NOTREACHED() << layer_tree_host()->source_frame_number();
1372 break; 1372 break;
1373 } 1373 }
1374 } 1374 }
1375 1375
1376 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1376 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
1377 ASSERT_EQ(1u, layer_tree_host()->settings().max_partial_texture_updates); 1377 ASSERT_EQ(1u, layer_tree_host()->settings().max_partial_texture_updates);
1378 1378
1379 TestWebGraphicsContext3D* context = TestContext(); 1379 TestWebGraphicsContext3D* context = TestContext();
1380 1380
1381 switch (impl->active_tree()->source_frame_number()) { 1381 switch (impl->active_tree()->source_frame_number()) {
1382 case 0: 1382 case 0:
1383 // Number of textures should be one for each layer. 1383 // Number of textures should be one for each layer.
1384 ASSERT_EQ(2u, context->NumTextures()); 1384 ASSERT_EQ(2u, context->NumTextures());
1385 // Number of textures used for commit should be one for each layer. 1385 // Number of textures used for commit should be one for each layer.
1386 EXPECT_EQ(2u, context->NumUsedTextures()); 1386 EXPECT_EQ(2u, context->NumUsedTextures());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 EXPECT_EQ(1u, context->NumUsedTextures()); 1456 EXPECT_EQ(1u, context->NumUsedTextures());
1457 1457
1458 context->ResetUsedTextures(); 1458 context->ResetUsedTextures();
1459 break; 1459 break;
1460 default: 1460 default:
1461 NOTREACHED(); 1461 NOTREACHED();
1462 break; 1462 break;
1463 } 1463 }
1464 } 1464 }
1465 1465
1466 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1466 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1467 EXPECT_LT(impl->active_tree()->source_frame_number(), 5); 1467 EXPECT_LT(impl->active_tree()->source_frame_number(), 5);
1468 1468
1469 TestWebGraphicsContext3D* context = TestContext(); 1469 TestWebGraphicsContext3D* context = TestContext();
1470 1470
1471 // Number of textures used for drawing should one per layer except for 1471 // Number of textures used for drawing should one per layer except for
1472 // frame 3 where the viewport only contains one layer. 1472 // frame 3 where the viewport only contains one layer.
1473 if (impl->active_tree()->source_frame_number() == 3) { 1473 if (impl->active_tree()->source_frame_number() == 3) {
1474 EXPECT_EQ(1u, context->NumUsedTextures()); 1474 EXPECT_EQ(1u, context->NumUsedTextures());
1475 } else { 1475 } else {
1476 EXPECT_EQ(2u, context->NumUsedTextures()) 1476 EXPECT_EQ(2u, context->NumUsedTextures())
1477 << "For frame " << impl->active_tree()->source_frame_number(); 1477 << "For frame " << impl->active_tree()->source_frame_number();
1478 } 1478 }
1479 1479
1480 context->ResetUsedTextures(); 1480 context->ResetUsedTextures();
1481 } 1481 }
1482 1482
1483 virtual void AfterTest() OVERRIDE {} 1483 virtual void AfterTest() override {}
1484 1484
1485 private: 1485 private:
1486 FakeContentLayerClient client_; 1486 FakeContentLayerClient client_;
1487 scoped_refptr<FakeContentLayer> parent_; 1487 scoped_refptr<FakeContentLayer> parent_;
1488 scoped_refptr<FakeContentLayer> child_; 1488 scoped_refptr<FakeContentLayer> child_;
1489 }; 1489 };
1490 1490
1491 // Partial updates are not possible with a delegating renderer. 1491 // Partial updates are not possible with a delegating renderer.
1492 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1492 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1493 LayerTreeHostTestAtomicCommitWithPartialUpdate); 1493 LayerTreeHostTestAtomicCommitWithPartialUpdate);
1494 1494
1495 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit 1495 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
1496 : public LayerTreeHostTest { 1496 : public LayerTreeHostTest {
1497 protected: 1497 protected:
1498 virtual void SetupTree() OVERRIDE { 1498 virtual void SetupTree() override {
1499 root_layer_ = FakeContentLayer::Create(&client_); 1499 root_layer_ = FakeContentLayer::Create(&client_);
1500 root_layer_->SetBounds(gfx::Size(100, 100)); 1500 root_layer_->SetBounds(gfx::Size(100, 100));
1501 1501
1502 surface_layer1_ = FakeContentLayer::Create(&client_); 1502 surface_layer1_ = FakeContentLayer::Create(&client_);
1503 surface_layer1_->SetBounds(gfx::Size(100, 100)); 1503 surface_layer1_->SetBounds(gfx::Size(100, 100));
1504 surface_layer1_->SetForceRenderSurface(true); 1504 surface_layer1_->SetForceRenderSurface(true);
1505 surface_layer1_->SetOpacity(0.5f); 1505 surface_layer1_->SetOpacity(0.5f);
1506 root_layer_->AddChild(surface_layer1_); 1506 root_layer_->AddChild(surface_layer1_);
1507 1507
1508 surface_layer2_ = FakeContentLayer::Create(&client_); 1508 surface_layer2_ = FakeContentLayer::Create(&client_);
1509 surface_layer2_->SetBounds(gfx::Size(100, 100)); 1509 surface_layer2_->SetBounds(gfx::Size(100, 100));
1510 surface_layer2_->SetForceRenderSurface(true); 1510 surface_layer2_->SetForceRenderSurface(true);
1511 surface_layer2_->SetOpacity(0.5f); 1511 surface_layer2_->SetOpacity(0.5f);
1512 surface_layer1_->AddChild(surface_layer2_); 1512 surface_layer1_->AddChild(surface_layer2_);
1513 1513
1514 replica_layer1_ = FakeContentLayer::Create(&client_); 1514 replica_layer1_ = FakeContentLayer::Create(&client_);
1515 surface_layer1_->SetReplicaLayer(replica_layer1_.get()); 1515 surface_layer1_->SetReplicaLayer(replica_layer1_.get());
1516 1516
1517 replica_layer2_ = FakeContentLayer::Create(&client_); 1517 replica_layer2_ = FakeContentLayer::Create(&client_);
1518 surface_layer2_->SetReplicaLayer(replica_layer2_.get()); 1518 surface_layer2_->SetReplicaLayer(replica_layer2_.get());
1519 1519
1520 layer_tree_host()->SetRootLayer(root_layer_); 1520 layer_tree_host()->SetRootLayer(root_layer_);
1521 LayerTreeHostTest::SetupTree(); 1521 LayerTreeHostTest::SetupTree();
1522 } 1522 }
1523 1523
1524 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1524 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1525 1525
1526 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1526 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
1527 Renderer* renderer = host_impl->renderer(); 1527 Renderer* renderer = host_impl->renderer();
1528 RenderPassId surface1_render_pass_id = host_impl->active_tree() 1528 RenderPassId surface1_render_pass_id = host_impl->active_tree()
1529 ->root_layer() 1529 ->root_layer()
1530 ->children()[0] 1530 ->children()[0]
1531 ->render_surface() 1531 ->render_surface()
1532 ->GetRenderPassId(); 1532 ->GetRenderPassId();
1533 RenderPassId surface2_render_pass_id = host_impl->active_tree() 1533 RenderPassId surface2_render_pass_id = host_impl->active_tree()
1534 ->root_layer() 1534 ->root_layer()
1535 ->children()[0] 1535 ->children()[0]
1536 ->children()[0] 1536 ->children()[0]
(...skipping 16 matching lines...) Expand all
1553 EXPECT_FALSE( 1553 EXPECT_FALSE(
1554 renderer->HasAllocatedResourcesForTesting(surface1_render_pass_id)); 1554 renderer->HasAllocatedResourcesForTesting(surface1_render_pass_id));
1555 EXPECT_FALSE( 1555 EXPECT_FALSE(
1556 renderer->HasAllocatedResourcesForTesting(surface2_render_pass_id)); 1556 renderer->HasAllocatedResourcesForTesting(surface2_render_pass_id));
1557 1557
1558 EndTest(); 1558 EndTest();
1559 break; 1559 break;
1560 } 1560 }
1561 } 1561 }
1562 1562
1563 virtual void DidCommitAndDrawFrame() OVERRIDE { 1563 virtual void DidCommitAndDrawFrame() override {
1564 if (layer_tree_host()->source_frame_number() < 2) 1564 if (layer_tree_host()->source_frame_number() < 2)
1565 root_layer_->SetNeedsDisplay(); 1565 root_layer_->SetNeedsDisplay();
1566 } 1566 }
1567 1567
1568 virtual void AfterTest() OVERRIDE { 1568 virtual void AfterTest() override {
1569 EXPECT_LE(2u, root_layer_->update_count()); 1569 EXPECT_LE(2u, root_layer_->update_count());
1570 EXPECT_LE(2u, surface_layer1_->update_count()); 1570 EXPECT_LE(2u, surface_layer1_->update_count());
1571 EXPECT_LE(2u, surface_layer2_->update_count()); 1571 EXPECT_LE(2u, surface_layer2_->update_count());
1572 } 1572 }
1573 1573
1574 FakeContentLayerClient client_; 1574 FakeContentLayerClient client_;
1575 scoped_refptr<FakeContentLayer> root_layer_; 1575 scoped_refptr<FakeContentLayer> root_layer_;
1576 scoped_refptr<FakeContentLayer> surface_layer1_; 1576 scoped_refptr<FakeContentLayer> surface_layer1_;
1577 scoped_refptr<FakeContentLayer> replica_layer1_; 1577 scoped_refptr<FakeContentLayer> replica_layer1_;
1578 scoped_refptr<FakeContentLayer> surface_layer2_; 1578 scoped_refptr<FakeContentLayer> surface_layer2_;
1579 scoped_refptr<FakeContentLayer> replica_layer2_; 1579 scoped_refptr<FakeContentLayer> replica_layer2_;
1580 }; 1580 };
1581 1581
1582 // Surfaces don't exist with a delegated renderer. 1582 // Surfaces don't exist with a delegated renderer.
1583 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 1583 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
1584 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit); 1584 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit);
1585 1585
1586 class EvictionTestLayer : public Layer { 1586 class EvictionTestLayer : public Layer {
1587 public: 1587 public:
1588 static scoped_refptr<EvictionTestLayer> Create() { 1588 static scoped_refptr<EvictionTestLayer> Create() {
1589 return make_scoped_refptr(new EvictionTestLayer()); 1589 return make_scoped_refptr(new EvictionTestLayer());
1590 } 1590 }
1591 1591
1592 virtual bool Update(ResourceUpdateQueue*, 1592 virtual bool Update(ResourceUpdateQueue*,
1593 const OcclusionTracker<Layer>*) OVERRIDE; 1593 const OcclusionTracker<Layer>*) override;
1594 virtual bool DrawsContent() const OVERRIDE { return true; } 1594 virtual bool DrawsContent() const override { return true; }
1595 1595
1596 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 1596 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
1597 OVERRIDE; 1597 override;
1598 virtual void PushPropertiesTo(LayerImpl* impl) OVERRIDE; 1598 virtual void PushPropertiesTo(LayerImpl* impl) override;
1599 virtual void SetTexturePriorities(const PriorityCalculator&) OVERRIDE; 1599 virtual void SetTexturePriorities(const PriorityCalculator&) override;
1600 1600
1601 bool HaveBackingTexture() const { 1601 bool HaveBackingTexture() const {
1602 return texture_.get() ? texture_->have_backing_texture() : false; 1602 return texture_.get() ? texture_->have_backing_texture() : false;
1603 } 1603 }
1604 1604
1605 private: 1605 private:
1606 EvictionTestLayer() : Layer() {} 1606 EvictionTestLayer() : Layer() {}
1607 virtual ~EvictionTestLayer() {} 1607 virtual ~EvictionTestLayer() {}
1608 1608
1609 void CreateTextureIfNeeded() { 1609 void CreateTextureIfNeeded() {
(...skipping 12 matching lines...) Expand all
1622 class EvictionTestLayerImpl : public LayerImpl { 1622 class EvictionTestLayerImpl : public LayerImpl {
1623 public: 1623 public:
1624 static scoped_ptr<EvictionTestLayerImpl> Create(LayerTreeImpl* tree_impl, 1624 static scoped_ptr<EvictionTestLayerImpl> Create(LayerTreeImpl* tree_impl,
1625 int id) { 1625 int id) {
1626 return make_scoped_ptr(new EvictionTestLayerImpl(tree_impl, id)); 1626 return make_scoped_ptr(new EvictionTestLayerImpl(tree_impl, id));
1627 } 1627 }
1628 virtual ~EvictionTestLayerImpl() {} 1628 virtual ~EvictionTestLayerImpl() {}
1629 1629
1630 virtual void AppendQuads(RenderPass* render_pass, 1630 virtual void AppendQuads(RenderPass* render_pass,
1631 const OcclusionTracker<LayerImpl>& occlusion_tracker, 1631 const OcclusionTracker<LayerImpl>& occlusion_tracker,
1632 AppendQuadsData* append_quads_data) OVERRIDE { 1632 AppendQuadsData* append_quads_data) override {
1633 ASSERT_TRUE(has_texture_); 1633 ASSERT_TRUE(has_texture_);
1634 ASSERT_NE(0u, layer_tree_impl()->resource_provider()->num_resources()); 1634 ASSERT_NE(0u, layer_tree_impl()->resource_provider()->num_resources());
1635 } 1635 }
1636 1636
1637 void SetHasTexture(bool has_texture) { has_texture_ = has_texture; } 1637 void SetHasTexture(bool has_texture) { has_texture_ = has_texture; }
1638 1638
1639 private: 1639 private:
1640 EvictionTestLayerImpl(LayerTreeImpl* tree_impl, int id) 1640 EvictionTestLayerImpl(LayerTreeImpl* tree_impl, int id)
1641 : LayerImpl(tree_impl, id), has_texture_(false) {} 1641 : LayerImpl(tree_impl, id), has_texture_(false) {}
1642 1642
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 test_layer_impl->SetHasTexture(texture_->have_backing_texture()); 1676 test_layer_impl->SetHasTexture(texture_->have_backing_texture());
1677 } 1677 }
1678 1678
1679 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest { 1679 class LayerTreeHostTestEvictTextures : public LayerTreeHostTest {
1680 public: 1680 public:
1681 LayerTreeHostTestEvictTextures() 1681 LayerTreeHostTestEvictTextures()
1682 : layer_(EvictionTestLayer::Create()), 1682 : layer_(EvictionTestLayer::Create()),
1683 impl_for_evict_textures_(0), 1683 impl_for_evict_textures_(0),
1684 num_commits_(0) {} 1684 num_commits_(0) {}
1685 1685
1686 virtual void BeginTest() OVERRIDE { 1686 virtual void BeginTest() override {
1687 layer_tree_host()->SetRootLayer(layer_); 1687 layer_tree_host()->SetRootLayer(layer_);
1688 layer_tree_host()->SetViewportSize(gfx::Size(10, 20)); 1688 layer_tree_host()->SetViewportSize(gfx::Size(10, 20));
1689 1689
1690 gfx::Transform identity_matrix; 1690 gfx::Transform identity_matrix;
1691 SetLayerPropertiesForTesting(layer_.get(), 1691 SetLayerPropertiesForTesting(layer_.get(),
1692 0, 1692 0,
1693 identity_matrix, 1693 identity_matrix,
1694 gfx::Point3F(0.f, 0.f, 0.f), 1694 gfx::Point3F(0.f, 0.f, 0.f),
1695 gfx::PointF(0.f, 0.f), 1695 gfx::PointF(0.f, 0.f),
1696 gfx::Size(10, 20), 1696 gfx::Size(10, 20),
(...skipping 29 matching lines...) Expand all
1726 // Commit 6: Triggered by the eviction, post an eviction task in 1726 // Commit 6: Triggered by the eviction, post an eviction task in
1727 // Layout(), which will be a noop, letting the commit (which recreates the 1727 // Layout(), which will be a noop, letting the commit (which recreates the
1728 // textures) go through and draw a frame, then end the test. 1728 // textures) go through and draw a frame, then end the test.
1729 // 1729 //
1730 // Commits 1+2 test the eviction recovery path where eviction happens outside 1730 // Commits 1+2 test the eviction recovery path where eviction happens outside
1731 // of the beginFrame/commit pair. 1731 // of the beginFrame/commit pair.
1732 // Commits 3+4 test the eviction recovery path where eviction happens inside 1732 // Commits 3+4 test the eviction recovery path where eviction happens inside
1733 // the beginFrame/commit pair. 1733 // the beginFrame/commit pair.
1734 // Commits 5+6 test the path where an eviction happens during the eviction 1734 // Commits 5+6 test the path where an eviction happens during the eviction
1735 // recovery path. 1735 // recovery path.
1736 virtual void DidCommit() OVERRIDE { 1736 virtual void DidCommit() override {
1737 switch (num_commits_) { 1737 switch (num_commits_) {
1738 case 1: 1738 case 1:
1739 EXPECT_TRUE(layer_->HaveBackingTexture()); 1739 EXPECT_TRUE(layer_->HaveBackingTexture());
1740 PostEvictTextures(); 1740 PostEvictTextures();
1741 break; 1741 break;
1742 case 2: 1742 case 2:
1743 EXPECT_TRUE(layer_->HaveBackingTexture()); 1743 EXPECT_TRUE(layer_->HaveBackingTexture());
1744 layer_tree_host()->SetNeedsCommit(); 1744 layer_tree_host()->SetNeedsCommit();
1745 break; 1745 break;
1746 case 3: 1746 case 3:
1747 break; 1747 break;
1748 case 4: 1748 case 4:
1749 EXPECT_TRUE(layer_->HaveBackingTexture()); 1749 EXPECT_TRUE(layer_->HaveBackingTexture());
1750 layer_tree_host()->SetNeedsCommit(); 1750 layer_tree_host()->SetNeedsCommit();
1751 break; 1751 break;
1752 case 5: 1752 case 5:
1753 break; 1753 break;
1754 case 6: 1754 case 6:
1755 EXPECT_TRUE(layer_->HaveBackingTexture()); 1755 EXPECT_TRUE(layer_->HaveBackingTexture());
1756 EndTest(); 1756 EndTest();
1757 break; 1757 break;
1758 default: 1758 default:
1759 NOTREACHED(); 1759 NOTREACHED();
1760 break; 1760 break;
1761 } 1761 }
1762 } 1762 }
1763 1763
1764 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1764 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
1765 impl_for_evict_textures_ = impl; 1765 impl_for_evict_textures_ = impl;
1766 } 1766 }
1767 1767
1768 virtual void Layout() OVERRIDE { 1768 virtual void Layout() override {
1769 ++num_commits_; 1769 ++num_commits_;
1770 switch (num_commits_) { 1770 switch (num_commits_) {
1771 case 1: 1771 case 1:
1772 case 2: 1772 case 2:
1773 break; 1773 break;
1774 case 3: 1774 case 3:
1775 PostEvictTextures(); 1775 PostEvictTextures();
1776 break; 1776 break;
1777 case 4: 1777 case 4:
1778 // We couldn't check in didCommitAndDrawFrame on commit 3, 1778 // We couldn't check in didCommitAndDrawFrame on commit 3,
1779 // so check here. 1779 // so check here.
1780 EXPECT_FALSE(layer_->HaveBackingTexture()); 1780 EXPECT_FALSE(layer_->HaveBackingTexture());
1781 break; 1781 break;
1782 case 5: 1782 case 5:
1783 PostEvictTextures(); 1783 PostEvictTextures();
1784 break; 1784 break;
1785 case 6: 1785 case 6:
1786 // We couldn't check in didCommitAndDrawFrame on commit 5, 1786 // We couldn't check in didCommitAndDrawFrame on commit 5,
1787 // so check here. 1787 // so check here.
1788 EXPECT_FALSE(layer_->HaveBackingTexture()); 1788 EXPECT_FALSE(layer_->HaveBackingTexture());
1789 PostEvictTextures(); 1789 PostEvictTextures();
1790 break; 1790 break;
1791 default: 1791 default:
1792 NOTREACHED(); 1792 NOTREACHED();
1793 break; 1793 break;
1794 } 1794 }
1795 } 1795 }
1796 1796
1797 virtual void AfterTest() OVERRIDE {} 1797 virtual void AfterTest() override {}
1798 1798
1799 private: 1799 private:
1800 FakeContentLayerClient client_; 1800 FakeContentLayerClient client_;
1801 scoped_refptr<EvictionTestLayer> layer_; 1801 scoped_refptr<EvictionTestLayer> layer_;
1802 LayerTreeHostImpl* impl_for_evict_textures_; 1802 LayerTreeHostImpl* impl_for_evict_textures_;
1803 int num_commits_; 1803 int num_commits_;
1804 }; 1804 };
1805 1805
1806 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestEvictTextures); 1806 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestEvictTextures);
1807 1807
1808 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { 1808 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
1809 public: 1809 public:
1810 LayerTreeHostTestContinuousInvalidate() 1810 LayerTreeHostTestContinuousInvalidate()
1811 : num_commit_complete_(0), num_draw_layers_(0) {} 1811 : num_commit_complete_(0), num_draw_layers_(0) {}
1812 1812
1813 virtual void BeginTest() OVERRIDE { 1813 virtual void BeginTest() override {
1814 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); 1814 layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
1815 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); 1815 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10));
1816 1816
1817 content_layer_ = ContentLayer::Create(&client_); 1817 content_layer_ = ContentLayer::Create(&client_);
1818 content_layer_->SetBounds(gfx::Size(10, 10)); 1818 content_layer_->SetBounds(gfx::Size(10, 10));
1819 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); 1819 content_layer_->SetPosition(gfx::PointF(0.f, 0.f));
1820 content_layer_->SetIsDrawable(true); 1820 content_layer_->SetIsDrawable(true);
1821 layer_tree_host()->root_layer()->AddChild(content_layer_); 1821 layer_tree_host()->root_layer()->AddChild(content_layer_);
1822 1822
1823 PostSetNeedsCommitToMainThread(); 1823 PostSetNeedsCommitToMainThread();
1824 } 1824 }
1825 1825
1826 virtual void DidCommitAndDrawFrame() OVERRIDE { 1826 virtual void DidCommitAndDrawFrame() override {
1827 if (num_draw_layers_ == 2) 1827 if (num_draw_layers_ == 2)
1828 return; 1828 return;
1829 content_layer_->SetNeedsDisplay(); 1829 content_layer_->SetNeedsDisplay();
1830 } 1830 }
1831 1831
1832 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1832 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
1833 if (num_draw_layers_ == 1) 1833 if (num_draw_layers_ == 1)
1834 num_commit_complete_++; 1834 num_commit_complete_++;
1835 } 1835 }
1836 1836
1837 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1837 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1838 num_draw_layers_++; 1838 num_draw_layers_++;
1839 if (num_draw_layers_ == 2) 1839 if (num_draw_layers_ == 2)
1840 EndTest(); 1840 EndTest();
1841 } 1841 }
1842 1842
1843 virtual void AfterTest() OVERRIDE { 1843 virtual void AfterTest() override {
1844 // Check that we didn't commit twice between first and second draw. 1844 // Check that we didn't commit twice between first and second draw.
1845 EXPECT_EQ(1, num_commit_complete_); 1845 EXPECT_EQ(1, num_commit_complete_);
1846 } 1846 }
1847 1847
1848 private: 1848 private:
1849 FakeContentLayerClient client_; 1849 FakeContentLayerClient client_;
1850 scoped_refptr<Layer> content_layer_; 1850 scoped_refptr<Layer> content_layer_;
1851 int num_commit_complete_; 1851 int num_commit_complete_;
1852 int num_draw_layers_; 1852 int num_draw_layers_;
1853 }; 1853 };
1854 1854
1855 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestContinuousInvalidate); 1855 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestContinuousInvalidate);
1856 1856
1857 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { 1857 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest {
1858 public: 1858 public:
1859 LayerTreeHostTestDeferCommits() 1859 LayerTreeHostTestDeferCommits()
1860 : num_commits_deferred_(0), num_complete_commits_(0) {} 1860 : num_commits_deferred_(0), num_complete_commits_(0) {}
1861 1861
1862 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1862 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1863 1863
1864 virtual void DidDeferCommit() OVERRIDE { 1864 virtual void DidDeferCommit() override {
1865 num_commits_deferred_++; 1865 num_commits_deferred_++;
1866 layer_tree_host()->SetDeferCommits(false); 1866 layer_tree_host()->SetDeferCommits(false);
1867 } 1867 }
1868 1868
1869 virtual void DidCommit() OVERRIDE { 1869 virtual void DidCommit() override {
1870 num_complete_commits_++; 1870 num_complete_commits_++;
1871 switch (num_complete_commits_) { 1871 switch (num_complete_commits_) {
1872 case 1: 1872 case 1:
1873 EXPECT_EQ(0, num_commits_deferred_); 1873 EXPECT_EQ(0, num_commits_deferred_);
1874 layer_tree_host()->SetDeferCommits(true); 1874 layer_tree_host()->SetDeferCommits(true);
1875 PostSetNeedsCommitToMainThread(); 1875 PostSetNeedsCommitToMainThread();
1876 break; 1876 break;
1877 case 2: 1877 case 2:
1878 EndTest(); 1878 EndTest();
1879 break; 1879 break;
1880 default: 1880 default:
1881 NOTREACHED(); 1881 NOTREACHED();
1882 break; 1882 break;
1883 } 1883 }
1884 } 1884 }
1885 1885
1886 virtual void AfterTest() OVERRIDE { 1886 virtual void AfterTest() override {
1887 EXPECT_EQ(1, num_commits_deferred_); 1887 EXPECT_EQ(1, num_commits_deferred_);
1888 EXPECT_EQ(2, num_complete_commits_); 1888 EXPECT_EQ(2, num_complete_commits_);
1889 } 1889 }
1890 1890
1891 private: 1891 private:
1892 int num_commits_deferred_; 1892 int num_commits_deferred_;
1893 int num_complete_commits_; 1893 int num_complete_commits_;
1894 }; 1894 };
1895 1895
1896 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); 1896 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 2049
2050 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted 2050 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
2051 : public LayerTreeHostTest { 2051 : public LayerTreeHostTest {
2052 public: 2052 public:
2053 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() 2053 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted()
2054 : root_layer_(FakeContentLayer::Create(&client_)), 2054 : root_layer_(FakeContentLayer::Create(&client_)),
2055 child_layer1_(FakeContentLayer::Create(&client_)), 2055 child_layer1_(FakeContentLayer::Create(&client_)),
2056 child_layer2_(FakeContentLayer::Create(&client_)), 2056 child_layer2_(FakeContentLayer::Create(&client_)),
2057 num_commits_(0) {} 2057 num_commits_(0) {}
2058 2058
2059 virtual void BeginTest() OVERRIDE { 2059 virtual void BeginTest() override {
2060 layer_tree_host()->SetViewportSize(gfx::Size(100, 100)); 2060 layer_tree_host()->SetViewportSize(gfx::Size(100, 100));
2061 root_layer_->SetBounds(gfx::Size(100, 100)); 2061 root_layer_->SetBounds(gfx::Size(100, 100));
2062 child_layer1_->SetBounds(gfx::Size(100, 100)); 2062 child_layer1_->SetBounds(gfx::Size(100, 100));
2063 child_layer2_->SetBounds(gfx::Size(100, 100)); 2063 child_layer2_->SetBounds(gfx::Size(100, 100));
2064 root_layer_->AddChild(child_layer1_); 2064 root_layer_->AddChild(child_layer1_);
2065 root_layer_->AddChild(child_layer2_); 2065 root_layer_->AddChild(child_layer2_);
2066 layer_tree_host()->SetRootLayer(root_layer_); 2066 layer_tree_host()->SetRootLayer(root_layer_);
2067 PostSetNeedsCommitToMainThread(); 2067 PostSetNeedsCommitToMainThread();
2068 } 2068 }
2069 2069
2070 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, 2070 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
2071 bool visible) OVERRIDE { 2071 bool visible) override {
2072 if (visible) { 2072 if (visible) {
2073 // One backing should remain unevicted. 2073 // One backing should remain unevicted.
2074 EXPECT_EQ( 2074 EXPECT_EQ(
2075 100u * 100u * 4u * 1u, 2075 100u * 100u * 4u * 1u,
2076 layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); 2076 layer_tree_host()->contents_texture_manager()->MemoryUseBytes());
2077 } else { 2077 } else {
2078 EXPECT_EQ( 2078 EXPECT_EQ(
2079 0u, layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); 2079 0u, layer_tree_host()->contents_texture_manager()->MemoryUseBytes());
2080 } 2080 }
2081 2081
2082 // Make sure that contents textures are marked as having been 2082 // Make sure that contents textures are marked as having been
2083 // purged. 2083 // purged.
2084 EXPECT_TRUE(host_impl->active_tree()->ContentsTexturesPurged()); 2084 EXPECT_TRUE(host_impl->active_tree()->ContentsTexturesPurged());
2085 // End the test in this state. 2085 // End the test in this state.
2086 EndTest(); 2086 EndTest();
2087 } 2087 }
2088 2088
2089 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2089 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
2090 ++num_commits_; 2090 ++num_commits_;
2091 switch (num_commits_) { 2091 switch (num_commits_) {
2092 case 1: 2092 case 1:
2093 // All three backings should have memory. 2093 // All three backings should have memory.
2094 EXPECT_EQ( 2094 EXPECT_EQ(
2095 100u * 100u * 4u * 3u, 2095 100u * 100u * 4u * 3u,
2096 layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); 2096 layer_tree_host()->contents_texture_manager()->MemoryUseBytes());
2097 // Set a new policy that will kick out 1 of the 3 resources. 2097 // Set a new policy that will kick out 1 of the 3 resources.
2098 // Because a resource was evicted, a commit will be kicked off. 2098 // Because a resource was evicted, a commit will be kicked off.
2099 host_impl->SetMemoryPolicy( 2099 host_impl->SetMemoryPolicy(
(...skipping 11 matching lines...) Expand all
2111 PostSetVisibleToMainThread(false); 2111 PostSetVisibleToMainThread(false);
2112 break; 2112 break;
2113 default: 2113 default:
2114 // No further commits should happen because this is not visible 2114 // No further commits should happen because this is not visible
2115 // anymore. 2115 // anymore.
2116 NOTREACHED(); 2116 NOTREACHED();
2117 break; 2117 break;
2118 } 2118 }
2119 } 2119 }
2120 2120
2121 virtual void AfterTest() OVERRIDE {} 2121 virtual void AfterTest() override {}
2122 2122
2123 private: 2123 private:
2124 FakeContentLayerClient client_; 2124 FakeContentLayerClient client_;
2125 scoped_refptr<FakeContentLayer> root_layer_; 2125 scoped_refptr<FakeContentLayer> root_layer_;
2126 scoped_refptr<FakeContentLayer> child_layer1_; 2126 scoped_refptr<FakeContentLayer> child_layer1_;
2127 scoped_refptr<FakeContentLayer> child_layer2_; 2127 scoped_refptr<FakeContentLayer> child_layer2_;
2128 int num_commits_; 2128 int num_commits_;
2129 }; 2129 };
2130 2130
2131 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( 2131 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
2132 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted); 2132 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
2133 2133
2134 class LayerTreeHostTestLCDNotification : public LayerTreeHostTest { 2134 class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
2135 public: 2135 public:
2136 class NotificationClient : public ContentLayerClient { 2136 class NotificationClient : public ContentLayerClient {
2137 public: 2137 public:
2138 NotificationClient() 2138 NotificationClient()
2139 : layer_(0), paint_count_(0), lcd_notification_count_(0) {} 2139 : layer_(0), paint_count_(0), lcd_notification_count_(0) {}
2140 2140
2141 void set_layer(Layer* layer) { layer_ = layer; } 2141 void set_layer(Layer* layer) { layer_ = layer; }
2142 int paint_count() const { return paint_count_; } 2142 int paint_count() const { return paint_count_; }
2143 int lcd_notification_count() const { return lcd_notification_count_; } 2143 int lcd_notification_count() const { return lcd_notification_count_; }
2144 2144
2145 virtual void PaintContents( 2145 virtual void PaintContents(
2146 SkCanvas* canvas, 2146 SkCanvas* canvas,
2147 const gfx::Rect& clip, 2147 const gfx::Rect& clip,
2148 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE { 2148 ContentLayerClient::GraphicsContextStatus gc_status) override {
2149 ++paint_count_; 2149 ++paint_count_;
2150 } 2150 }
2151 virtual void DidChangeLayerCanUseLCDText() OVERRIDE { 2151 virtual void DidChangeLayerCanUseLCDText() override {
2152 ++lcd_notification_count_; 2152 ++lcd_notification_count_;
2153 layer_->SetNeedsDisplay(); 2153 layer_->SetNeedsDisplay();
2154 } 2154 }
2155 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } 2155 virtual bool FillsBoundsCompletely() const override { return false; }
2156 2156
2157 private: 2157 private:
2158 Layer* layer_; 2158 Layer* layer_;
2159 int paint_count_; 2159 int paint_count_;
2160 int lcd_notification_count_; 2160 int lcd_notification_count_;
2161 }; 2161 };
2162 2162
2163 virtual void SetupTree() OVERRIDE { 2163 virtual void SetupTree() override {
2164 scoped_refptr<Layer> root_layer; 2164 scoped_refptr<Layer> root_layer;
2165 if (layer_tree_host()->settings().impl_side_painting) 2165 if (layer_tree_host()->settings().impl_side_painting)
2166 root_layer = PictureLayer::Create(&client_); 2166 root_layer = PictureLayer::Create(&client_);
2167 else 2167 else
2168 root_layer = ContentLayer::Create(&client_); 2168 root_layer = ContentLayer::Create(&client_);
2169 root_layer->SetIsDrawable(true); 2169 root_layer->SetIsDrawable(true);
2170 root_layer->SetBounds(gfx::Size(1, 1)); 2170 root_layer->SetBounds(gfx::Size(1, 1));
2171 2171
2172 layer_tree_host()->SetRootLayer(root_layer); 2172 layer_tree_host()->SetRootLayer(root_layer);
2173 client_.set_layer(root_layer.get()); 2173 client_.set_layer(root_layer.get());
2174 2174
2175 // The expecations are based on the assumption that the default 2175 // The expecations are based on the assumption that the default
2176 // LCD settings are: 2176 // LCD settings are:
2177 EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text); 2177 EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text);
2178 EXPECT_FALSE(root_layer->can_use_lcd_text()); 2178 EXPECT_FALSE(root_layer->can_use_lcd_text());
2179 2179
2180 LayerTreeHostTest::SetupTree(); 2180 LayerTreeHostTest::SetupTree();
2181 } 2181 }
2182 2182
2183 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2183 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2184 virtual void AfterTest() OVERRIDE {} 2184 virtual void AfterTest() override {}
2185 2185
2186 virtual void DidCommit() OVERRIDE { 2186 virtual void DidCommit() override {
2187 switch (layer_tree_host()->source_frame_number()) { 2187 switch (layer_tree_host()->source_frame_number()) {
2188 case 1: 2188 case 1:
2189 // The first update consists of one LCD notification and one paint. 2189 // The first update consists of one LCD notification and one paint.
2190 EXPECT_EQ(1, client_.lcd_notification_count()); 2190 EXPECT_EQ(1, client_.lcd_notification_count());
2191 EXPECT_EQ(1, client_.paint_count()); 2191 EXPECT_EQ(1, client_.paint_count());
2192 // LCD text must have been enabled on the layer. 2192 // LCD text must have been enabled on the layer.
2193 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); 2193 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
2194 PostSetNeedsCommitToMainThread(); 2194 PostSetNeedsCommitToMainThread();
2195 break; 2195 break;
2196 case 2: 2196 case 2:
(...skipping 24 matching lines...) Expand all
2221 2221
2222 private: 2222 private:
2223 NotificationClient client_; 2223 NotificationClient client_;
2224 }; 2224 };
2225 2225
2226 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); 2226 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
2227 2227
2228 // Verify that the BeginFrame notification is used to initiate rendering. 2228 // Verify that the BeginFrame notification is used to initiate rendering.
2229 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { 2229 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
2230 public: 2230 public:
2231 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2231 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2232 settings->begin_frame_scheduling_enabled = true; 2232 settings->begin_frame_scheduling_enabled = true;
2233 } 2233 }
2234 2234
2235 virtual void BeginTest() OVERRIDE { 2235 virtual void BeginTest() override {
2236 // This will trigger a SetNeedsBeginFrame which will trigger a 2236 // This will trigger a SetNeedsBeginFrame which will trigger a
2237 // BeginFrame. 2237 // BeginFrame.
2238 PostSetNeedsCommitToMainThread(); 2238 PostSetNeedsCommitToMainThread();
2239 } 2239 }
2240 2240
2241 virtual DrawResult PrepareToDrawOnThread( 2241 virtual DrawResult PrepareToDrawOnThread(
2242 LayerTreeHostImpl* host_impl, 2242 LayerTreeHostImpl* host_impl,
2243 LayerTreeHostImpl::FrameData* frame, 2243 LayerTreeHostImpl::FrameData* frame,
2244 DrawResult draw_result) OVERRIDE { 2244 DrawResult draw_result) override {
2245 EndTest(); 2245 EndTest();
2246 return DRAW_SUCCESS; 2246 return DRAW_SUCCESS;
2247 } 2247 }
2248 2248
2249 virtual void AfterTest() OVERRIDE {} 2249 virtual void AfterTest() override {}
2250 2250
2251 private: 2251 private:
2252 base::TimeTicks frame_time_; 2252 base::TimeTicks frame_time_;
2253 }; 2253 };
2254 2254
2255 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); 2255 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification);
2256 2256
2257 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled 2257 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
2258 : public LayerTreeHostTest { 2258 : public LayerTreeHostTest {
2259 public: 2259 public:
2260 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2260 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2261 settings->begin_frame_scheduling_enabled = true; 2261 settings->begin_frame_scheduling_enabled = true;
2262 settings->using_synchronous_renderer_compositor = true; 2262 settings->using_synchronous_renderer_compositor = true;
2263 } 2263 }
2264 2264
2265 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2265 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2266 2266
2267 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2267 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
2268 // The BeginFrame notification is turned off now but will get enabled 2268 // The BeginFrame notification is turned off now but will get enabled
2269 // once we return. End test while it's enabled. 2269 // once we return. End test while it's enabled.
2270 ImplThreadTaskRunner()->PostTask( 2270 ImplThreadTaskRunner()->PostTask(
2271 FROM_HERE, 2271 FROM_HERE,
2272 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, 2272 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest,
2273 base::Unretained(this))); 2273 base::Unretained(this)));
2274 } 2274 }
2275 2275
2276 virtual void AfterTest() OVERRIDE {} 2276 virtual void AfterTest() override {}
2277 }; 2277 };
2278 2278
2279 MULTI_THREAD_TEST_F( 2279 MULTI_THREAD_TEST_F(
2280 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); 2280 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled);
2281 2281
2282 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { 2282 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest {
2283 protected: 2283 protected:
2284 LayerTreeHostTestAbortedCommitDoesntStall() 2284 LayerTreeHostTestAbortedCommitDoesntStall()
2285 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} 2285 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {}
2286 2286
2287 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2287 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2288 settings->begin_frame_scheduling_enabled = true; 2288 settings->begin_frame_scheduling_enabled = true;
2289 } 2289 }
2290 2290
2291 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2291 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2292 2292
2293 virtual void DidCommit() OVERRIDE { 2293 virtual void DidCommit() override {
2294 commit_count_++; 2294 commit_count_++;
2295 if (commit_count_ == 4) { 2295 if (commit_count_ == 4) {
2296 // After two aborted commits, request a real commit now to make sure a 2296 // After two aborted commits, request a real commit now to make sure a
2297 // real commit following an aborted commit will still complete and 2297 // real commit following an aborted commit will still complete and
2298 // end the test even when the Impl thread is idle. 2298 // end the test even when the Impl thread is idle.
2299 layer_tree_host()->SetNeedsCommit(); 2299 layer_tree_host()->SetNeedsCommit();
2300 } 2300 }
2301 } 2301 }
2302 2302
2303 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, 2303 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
2304 bool did_handle) OVERRIDE { 2304 bool did_handle) override {
2305 commit_abort_count_++; 2305 commit_abort_count_++;
2306 // Initiate another abortable commit. 2306 // Initiate another abortable commit.
2307 host_impl->SetNeedsCommit(); 2307 host_impl->SetNeedsCommit();
2308 } 2308 }
2309 2309
2310 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2310 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
2311 commit_complete_count_++; 2311 commit_complete_count_++;
2312 if (commit_complete_count_ == 1) { 2312 if (commit_complete_count_ == 1) {
2313 // Initiate an abortable commit after the first commit. 2313 // Initiate an abortable commit after the first commit.
2314 host_impl->SetNeedsCommit(); 2314 host_impl->SetNeedsCommit();
2315 } else { 2315 } else {
2316 EndTest(); 2316 EndTest();
2317 } 2317 }
2318 } 2318 }
2319 2319
2320 virtual void AfterTest() OVERRIDE { 2320 virtual void AfterTest() override {
2321 EXPECT_EQ(commit_count_, 5); 2321 EXPECT_EQ(commit_count_, 5);
2322 EXPECT_EQ(commit_abort_count_, 3); 2322 EXPECT_EQ(commit_abort_count_, 3);
2323 EXPECT_EQ(commit_complete_count_, 2); 2323 EXPECT_EQ(commit_complete_count_, 2);
2324 } 2324 }
2325 2325
2326 int commit_count_; 2326 int commit_count_;
2327 int commit_abort_count_; 2327 int commit_abort_count_;
2328 int commit_complete_count_; 2328 int commit_complete_count_;
2329 }; 2329 };
2330 2330
2331 class LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor 2331 class LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor
2332 : public LayerTreeHostTestAbortedCommitDoesntStall { 2332 : public LayerTreeHostTestAbortedCommitDoesntStall {
2333 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2333 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2334 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); 2334 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings);
2335 settings->using_synchronous_renderer_compositor = true; 2335 settings->using_synchronous_renderer_compositor = true;
2336 } 2336 }
2337 }; 2337 };
2338 2338
2339 MULTI_THREAD_TEST_F( 2339 MULTI_THREAD_TEST_F(
2340 LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor); 2340 LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor);
2341 2341
2342 class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync 2342 class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync
2343 : public LayerTreeHostTestAbortedCommitDoesntStall { 2343 : public LayerTreeHostTestAbortedCommitDoesntStall {
2344 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2344 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2345 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); 2345 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings);
2346 settings->throttle_frame_production = false; 2346 settings->throttle_frame_production = false;
2347 } 2347 }
2348 }; 2348 };
2349 2349
2350 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync); 2350 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync);
2351 2351
2352 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation 2352 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation
2353 : public LayerTreeHostTest { 2353 : public LayerTreeHostTest {
2354 protected: 2354 protected:
2355 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2355 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2356 settings->impl_side_painting = true; 2356 settings->impl_side_painting = true;
2357 } 2357 }
2358 2358
2359 virtual void SetupTree() OVERRIDE { 2359 virtual void SetupTree() override {
2360 LayerTreeHostTest::SetupTree(); 2360 LayerTreeHostTest::SetupTree();
2361 2361
2362 scoped_refptr<Layer> layer = PictureLayer::Create(&client_); 2362 scoped_refptr<Layer> layer = PictureLayer::Create(&client_);
2363 layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); 2363 layer->SetTransform(gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
2364 layer->SetBounds(gfx::Size(10, 10)); 2364 layer->SetBounds(gfx::Size(10, 10));
2365 layer_tree_host()->root_layer()->AddChild(layer); 2365 layer_tree_host()->root_layer()->AddChild(layer);
2366 } 2366 }
2367 2367
2368 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2368 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2369 2369
2370 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2370 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
2371 EndTest(); 2371 EndTest();
2372 } 2372 }
2373 2373
2374 virtual void AfterTest() OVERRIDE {} 2374 virtual void AfterTest() override {}
2375 2375
2376 FakeContentLayerClient client_; 2376 FakeContentLayerClient client_;
2377 }; 2377 };
2378 2378
2379 MULTI_THREAD_TEST_F( 2379 MULTI_THREAD_TEST_F(
2380 LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation); 2380 LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation);
2381 2381
2382 class LayerTreeHostTestChangeLayerPropertiesInPaintContents 2382 class LayerTreeHostTestChangeLayerPropertiesInPaintContents
2383 : public LayerTreeHostTest { 2383 : public LayerTreeHostTest {
2384 public: 2384 public:
2385 class SetBoundsClient : public ContentLayerClient { 2385 class SetBoundsClient : public ContentLayerClient {
2386 public: 2386 public:
2387 SetBoundsClient() : layer_(0) {} 2387 SetBoundsClient() : layer_(0) {}
2388 2388
2389 void set_layer(Layer* layer) { layer_ = layer; } 2389 void set_layer(Layer* layer) { layer_ = layer; }
2390 2390
2391 virtual void PaintContents( 2391 virtual void PaintContents(
2392 SkCanvas* canvas, 2392 SkCanvas* canvas,
2393 const gfx::Rect& clip, 2393 const gfx::Rect& clip,
2394 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE { 2394 ContentLayerClient::GraphicsContextStatus gc_status) override {
2395 layer_->SetBounds(gfx::Size(2, 2)); 2395 layer_->SetBounds(gfx::Size(2, 2));
2396 } 2396 }
2397 2397
2398 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} 2398 virtual void DidChangeLayerCanUseLCDText() override {}
2399 2399
2400 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } 2400 virtual bool FillsBoundsCompletely() const override { return false; }
2401 2401
2402 private: 2402 private:
2403 Layer* layer_; 2403 Layer* layer_;
2404 }; 2404 };
2405 2405
2406 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} 2406 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {}
2407 2407
2408 virtual void SetupTree() OVERRIDE { 2408 virtual void SetupTree() override {
2409 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); 2409 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_);
2410 root_layer->SetIsDrawable(true); 2410 root_layer->SetIsDrawable(true);
2411 root_layer->SetBounds(gfx::Size(1, 1)); 2411 root_layer->SetBounds(gfx::Size(1, 1));
2412 2412
2413 layer_tree_host()->SetRootLayer(root_layer); 2413 layer_tree_host()->SetRootLayer(root_layer);
2414 client_.set_layer(root_layer.get()); 2414 client_.set_layer(root_layer.get());
2415 2415
2416 LayerTreeHostTest::SetupTree(); 2416 LayerTreeHostTest::SetupTree();
2417 } 2417 }
2418 2418
2419 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2419 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2420 virtual void AfterTest() OVERRIDE {} 2420 virtual void AfterTest() override {}
2421 2421
2422 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2422 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
2423 num_commits_++; 2423 num_commits_++;
2424 if (num_commits_ == 1) { 2424 if (num_commits_ == 1) {
2425 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2425 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2426 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); 2426 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds());
2427 } else { 2427 } else {
2428 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2428 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2429 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); 2429 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds());
2430 EndTest(); 2430 EndTest();
2431 } 2431 }
2432 } 2432 }
2433 2433
2434 private: 2434 private:
2435 SetBoundsClient client_; 2435 SetBoundsClient client_;
2436 int num_commits_; 2436 int num_commits_;
2437 }; 2437 };
2438 2438
2439 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); 2439 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents);
2440 2440
2441 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { 2441 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D {
2442 public: 2442 public:
2443 MockIOSurfaceWebGraphicsContext3D() { 2443 MockIOSurfaceWebGraphicsContext3D() {
2444 test_capabilities_.gpu.iosurface = true; 2444 test_capabilities_.gpu.iosurface = true;
2445 test_capabilities_.gpu.texture_rectangle = true; 2445 test_capabilities_.gpu.texture_rectangle = true;
2446 } 2446 }
2447 2447
2448 virtual GLuint createTexture() OVERRIDE { 2448 virtual GLuint createTexture() override {
2449 return 1; 2449 return 1;
2450 } 2450 }
2451 MOCK_METHOD1(activeTexture, void(GLenum texture)); 2451 MOCK_METHOD1(activeTexture, void(GLenum texture));
2452 MOCK_METHOD2(bindTexture, void(GLenum target, 2452 MOCK_METHOD2(bindTexture, void(GLenum target,
2453 GLuint texture_id)); 2453 GLuint texture_id));
2454 MOCK_METHOD3(texParameteri, void(GLenum target, 2454 MOCK_METHOD3(texParameteri, void(GLenum target,
2455 GLenum pname, 2455 GLenum pname,
2456 GLint param)); 2456 GLint param));
2457 MOCK_METHOD5(texImageIOSurface2DCHROMIUM, void(GLenum target, 2457 MOCK_METHOD5(texImageIOSurface2DCHROMIUM, void(GLenum target,
2458 GLint width, 2458 GLint width,
2459 GLint height, 2459 GLint height,
2460 GLuint ioSurfaceId, 2460 GLuint ioSurfaceId,
2461 GLuint plane)); 2461 GLuint plane));
2462 MOCK_METHOD4(drawElements, void(GLenum mode, 2462 MOCK_METHOD4(drawElements, void(GLenum mode,
2463 GLsizei count, 2463 GLsizei count,
2464 GLenum type, 2464 GLenum type,
2465 GLintptr offset)); 2465 GLintptr offset));
2466 MOCK_METHOD1(deleteTexture, void(GLenum texture)); 2466 MOCK_METHOD1(deleteTexture, void(GLenum texture));
2467 MOCK_METHOD2(produceTextureCHROMIUM, 2467 MOCK_METHOD2(produceTextureCHROMIUM,
2468 void(GLenum target, const GLbyte* mailbox)); 2468 void(GLenum target, const GLbyte* mailbox));
2469 }; 2469 };
2470 2470
2471 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { 2471 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
2472 protected: 2472 protected:
2473 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) 2473 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
2474 OVERRIDE { 2474 override {
2475 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( 2475 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned(
2476 new MockIOSurfaceWebGraphicsContext3D); 2476 new MockIOSurfaceWebGraphicsContext3D);
2477 mock_context_ = mock_context_owned.get(); 2477 mock_context_ = mock_context_owned.get();
2478 2478
2479 if (delegating_renderer()) 2479 if (delegating_renderer())
2480 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); 2480 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass());
2481 else 2481 else
2482 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); 2482 return FakeOutputSurface::Create3d(mock_context_owned.Pass());
2483 } 2483 }
2484 2484
2485 virtual void SetupTree() OVERRIDE { 2485 virtual void SetupTree() override {
2486 LayerTreeHostTest::SetupTree(); 2486 LayerTreeHostTest::SetupTree();
2487 2487
2488 layer_tree_host()->root_layer()->SetIsDrawable(false); 2488 layer_tree_host()->root_layer()->SetIsDrawable(false);
2489 2489
2490 io_surface_id_ = 9; 2490 io_surface_id_ = 9;
2491 io_surface_size_ = gfx::Size(6, 7); 2491 io_surface_size_ = gfx::Size(6, 7);
2492 2492
2493 scoped_refptr<IOSurfaceLayer> io_surface_layer = IOSurfaceLayer::Create(); 2493 scoped_refptr<IOSurfaceLayer> io_surface_layer = IOSurfaceLayer::Create();
2494 io_surface_layer->SetBounds(gfx::Size(10, 10)); 2494 io_surface_layer->SetBounds(gfx::Size(10, 10));
2495 io_surface_layer->SetIsDrawable(true); 2495 io_surface_layer->SetIsDrawable(true);
2496 io_surface_layer->SetContentsOpaque(true); 2496 io_surface_layer->SetContentsOpaque(true);
2497 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); 2497 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_);
2498 layer_tree_host()->root_layer()->AddChild(io_surface_layer); 2498 layer_tree_host()->root_layer()->AddChild(io_surface_layer);
2499 } 2499 }
2500 2500
2501 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2501 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2502 2502
2503 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2503 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
2504 EXPECT_EQ(0u, host_impl->resource_provider()->num_resources()); 2504 EXPECT_EQ(0u, host_impl->resource_provider()->num_resources());
2505 // In WillDraw, the IOSurfaceLayer sets up the io surface texture. 2505 // In WillDraw, the IOSurfaceLayer sets up the io surface texture.
2506 2506
2507 EXPECT_CALL(*mock_context_, activeTexture(_)).Times(0); 2507 EXPECT_CALL(*mock_context_, activeTexture(_)).Times(0);
2508 EXPECT_CALL(*mock_context_, bindTexture(GL_TEXTURE_RECTANGLE_ARB, 1)) 2508 EXPECT_CALL(*mock_context_, bindTexture(GL_TEXTURE_RECTANGLE_ARB, 1))
2509 .Times(AtLeast(1)); 2509 .Times(AtLeast(1));
2510 EXPECT_CALL(*mock_context_, 2510 EXPECT_CALL(*mock_context_,
2511 texParameteri( 2511 texParameteri(
2512 GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR)) 2512 GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR))
2513 .Times(1); 2513 .Times(1);
(...skipping 20 matching lines...) Expand all
2534 io_surface_size_.height(), 2534 io_surface_size_.height(),
2535 io_surface_id_, 2535 io_surface_id_,
2536 0)).Times(1); 2536 0)).Times(1);
2537 2537
2538 EXPECT_CALL(*mock_context_, bindTexture(_, 0)).Times(AnyNumber()); 2538 EXPECT_CALL(*mock_context_, bindTexture(_, 0)).Times(AnyNumber());
2539 } 2539 }
2540 2540
2541 virtual DrawResult PrepareToDrawOnThread( 2541 virtual DrawResult PrepareToDrawOnThread(
2542 LayerTreeHostImpl* host_impl, 2542 LayerTreeHostImpl* host_impl,
2543 LayerTreeHostImpl::FrameData* frame, 2543 LayerTreeHostImpl::FrameData* frame,
2544 DrawResult draw_result) OVERRIDE { 2544 DrawResult draw_result) override {
2545 Mock::VerifyAndClearExpectations(&mock_context_); 2545 Mock::VerifyAndClearExpectations(&mock_context_);
2546 ResourceProvider* resource_provider = host_impl->resource_provider(); 2546 ResourceProvider* resource_provider = host_impl->resource_provider();
2547 EXPECT_EQ(1u, resource_provider->num_resources()); 2547 EXPECT_EQ(1u, resource_provider->num_resources());
2548 CHECK_EQ(1u, frame->render_passes.size()); 2548 CHECK_EQ(1u, frame->render_passes.size());
2549 CHECK_LE(1u, frame->render_passes[0]->quad_list.size()); 2549 CHECK_LE(1u, frame->render_passes[0]->quad_list.size());
2550 const DrawQuad* quad = frame->render_passes[0]->quad_list.front(); 2550 const DrawQuad* quad = frame->render_passes[0]->quad_list.front();
2551 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material); 2551 CHECK_EQ(DrawQuad::IO_SURFACE_CONTENT, quad->material);
2552 const IOSurfaceDrawQuad* io_surface_draw_quad = 2552 const IOSurfaceDrawQuad* io_surface_draw_quad =
2553 IOSurfaceDrawQuad::MaterialCast(quad); 2553 IOSurfaceDrawQuad::MaterialCast(quad);
2554 EXPECT_SIZE_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size); 2554 EXPECT_SIZE_EQ(io_surface_size_, io_surface_draw_quad->io_surface_size);
(...skipping 11 matching lines...) Expand all
2566 } else { 2566 } else {
2567 // The io surface layer's texture is drawn. 2567 // The io surface layer's texture is drawn.
2568 EXPECT_CALL(*mock_context_, activeTexture(GL_TEXTURE0)).Times(AtLeast(1)); 2568 EXPECT_CALL(*mock_context_, activeTexture(GL_TEXTURE0)).Times(AtLeast(1));
2569 EXPECT_CALL(*mock_context_, drawElements(GL_TRIANGLES, 6, _, _)) 2569 EXPECT_CALL(*mock_context_, drawElements(GL_TRIANGLES, 6, _, _))
2570 .Times(AtLeast(1)); 2570 .Times(AtLeast(1));
2571 } 2571 }
2572 2572
2573 return draw_result; 2573 return draw_result;
2574 } 2574 }
2575 2575
2576 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2576 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
2577 Mock::VerifyAndClearExpectations(&mock_context_); 2577 Mock::VerifyAndClearExpectations(&mock_context_);
2578 2578
2579 EXPECT_CALL(*mock_context_, deleteTexture(1)).Times(AtLeast(1)); 2579 EXPECT_CALL(*mock_context_, deleteTexture(1)).Times(AtLeast(1));
2580 EndTest(); 2580 EndTest();
2581 } 2581 }
2582 2582
2583 virtual void AfterTest() OVERRIDE {} 2583 virtual void AfterTest() override {}
2584 2584
2585 int io_surface_id_; 2585 int io_surface_id_;
2586 MockIOSurfaceWebGraphicsContext3D* mock_context_; 2586 MockIOSurfaceWebGraphicsContext3D* mock_context_;
2587 gfx::Size io_surface_size_; 2587 gfx::Size io_surface_size_;
2588 }; 2588 };
2589 2589
2590 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestIOSurfaceDrawing); 2590 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestIOSurfaceDrawing);
2591 2591
2592 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { 2592 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
2593 public: 2593 public:
2594 virtual void BeginTest() OVERRIDE { 2594 virtual void BeginTest() override {
2595 frame_ = 0; 2595 frame_ = 0;
2596 PostSetNeedsCommitToMainThread(); 2596 PostSetNeedsCommitToMainThread();
2597 } 2597 }
2598 2598
2599 // Round 1: commit + draw 2599 // Round 1: commit + draw
2600 // Round 2: commit only (no draw/swap) 2600 // Round 2: commit only (no draw/swap)
2601 // Round 3: draw only (no commit) 2601 // Round 3: draw only (no commit)
2602 2602
2603 virtual void DidCommit() OVERRIDE { 2603 virtual void DidCommit() override {
2604 int commit = layer_tree_host()->source_frame_number(); 2604 int commit = layer_tree_host()->source_frame_number();
2605 switch (commit) { 2605 switch (commit) {
2606 case 2: 2606 case 2:
2607 // Round 2 done. 2607 // Round 2 done.
2608 EXPECT_EQ(1, frame_); 2608 EXPECT_EQ(1, frame_);
2609 layer_tree_host()->SetNeedsRedraw(); 2609 layer_tree_host()->SetNeedsRedraw();
2610 break; 2610 break;
2611 } 2611 }
2612 } 2612 }
2613 2613
2614 virtual void DidCompleteSwapBuffers() OVERRIDE { 2614 virtual void DidCompleteSwapBuffers() override {
2615 int commit = layer_tree_host()->source_frame_number(); 2615 int commit = layer_tree_host()->source_frame_number();
2616 ++frame_; 2616 ++frame_;
2617 switch (frame_) { 2617 switch (frame_) {
2618 case 1: 2618 case 1:
2619 // Round 1 done. 2619 // Round 1 done.
2620 EXPECT_EQ(1, commit); 2620 EXPECT_EQ(1, commit);
2621 layer_tree_host()->SetNeedsCommit(); 2621 layer_tree_host()->SetNeedsCommit();
2622 break; 2622 break;
2623 case 2: 2623 case 2:
2624 // Round 3 done. 2624 // Round 3 done.
2625 EXPECT_EQ(2, commit); 2625 EXPECT_EQ(2, commit);
2626 EndTest(); 2626 EndTest();
2627 break; 2627 break;
2628 } 2628 }
2629 } 2629 }
2630 2630
2631 virtual void AfterTest() OVERRIDE {} 2631 virtual void AfterTest() override {}
2632 2632
2633 protected: 2633 protected:
2634 int frame_; 2634 int frame_;
2635 }; 2635 };
2636 2636
2637 // Flaky on all platforms: http://crbug.com/327498 2637 // Flaky on all platforms: http://crbug.com/327498
2638 TEST_F(LayerTreeHostTestNumFramesPending, DISABLED_DelegatingRenderer) { 2638 TEST_F(LayerTreeHostTestNumFramesPending, DISABLED_DelegatingRenderer) {
2639 RunTest(true, true, true); 2639 RunTest(true, true, true);
2640 } 2640 }
2641 2641
2642 TEST_F(LayerTreeHostTestNumFramesPending, DISABLED_GLRenderer) { 2642 TEST_F(LayerTreeHostTestNumFramesPending, DISABLED_GLRenderer) {
2643 RunTest(true, false, true); 2643 RunTest(true, false, true);
2644 } 2644 }
2645 2645
2646 class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest { 2646 class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest {
2647 public: 2647 public:
2648 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2648 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2649 // PictureLayer can only be used with impl side painting enabled. 2649 // PictureLayer can only be used with impl side painting enabled.
2650 settings->impl_side_painting = true; 2650 settings->impl_side_painting = true;
2651 } 2651 }
2652 2652
2653 virtual void SetupTree() OVERRIDE { 2653 virtual void SetupTree() override {
2654 layer_ = FakePictureLayer::Create(&client_); 2654 layer_ = FakePictureLayer::Create(&client_);
2655 // Force commits to not be aborted so new frames get drawn, otherwise 2655 // Force commits to not be aborted so new frames get drawn, otherwise
2656 // the renderer gets deferred initialized but nothing new needs drawing. 2656 // the renderer gets deferred initialized but nothing new needs drawing.
2657 layer_->set_always_update_resources(true); 2657 layer_->set_always_update_resources(true);
2658 layer_tree_host()->SetRootLayer(layer_); 2658 layer_tree_host()->SetRootLayer(layer_);
2659 LayerTreeHostTest::SetupTree(); 2659 LayerTreeHostTest::SetupTree();
2660 } 2660 }
2661 2661
2662 virtual void BeginTest() OVERRIDE { 2662 virtual void BeginTest() override {
2663 did_initialize_gl_ = false; 2663 did_initialize_gl_ = false;
2664 did_release_gl_ = false; 2664 did_release_gl_ = false;
2665 last_source_frame_number_drawn_ = -1; // Never drawn. 2665 last_source_frame_number_drawn_ = -1; // Never drawn.
2666 PostSetNeedsCommitToMainThread(); 2666 PostSetNeedsCommitToMainThread();
2667 } 2667 }
2668 2668
2669 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) 2669 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
2670 OVERRIDE { 2670 override {
2671 scoped_ptr<TestWebGraphicsContext3D> context3d( 2671 scoped_ptr<TestWebGraphicsContext3D> context3d(
2672 TestWebGraphicsContext3D::Create()); 2672 TestWebGraphicsContext3D::Create());
2673 2673
2674 return FakeOutputSurface::CreateDeferredGL( 2674 return FakeOutputSurface::CreateDeferredGL(
2675 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), 2675 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice),
2676 delegating_renderer()); 2676 delegating_renderer());
2677 } 2677 }
2678 2678
2679 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2679 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
2680 ASSERT_TRUE(host_impl->RootLayer()); 2680 ASSERT_TRUE(host_impl->RootLayer());
2681 FakePictureLayerImpl* layer_impl = 2681 FakePictureLayerImpl* layer_impl =
2682 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); 2682 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer());
2683 2683
2684 // The same frame can be draw multiple times if new visible tiles are 2684 // The same frame can be draw multiple times if new visible tiles are
2685 // rasterized. But we want to make sure we only post DeferredInitialize 2685 // rasterized. But we want to make sure we only post DeferredInitialize
2686 // and ReleaseGL once, so early out if the same frame is drawn again. 2686 // and ReleaseGL once, so early out if the same frame is drawn again.
2687 if (last_source_frame_number_drawn_ == 2687 if (last_source_frame_number_drawn_ ==
2688 host_impl->active_tree()->source_frame_number()) 2688 host_impl->active_tree()->source_frame_number())
2689 return; 2689 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 2726
2727 void ReleaseGLAndRedraw(LayerTreeHostImpl* host_impl) { 2727 void ReleaseGLAndRedraw(LayerTreeHostImpl* host_impl) {
2728 EXPECT_TRUE(did_initialize_gl_); 2728 EXPECT_TRUE(did_initialize_gl_);
2729 EXPECT_FALSE(did_release_gl_); 2729 EXPECT_FALSE(did_release_gl_);
2730 // ReleaseGL calls SetNeedsCommit. 2730 // ReleaseGL calls SetNeedsCommit.
2731 static_cast<FakeOutputSurface*>(host_impl->output_surface())->ReleaseGL(); 2731 static_cast<FakeOutputSurface*>(host_impl->output_surface())->ReleaseGL();
2732 did_release_gl_ = true; 2732 did_release_gl_ = true;
2733 } 2733 }
2734 2734
2735 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 2735 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
2736 bool result) OVERRIDE { 2736 bool result) override {
2737 ASSERT_TRUE(result); 2737 ASSERT_TRUE(result);
2738 DelegatedFrameData* delegated_frame_data = 2738 DelegatedFrameData* delegated_frame_data =
2739 output_surface()->last_sent_frame().delegated_frame_data.get(); 2739 output_surface()->last_sent_frame().delegated_frame_data.get();
2740 if (!delegated_frame_data) 2740 if (!delegated_frame_data)
2741 return; 2741 return;
2742 2742
2743 // Return all resources immediately. 2743 // Return all resources immediately.
2744 TransferableResourceArray resources_to_return = 2744 TransferableResourceArray resources_to_return =
2745 output_surface()->resources_held_by_parent(); 2745 output_surface()->resources_held_by_parent();
2746 2746
2747 CompositorFrameAck ack; 2747 CompositorFrameAck ack;
2748 for (size_t i = 0; i < resources_to_return.size(); ++i) 2748 for (size_t i = 0; i < resources_to_return.size(); ++i)
2749 output_surface()->ReturnResource(resources_to_return[i].id, &ack); 2749 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
2750 host_impl->ReclaimResources(&ack); 2750 host_impl->ReclaimResources(&ack);
2751 } 2751 }
2752 2752
2753 virtual void AfterTest() OVERRIDE { 2753 virtual void AfterTest() override {
2754 EXPECT_TRUE(did_initialize_gl_); 2754 EXPECT_TRUE(did_initialize_gl_);
2755 EXPECT_TRUE(did_release_gl_); 2755 EXPECT_TRUE(did_release_gl_);
2756 } 2756 }
2757 2757
2758 private: 2758 private:
2759 FakeContentLayerClient client_; 2759 FakeContentLayerClient client_;
2760 scoped_refptr<FakePictureLayer> layer_; 2760 scoped_refptr<FakePictureLayer> layer_;
2761 bool did_initialize_gl_; 2761 bool did_initialize_gl_;
2762 bool did_release_gl_; 2762 bool did_release_gl_;
2763 int last_source_frame_number_drawn_; 2763 int last_source_frame_number_drawn_;
2764 }; 2764 };
2765 2765
2766 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); 2766 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2767 2767
2768 class LayerTreeHostTestDeferredInitializeWithGpuRasterization 2768 class LayerTreeHostTestDeferredInitializeWithGpuRasterization
2769 : public LayerTreeHostTestDeferredInitialize { 2769 : public LayerTreeHostTestDeferredInitialize {
2770 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2770 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2771 // PictureLayer can only be used with impl side painting enabled. 2771 // PictureLayer can only be used with impl side painting enabled.
2772 settings->impl_side_painting = true; 2772 settings->impl_side_painting = true;
2773 settings->gpu_rasterization_enabled = true; 2773 settings->gpu_rasterization_enabled = true;
2774 settings->gpu_rasterization_forced = true; 2774 settings->gpu_rasterization_forced = true;
2775 } 2775 }
2776 }; 2776 };
2777 2777
2778 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitializeWithGpuRasterization); 2778 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitializeWithGpuRasterization);
2779 2779
2780 // Test for UI Resource management. 2780 // Test for UI Resource management.
2781 class LayerTreeHostTestUIResource : public LayerTreeHostTest { 2781 class LayerTreeHostTestUIResource : public LayerTreeHostTest {
2782 public: 2782 public:
2783 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} 2783 LayerTreeHostTestUIResource() : num_ui_resources_(0) {}
2784 2784
2785 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2785 virtual void InitializeSettings(LayerTreeSettings* settings) override {
2786 settings->texture_id_allocation_chunk_size = 1; 2786 settings->texture_id_allocation_chunk_size = 1;
2787 } 2787 }
2788 2788
2789 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2789 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2790 2790
2791 virtual void DidCommit() OVERRIDE { 2791 virtual void DidCommit() override {
2792 int frame = layer_tree_host()->source_frame_number(); 2792 int frame = layer_tree_host()->source_frame_number();
2793 switch (frame) { 2793 switch (frame) {
2794 case 1: 2794 case 1:
2795 CreateResource(); 2795 CreateResource();
2796 CreateResource(); 2796 CreateResource();
2797 PostSetNeedsCommitToMainThread(); 2797 PostSetNeedsCommitToMainThread();
2798 break; 2798 break;
2799 case 2: 2799 case 2:
2800 // Usually ScopedUIResource are deleted from the manager in their 2800 // Usually ScopedUIResource are deleted from the manager in their
2801 // destructor. Here we just want to test that a direct call to 2801 // destructor. Here we just want to test that a direct call to
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 ASSERT_EQ(1u, context->NumTextures()); 2842 ASSERT_EQ(1u, context->NumTextures());
2843 break; 2843 break;
2844 case 4: 2844 case 4:
2845 // Creation after deletion: two more creates should total up to 2845 // Creation after deletion: two more creates should total up to
2846 // three textures. 2846 // three textures.
2847 ASSERT_EQ(3u, context->NumTextures()); 2847 ASSERT_EQ(3u, context->NumTextures());
2848 break; 2848 break;
2849 } 2849 }
2850 } 2850 }
2851 2851
2852 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 2852 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
2853 if (!layer_tree_host()->settings().impl_side_painting) 2853 if (!layer_tree_host()->settings().impl_side_painting)
2854 PerformTest(impl); 2854 PerformTest(impl);
2855 } 2855 }
2856 2856
2857 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 2857 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
2858 if (layer_tree_host()->settings().impl_side_painting) 2858 if (layer_tree_host()->settings().impl_side_painting)
2859 PerformTest(impl); 2859 PerformTest(impl);
2860 } 2860 }
2861 2861
2862 virtual void AfterTest() OVERRIDE {} 2862 virtual void AfterTest() override {}
2863 2863
2864 private: 2864 private:
2865 // Must clear all resources before exiting. 2865 // Must clear all resources before exiting.
2866 void ClearResources() { 2866 void ClearResources() {
2867 for (int i = 0; i < num_ui_resources_; i++) 2867 for (int i = 0; i < num_ui_resources_; i++)
2868 ui_resources_[i] = nullptr; 2868 ui_resources_[i] = nullptr;
2869 } 2869 }
2870 2870
2871 void CreateResource() { 2871 void CreateResource() {
2872 ui_resources_[num_ui_resources_++] = 2872 ui_resources_[num_ui_resources_++] =
2873 FakeScopedUIResource::Create(layer_tree_host()); 2873 FakeScopedUIResource::Create(layer_tree_host());
2874 } 2874 }
2875 2875
2876 scoped_ptr<FakeScopedUIResource> ui_resources_[5]; 2876 scoped_ptr<FakeScopedUIResource> ui_resources_[5];
2877 int num_ui_resources_; 2877 int num_ui_resources_;
2878 }; 2878 };
2879 2879
2880 MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource); 2880 MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource);
2881 2881
2882 class PushPropertiesCountingLayerImpl : public LayerImpl { 2882 class PushPropertiesCountingLayerImpl : public LayerImpl {
2883 public: 2883 public:
2884 static scoped_ptr<PushPropertiesCountingLayerImpl> Create( 2884 static scoped_ptr<PushPropertiesCountingLayerImpl> Create(
2885 LayerTreeImpl* tree_impl, int id) { 2885 LayerTreeImpl* tree_impl, int id) {
2886 return make_scoped_ptr(new PushPropertiesCountingLayerImpl(tree_impl, id)); 2886 return make_scoped_ptr(new PushPropertiesCountingLayerImpl(tree_impl, id));
2887 } 2887 }
2888 2888
2889 virtual ~PushPropertiesCountingLayerImpl() {} 2889 virtual ~PushPropertiesCountingLayerImpl() {}
2890 2890
2891 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE { 2891 virtual void PushPropertiesTo(LayerImpl* layer) override {
2892 LayerImpl::PushPropertiesTo(layer); 2892 LayerImpl::PushPropertiesTo(layer);
2893 push_properties_count_++; 2893 push_properties_count_++;
2894 // Push state to the active tree because we can only access it from there. 2894 // Push state to the active tree because we can only access it from there.
2895 static_cast<PushPropertiesCountingLayerImpl*>( 2895 static_cast<PushPropertiesCountingLayerImpl*>(
2896 layer)->push_properties_count_ = push_properties_count_; 2896 layer)->push_properties_count_ = push_properties_count_;
2897 } 2897 }
2898 2898
2899 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 2899 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
2900 OVERRIDE { 2900 override {
2901 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 2901 return PushPropertiesCountingLayerImpl::Create(tree_impl, id());
2902 } 2902 }
2903 2903
2904 size_t push_properties_count() const { return push_properties_count_; } 2904 size_t push_properties_count() const { return push_properties_count_; }
2905 void reset_push_properties_count() { push_properties_count_ = 0; } 2905 void reset_push_properties_count() { push_properties_count_ = 0; }
2906 2906
2907 private: 2907 private:
2908 size_t push_properties_count_; 2908 size_t push_properties_count_;
2909 2909
2910 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id) 2910 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id)
2911 : LayerImpl(tree_impl, id), 2911 : LayerImpl(tree_impl, id),
2912 push_properties_count_(0) { 2912 push_properties_count_(0) {
2913 SetBounds(gfx::Size(1, 1)); 2913 SetBounds(gfx::Size(1, 1));
2914 } 2914 }
2915 }; 2915 };
2916 2916
2917 class PushPropertiesCountingLayer : public Layer { 2917 class PushPropertiesCountingLayer : public Layer {
2918 public: 2918 public:
2919 static scoped_refptr<PushPropertiesCountingLayer> Create() { 2919 static scoped_refptr<PushPropertiesCountingLayer> Create() {
2920 return new PushPropertiesCountingLayer(); 2920 return new PushPropertiesCountingLayer();
2921 } 2921 }
2922 2922
2923 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE { 2923 virtual void PushPropertiesTo(LayerImpl* layer) override {
2924 Layer::PushPropertiesTo(layer); 2924 Layer::PushPropertiesTo(layer);
2925 push_properties_count_++; 2925 push_properties_count_++;
2926 if (persist_needs_push_properties_) 2926 if (persist_needs_push_properties_)
2927 needs_push_properties_ = true; 2927 needs_push_properties_ = true;
2928 } 2928 }
2929 2929
2930 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 2930 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
2931 OVERRIDE { 2931 override {
2932 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 2932 return PushPropertiesCountingLayerImpl::Create(tree_impl, id());
2933 } 2933 }
2934 2934
2935 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); } 2935 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); }
2936 2936
2937 size_t push_properties_count() const { return push_properties_count_; } 2937 size_t push_properties_count() const { return push_properties_count_; }
2938 void reset_push_properties_count() { push_properties_count_ = 0; } 2938 void reset_push_properties_count() { push_properties_count_ = 0; }
2939 2939
2940 void set_persist_needs_push_properties(bool persist) { 2940 void set_persist_needs_push_properties(bool persist) {
2941 persist_needs_push_properties_ = persist; 2941 persist_needs_push_properties_ = persist;
2942 } 2942 }
2943 2943
2944 private: 2944 private:
2945 PushPropertiesCountingLayer() 2945 PushPropertiesCountingLayer()
2946 : push_properties_count_(0), persist_needs_push_properties_(false) { 2946 : push_properties_count_(0), persist_needs_push_properties_(false) {
2947 SetBounds(gfx::Size(1, 1)); 2947 SetBounds(gfx::Size(1, 1));
2948 } 2948 }
2949 virtual ~PushPropertiesCountingLayer() {} 2949 virtual ~PushPropertiesCountingLayer() {}
2950 2950
2951 size_t push_properties_count_; 2951 size_t push_properties_count_;
2952 bool persist_needs_push_properties_; 2952 bool persist_needs_push_properties_;
2953 }; 2953 };
2954 2954
2955 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { 2955 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
2956 protected: 2956 protected:
2957 virtual void BeginTest() OVERRIDE { 2957 virtual void BeginTest() override {
2958 num_commits_ = 0; 2958 num_commits_ = 0;
2959 expected_push_properties_root_ = 0; 2959 expected_push_properties_root_ = 0;
2960 expected_push_properties_child_ = 0; 2960 expected_push_properties_child_ = 0;
2961 expected_push_properties_grandchild_ = 0; 2961 expected_push_properties_grandchild_ = 0;
2962 expected_push_properties_child2_ = 0; 2962 expected_push_properties_child2_ = 0;
2963 expected_push_properties_other_root_ = 0; 2963 expected_push_properties_other_root_ = 0;
2964 expected_push_properties_leaf_layer_ = 0; 2964 expected_push_properties_leaf_layer_ = 0;
2965 PostSetNeedsCommitToMainThread(); 2965 PostSetNeedsCommitToMainThread();
2966 } 2966 }
2967 2967
2968 virtual void SetupTree() OVERRIDE { 2968 virtual void SetupTree() override {
2969 root_ = PushPropertiesCountingLayer::Create(); 2969 root_ = PushPropertiesCountingLayer::Create();
2970 child_ = PushPropertiesCountingLayer::Create(); 2970 child_ = PushPropertiesCountingLayer::Create();
2971 child2_ = PushPropertiesCountingLayer::Create(); 2971 child2_ = PushPropertiesCountingLayer::Create();
2972 grandchild_ = PushPropertiesCountingLayer::Create(); 2972 grandchild_ = PushPropertiesCountingLayer::Create();
2973 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); 2973 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create();
2974 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); 2974 leaf_always_pushing_layer_->set_persist_needs_push_properties(true);
2975 2975
2976 root_->AddChild(child_); 2976 root_->AddChild(child_);
2977 root_->AddChild(child2_); 2977 root_->AddChild(child2_);
2978 child_->AddChild(grandchild_); 2978 child_->AddChild(grandchild_);
2979 child2_->AddChild(leaf_always_pushing_layer_); 2979 child2_->AddChild(leaf_always_pushing_layer_);
2980 2980
2981 other_root_ = PushPropertiesCountingLayer::Create(); 2981 other_root_ = PushPropertiesCountingLayer::Create();
2982 2982
2983 // Don't set the root layer here. 2983 // Don't set the root layer here.
2984 LayerTreeHostTest::SetupTree(); 2984 LayerTreeHostTest::SetupTree();
2985 } 2985 }
2986 2986
2987 virtual void DidCommitAndDrawFrame() OVERRIDE { 2987 virtual void DidCommitAndDrawFrame() override {
2988 ++num_commits_; 2988 ++num_commits_;
2989 2989
2990 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 2990 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
2991 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 2991 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
2992 EXPECT_EQ(expected_push_properties_grandchild_, 2992 EXPECT_EQ(expected_push_properties_grandchild_,
2993 grandchild_->push_properties_count()); 2993 grandchild_->push_properties_count());
2994 EXPECT_EQ(expected_push_properties_child2_, 2994 EXPECT_EQ(expected_push_properties_child2_,
2995 child2_->push_properties_count()); 2995 child2_->push_properties_count());
2996 EXPECT_EQ(expected_push_properties_other_root_, 2996 EXPECT_EQ(expected_push_properties_other_root_,
2997 other_root_->push_properties_count()); 2997 other_root_->push_properties_count());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 case 17: 3117 case 17:
3118 EndTest(); 3118 EndTest();
3119 break; 3119 break;
3120 } 3120 }
3121 3121
3122 // The leaf layer always pushes. 3122 // The leaf layer always pushes.
3123 if (leaf_always_pushing_layer_->layer_tree_host()) 3123 if (leaf_always_pushing_layer_->layer_tree_host())
3124 ++expected_push_properties_leaf_layer_; 3124 ++expected_push_properties_leaf_layer_;
3125 } 3125 }
3126 3126
3127 virtual void AfterTest() OVERRIDE {} 3127 virtual void AfterTest() override {}
3128 3128
3129 int num_commits_; 3129 int num_commits_;
3130 FakeContentLayerClient client_; 3130 FakeContentLayerClient client_;
3131 scoped_refptr<PushPropertiesCountingLayer> root_; 3131 scoped_refptr<PushPropertiesCountingLayer> root_;
3132 scoped_refptr<PushPropertiesCountingLayer> child_; 3132 scoped_refptr<PushPropertiesCountingLayer> child_;
3133 scoped_refptr<PushPropertiesCountingLayer> child2_; 3133 scoped_refptr<PushPropertiesCountingLayer> child2_;
3134 scoped_refptr<PushPropertiesCountingLayer> grandchild_; 3134 scoped_refptr<PushPropertiesCountingLayer> grandchild_;
3135 scoped_refptr<PushPropertiesCountingLayer> other_root_; 3135 scoped_refptr<PushPropertiesCountingLayer> other_root_;
3136 scoped_refptr<PushPropertiesCountingLayer> leaf_always_pushing_layer_; 3136 scoped_refptr<PushPropertiesCountingLayer> leaf_always_pushing_layer_;
3137 size_t expected_push_properties_root_; 3137 size_t expected_push_properties_root_;
3138 size_t expected_push_properties_child_; 3138 size_t expected_push_properties_child_;
3139 size_t expected_push_properties_child2_; 3139 size_t expected_push_properties_child2_;
3140 size_t expected_push_properties_grandchild_; 3140 size_t expected_push_properties_grandchild_;
3141 size_t expected_push_properties_other_root_; 3141 size_t expected_push_properties_other_root_;
3142 size_t expected_push_properties_leaf_layer_; 3142 size_t expected_push_properties_leaf_layer_;
3143 }; 3143 };
3144 3144
3145 MULTI_THREAD_TEST_F(LayerTreeHostTestLayersPushProperties); 3145 MULTI_THREAD_TEST_F(LayerTreeHostTestLayersPushProperties);
3146 3146
3147 class LayerTreeHostTestImplLayersPushProperties 3147 class LayerTreeHostTestImplLayersPushProperties
3148 : public LayerTreeHostTestLayersPushProperties { 3148 : public LayerTreeHostTestLayersPushProperties {
3149 protected: 3149 protected:
3150 virtual void BeginTest() OVERRIDE { 3150 virtual void BeginTest() override {
3151 expected_push_properties_root_impl_ = 0; 3151 expected_push_properties_root_impl_ = 0;
3152 expected_push_properties_child_impl_ = 0; 3152 expected_push_properties_child_impl_ = 0;
3153 expected_push_properties_grandchild_impl_ = 0; 3153 expected_push_properties_grandchild_impl_ = 0;
3154 expected_push_properties_child2_impl_ = 0; 3154 expected_push_properties_child2_impl_ = 0;
3155 expected_push_properties_grandchild2_impl_ = 0; 3155 expected_push_properties_grandchild2_impl_ = 0;
3156 LayerTreeHostTestLayersPushProperties::BeginTest(); 3156 LayerTreeHostTestLayersPushProperties::BeginTest();
3157 } 3157 }
3158 3158
3159 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 3159 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
3160 // These commits are in response to the changes made in 3160 // These commits are in response to the changes made in
3161 // LayerTreeHostTestLayersPushProperties::DidCommitAndDrawFrame() 3161 // LayerTreeHostTestLayersPushProperties::DidCommitAndDrawFrame()
3162 switch (num_commits_) { 3162 switch (num_commits_) {
3163 case 0: 3163 case 0:
3164 // Tree hasn't been setup yet don't bother to check anything. 3164 // Tree hasn't been setup yet don't bother to check anything.
3165 return; 3165 return;
3166 case 1: 3166 case 1:
3167 // Root gets set up, Everyone is initialized. 3167 // Root gets set up, Everyone is initialized.
3168 ++expected_push_properties_root_impl_; 3168 ++expected_push_properties_root_impl_;
3169 ++expected_push_properties_child_impl_; 3169 ++expected_push_properties_child_impl_;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 size_t expected_push_properties_grandchild2_impl_; 3340 size_t expected_push_properties_grandchild2_impl_;
3341 }; 3341 };
3342 3342
3343 TEST_F(LayerTreeHostTestImplLayersPushProperties, DelegatingRenderer) { 3343 TEST_F(LayerTreeHostTestImplLayersPushProperties, DelegatingRenderer) {
3344 RunTestWithImplSidePainting(); 3344 RunTestWithImplSidePainting();
3345 } 3345 }
3346 3346
3347 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed 3347 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
3348 : public LayerTreeHostTest { 3348 : public LayerTreeHostTest {
3349 protected: 3349 protected:
3350 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3350 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
3351 3351
3352 virtual void SetupTree() OVERRIDE { 3352 virtual void SetupTree() override {
3353 root_ = Layer::Create(); 3353 root_ = Layer::Create();
3354 root_->SetBounds(gfx::Size(1, 1)); 3354 root_->SetBounds(gfx::Size(1, 1));
3355 3355
3356 bool paint_scrollbar = true; 3356 bool paint_scrollbar = true;
3357 bool has_thumb = false; 3357 bool has_thumb = false;
3358 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( 3358 scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
3359 paint_scrollbar, has_thumb, root_->id()); 3359 paint_scrollbar, has_thumb, root_->id());
3360 3360
3361 root_->AddChild(scrollbar_layer_); 3361 root_->AddChild(scrollbar_layer_);
3362 3362
3363 layer_tree_host()->SetRootLayer(root_); 3363 layer_tree_host()->SetRootLayer(root_);
3364 LayerTreeHostTest::SetupTree(); 3364 LayerTreeHostTest::SetupTree();
3365 } 3365 }
3366 3366
3367 virtual void DidCommitAndDrawFrame() OVERRIDE { 3367 virtual void DidCommitAndDrawFrame() override {
3368 switch (layer_tree_host()->source_frame_number()) { 3368 switch (layer_tree_host()->source_frame_number()) {
3369 case 0: 3369 case 0:
3370 break; 3370 break;
3371 case 1: { 3371 case 1: {
3372 // During update, the ignore_set_needs_commit_ bit is set to true to 3372 // During update, the ignore_set_needs_commit_ bit is set to true to
3373 // avoid causing a second commit to be scheduled. If a property change 3373 // avoid causing a second commit to be scheduled. If a property change
3374 // is made during this, however, it needs to be pushed in the upcoming 3374 // is made during this, however, it needs to be pushed in the upcoming
3375 // commit. 3375 // commit.
3376 scoped_ptr<base::AutoReset<bool> > ignore = 3376 scoped_ptr<base::AutoReset<bool> > ignore =
3377 scrollbar_layer_->IgnoreSetNeedsCommit(); 3377 scrollbar_layer_->IgnoreSetNeedsCommit();
3378 3378
3379 scrollbar_layer_->SetBounds(gfx::Size(30, 30)); 3379 scrollbar_layer_->SetBounds(gfx::Size(30, 30));
3380 3380
3381 EXPECT_TRUE(scrollbar_layer_->needs_push_properties()); 3381 EXPECT_TRUE(scrollbar_layer_->needs_push_properties());
3382 EXPECT_TRUE(root_->descendant_needs_push_properties()); 3382 EXPECT_TRUE(root_->descendant_needs_push_properties());
3383 layer_tree_host()->SetNeedsCommit(); 3383 layer_tree_host()->SetNeedsCommit();
3384 3384
3385 scrollbar_layer_->reset_push_properties_count(); 3385 scrollbar_layer_->reset_push_properties_count();
3386 EXPECT_EQ(0u, scrollbar_layer_->push_properties_count()); 3386 EXPECT_EQ(0u, scrollbar_layer_->push_properties_count());
3387 break; 3387 break;
3388 } 3388 }
3389 case 2: 3389 case 2:
3390 EXPECT_EQ(1u, scrollbar_layer_->push_properties_count()); 3390 EXPECT_EQ(1u, scrollbar_layer_->push_properties_count());
3391 EndTest(); 3391 EndTest();
3392 break; 3392 break;
3393 } 3393 }
3394 } 3394 }
3395 3395
3396 virtual void AfterTest() OVERRIDE {} 3396 virtual void AfterTest() override {}
3397 3397
3398 scoped_refptr<Layer> root_; 3398 scoped_refptr<Layer> root_;
3399 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; 3399 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_;
3400 }; 3400 };
3401 3401
3402 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); 3402 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed);
3403 3403
3404 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { 3404 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
3405 protected: 3405 protected:
3406 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3406 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
3407 3407
3408 virtual void SetupTree() OVERRIDE { 3408 virtual void SetupTree() override {
3409 root_ = PushPropertiesCountingLayer::Create(); 3409 root_ = PushPropertiesCountingLayer::Create();
3410 child_ = PushPropertiesCountingLayer::Create(); 3410 child_ = PushPropertiesCountingLayer::Create();
3411 root_->AddChild(child_); 3411 root_->AddChild(child_);
3412 3412
3413 layer_tree_host()->SetRootLayer(root_); 3413 layer_tree_host()->SetRootLayer(root_);
3414 LayerTreeHostTest::SetupTree(); 3414 LayerTreeHostTest::SetupTree();
3415 } 3415 }
3416 3416
3417 virtual void DidCommitAndDrawFrame() OVERRIDE { 3417 virtual void DidCommitAndDrawFrame() override {
3418 switch (layer_tree_host()->source_frame_number()) { 3418 switch (layer_tree_host()->source_frame_number()) {
3419 case 0: 3419 case 0:
3420 break; 3420 break;
3421 case 1: { 3421 case 1: {
3422 // During update, the ignore_set_needs_commit_ bit is set to true to 3422 // During update, the ignore_set_needs_commit_ bit is set to true to
3423 // avoid causing a second commit to be scheduled. If a property change 3423 // avoid causing a second commit to be scheduled. If a property change
3424 // is made during this, however, it needs to be pushed in the upcoming 3424 // is made during this, however, it needs to be pushed in the upcoming
3425 // commit. 3425 // commit.
3426 EXPECT_FALSE(root_->needs_push_properties()); 3426 EXPECT_FALSE(root_->needs_push_properties());
3427 EXPECT_FALSE(child_->needs_push_properties()); 3427 EXPECT_FALSE(child_->needs_push_properties());
(...skipping 11 matching lines...) Expand all
3439 case 2: 3439 case 2:
3440 EXPECT_EQ(1u, root_->push_properties_count()); 3440 EXPECT_EQ(1u, root_->push_properties_count());
3441 EXPECT_EQ(1u, child_->push_properties_count()); 3441 EXPECT_EQ(1u, child_->push_properties_count());
3442 EXPECT_FALSE(root_->needs_push_properties()); 3442 EXPECT_FALSE(root_->needs_push_properties());
3443 EXPECT_FALSE(child_->needs_push_properties()); 3443 EXPECT_FALSE(child_->needs_push_properties());
3444 EndTest(); 3444 EndTest();
3445 break; 3445 break;
3446 } 3446 }
3447 } 3447 }
3448 3448
3449 virtual void AfterTest() OVERRIDE {} 3449 virtual void AfterTest() override {}
3450 3450
3451 scoped_refptr<PushPropertiesCountingLayer> root_; 3451 scoped_refptr<PushPropertiesCountingLayer> root_;
3452 scoped_refptr<PushPropertiesCountingLayer> child_; 3452 scoped_refptr<PushPropertiesCountingLayer> child_;
3453 }; 3453 };
3454 3454
3455 MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit); 3455 MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit);
3456 3456
3457 class LayerTreeHostTestCasePushPropertiesThreeGrandChildren 3457 class LayerTreeHostTestCasePushPropertiesThreeGrandChildren
3458 : public LayerTreeHostTest { 3458 : public LayerTreeHostTest {
3459 protected: 3459 protected:
3460 virtual void BeginTest() OVERRIDE { 3460 virtual void BeginTest() override {
3461 expected_push_properties_root_ = 0; 3461 expected_push_properties_root_ = 0;
3462 expected_push_properties_child_ = 0; 3462 expected_push_properties_child_ = 0;
3463 expected_push_properties_grandchild1_ = 0; 3463 expected_push_properties_grandchild1_ = 0;
3464 expected_push_properties_grandchild2_ = 0; 3464 expected_push_properties_grandchild2_ = 0;
3465 expected_push_properties_grandchild3_ = 0; 3465 expected_push_properties_grandchild3_ = 0;
3466 PostSetNeedsCommitToMainThread(); 3466 PostSetNeedsCommitToMainThread();
3467 } 3467 }
3468 3468
3469 virtual void SetupTree() OVERRIDE { 3469 virtual void SetupTree() override {
3470 root_ = PushPropertiesCountingLayer::Create(); 3470 root_ = PushPropertiesCountingLayer::Create();
3471 child_ = PushPropertiesCountingLayer::Create(); 3471 child_ = PushPropertiesCountingLayer::Create();
3472 grandchild1_ = PushPropertiesCountingLayer::Create(); 3472 grandchild1_ = PushPropertiesCountingLayer::Create();
3473 grandchild2_ = PushPropertiesCountingLayer::Create(); 3473 grandchild2_ = PushPropertiesCountingLayer::Create();
3474 grandchild3_ = PushPropertiesCountingLayer::Create(); 3474 grandchild3_ = PushPropertiesCountingLayer::Create();
3475 3475
3476 root_->AddChild(child_); 3476 root_->AddChild(child_);
3477 child_->AddChild(grandchild1_); 3477 child_->AddChild(grandchild1_);
3478 child_->AddChild(grandchild2_); 3478 child_->AddChild(grandchild2_);
3479 child_->AddChild(grandchild3_); 3479 child_->AddChild(grandchild3_);
3480 3480
3481 // Don't set the root layer here. 3481 // Don't set the root layer here.
3482 LayerTreeHostTest::SetupTree(); 3482 LayerTreeHostTest::SetupTree();
3483 } 3483 }
3484 3484
3485 virtual void AfterTest() OVERRIDE {} 3485 virtual void AfterTest() override {}
3486 3486
3487 FakeContentLayerClient client_; 3487 FakeContentLayerClient client_;
3488 scoped_refptr<PushPropertiesCountingLayer> root_; 3488 scoped_refptr<PushPropertiesCountingLayer> root_;
3489 scoped_refptr<PushPropertiesCountingLayer> child_; 3489 scoped_refptr<PushPropertiesCountingLayer> child_;
3490 scoped_refptr<PushPropertiesCountingLayer> grandchild1_; 3490 scoped_refptr<PushPropertiesCountingLayer> grandchild1_;
3491 scoped_refptr<PushPropertiesCountingLayer> grandchild2_; 3491 scoped_refptr<PushPropertiesCountingLayer> grandchild2_;
3492 scoped_refptr<PushPropertiesCountingLayer> grandchild3_; 3492 scoped_refptr<PushPropertiesCountingLayer> grandchild3_;
3493 size_t expected_push_properties_root_; 3493 size_t expected_push_properties_root_;
3494 size_t expected_push_properties_child_; 3494 size_t expected_push_properties_child_;
3495 size_t expected_push_properties_grandchild1_; 3495 size_t expected_push_properties_grandchild1_;
3496 size_t expected_push_properties_grandchild2_; 3496 size_t expected_push_properties_grandchild2_;
3497 size_t expected_push_properties_grandchild3_; 3497 size_t expected_push_properties_grandchild3_;
3498 }; 3498 };
3499 3499
3500 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush 3500 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush
3501 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3501 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3502 protected: 3502 protected:
3503 virtual void DidCommitAndDrawFrame() OVERRIDE { 3503 virtual void DidCommitAndDrawFrame() override {
3504 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3504 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3505 switch (last_source_frame_number) { 3505 switch (last_source_frame_number) {
3506 case 0: 3506 case 0:
3507 EXPECT_FALSE(root_->needs_push_properties()); 3507 EXPECT_FALSE(root_->needs_push_properties());
3508 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3508 EXPECT_FALSE(root_->descendant_needs_push_properties());
3509 EXPECT_FALSE(child_->needs_push_properties()); 3509 EXPECT_FALSE(child_->needs_push_properties());
3510 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3510 EXPECT_FALSE(child_->descendant_needs_push_properties());
3511 EXPECT_FALSE(grandchild1_->needs_push_properties()); 3511 EXPECT_FALSE(grandchild1_->needs_push_properties());
3512 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties()); 3512 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties());
3513 EXPECT_FALSE(grandchild2_->needs_push_properties()); 3513 EXPECT_FALSE(grandchild2_->needs_push_properties());
(...skipping 19 matching lines...) Expand all
3533 break; 3533 break;
3534 } 3534 }
3535 } 3535 }
3536 }; 3536 };
3537 3537
3538 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush); 3538 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush);
3539 3539
3540 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion 3540 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
3541 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3541 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3542 protected: 3542 protected:
3543 virtual void DidCommitAndDrawFrame() OVERRIDE { 3543 virtual void DidCommitAndDrawFrame() override {
3544 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3544 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3545 switch (last_source_frame_number) { 3545 switch (last_source_frame_number) {
3546 case 0: 3546 case 0:
3547 layer_tree_host()->SetRootLayer(root_); 3547 layer_tree_host()->SetRootLayer(root_);
3548 break; 3548 break;
3549 case 1: 3549 case 1:
3550 EXPECT_FALSE(root_->needs_push_properties()); 3550 EXPECT_FALSE(root_->needs_push_properties());
3551 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3551 EXPECT_FALSE(root_->descendant_needs_push_properties());
3552 EXPECT_FALSE(child_->needs_push_properties()); 3552 EXPECT_FALSE(child_->needs_push_properties());
3553 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3553 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3616 break; 3616 break;
3617 } 3617 }
3618 } 3618 }
3619 }; 3619 };
3620 3620
3621 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion); 3621 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion);
3622 3622
3623 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence 3623 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
3624 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3624 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3625 protected: 3625 protected:
3626 virtual void DidCommitAndDrawFrame() OVERRIDE { 3626 virtual void DidCommitAndDrawFrame() override {
3627 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3627 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3628 switch (last_source_frame_number) { 3628 switch (last_source_frame_number) {
3629 case 0: 3629 case 0:
3630 layer_tree_host()->SetRootLayer(root_); 3630 layer_tree_host()->SetRootLayer(root_);
3631 grandchild1_->set_persist_needs_push_properties(true); 3631 grandchild1_->set_persist_needs_push_properties(true);
3632 grandchild2_->set_persist_needs_push_properties(true); 3632 grandchild2_->set_persist_needs_push_properties(true);
3633 break; 3633 break;
3634 case 1: 3634 case 1:
3635 EXPECT_FALSE(root_->needs_push_properties()); 3635 EXPECT_FALSE(root_->needs_push_properties());
3636 EXPECT_TRUE(root_->descendant_needs_push_properties()); 3636 EXPECT_TRUE(root_->descendant_needs_push_properties());
(...skipping 27 matching lines...) Expand all
3664 } 3664 }
3665 } 3665 }
3666 }; 3666 };
3667 3667
3668 MULTI_THREAD_TEST_F( 3668 MULTI_THREAD_TEST_F(
3669 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence); 3669 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence);
3670 3670
3671 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree 3671 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
3672 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3672 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3673 protected: 3673 protected:
3674 virtual void DidCommitAndDrawFrame() OVERRIDE { 3674 virtual void DidCommitAndDrawFrame() override {
3675 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3675 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3676 switch (last_source_frame_number) { 3676 switch (last_source_frame_number) {
3677 case 0: 3677 case 0:
3678 layer_tree_host()->SetRootLayer(root_); 3678 layer_tree_host()->SetRootLayer(root_);
3679 break; 3679 break;
3680 case 1: 3680 case 1:
3681 EXPECT_FALSE(root_->needs_push_properties()); 3681 EXPECT_FALSE(root_->needs_push_properties());
3682 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3682 EXPECT_FALSE(root_->descendant_needs_push_properties());
3683 EXPECT_FALSE(child_->needs_push_properties()); 3683 EXPECT_FALSE(child_->needs_push_properties());
3684 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3684 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3732 } 3732 }
3733 } 3733 }
3734 }; 3734 };
3735 3735
3736 MULTI_THREAD_TEST_F( 3736 MULTI_THREAD_TEST_F(
3737 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree); 3737 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree);
3738 3738
3739 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild 3739 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
3740 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3740 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3741 protected: 3741 protected:
3742 virtual void DidCommitAndDrawFrame() OVERRIDE { 3742 virtual void DidCommitAndDrawFrame() override {
3743 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3743 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3744 switch (last_source_frame_number) { 3744 switch (last_source_frame_number) {
3745 case 0: 3745 case 0:
3746 layer_tree_host()->SetRootLayer(root_); 3746 layer_tree_host()->SetRootLayer(root_);
3747 break; 3747 break;
3748 case 1: 3748 case 1:
3749 EXPECT_FALSE(root_->needs_push_properties()); 3749 EXPECT_FALSE(root_->needs_push_properties());
3750 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3750 EXPECT_FALSE(root_->descendant_needs_push_properties());
3751 EXPECT_FALSE(child_->needs_push_properties()); 3751 EXPECT_FALSE(child_->needs_push_properties());
3752 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3752 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3796 } 3796 }
3797 } 3797 }
3798 }; 3798 };
3799 3799
3800 MULTI_THREAD_TEST_F( 3800 MULTI_THREAD_TEST_F(
3801 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild); 3801 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild);
3802 3802
3803 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent 3803 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
3804 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3804 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3805 protected: 3805 protected:
3806 virtual void DidCommitAndDrawFrame() OVERRIDE { 3806 virtual void DidCommitAndDrawFrame() override {
3807 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3807 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3808 switch (last_source_frame_number) { 3808 switch (last_source_frame_number) {
3809 case 0: 3809 case 0:
3810 layer_tree_host()->SetRootLayer(root_); 3810 layer_tree_host()->SetRootLayer(root_);
3811 break; 3811 break;
3812 case 1: 3812 case 1:
3813 EXPECT_FALSE(root_->needs_push_properties()); 3813 EXPECT_FALSE(root_->needs_push_properties());
3814 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3814 EXPECT_FALSE(root_->descendant_needs_push_properties());
3815 EXPECT_FALSE(child_->needs_push_properties()); 3815 EXPECT_FALSE(child_->needs_push_properties());
3816 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3816 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 3863
3864 MULTI_THREAD_TEST_F( 3864 MULTI_THREAD_TEST_F(
3865 LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent); 3865 LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent);
3866 3866
3867 // This test verifies that the tree activation callback is invoked correctly. 3867 // This test verifies that the tree activation callback is invoked correctly.
3868 class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest { 3868 class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest {
3869 public: 3869 public:
3870 LayerTreeHostTestTreeActivationCallback() 3870 LayerTreeHostTestTreeActivationCallback()
3871 : num_commits_(0), callback_count_(0) {} 3871 : num_commits_(0), callback_count_(0) {}
3872 3872
3873 virtual void BeginTest() OVERRIDE { 3873 virtual void BeginTest() override {
3874 EXPECT_TRUE(HasImplThread()); 3874 EXPECT_TRUE(HasImplThread());
3875 PostSetNeedsCommitToMainThread(); 3875 PostSetNeedsCommitToMainThread();
3876 } 3876 }
3877 3877
3878 virtual DrawResult PrepareToDrawOnThread( 3878 virtual DrawResult PrepareToDrawOnThread(
3879 LayerTreeHostImpl* host_impl, 3879 LayerTreeHostImpl* host_impl,
3880 LayerTreeHostImpl::FrameData* frame_data, 3880 LayerTreeHostImpl::FrameData* frame_data,
3881 DrawResult draw_result) OVERRIDE { 3881 DrawResult draw_result) override {
3882 ++num_commits_; 3882 ++num_commits_;
3883 switch (num_commits_) { 3883 switch (num_commits_) {
3884 case 1: 3884 case 1:
3885 EXPECT_EQ(0, callback_count_); 3885 EXPECT_EQ(0, callback_count_);
3886 callback_count_ = 0; 3886 callback_count_ = 0;
3887 SetCallback(true); 3887 SetCallback(true);
3888 PostSetNeedsCommitToMainThread(); 3888 PostSetNeedsCommitToMainThread();
3889 break; 3889 break;
3890 case 2: 3890 case 2:
3891 EXPECT_EQ(1, callback_count_); 3891 EXPECT_EQ(1, callback_count_);
3892 callback_count_ = 0; 3892 callback_count_ = 0;
3893 SetCallback(false); 3893 SetCallback(false);
3894 PostSetNeedsCommitToMainThread(); 3894 PostSetNeedsCommitToMainThread();
3895 break; 3895 break;
3896 case 3: 3896 case 3:
3897 EXPECT_EQ(0, callback_count_); 3897 EXPECT_EQ(0, callback_count_);
3898 callback_count_ = 0; 3898 callback_count_ = 0;
3899 EndTest(); 3899 EndTest();
3900 break; 3900 break;
3901 default: 3901 default:
3902 ADD_FAILURE() << num_commits_; 3902 ADD_FAILURE() << num_commits_;
3903 EndTest(); 3903 EndTest();
3904 break; 3904 break;
3905 } 3905 }
3906 return LayerTreeHostTest::PrepareToDrawOnThread( 3906 return LayerTreeHostTest::PrepareToDrawOnThread(
3907 host_impl, frame_data, draw_result); 3907 host_impl, frame_data, draw_result);
3908 } 3908 }
3909 3909
3910 virtual void AfterTest() OVERRIDE { EXPECT_EQ(3, num_commits_); } 3910 virtual void AfterTest() override { EXPECT_EQ(3, num_commits_); }
3911 3911
3912 void SetCallback(bool enable) { 3912 void SetCallback(bool enable) {
3913 output_surface()->SetTreeActivationCallback( 3913 output_surface()->SetTreeActivationCallback(
3914 enable 3914 enable
3915 ? base::Bind( 3915 ? base::Bind(
3916 &LayerTreeHostTestTreeActivationCallback::ActivationCallback, 3916 &LayerTreeHostTestTreeActivationCallback::ActivationCallback,
3917 base::Unretained(this)) 3917 base::Unretained(this))
3918 : base::Closure()); 3918 : base::Closure());
3919 } 3919 }
3920 3920
3921 void ActivationCallback() { ++callback_count_; } 3921 void ActivationCallback() { ++callback_count_; }
3922 3922
3923 int num_commits_; 3923 int num_commits_;
3924 int callback_count_; 3924 int callback_count_;
3925 }; 3925 };
3926 3926
3927 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) { 3927 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) {
3928 RunTest(true, false, true); 3928 RunTest(true, false, true);
3929 } 3929 }
3930 3930
3931 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { 3931 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) {
3932 RunTest(true, true, true); 3932 RunTest(true, true, true);
3933 } 3933 }
3934 3934
3935 class LayerInvalidateCausesDraw : public LayerTreeHostTest { 3935 class LayerInvalidateCausesDraw : public LayerTreeHostTest {
3936 public: 3936 public:
3937 LayerInvalidateCausesDraw() : num_commits_(0), num_draws_(0) {} 3937 LayerInvalidateCausesDraw() : num_commits_(0), num_draws_(0) {}
3938 3938
3939 virtual void BeginTest() OVERRIDE { 3939 virtual void BeginTest() override {
3940 ASSERT_TRUE(!!invalidate_layer_.get()) 3940 ASSERT_TRUE(!!invalidate_layer_.get())
3941 << "Derived tests must set this in SetupTree"; 3941 << "Derived tests must set this in SetupTree";
3942 3942
3943 // One initial commit. 3943 // One initial commit.
3944 PostSetNeedsCommitToMainThread(); 3944 PostSetNeedsCommitToMainThread();
3945 } 3945 }
3946 3946
3947 virtual void DidCommitAndDrawFrame() OVERRIDE { 3947 virtual void DidCommitAndDrawFrame() override {
3948 // After commit, invalidate the layer. This should cause a commit. 3948 // After commit, invalidate the layer. This should cause a commit.
3949 if (layer_tree_host()->source_frame_number() == 1) 3949 if (layer_tree_host()->source_frame_number() == 1)
3950 invalidate_layer_->SetNeedsDisplay(); 3950 invalidate_layer_->SetNeedsDisplay();
3951 } 3951 }
3952 3952
3953 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 3953 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
3954 num_draws_++; 3954 num_draws_++;
3955 if (impl->active_tree()->source_frame_number() == 1) 3955 if (impl->active_tree()->source_frame_number() == 1)
3956 EndTest(); 3956 EndTest();
3957 } 3957 }
3958 3958
3959 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 3959 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
3960 num_commits_++; 3960 num_commits_++;
3961 } 3961 }
3962 3962
3963 virtual void AfterTest() OVERRIDE { 3963 virtual void AfterTest() override {
3964 EXPECT_GE(2, num_commits_); 3964 EXPECT_GE(2, num_commits_);
3965 EXPECT_GE(2, num_draws_); 3965 EXPECT_GE(2, num_draws_);
3966 } 3966 }
3967 3967
3968 protected: 3968 protected:
3969 scoped_refptr<Layer> invalidate_layer_; 3969 scoped_refptr<Layer> invalidate_layer_;
3970 3970
3971 private: 3971 private:
3972 int num_commits_; 3972 int num_commits_;
3973 int num_draws_; 3973 int num_draws_;
3974 }; 3974 };
3975 3975
3976 // VideoLayer must support being invalidated and then passing that along 3976 // VideoLayer must support being invalidated and then passing that along
3977 // to the compositor thread, even though no resources are updated in 3977 // to the compositor thread, even though no resources are updated in
3978 // response to that invalidation. 3978 // response to that invalidation.
3979 class LayerTreeHostTestVideoLayerInvalidate : public LayerInvalidateCausesDraw { 3979 class LayerTreeHostTestVideoLayerInvalidate : public LayerInvalidateCausesDraw {
3980 public: 3980 public:
3981 virtual void SetupTree() OVERRIDE { 3981 virtual void SetupTree() override {
3982 LayerTreeHostTest::SetupTree(); 3982 LayerTreeHostTest::SetupTree();
3983 scoped_refptr<VideoLayer> video_layer = 3983 scoped_refptr<VideoLayer> video_layer =
3984 VideoLayer::Create(&provider_, media::VIDEO_ROTATION_0); 3984 VideoLayer::Create(&provider_, media::VIDEO_ROTATION_0);
3985 video_layer->SetBounds(gfx::Size(10, 10)); 3985 video_layer->SetBounds(gfx::Size(10, 10));
3986 video_layer->SetIsDrawable(true); 3986 video_layer->SetIsDrawable(true);
3987 layer_tree_host()->root_layer()->AddChild(video_layer); 3987 layer_tree_host()->root_layer()->AddChild(video_layer);
3988 3988
3989 invalidate_layer_ = video_layer; 3989 invalidate_layer_ = video_layer;
3990 } 3990 }
3991 3991
3992 private: 3992 private:
3993 FakeVideoFrameProvider provider_; 3993 FakeVideoFrameProvider provider_;
3994 }; 3994 };
3995 3995
3996 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate); 3996 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate);
3997 3997
3998 // IOSurfaceLayer must support being invalidated and then passing that along 3998 // IOSurfaceLayer must support being invalidated and then passing that along
3999 // to the compositor thread, even though no resources are updated in 3999 // to the compositor thread, even though no resources are updated in
4000 // response to that invalidation. 4000 // response to that invalidation.
4001 class LayerTreeHostTestIOSurfaceLayerInvalidate 4001 class LayerTreeHostTestIOSurfaceLayerInvalidate
4002 : public LayerInvalidateCausesDraw { 4002 : public LayerInvalidateCausesDraw {
4003 public: 4003 public:
4004 virtual void SetupTree() OVERRIDE { 4004 virtual void SetupTree() override {
4005 LayerTreeHostTest::SetupTree(); 4005 LayerTreeHostTest::SetupTree();
4006 scoped_refptr<IOSurfaceLayer> layer = IOSurfaceLayer::Create(); 4006 scoped_refptr<IOSurfaceLayer> layer = IOSurfaceLayer::Create();
4007 layer->SetBounds(gfx::Size(10, 10)); 4007 layer->SetBounds(gfx::Size(10, 10));
4008 uint32_t fake_io_surface_id = 7; 4008 uint32_t fake_io_surface_id = 7;
4009 layer->SetIOSurfaceProperties(fake_io_surface_id, layer->bounds()); 4009 layer->SetIOSurfaceProperties(fake_io_surface_id, layer->bounds());
4010 layer->SetIsDrawable(true); 4010 layer->SetIsDrawable(true);
4011 layer_tree_host()->root_layer()->AddChild(layer); 4011 layer_tree_host()->root_layer()->AddChild(layer);
4012 4012
4013 invalidate_layer_ = layer; 4013 invalidate_layer_ = layer;
4014 } 4014 }
4015 }; 4015 };
4016 4016
4017 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 4017 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
4018 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 4018 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
4019 LayerTreeHostTestIOSurfaceLayerInvalidate); 4019 LayerTreeHostTestIOSurfaceLayerInvalidate);
4020 4020
4021 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { 4021 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
4022 protected: 4022 protected:
4023 virtual void SetupTree() OVERRIDE { 4023 virtual void SetupTree() override {
4024 root_layer_ = Layer::Create(); 4024 root_layer_ = Layer::Create();
4025 root_layer_->SetPosition(gfx::Point()); 4025 root_layer_->SetPosition(gfx::Point());
4026 root_layer_->SetBounds(gfx::Size(10, 10)); 4026 root_layer_->SetBounds(gfx::Size(10, 10));
4027 4027
4028 parent_layer_ = SolidColorLayer::Create(); 4028 parent_layer_ = SolidColorLayer::Create();
4029 parent_layer_->SetPosition(gfx::Point()); 4029 parent_layer_->SetPosition(gfx::Point());
4030 parent_layer_->SetBounds(gfx::Size(10, 10)); 4030 parent_layer_->SetBounds(gfx::Size(10, 10));
4031 parent_layer_->SetIsDrawable(true); 4031 parent_layer_->SetIsDrawable(true);
4032 root_layer_->AddChild(parent_layer_); 4032 root_layer_->AddChild(parent_layer_);
4033 4033
4034 child_layer_ = SolidColorLayer::Create(); 4034 child_layer_ = SolidColorLayer::Create();
4035 child_layer_->SetPosition(gfx::Point()); 4035 child_layer_->SetPosition(gfx::Point());
4036 child_layer_->SetBounds(gfx::Size(10, 10)); 4036 child_layer_->SetBounds(gfx::Size(10, 10));
4037 child_layer_->SetIsDrawable(true); 4037 child_layer_->SetIsDrawable(true);
4038 parent_layer_->AddChild(child_layer_); 4038 parent_layer_->AddChild(child_layer_);
4039 4039
4040 layer_tree_host()->SetRootLayer(root_layer_); 4040 layer_tree_host()->SetRootLayer(root_layer_);
4041 LayerTreeHostTest::SetupTree(); 4041 LayerTreeHostTest::SetupTree();
4042 } 4042 }
4043 4043
4044 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4044 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4045 4045
4046 virtual void DidCommitAndDrawFrame() OVERRIDE { 4046 virtual void DidCommitAndDrawFrame() override {
4047 switch (layer_tree_host()->source_frame_number()) { 4047 switch (layer_tree_host()->source_frame_number()) {
4048 case 1: 4048 case 1:
4049 // The layer type used does not need to push properties every frame. 4049 // The layer type used does not need to push properties every frame.
4050 EXPECT_FALSE(child_layer_->needs_push_properties()); 4050 EXPECT_FALSE(child_layer_->needs_push_properties());
4051 4051
4052 // Change the bounds of the child layer, but make it skipped 4052 // Change the bounds of the child layer, but make it skipped
4053 // by CalculateDrawProperties. 4053 // by CalculateDrawProperties.
4054 parent_layer_->SetOpacity(0.f); 4054 parent_layer_->SetOpacity(0.f);
4055 child_layer_->SetBounds(gfx::Size(5, 5)); 4055 child_layer_->SetBounds(gfx::Size(5, 5));
4056 break; 4056 break;
4057 case 2: 4057 case 2:
4058 // The bounds of the child layer were pushed to the impl side. 4058 // The bounds of the child layer were pushed to the impl side.
4059 EXPECT_FALSE(child_layer_->needs_push_properties()); 4059 EXPECT_FALSE(child_layer_->needs_push_properties());
4060 4060
4061 EndTest(); 4061 EndTest();
4062 break; 4062 break;
4063 } 4063 }
4064 } 4064 }
4065 4065
4066 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4066 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
4067 LayerImpl* root = impl->active_tree()->root_layer(); 4067 LayerImpl* root = impl->active_tree()->root_layer();
4068 LayerImpl* parent = root->children()[0]; 4068 LayerImpl* parent = root->children()[0];
4069 LayerImpl* child = parent->children()[0]; 4069 LayerImpl* child = parent->children()[0];
4070 4070
4071 switch (impl->active_tree()->source_frame_number()) { 4071 switch (impl->active_tree()->source_frame_number()) {
4072 case 1: 4072 case 1:
4073 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); 4073 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString());
4074 break; 4074 break;
4075 } 4075 }
4076 } 4076 }
4077 4077
4078 virtual void AfterTest() OVERRIDE {} 4078 virtual void AfterTest() override {}
4079 4079
4080 scoped_refptr<Layer> root_layer_; 4080 scoped_refptr<Layer> root_layer_;
4081 scoped_refptr<SolidColorLayer> parent_layer_; 4081 scoped_refptr<SolidColorLayer> parent_layer_;
4082 scoped_refptr<SolidColorLayer> child_layer_; 4082 scoped_refptr<SolidColorLayer> child_layer_;
4083 }; 4083 };
4084 4084
4085 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer); 4085 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer);
4086 4086
4087 class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest { 4087 class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest {
4088 protected: 4088 protected:
4089 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4089 virtual void InitializeSettings(LayerTreeSettings* settings) override {
4090 settings->impl_side_painting = true; 4090 settings->impl_side_painting = true;
4091 } 4091 }
4092 4092
4093 virtual void SetupTree() OVERRIDE { 4093 virtual void SetupTree() override {
4094 root_layer_ = FakePictureLayer::Create(&client_); 4094 root_layer_ = FakePictureLayer::Create(&client_);
4095 root_layer_->SetBounds(gfx::Size(10, 10)); 4095 root_layer_->SetBounds(gfx::Size(10, 10));
4096 4096
4097 layer_tree_host()->SetRootLayer(root_layer_); 4097 layer_tree_host()->SetRootLayer(root_layer_);
4098 LayerTreeHostTest::SetupTree(); 4098 LayerTreeHostTest::SetupTree();
4099 } 4099 }
4100 4100
4101 virtual void BeginTest() OVERRIDE { 4101 virtual void BeginTest() override {
4102 // The viewport is empty, but we still need to update layers on the main 4102 // The viewport is empty, but we still need to update layers on the main
4103 // thread. 4103 // thread.
4104 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); 4104 layer_tree_host()->SetViewportSize(gfx::Size(0, 0));
4105 PostSetNeedsCommitToMainThread(); 4105 PostSetNeedsCommitToMainThread();
4106 } 4106 }
4107 4107
4108 virtual void DidCommit() OVERRIDE { 4108 virtual void DidCommit() override {
4109 // The layer should be updated even though the viewport is empty, so we 4109 // The layer should be updated even though the viewport is empty, so we
4110 // are capable of drawing it on the impl tree. 4110 // are capable of drawing it on the impl tree.
4111 EXPECT_GT(root_layer_->update_count(), 0u); 4111 EXPECT_GT(root_layer_->update_count(), 0u);
4112 EndTest(); 4112 EndTest();
4113 } 4113 }
4114 4114
4115 virtual void AfterTest() OVERRIDE {} 4115 virtual void AfterTest() override {}
4116 4116
4117 FakeContentLayerClient client_; 4117 FakeContentLayerClient client_;
4118 scoped_refptr<FakePictureLayer> root_layer_; 4118 scoped_refptr<FakePictureLayer> root_layer_;
4119 }; 4119 };
4120 4120
4121 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); 4121 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport);
4122 4122
4123 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { 4123 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest {
4124 public: 4124 public:
4125 LayerTreeHostTestAbortEvictedTextures() 4125 LayerTreeHostTestAbortEvictedTextures()
4126 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} 4126 : num_will_begin_main_frames_(0), num_impl_commits_(0) {}
4127 4127
4128 protected: 4128 protected:
4129 virtual void SetupTree() OVERRIDE { 4129 virtual void SetupTree() override {
4130 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); 4130 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create();
4131 root_layer->SetBounds(gfx::Size(200, 200)); 4131 root_layer->SetBounds(gfx::Size(200, 200));
4132 root_layer->SetIsDrawable(true); 4132 root_layer->SetIsDrawable(true);
4133 4133
4134 layer_tree_host()->SetRootLayer(root_layer); 4134 layer_tree_host()->SetRootLayer(root_layer);
4135 LayerTreeHostTest::SetupTree(); 4135 LayerTreeHostTest::SetupTree();
4136 } 4136 }
4137 4137
4138 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4138 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4139 4139
4140 virtual void WillBeginMainFrame() OVERRIDE { 4140 virtual void WillBeginMainFrame() override {
4141 num_will_begin_main_frames_++; 4141 num_will_begin_main_frames_++;
4142 switch (num_will_begin_main_frames_) { 4142 switch (num_will_begin_main_frames_) {
4143 case 2: 4143 case 2:
4144 // Send a redraw to the compositor thread. This will (wrongly) be 4144 // Send a redraw to the compositor thread. This will (wrongly) be
4145 // ignored unless aborting resets the texture state. 4145 // ignored unless aborting resets the texture state.
4146 layer_tree_host()->SetNeedsRedraw(); 4146 layer_tree_host()->SetNeedsRedraw();
4147 break; 4147 break;
4148 } 4148 }
4149 } 4149 }
4150 4150
4151 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4151 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
4152 num_impl_commits_++; 4152 num_impl_commits_++;
4153 } 4153 }
4154 4154
4155 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4155 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
4156 switch (impl->SourceAnimationFrameNumber()) { 4156 switch (impl->SourceAnimationFrameNumber()) {
4157 case 1: 4157 case 1:
4158 // Prevent draws until commit. 4158 // Prevent draws until commit.
4159 impl->active_tree()->SetContentsTexturesPurged(); 4159 impl->active_tree()->SetContentsTexturesPurged();
4160 EXPECT_FALSE(impl->CanDraw()); 4160 EXPECT_FALSE(impl->CanDraw());
4161 // Trigger an abortable commit. 4161 // Trigger an abortable commit.
4162 impl->SetNeedsCommit(); 4162 impl->SetNeedsCommit();
4163 break; 4163 break;
4164 case 2: 4164 case 2:
4165 EndTest(); 4165 EndTest();
4166 break; 4166 break;
4167 } 4167 }
4168 } 4168 }
4169 4169
4170 virtual void AfterTest() OVERRIDE { 4170 virtual void AfterTest() override {
4171 // Ensure that the commit was truly aborted. 4171 // Ensure that the commit was truly aborted.
4172 EXPECT_EQ(2, num_will_begin_main_frames_); 4172 EXPECT_EQ(2, num_will_begin_main_frames_);
4173 EXPECT_EQ(1, num_impl_commits_); 4173 EXPECT_EQ(1, num_impl_commits_);
4174 } 4174 }
4175 4175
4176 private: 4176 private:
4177 int num_will_begin_main_frames_; 4177 int num_will_begin_main_frames_;
4178 int num_impl_commits_; 4178 int num_impl_commits_;
4179 }; 4179 };
4180 4180
4181 // Commits can only be aborted when using the thread proxy. 4181 // Commits can only be aborted when using the thread proxy.
4182 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4182 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4183 4183
4184 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { 4184 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest {
4185 protected: 4185 protected:
4186 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4186 virtual void InitializeSettings(LayerTreeSettings* settings) override {
4187 settings->impl_side_painting = true; 4187 settings->impl_side_painting = true;
4188 } 4188 }
4189 4189
4190 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) 4190 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
4191 OVERRIDE { 4191 override {
4192 scoped_refptr<TestContextProvider> context_provider = 4192 scoped_refptr<TestContextProvider> context_provider =
4193 TestContextProvider::Create(); 4193 TestContextProvider::Create();
4194 context_provider->SetMaxTransferBufferUsageBytes(1024 * 1024); 4194 context_provider->SetMaxTransferBufferUsageBytes(1024 * 1024);
4195 if (delegating_renderer()) 4195 if (delegating_renderer())
4196 return FakeOutputSurface::CreateDelegating3d(context_provider); 4196 return FakeOutputSurface::CreateDelegating3d(context_provider);
4197 else 4197 else
4198 return FakeOutputSurface::Create3d(context_provider); 4198 return FakeOutputSurface::Create3d(context_provider);
4199 } 4199 }
4200 4200
4201 virtual void SetupTree() OVERRIDE { 4201 virtual void SetupTree() override {
4202 client_.set_fill_with_nonsolid_color(true); 4202 client_.set_fill_with_nonsolid_color(true);
4203 scoped_refptr<FakePictureLayer> root_layer = 4203 scoped_refptr<FakePictureLayer> root_layer =
4204 FakePictureLayer::Create(&client_); 4204 FakePictureLayer::Create(&client_);
4205 root_layer->SetBounds(gfx::Size(6000, 6000)); 4205 root_layer->SetBounds(gfx::Size(6000, 6000));
4206 root_layer->SetIsDrawable(true); 4206 root_layer->SetIsDrawable(true);
4207 4207
4208 layer_tree_host()->SetRootLayer(root_layer); 4208 layer_tree_host()->SetRootLayer(root_layer);
4209 LayerTreeHostTest::SetupTree(); 4209 LayerTreeHostTest::SetupTree();
4210 } 4210 }
4211 4211
4212 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4212 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4213 4213
4214 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4214 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
4215 TestWebGraphicsContext3D* context = TestContext(); 4215 TestWebGraphicsContext3D* context = TestContext();
4216 4216
4217 // Expect that the transfer buffer memory used is equal to the 4217 // Expect that the transfer buffer memory used is equal to the
4218 // MaxTransferBufferUsageBytes value set in CreateOutputSurface. 4218 // MaxTransferBufferUsageBytes value set in CreateOutputSurface.
4219 EXPECT_EQ(1024 * 1024u, context->max_used_transfer_buffer_usage_bytes()); 4219 EXPECT_EQ(1024 * 1024u, context->max_used_transfer_buffer_usage_bytes());
4220 EndTest(); 4220 EndTest();
4221 } 4221 }
4222 4222
4223 virtual void AfterTest() OVERRIDE {} 4223 virtual void AfterTest() override {}
4224 4224
4225 private: 4225 private:
4226 FakeContentLayerClient client_; 4226 FakeContentLayerClient client_;
4227 }; 4227 };
4228 4228
4229 // Impl-side painting is a multi-threaded compositor feature. 4229 // Impl-side painting is a multi-threaded compositor feature.
4230 MULTI_THREAD_TEST_F(LayerTreeHostTestMaxTransferBufferUsageBytes); 4230 MULTI_THREAD_TEST_F(LayerTreeHostTestMaxTransferBufferUsageBytes);
4231 4231
4232 // Test ensuring that memory limits are sent to the prioritized resource 4232 // Test ensuring that memory limits are sent to the prioritized resource
4233 // manager. 4233 // manager.
4234 class LayerTreeHostTestMemoryLimits : public LayerTreeHostTest { 4234 class LayerTreeHostTestMemoryLimits : public LayerTreeHostTest {
4235 public: 4235 public:
4236 LayerTreeHostTestMemoryLimits() : num_commits_(0) {} 4236 LayerTreeHostTestMemoryLimits() : num_commits_(0) {}
4237 4237
4238 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4238 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4239 4239
4240 virtual void WillCommit() OVERRIDE { 4240 virtual void WillCommit() override {
4241 // Some commits are aborted, so increment number of attempted commits here. 4241 // Some commits are aborted, so increment number of attempted commits here.
4242 num_commits_++; 4242 num_commits_++;
4243 } 4243 }
4244 4244
4245 virtual void DidCommit() OVERRIDE { 4245 virtual void DidCommit() override {
4246 switch (num_commits_) { 4246 switch (num_commits_) {
4247 case 1: 4247 case 1:
4248 // Verify default values. 4248 // Verify default values.
4249 EXPECT_EQ(PrioritizedResourceManager::DefaultMemoryAllocationLimit(), 4249 EXPECT_EQ(PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
4250 layer_tree_host() 4250 layer_tree_host()
4251 ->contents_texture_manager() 4251 ->contents_texture_manager()
4252 ->MaxMemoryLimitBytes()); 4252 ->MaxMemoryLimitBytes());
4253 EXPECT_EQ(PriorityCalculator::AllowEverythingCutoff(), 4253 EXPECT_EQ(PriorityCalculator::AllowEverythingCutoff(),
4254 layer_tree_host() 4254 layer_tree_host()
4255 ->contents_texture_manager() 4255 ->contents_texture_manager()
(...skipping 24 matching lines...) Expand all
4280 ->ExternalPriorityCutoff()); 4280 ->ExternalPriorityCutoff());
4281 EndTest(); 4281 EndTest();
4282 break; 4282 break;
4283 case 4: 4283 case 4:
4284 // Make sure no extra commits happen. 4284 // Make sure no extra commits happen.
4285 NOTREACHED(); 4285 NOTREACHED();
4286 break; 4286 break;
4287 } 4287 }
4288 } 4288 }
4289 4289
4290 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4290 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
4291 switch (num_commits_) { 4291 switch (num_commits_) {
4292 case 1: 4292 case 1:
4293 break; 4293 break;
4294 case 2: 4294 case 2:
4295 // This will trigger a commit because the priority cutoff has changed. 4295 // This will trigger a commit because the priority cutoff has changed.
4296 impl->SetMemoryPolicy(ManagedMemoryPolicy( 4296 impl->SetMemoryPolicy(ManagedMemoryPolicy(
4297 16u * 1024u * 1024u, 4297 16u * 1024u * 1024u,
4298 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 4298 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
4299 1000)); 4299 1000));
4300 break; 4300 break;
4301 case 3: 4301 case 3:
4302 // This will not trigger a commit because the priority cutoff has not 4302 // This will not trigger a commit because the priority cutoff has not
4303 // changed, and there is already enough memory for all allocations. 4303 // changed, and there is already enough memory for all allocations.
4304 impl->SetMemoryPolicy(ManagedMemoryPolicy( 4304 impl->SetMemoryPolicy(ManagedMemoryPolicy(
4305 32u * 1024u * 1024u, 4305 32u * 1024u * 1024u,
4306 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 4306 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
4307 1000)); 4307 1000));
4308 break; 4308 break;
4309 case 4: 4309 case 4:
4310 NOTREACHED(); 4310 NOTREACHED();
4311 break; 4311 break;
4312 } 4312 }
4313 } 4313 }
4314 4314
4315 virtual void AfterTest() OVERRIDE {} 4315 virtual void AfterTest() override {}
4316 4316
4317 private: 4317 private:
4318 int num_commits_; 4318 int num_commits_;
4319 }; 4319 };
4320 4320
4321 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestMemoryLimits); 4321 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestMemoryLimits);
4322 4322
4323 } // namespace 4323 } // namespace
4324 4324
4325 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface 4325 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
4326 : public LayerTreeHostTest { 4326 : public LayerTreeHostTest {
4327 protected: 4327 protected:
4328 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() 4328 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface()
4329 : first_output_surface_memory_limit_(4321234), 4329 : first_output_surface_memory_limit_(4321234),
4330 second_output_surface_memory_limit_(1234321) {} 4330 second_output_surface_memory_limit_(1234321) {}
4331 4331
4332 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) 4332 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
4333 OVERRIDE { 4333 override {
4334 if (!first_context_provider_.get()) { 4334 if (!first_context_provider_.get()) {
4335 first_context_provider_ = TestContextProvider::Create(); 4335 first_context_provider_ = TestContextProvider::Create();
4336 } else { 4336 } else {
4337 EXPECT_FALSE(second_context_provider_.get()); 4337 EXPECT_FALSE(second_context_provider_.get());
4338 second_context_provider_ = TestContextProvider::Create(); 4338 second_context_provider_ = TestContextProvider::Create();
4339 } 4339 }
4340 4340
4341 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() 4341 scoped_refptr<TestContextProvider> provider(second_context_provider_.get()
4342 ? second_context_provider_ 4342 ? second_context_provider_
4343 : first_context_provider_); 4343 : first_context_provider_);
4344 scoped_ptr<FakeOutputSurface> output_surface; 4344 scoped_ptr<FakeOutputSurface> output_surface;
4345 if (delegating_renderer()) 4345 if (delegating_renderer())
4346 output_surface = FakeOutputSurface::CreateDelegating3d(provider); 4346 output_surface = FakeOutputSurface::CreateDelegating3d(provider);
4347 else 4347 else
4348 output_surface = FakeOutputSurface::Create3d(provider); 4348 output_surface = FakeOutputSurface::Create3d(provider);
4349 output_surface->SetMemoryPolicyToSetAtBind( 4349 output_surface->SetMemoryPolicyToSetAtBind(
4350 make_scoped_ptr(new ManagedMemoryPolicy( 4350 make_scoped_ptr(new ManagedMemoryPolicy(
4351 second_context_provider_.get() ? second_output_surface_memory_limit_ 4351 second_context_provider_.get() ? second_output_surface_memory_limit_
4352 : first_output_surface_memory_limit_, 4352 : first_output_surface_memory_limit_,
4353 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 4353 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
4354 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); 4354 ManagedMemoryPolicy::kDefaultNumResourcesLimit)));
4355 return output_surface.Pass(); 4355 return output_surface.Pass();
4356 } 4356 }
4357 4357
4358 virtual void SetupTree() OVERRIDE { 4358 virtual void SetupTree() override {
4359 root_ = FakeContentLayer::Create(&client_); 4359 root_ = FakeContentLayer::Create(&client_);
4360 root_->SetBounds(gfx::Size(20, 20)); 4360 root_->SetBounds(gfx::Size(20, 20));
4361 layer_tree_host()->SetRootLayer(root_); 4361 layer_tree_host()->SetRootLayer(root_);
4362 LayerTreeHostTest::SetupTree(); 4362 LayerTreeHostTest::SetupTree();
4363 } 4363 }
4364 4364
4365 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4365 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4366 4366
4367 virtual void DidCommitAndDrawFrame() OVERRIDE { 4367 virtual void DidCommitAndDrawFrame() override {
4368 // Lost context sometimes takes two frames to recreate. The third frame 4368 // Lost context sometimes takes two frames to recreate. The third frame
4369 // is sometimes aborted, so wait until the fourth frame to verify that 4369 // is sometimes aborted, so wait until the fourth frame to verify that
4370 // the memory has been set, and the fifth frame to end the test. 4370 // the memory has been set, and the fifth frame to end the test.
4371 if (layer_tree_host()->source_frame_number() < 5) { 4371 if (layer_tree_host()->source_frame_number() < 5) {
4372 layer_tree_host()->SetNeedsCommit(); 4372 layer_tree_host()->SetNeedsCommit();
4373 } else if (layer_tree_host()->source_frame_number() == 5) { 4373 } else if (layer_tree_host()->source_frame_number() == 5) {
4374 EndTest(); 4374 EndTest();
4375 } 4375 }
4376 } 4376 }
4377 4377
4378 virtual void SwapBuffersOnThread(LayerTreeHostImpl* impl, 4378 virtual void SwapBuffersOnThread(LayerTreeHostImpl* impl,
4379 bool result) OVERRIDE { 4379 bool result) override {
4380 switch (impl->active_tree()->source_frame_number()) { 4380 switch (impl->active_tree()->source_frame_number()) {
4381 case 1: 4381 case 1:
4382 EXPECT_EQ(first_output_surface_memory_limit_, 4382 EXPECT_EQ(first_output_surface_memory_limit_,
4383 impl->memory_allocation_limit_bytes()); 4383 impl->memory_allocation_limit_bytes());
4384 // Lose the output surface. 4384 // Lose the output surface.
4385 first_context_provider_->TestContext3d()->loseContextCHROMIUM( 4385 first_context_provider_->TestContext3d()->loseContextCHROMIUM(
4386 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); 4386 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
4387 break; 4387 break;
4388 case 4: 4388 case 4:
4389 EXPECT_EQ(second_output_surface_memory_limit_, 4389 EXPECT_EQ(second_output_surface_memory_limit_,
4390 impl->memory_allocation_limit_bytes()); 4390 impl->memory_allocation_limit_bytes());
4391 break; 4391 break;
4392 } 4392 }
4393 } 4393 }
4394 4394
4395 virtual void AfterTest() OVERRIDE {} 4395 virtual void AfterTest() override {}
4396 4396
4397 scoped_refptr<TestContextProvider> first_context_provider_; 4397 scoped_refptr<TestContextProvider> first_context_provider_;
4398 scoped_refptr<TestContextProvider> second_context_provider_; 4398 scoped_refptr<TestContextProvider> second_context_provider_;
4399 size_t first_output_surface_memory_limit_; 4399 size_t first_output_surface_memory_limit_;
4400 size_t second_output_surface_memory_limit_; 4400 size_t second_output_surface_memory_limit_;
4401 FakeContentLayerClient client_; 4401 FakeContentLayerClient client_;
4402 scoped_refptr<FakeContentLayer> root_; 4402 scoped_refptr<FakeContentLayer> root_;
4403 }; 4403 };
4404 4404
4405 // No output to copy for delegated renderers. 4405 // No output to copy for delegated renderers.
(...skipping 16 matching lines...) Expand all
4422 4422
4423 class TestSwapPromise : public SwapPromise { 4423 class TestSwapPromise : public SwapPromise {
4424 public: 4424 public:
4425 explicit TestSwapPromise(TestSwapPromiseResult* result) : result_(result) {} 4425 explicit TestSwapPromise(TestSwapPromiseResult* result) : result_(result) {}
4426 4426
4427 virtual ~TestSwapPromise() { 4427 virtual ~TestSwapPromise() {
4428 base::AutoLock lock(result_->lock); 4428 base::AutoLock lock(result_->lock);
4429 result_->dtor_called = true; 4429 result_->dtor_called = true;
4430 } 4430 }
4431 4431
4432 virtual void DidSwap(CompositorFrameMetadata* metadata) OVERRIDE { 4432 virtual void DidSwap(CompositorFrameMetadata* metadata) override {
4433 base::AutoLock lock(result_->lock); 4433 base::AutoLock lock(result_->lock);
4434 EXPECT_FALSE(result_->did_swap_called); 4434 EXPECT_FALSE(result_->did_swap_called);
4435 EXPECT_FALSE(result_->did_not_swap_called); 4435 EXPECT_FALSE(result_->did_not_swap_called);
4436 result_->did_swap_called = true; 4436 result_->did_swap_called = true;
4437 } 4437 }
4438 4438
4439 virtual void DidNotSwap(DidNotSwapReason reason) OVERRIDE { 4439 virtual void DidNotSwap(DidNotSwapReason reason) override {
4440 base::AutoLock lock(result_->lock); 4440 base::AutoLock lock(result_->lock);
4441 EXPECT_FALSE(result_->did_swap_called); 4441 EXPECT_FALSE(result_->did_swap_called);
4442 EXPECT_FALSE(result_->did_not_swap_called); 4442 EXPECT_FALSE(result_->did_not_swap_called);
4443 result_->did_not_swap_called = true; 4443 result_->did_not_swap_called = true;
4444 result_->reason = reason; 4444 result_->reason = reason;
4445 } 4445 }
4446 4446
4447 virtual int64 TraceId() const OVERRIDE { return 0; } 4447 virtual int64 TraceId() const override { return 0; }
4448 4448
4449 private: 4449 private:
4450 // Not owned. 4450 // Not owned.
4451 TestSwapPromiseResult* result_; 4451 TestSwapPromiseResult* result_;
4452 }; 4452 };
4453 4453
4454 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { 4454 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest {
4455 protected: 4455 protected:
4456 LayerTreeHostTestBreakSwapPromise() 4456 LayerTreeHostTestBreakSwapPromise()
4457 : commit_count_(0), commit_complete_count_(0) {} 4457 : commit_count_(0), commit_complete_count_(0) {}
4458 4458
4459 virtual void WillBeginMainFrame() OVERRIDE { 4459 virtual void WillBeginMainFrame() override {
4460 ASSERT_LE(commit_count_, 2); 4460 ASSERT_LE(commit_count_, 2);
4461 scoped_ptr<SwapPromise> swap_promise( 4461 scoped_ptr<SwapPromise> swap_promise(
4462 new TestSwapPromise(&swap_promise_result_[commit_count_])); 4462 new TestSwapPromise(&swap_promise_result_[commit_count_]));
4463 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); 4463 layer_tree_host()->QueueSwapPromise(swap_promise.Pass());
4464 } 4464 }
4465 4465
4466 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4466 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4467 4467
4468 virtual void DidCommit() OVERRIDE { 4468 virtual void DidCommit() override {
4469 commit_count_++; 4469 commit_count_++;
4470 if (commit_count_ == 2) { 4470 if (commit_count_ == 2) {
4471 // This commit will finish. 4471 // This commit will finish.
4472 layer_tree_host()->SetNeedsCommit(); 4472 layer_tree_host()->SetNeedsCommit();
4473 } 4473 }
4474 } 4474 }
4475 4475
4476 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4476 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4477 commit_complete_count_++; 4477 commit_complete_count_++;
4478 if (commit_complete_count_ == 1) { 4478 if (commit_complete_count_ == 1) {
4479 // This commit will be aborted because no actual update. 4479 // This commit will be aborted because no actual update.
4480 PostSetNeedsUpdateLayersToMainThread(); 4480 PostSetNeedsUpdateLayersToMainThread();
4481 } else { 4481 } else {
4482 EndTest(); 4482 EndTest();
4483 } 4483 }
4484 } 4484 }
4485 4485
4486 virtual void AfterTest() OVERRIDE { 4486 virtual void AfterTest() override {
4487 // 3 commits are scheduled. 2 completes. 1 is aborted. 4487 // 3 commits are scheduled. 2 completes. 1 is aborted.
4488 EXPECT_EQ(commit_count_, 3); 4488 EXPECT_EQ(commit_count_, 3);
4489 EXPECT_EQ(commit_complete_count_, 2); 4489 EXPECT_EQ(commit_complete_count_, 2);
4490 4490
4491 { 4491 {
4492 // The first commit completes and causes swap buffer which finishes 4492 // The first commit completes and causes swap buffer which finishes
4493 // the promise. 4493 // the promise.
4494 base::AutoLock lock(swap_promise_result_[0].lock); 4494 base::AutoLock lock(swap_promise_result_[0].lock);
4495 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); 4495 EXPECT_TRUE(swap_promise_result_[0].did_swap_called);
4496 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); 4496 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called);
(...skipping 23 matching lines...) Expand all
4520 int commit_count_; 4520 int commit_count_;
4521 int commit_complete_count_; 4521 int commit_complete_count_;
4522 TestSwapPromiseResult swap_promise_result_[3]; 4522 TestSwapPromiseResult swap_promise_result_[3];
4523 }; 4523 };
4524 4524
4525 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); 4525 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise);
4526 4526
4527 class LayerTreeHostTestBreakSwapPromiseForVisibilityAbortedCommit 4527 class LayerTreeHostTestBreakSwapPromiseForVisibilityAbortedCommit
4528 : public LayerTreeHostTest { 4528 : public LayerTreeHostTest {
4529 protected: 4529 protected:
4530 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4530 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4531 4531
4532 virtual void DidCommit() OVERRIDE { 4532 virtual void DidCommit() override {
4533 layer_tree_host()->SetDeferCommits(true); 4533 layer_tree_host()->SetDeferCommits(true);
4534 layer_tree_host()->SetNeedsCommit(); 4534 layer_tree_host()->SetNeedsCommit();
4535 } 4535 }
4536 4536
4537 virtual void DidDeferCommit() OVERRIDE { 4537 virtual void DidDeferCommit() override {
4538 layer_tree_host()->SetVisible(false); 4538 layer_tree_host()->SetVisible(false);
4539 scoped_ptr<SwapPromise> swap_promise( 4539 scoped_ptr<SwapPromise> swap_promise(
4540 new TestSwapPromise(&swap_promise_result_)); 4540 new TestSwapPromise(&swap_promise_result_));
4541 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); 4541 layer_tree_host()->QueueSwapPromise(swap_promise.Pass());
4542 layer_tree_host()->SetDeferCommits(false); 4542 layer_tree_host()->SetDeferCommits(false);
4543 } 4543 }
4544 4544
4545 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, 4545 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4546 bool did_handle) OVERRIDE { 4546 bool did_handle) override {
4547 EndTest(); 4547 EndTest();
4548 } 4548 }
4549 4549
4550 virtual void AfterTest() OVERRIDE { 4550 virtual void AfterTest() override {
4551 { 4551 {
4552 base::AutoLock lock(swap_promise_result_.lock); 4552 base::AutoLock lock(swap_promise_result_.lock);
4553 EXPECT_FALSE(swap_promise_result_.did_swap_called); 4553 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4554 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); 4554 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4555 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); 4555 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4556 EXPECT_TRUE(swap_promise_result_.dtor_called); 4556 EXPECT_TRUE(swap_promise_result_.dtor_called);
4557 } 4557 }
4558 } 4558 }
4559 4559
4560 TestSwapPromiseResult swap_promise_result_; 4560 TestSwapPromiseResult swap_promise_result_;
4561 }; 4561 };
4562 4562
4563 SINGLE_AND_MULTI_THREAD_TEST_F( 4563 SINGLE_AND_MULTI_THREAD_TEST_F(
4564 LayerTreeHostTestBreakSwapPromiseForVisibilityAbortedCommit); 4564 LayerTreeHostTestBreakSwapPromiseForVisibilityAbortedCommit);
4565 4565
4566 class LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit 4566 class LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit
4567 : public LayerTreeHostTest { 4567 : public LayerTreeHostTest {
4568 protected: 4568 protected:
4569 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4569 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4570 4570
4571 virtual void DidCommit() OVERRIDE { 4571 virtual void DidCommit() override {
4572 if (TestEnded()) 4572 if (TestEnded())
4573 return; 4573 return;
4574 layer_tree_host()->SetDeferCommits(true); 4574 layer_tree_host()->SetDeferCommits(true);
4575 layer_tree_host()->SetNeedsCommit(); 4575 layer_tree_host()->SetNeedsCommit();
4576 } 4576 }
4577 4577
4578 virtual void DidDeferCommit() OVERRIDE { 4578 virtual void DidDeferCommit() override {
4579 layer_tree_host()->DidLoseOutputSurface(); 4579 layer_tree_host()->DidLoseOutputSurface();
4580 scoped_ptr<SwapPromise> swap_promise( 4580 scoped_ptr<SwapPromise> swap_promise(
4581 new TestSwapPromise(&swap_promise_result_)); 4581 new TestSwapPromise(&swap_promise_result_));
4582 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); 4582 layer_tree_host()->QueueSwapPromise(swap_promise.Pass());
4583 layer_tree_host()->SetDeferCommits(false); 4583 layer_tree_host()->SetDeferCommits(false);
4584 } 4584 }
4585 4585
4586 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, 4586 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4587 bool did_handle) OVERRIDE { 4587 bool did_handle) override {
4588 EndTest(); 4588 EndTest();
4589 // This lets the test finally commit and exit. 4589 // This lets the test finally commit and exit.
4590 MainThreadTaskRunner()->PostTask( 4590 MainThreadTaskRunner()->PostTask(
4591 FROM_HERE, 4591 FROM_HERE,
4592 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit:: 4592 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit::
4593 FindOutputSurface, 4593 FindOutputSurface,
4594 base::Unretained(this))); 4594 base::Unretained(this)));
4595 } 4595 }
4596 4596
4597 void FindOutputSurface() { 4597 void FindOutputSurface() {
4598 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(true); 4598 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(true);
4599 } 4599 }
4600 4600
4601 virtual void AfterTest() OVERRIDE { 4601 virtual void AfterTest() override {
4602 { 4602 {
4603 base::AutoLock lock(swap_promise_result_.lock); 4603 base::AutoLock lock(swap_promise_result_.lock);
4604 EXPECT_FALSE(swap_promise_result_.did_swap_called); 4604 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4605 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); 4605 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4606 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); 4606 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4607 EXPECT_TRUE(swap_promise_result_.dtor_called); 4607 EXPECT_TRUE(swap_promise_result_.dtor_called);
4608 } 4608 }
4609 } 4609 }
4610 4610
4611 TestSwapPromiseResult swap_promise_result_; 4611 TestSwapPromiseResult swap_promise_result_;
4612 }; 4612 };
4613 4613
4614 SINGLE_AND_MULTI_THREAD_TEST_F( 4614 SINGLE_AND_MULTI_THREAD_TEST_F(
4615 LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit); 4615 LayerTreeHostTestBreakSwapPromiseForContextAbortedCommit);
4616 4616
4617 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 4617 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
4618 public: 4618 public:
4619 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, 4619 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
4620 LayerTreeHostImpl* layer_tree_host_impl, 4620 LayerTreeHostImpl* layer_tree_host_impl,
4621 int* set_needs_commit_count, 4621 int* set_needs_commit_count,
4622 int* set_needs_redraw_count) 4622 int* set_needs_redraw_count)
4623 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 4623 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
4624 set_needs_commit_count_(set_needs_commit_count) {} 4624 set_needs_commit_count_(set_needs_commit_count) {}
4625 4625
4626 virtual ~SimpleSwapPromiseMonitor() {} 4626 virtual ~SimpleSwapPromiseMonitor() {}
4627 4627
4628 virtual void OnSetNeedsCommitOnMain() OVERRIDE { 4628 virtual void OnSetNeedsCommitOnMain() override {
4629 (*set_needs_commit_count_)++; 4629 (*set_needs_commit_count_)++;
4630 } 4630 }
4631 4631
4632 virtual void OnSetNeedsRedrawOnImpl() OVERRIDE { 4632 virtual void OnSetNeedsRedrawOnImpl() override {
4633 ADD_FAILURE() << "Should not get called on main thread."; 4633 ADD_FAILURE() << "Should not get called on main thread.";
4634 } 4634 }
4635 4635
4636 virtual void OnForwardScrollUpdateToMainThreadOnImpl() OVERRIDE { 4636 virtual void OnForwardScrollUpdateToMainThreadOnImpl() override {
4637 ADD_FAILURE() << "Should not get called on main thread."; 4637 ADD_FAILURE() << "Should not get called on main thread.";
4638 } 4638 }
4639 4639
4640 private: 4640 private:
4641 int* set_needs_commit_count_; 4641 int* set_needs_commit_count_;
4642 }; 4642 };
4643 4643
4644 class LayerTreeHostTestSimpleSwapPromiseMonitor : public LayerTreeHostTest { 4644 class LayerTreeHostTestSimpleSwapPromiseMonitor : public LayerTreeHostTest {
4645 public: 4645 public:
4646 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4646 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4647 4647
4648 virtual void WillBeginMainFrame() OVERRIDE { 4648 virtual void WillBeginMainFrame() override {
4649 if (TestEnded()) 4649 if (TestEnded())
4650 return; 4650 return;
4651 4651
4652 int set_needs_commit_count = 0; 4652 int set_needs_commit_count = 0;
4653 int set_needs_redraw_count = 0; 4653 int set_needs_redraw_count = 0;
4654 4654
4655 { 4655 {
4656 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( 4656 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
4657 new SimpleSwapPromiseMonitor(layer_tree_host(), 4657 new SimpleSwapPromiseMonitor(layer_tree_host(),
4658 NULL, 4658 NULL,
(...skipping 28 matching lines...) Expand all
4687 &set_needs_commit_count, 4687 &set_needs_commit_count,
4688 &set_needs_redraw_count)); 4688 &set_needs_redraw_count));
4689 layer_tree_host()->SetNeedsAnimate(); 4689 layer_tree_host()->SetNeedsAnimate();
4690 EXPECT_EQ(3, set_needs_commit_count); 4690 EXPECT_EQ(3, set_needs_commit_count);
4691 EXPECT_EQ(0, set_needs_redraw_count); 4691 EXPECT_EQ(0, set_needs_redraw_count);
4692 } 4692 }
4693 4693
4694 EndTest(); 4694 EndTest();
4695 } 4695 }
4696 4696
4697 virtual void AfterTest() OVERRIDE {} 4697 virtual void AfterTest() override {}
4698 }; 4698 };
4699 4699
4700 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); 4700 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor);
4701 4701
4702 class LayerTreeHostTestHighResRequiredAfterEvictingUIResources 4702 class LayerTreeHostTestHighResRequiredAfterEvictingUIResources
4703 : public LayerTreeHostTest { 4703 : public LayerTreeHostTest {
4704 protected: 4704 protected:
4705 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4705 virtual void InitializeSettings(LayerTreeSettings* settings) override {
4706 settings->impl_side_painting = true; 4706 settings->impl_side_painting = true;
4707 } 4707 }
4708 4708
4709 virtual void SetupTree() OVERRIDE { 4709 virtual void SetupTree() override {
4710 LayerTreeHostTest::SetupTree(); 4710 LayerTreeHostTest::SetupTree();
4711 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); 4711 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host());
4712 } 4712 }
4713 4713
4714 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4714 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4715 4715
4716 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4716 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4717 host_impl->EvictAllUIResources(); 4717 host_impl->EvictAllUIResources();
4718 // Existence of evicted UI resources will trigger NEW_CONTENT_TAKES_PRIORITY 4718 // Existence of evicted UI resources will trigger NEW_CONTENT_TAKES_PRIORITY
4719 // mode. Active tree should require high-res to draw after entering this 4719 // mode. Active tree should require high-res to draw after entering this
4720 // mode to ensure that high-res tiles are also required for a pending tree 4720 // mode to ensure that high-res tiles are also required for a pending tree
4721 // to be activated. 4721 // to be activated.
4722 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw()); 4722 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw());
4723 } 4723 }
4724 4724
4725 virtual void DidCommit() OVERRIDE { 4725 virtual void DidCommit() override {
4726 int frame = layer_tree_host()->source_frame_number(); 4726 int frame = layer_tree_host()->source_frame_number();
4727 switch (frame) { 4727 switch (frame) {
4728 case 1: 4728 case 1:
4729 PostSetNeedsCommitToMainThread(); 4729 PostSetNeedsCommitToMainThread();
4730 break; 4730 break;
4731 case 2: 4731 case 2:
4732 ui_resource_ = nullptr; 4732 ui_resource_ = nullptr;
4733 EndTest(); 4733 EndTest();
4734 break; 4734 break;
4735 } 4735 }
4736 } 4736 }
4737 4737
4738 virtual void AfterTest() OVERRIDE {} 4738 virtual void AfterTest() override {}
4739 4739
4740 FakeContentLayerClient client_; 4740 FakeContentLayerClient client_;
4741 scoped_ptr<FakeScopedUIResource> ui_resource_; 4741 scoped_ptr<FakeScopedUIResource> ui_resource_;
4742 }; 4742 };
4743 4743
4744 // This test is flaky, see http://crbug.com/386199 4744 // This test is flaky, see http://crbug.com/386199
4745 // MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources) 4745 // MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources)
4746 4746
4747 class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest { 4747 class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest {
4748 protected: 4748 protected:
4749 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4749 virtual void InitializeSettings(LayerTreeSettings* settings) override {
4750 settings->impl_side_painting = true; 4750 settings->impl_side_painting = true;
4751 4751
4752 EXPECT_FALSE(settings->gpu_rasterization_enabled); 4752 EXPECT_FALSE(settings->gpu_rasterization_enabled);
4753 EXPECT_FALSE(settings->gpu_rasterization_forced); 4753 EXPECT_FALSE(settings->gpu_rasterization_forced);
4754 } 4754 }
4755 4755
4756 virtual void SetupTree() OVERRIDE { 4756 virtual void SetupTree() override {
4757 LayerTreeHostTest::SetupTree(); 4757 LayerTreeHostTest::SetupTree();
4758 4758
4759 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); 4759 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_);
4760 layer->SetBounds(gfx::Size(10, 10)); 4760 layer->SetBounds(gfx::Size(10, 10));
4761 layer->SetIsDrawable(true); 4761 layer->SetIsDrawable(true);
4762 layer_tree_host()->root_layer()->AddChild(layer); 4762 layer_tree_host()->root_layer()->AddChild(layer);
4763 } 4763 }
4764 4764
4765 virtual void BeginTest() OVERRIDE { 4765 virtual void BeginTest() override {
4766 Layer* root = layer_tree_host()->root_layer(); 4766 Layer* root = layer_tree_host()->root_layer();
4767 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); 4767 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0));
4768 PicturePile* pile = layer->GetPicturePileForTesting(); 4768 PicturePile* pile = layer->GetPicturePileForTesting();
4769 4769
4770 // Verify default values. 4770 // Verify default values.
4771 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); 4771 EXPECT_TRUE(root->IsSuitableForGpuRasterization());
4772 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); 4772 EXPECT_TRUE(layer->IsSuitableForGpuRasterization());
4773 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); 4773 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization());
4774 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 4774 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4775 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); 4775 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization());
4776 4776
4777 // Setting gpu rasterization trigger does not enable gpu rasterization. 4777 // Setting gpu rasterization trigger does not enable gpu rasterization.
4778 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4778 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4779 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4779 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4780 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); 4780 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization());
4781 4781
4782 PostSetNeedsCommitToMainThread(); 4782 PostSetNeedsCommitToMainThread();
4783 } 4783 }
4784 4784
4785 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4785 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4786 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); 4786 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization());
4787 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4787 EXPECT_FALSE(host_impl->use_gpu_rasterization());
4788 } 4788 }
4789 4789
4790 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4790 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4791 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); 4791 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization());
4792 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4792 EXPECT_FALSE(host_impl->use_gpu_rasterization());
4793 EndTest(); 4793 EndTest();
4794 } 4794 }
4795 4795
4796 virtual void AfterTest() OVERRIDE {} 4796 virtual void AfterTest() override {}
4797 4797
4798 FakeContentLayerClient layer_client_; 4798 FakeContentLayerClient layer_client_;
4799 }; 4799 };
4800 4800
4801 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault); 4801 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault);
4802 4802
4803 class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { 4803 class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest {
4804 protected: 4804 protected:
4805 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4805 virtual void InitializeSettings(LayerTreeSettings* settings) override {
4806 settings->impl_side_painting = true; 4806 settings->impl_side_painting = true;
4807 4807
4808 EXPECT_FALSE(settings->gpu_rasterization_enabled); 4808 EXPECT_FALSE(settings->gpu_rasterization_enabled);
4809 settings->gpu_rasterization_enabled = true; 4809 settings->gpu_rasterization_enabled = true;
4810 } 4810 }
4811 4811
4812 virtual void SetupTree() OVERRIDE { 4812 virtual void SetupTree() override {
4813 LayerTreeHostTest::SetupTree(); 4813 LayerTreeHostTest::SetupTree();
4814 4814
4815 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); 4815 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_);
4816 layer->SetBounds(gfx::Size(10, 10)); 4816 layer->SetBounds(gfx::Size(10, 10));
4817 layer->SetIsDrawable(true); 4817 layer->SetIsDrawable(true);
4818 layer_tree_host()->root_layer()->AddChild(layer); 4818 layer_tree_host()->root_layer()->AddChild(layer);
4819 } 4819 }
4820 4820
4821 virtual void BeginTest() OVERRIDE { 4821 virtual void BeginTest() override {
4822 Layer* root = layer_tree_host()->root_layer(); 4822 Layer* root = layer_tree_host()->root_layer();
4823 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); 4823 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0));
4824 PicturePile* pile = layer->GetPicturePileForTesting(); 4824 PicturePile* pile = layer->GetPicturePileForTesting();
4825 4825
4826 // Verify default values. 4826 // Verify default values.
4827 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); 4827 EXPECT_TRUE(root->IsSuitableForGpuRasterization());
4828 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); 4828 EXPECT_TRUE(layer->IsSuitableForGpuRasterization());
4829 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); 4829 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization());
4830 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 4830 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4831 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); 4831 EXPECT_FALSE(layer_tree_host()->UseGpuRasterization());
4832 4832
4833 // Gpu rasterization trigger is relevant. 4833 // Gpu rasterization trigger is relevant.
4834 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4834 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4835 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4835 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4836 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); 4836 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization());
4837 4837
4838 // Content-based veto is relevant as well. 4838 // Content-based veto is relevant as well.
4839 pile->SetUnsuitableForGpuRasterizationForTesting(); 4839 pile->SetUnsuitableForGpuRasterizationForTesting();
4840 EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); 4840 EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization());
4841 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); 4841 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
4842 // Veto will take effect when layers are updated. 4842 // Veto will take effect when layers are updated.
4843 // The results will be verified after commit is completed below. 4843 // The results will be verified after commit is completed below.
4844 // Since we are manually marking picture pile as unsuitable, 4844 // Since we are manually marking picture pile as unsuitable,
4845 // make sure that the layer gets a chance to update. 4845 // make sure that the layer gets a chance to update.
4846 layer->SetNeedsDisplay(); 4846 layer->SetNeedsDisplay();
4847 PostSetNeedsCommitToMainThread(); 4847 PostSetNeedsCommitToMainThread();
4848 } 4848 }
4849 4849
4850 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4850 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4851 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); 4851 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization());
4852 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4852 EXPECT_FALSE(host_impl->use_gpu_rasterization());
4853 } 4853 }
4854 4854
4855 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4855 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4856 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); 4856 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization());
4857 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4857 EXPECT_FALSE(host_impl->use_gpu_rasterization());
4858 EndTest(); 4858 EndTest();
4859 } 4859 }
4860 4860
4861 virtual void AfterTest() OVERRIDE {} 4861 virtual void AfterTest() override {}
4862 4862
4863 FakeContentLayerClient layer_client_; 4863 FakeContentLayerClient layer_client_;
4864 }; 4864 };
4865 4865
4866 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); 4866 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled);
4867 4867
4868 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { 4868 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
4869 protected: 4869 protected:
4870 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4870 virtual void InitializeSettings(LayerTreeSettings* settings) override {
4871 settings->impl_side_painting = true; 4871 settings->impl_side_painting = true;
4872 4872
4873 EXPECT_FALSE(settings->gpu_rasterization_forced); 4873 EXPECT_FALSE(settings->gpu_rasterization_forced);
4874 settings->gpu_rasterization_forced = true; 4874 settings->gpu_rasterization_forced = true;
4875 } 4875 }
4876 4876
4877 virtual void SetupTree() OVERRIDE { 4877 virtual void SetupTree() override {
4878 LayerTreeHostTest::SetupTree(); 4878 LayerTreeHostTest::SetupTree();
4879 4879
4880 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_); 4880 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&layer_client_);
4881 layer->SetBounds(gfx::Size(10, 10)); 4881 layer->SetBounds(gfx::Size(10, 10));
4882 layer->SetIsDrawable(true); 4882 layer->SetIsDrawable(true);
4883 layer_tree_host()->root_layer()->AddChild(layer); 4883 layer_tree_host()->root_layer()->AddChild(layer);
4884 } 4884 }
4885 4885
4886 virtual void BeginTest() OVERRIDE { 4886 virtual void BeginTest() override {
4887 Layer* root = layer_tree_host()->root_layer(); 4887 Layer* root = layer_tree_host()->root_layer();
4888 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); 4888 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0));
4889 PicturePile* pile = layer->GetPicturePileForTesting(); 4889 PicturePile* pile = layer->GetPicturePileForTesting();
4890 4890
4891 // Verify default values. 4891 // Verify default values.
4892 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); 4892 EXPECT_TRUE(root->IsSuitableForGpuRasterization());
4893 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); 4893 EXPECT_TRUE(layer->IsSuitableForGpuRasterization());
4894 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); 4894 EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization());
4895 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 4895 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4896 4896
4897 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. 4897 // With gpu rasterization forced, gpu rasterization trigger is irrelevant.
4898 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); 4898 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization());
4899 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4899 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4900 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4900 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4901 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); 4901 EXPECT_TRUE(layer_tree_host()->UseGpuRasterization());
4902 4902
4903 // Content-based veto is irrelevant as well. 4903 // Content-based veto is irrelevant as well.
4904 pile->SetUnsuitableForGpuRasterizationForTesting(); 4904 pile->SetUnsuitableForGpuRasterizationForTesting();
4905 EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); 4905 EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization());
4906 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); 4906 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
4907 // Veto will take effect when layers are updated. 4907 // Veto will take effect when layers are updated.
4908 // The results will be verified after commit is completed below. 4908 // The results will be verified after commit is completed below.
4909 // Since we are manually marking picture pile as unsuitable, 4909 // Since we are manually marking picture pile as unsuitable,
4910 // make sure that the layer gets a chance to update. 4910 // make sure that the layer gets a chance to update.
4911 layer->SetNeedsDisplay(); 4911 layer->SetNeedsDisplay();
4912 PostSetNeedsCommitToMainThread(); 4912 PostSetNeedsCommitToMainThread();
4913 } 4913 }
4914 4914
4915 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4915 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4916 EXPECT_TRUE(host_impl->pending_tree()->use_gpu_rasterization()); 4916 EXPECT_TRUE(host_impl->pending_tree()->use_gpu_rasterization());
4917 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 4917 EXPECT_TRUE(host_impl->use_gpu_rasterization());
4918 } 4918 }
4919 4919
4920 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 4920 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4921 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); 4921 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization());
4922 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 4922 EXPECT_TRUE(host_impl->use_gpu_rasterization());
4923 EndTest(); 4923 EndTest();
4924 } 4924 }
4925 4925
4926 virtual void AfterTest() OVERRIDE {} 4926 virtual void AfterTest() override {}
4927 4927
4928 FakeContentLayerClient layer_client_; 4928 FakeContentLayerClient layer_client_;
4929 }; 4929 };
4930 4930
4931 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); 4931 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced);
4932 4932
4933 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { 4933 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest {
4934 public: 4934 public:
4935 LayerTreeHostTestContinuousPainting() 4935 LayerTreeHostTestContinuousPainting()
4936 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} 4936 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {}
4937 4937
4938 protected: 4938 protected:
4939 enum { kExpectedNumCommits = 10 }; 4939 enum { kExpectedNumCommits = 10 };
4940 4940
4941 virtual void SetupTree() OVERRIDE { 4941 virtual void SetupTree() override {
4942 scoped_refptr<Layer> root_layer = Layer::Create(); 4942 scoped_refptr<Layer> root_layer = Layer::Create();
4943 root_layer->SetBounds(bounds_); 4943 root_layer->SetBounds(bounds_);
4944 4944
4945 if (layer_tree_host()->settings().impl_side_painting) { 4945 if (layer_tree_host()->settings().impl_side_painting) {
4946 picture_layer_ = FakePictureLayer::Create(&client_); 4946 picture_layer_ = FakePictureLayer::Create(&client_);
4947 child_layer_ = picture_layer_.get(); 4947 child_layer_ = picture_layer_.get();
4948 } else { 4948 } else {
4949 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); 4949 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_);
4950 child_layer_ = content_layer_.get(); 4950 child_layer_ = content_layer_.get();
4951 } 4951 }
4952 child_layer_->SetBounds(bounds_); 4952 child_layer_->SetBounds(bounds_);
4953 child_layer_->SetIsDrawable(true); 4953 child_layer_->SetIsDrawable(true);
4954 root_layer->AddChild(child_layer_); 4954 root_layer->AddChild(child_layer_);
4955 4955
4956 layer_tree_host()->SetRootLayer(root_layer); 4956 layer_tree_host()->SetRootLayer(root_layer);
4957 layer_tree_host()->SetViewportSize(bounds_); 4957 layer_tree_host()->SetViewportSize(bounds_);
4958 LayerTreeHostTest::SetupTree(); 4958 LayerTreeHostTest::SetupTree();
4959 } 4959 }
4960 4960
4961 virtual void BeginTest() OVERRIDE { 4961 virtual void BeginTest() override {
4962 MainThreadTaskRunner()->PostTask( 4962 MainThreadTaskRunner()->PostTask(
4963 FROM_HERE, 4963 FROM_HERE,
4964 base::Bind( 4964 base::Bind(
4965 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, 4965 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting,
4966 base::Unretained(this))); 4966 base::Unretained(this)));
4967 // Wait 50x longer than expected. 4967 // Wait 50x longer than expected.
4968 double milliseconds_per_frame = 4968 double milliseconds_per_frame =
4969 1000.0 / layer_tree_host()->settings().refresh_rate; 4969 1000.0 / layer_tree_host()->settings().refresh_rate;
4970 MainThreadTaskRunner()->PostDelayedTask( 4970 MainThreadTaskRunner()->PostDelayedTask(
4971 FROM_HERE, 4971 FROM_HERE,
4972 base::Bind( 4972 base::Bind(
4973 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, 4973 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting,
4974 base::Unretained(this)), 4974 base::Unretained(this)),
4975 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * 4975 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits *
4976 milliseconds_per_frame)); 4976 milliseconds_per_frame));
4977 } 4977 }
4978 4978
4979 virtual void BeginMainFrame(const BeginFrameArgs& args) OVERRIDE { 4979 virtual void BeginMainFrame(const BeginFrameArgs& args) override {
4980 child_layer_->SetNeedsDisplay(); 4980 child_layer_->SetNeedsDisplay();
4981 } 4981 }
4982 4982
4983 virtual void AfterTest() OVERRIDE { 4983 virtual void AfterTest() override {
4984 EXPECT_LE(kExpectedNumCommits, num_commits_); 4984 EXPECT_LE(kExpectedNumCommits, num_commits_);
4985 EXPECT_LE(kExpectedNumCommits, num_draws_); 4985 EXPECT_LE(kExpectedNumCommits, num_draws_);
4986 int update_count = content_layer_.get() 4986 int update_count = content_layer_.get()
4987 ? content_layer_->PaintContentsCount() 4987 ? content_layer_->PaintContentsCount()
4988 : picture_layer_->update_count(); 4988 : picture_layer_->update_count();
4989 EXPECT_LE(kExpectedNumCommits, update_count); 4989 EXPECT_LE(kExpectedNumCommits, update_count);
4990 } 4990 }
4991 4991
4992 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4992 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
4993 if (++num_draws_ == kExpectedNumCommits) 4993 if (++num_draws_ == kExpectedNumCommits)
4994 EndTest(); 4994 EndTest();
4995 } 4995 }
4996 4996
4997 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4997 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
4998 ++num_commits_; 4998 ++num_commits_;
4999 } 4999 }
5000 5000
5001 private: 5001 private:
5002 void EnableContinuousPainting() { 5002 void EnableContinuousPainting() {
5003 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); 5003 LayerTreeDebugState debug_state = layer_tree_host()->debug_state();
5004 debug_state.continuous_painting = true; 5004 debug_state.continuous_painting = true;
5005 layer_tree_host()->SetDebugState(debug_state); 5005 layer_tree_host()->SetDebugState(debug_state);
5006 } 5006 }
5007 5007
(...skipping 13 matching lines...) Expand all
5021 Layer* child_layer_; 5021 Layer* child_layer_;
5022 }; 5022 };
5023 5023
5024 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5024 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5025 5025
5026 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest { 5026 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest {
5027 public: 5027 public:
5028 LayerTreeHostTestActivateOnInvisible() 5028 LayerTreeHostTestActivateOnInvisible()
5029 : activation_count_(0), visible_(true) {} 5029 : activation_count_(0), visible_(true) {}
5030 5030
5031 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 5031 virtual void InitializeSettings(LayerTreeSettings* settings) override {
5032 settings->impl_side_painting = true; 5032 settings->impl_side_painting = true;
5033 } 5033 }
5034 5034
5035 virtual void BeginTest() OVERRIDE { 5035 virtual void BeginTest() override {
5036 // Kick off the test with a commit. 5036 // Kick off the test with a commit.
5037 PostSetNeedsCommitToMainThread(); 5037 PostSetNeedsCommitToMainThread();
5038 } 5038 }
5039 5039
5040 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 5040 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
5041 // Make sure we don't activate using the notify signal from tile manager. 5041 // Make sure we don't activate using the notify signal from tile manager.
5042 host_impl->BlockNotifyReadyToActivateForTesting(true); 5042 host_impl->BlockNotifyReadyToActivateForTesting(true);
5043 } 5043 }
5044 5044
5045 virtual void DidCommit() OVERRIDE { layer_tree_host()->SetVisible(false); } 5045 virtual void DidCommit() override { layer_tree_host()->SetVisible(false); }
5046 5046
5047 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, 5047 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
5048 bool visible) OVERRIDE { 5048 bool visible) override {
5049 visible_ = visible; 5049 visible_ = visible;
5050 5050
5051 // Once invisible, we can go visible again. 5051 // Once invisible, we can go visible again.
5052 if (!visible) { 5052 if (!visible) {
5053 PostSetVisibleToMainThread(true); 5053 PostSetVisibleToMainThread(true);
5054 } else { 5054 } else {
5055 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw()); 5055 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw());
5056 EndTest(); 5056 EndTest();
5057 } 5057 }
5058 } 5058 }
5059 5059
5060 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 5060 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5061 ++activation_count_; 5061 ++activation_count_;
5062 EXPECT_FALSE(visible_); 5062 EXPECT_FALSE(visible_);
5063 } 5063 }
5064 5064
5065 virtual void AfterTest() OVERRIDE { 5065 virtual void AfterTest() override {
5066 // Ensure we activated even though the signal was blocked. 5066 // Ensure we activated even though the signal was blocked.
5067 EXPECT_EQ(1, activation_count_); 5067 EXPECT_EQ(1, activation_count_);
5068 EXPECT_TRUE(visible_); 5068 EXPECT_TRUE(visible_);
5069 } 5069 }
5070 5070
5071 private: 5071 private:
5072 int activation_count_; 5072 int activation_count_;
5073 bool visible_; 5073 bool visible_;
5074 5074
5075 FakeContentLayerClient client_; 5075 FakeContentLayerClient client_;
5076 scoped_refptr<FakePictureLayer> picture_layer_; 5076 scoped_refptr<FakePictureLayer> picture_layer_;
5077 }; 5077 };
5078 5078
5079 // TODO(vmpstr): Enable with single thread impl-side painting. 5079 // TODO(vmpstr): Enable with single thread impl-side painting.
5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); 5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible);
5081 5081
5082 } // namespace cc 5082 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_pixeltest_readback.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698