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

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

Issue 1169643002: cc: Make unittests use FakePictureLayer instead of FakeContentLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implsidetests: . Created 5 years, 6 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
« no previous file with comments | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/layer_iterator.h" 5 #include "cc/layers/layer_iterator.h"
6 #include "cc/output/copy_output_request.h" 6 #include "cc/output/copy_output_request.h"
7 #include "cc/output/copy_output_result.h" 7 #include "cc/output/copy_output_result.h"
8 #include "cc/test/fake_content_layer.h"
9 #include "cc/test/fake_content_layer_client.h" 8 #include "cc/test/fake_content_layer_client.h"
10 #include "cc/test/fake_output_surface.h" 9 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/fake_picture_layer.h"
11 #include "cc/test/layer_tree_test.h" 11 #include "cc/test/layer_tree_test.h"
12 #include "cc/trees/layer_tree_impl.h" 12 #include "cc/trees/layer_tree_impl.h"
13 #include "gpu/GLES2/gl2extchromium.h" 13 #include "gpu/GLES2/gl2extchromium.h"
14 14
15 namespace cc { 15 namespace cc {
16 namespace { 16 namespace {
17 17
18 // These tests only use direct rendering, as there is no output to copy for 18 // These tests only use direct rendering, as there is no output to copy for
19 // delegated renderers. 19 // delegated renderers.
20 class LayerTreeHostCopyRequestTest : public LayerTreeTest {}; 20 class LayerTreeHostCopyRequestTest : public LayerTreeTest {};
21 21
22 class LayerTreeHostCopyRequestTestMultipleRequests 22 class LayerTreeHostCopyRequestTestMultipleRequests
23 : public LayerTreeHostCopyRequestTest { 23 : public LayerTreeHostCopyRequestTest {
24 protected: 24 protected:
25 void SetupTree() override { 25 void SetupTree() override {
26 root = FakeContentLayer::Create(layer_settings(), &client_); 26 root = FakePictureLayer::Create(layer_settings(), &client_);
27 root->SetBounds(gfx::Size(20, 20)); 27 root->SetBounds(gfx::Size(20, 20));
28 28
29 child = FakeContentLayer::Create(layer_settings(), &client_); 29 child = FakePictureLayer::Create(layer_settings(), &client_);
30 child->SetBounds(gfx::Size(10, 10)); 30 child->SetBounds(gfx::Size(10, 10));
31 root->AddChild(child); 31 root->AddChild(child);
32 32
33 layer_tree_host()->SetRootLayer(root); 33 layer_tree_host()->SetRootLayer(root);
34 LayerTreeHostCopyRequestTest::SetupTree(); 34 LayerTreeHostCopyRequestTest::SetupTree();
35 } 35 }
36 36
37 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 37 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
38 38
39 void DidCommitAndDrawFrame() override { WaitForCallback(); } 39 void DidCommitAndDrawFrame() override { WaitForCallback(); }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 107 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
108 if (use_gl_renderer_) 108 if (use_gl_renderer_)
109 return FakeOutputSurface::Create3d(); 109 return FakeOutputSurface::Create3d();
110 return FakeOutputSurface::CreateSoftware( 110 return FakeOutputSurface::CreateSoftware(
111 make_scoped_ptr(new SoftwareOutputDevice)); 111 make_scoped_ptr(new SoftwareOutputDevice));
112 } 112 }
113 113
114 bool use_gl_renderer_; 114 bool use_gl_renderer_;
115 std::vector<gfx::Size> callbacks_; 115 std::vector<gfx::Size> callbacks_;
116 FakeContentLayerClient client_; 116 FakeContentLayerClient client_;
117 scoped_refptr<FakeContentLayer> root; 117 scoped_refptr<FakePictureLayer> root;
118 scoped_refptr<FakeContentLayer> child; 118 scoped_refptr<FakePictureLayer> child;
119 }; 119 };
120 120
121 // Readback can't be done with a delegating renderer. 121 // Readback can't be done with a delegating renderer.
122 // Disabled due to flake: http://crbug.com/448521 122 // Disabled due to flake: http://crbug.com/448521
123 TEST_F(LayerTreeHostCopyRequestTestMultipleRequests, 123 TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
124 DISABLED_GLRenderer_RunSingleThread) { 124 DISABLED_GLRenderer_RunSingleThread) {
125 use_gl_renderer_ = true; 125 use_gl_renderer_ = true;
126 RunTest(false, false, false); 126 RunTest(false, false, false);
127 } 127 }
128 128
(...skipping 12 matching lines...) Expand all
141 TEST_F(LayerTreeHostCopyRequestTestMultipleRequests, 141 TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
142 SoftwareRenderer_RunMultiThread_MainThreadPainting) { 142 SoftwareRenderer_RunMultiThread_MainThreadPainting) {
143 use_gl_renderer_ = false; 143 use_gl_renderer_ = false;
144 RunTest(true, false, false); 144 RunTest(true, false, false);
145 } 145 }
146 146
147 class LayerTreeHostCopyRequestTestLayerDestroyed 147 class LayerTreeHostCopyRequestTestLayerDestroyed
148 : public LayerTreeHostCopyRequestTest { 148 : public LayerTreeHostCopyRequestTest {
149 protected: 149 protected:
150 void SetupTree() override { 150 void SetupTree() override {
151 root_ = FakeContentLayer::Create(layer_settings(), &client_); 151 root_ = FakePictureLayer::Create(layer_settings(), &client_);
152 root_->SetBounds(gfx::Size(20, 20)); 152 root_->SetBounds(gfx::Size(20, 20));
153 153
154 main_destroyed_ = FakeContentLayer::Create(layer_settings(), &client_); 154 main_destroyed_ = FakePictureLayer::Create(layer_settings(), &client_);
155 main_destroyed_->SetBounds(gfx::Size(15, 15)); 155 main_destroyed_->SetBounds(gfx::Size(15, 15));
156 root_->AddChild(main_destroyed_); 156 root_->AddChild(main_destroyed_);
157 157
158 impl_destroyed_ = FakeContentLayer::Create(layer_settings(), &client_); 158 impl_destroyed_ = FakePictureLayer::Create(layer_settings(), &client_);
159 impl_destroyed_->SetBounds(gfx::Size(10, 10)); 159 impl_destroyed_->SetBounds(gfx::Size(10, 10));
160 root_->AddChild(impl_destroyed_); 160 root_->AddChild(impl_destroyed_);
161 161
162 layer_tree_host()->SetRootLayer(root_); 162 layer_tree_host()->SetRootLayer(root_);
163 LayerTreeHostCopyRequestTest::SetupTree(); 163 LayerTreeHostCopyRequestTest::SetupTree();
164 } 164 }
165 165
166 void BeginTest() override { 166 void BeginTest() override {
167 callback_count_ = 0; 167 callback_count_ = 0;
168 PostSetNeedsCommitToMainThread(); 168 PostSetNeedsCommitToMainThread();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { 222 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
223 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); 223 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
224 EXPECT_TRUE(result->IsEmpty()); 224 EXPECT_TRUE(result->IsEmpty());
225 ++callback_count_; 225 ++callback_count_;
226 } 226 }
227 227
228 void AfterTest() override {} 228 void AfterTest() override {}
229 229
230 int callback_count_; 230 int callback_count_;
231 FakeContentLayerClient client_; 231 FakeContentLayerClient client_;
232 scoped_refptr<FakeContentLayer> root_; 232 scoped_refptr<FakePictureLayer> root_;
233 scoped_refptr<FakeContentLayer> main_destroyed_; 233 scoped_refptr<FakePictureLayer> main_destroyed_;
234 scoped_refptr<FakeContentLayer> impl_destroyed_; 234 scoped_refptr<FakePictureLayer> impl_destroyed_;
235 }; 235 };
236 236
237 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestLayerDestroyed); 237 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestLayerDestroyed);
238 238
239 class LayerTreeHostCopyRequestTestInHiddenSubtree 239 class LayerTreeHostCopyRequestTestInHiddenSubtree
240 : public LayerTreeHostCopyRequestTest { 240 : public LayerTreeHostCopyRequestTest {
241 protected: 241 protected:
242 void SetupTree() override { 242 void SetupTree() override {
243 root_ = FakeContentLayer::Create(layer_settings(), &client_); 243 root_ = FakePictureLayer::Create(layer_settings(), &client_);
244 root_->SetBounds(gfx::Size(20, 20)); 244 root_->SetBounds(gfx::Size(20, 20));
245 245
246 grand_parent_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 246 grand_parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
247 grand_parent_layer_->SetBounds(gfx::Size(15, 15)); 247 grand_parent_layer_->SetBounds(gfx::Size(15, 15));
248 root_->AddChild(grand_parent_layer_); 248 root_->AddChild(grand_parent_layer_);
249 249
250 // parent_layer_ owns a render surface. 250 // parent_layer_ owns a render surface.
251 parent_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 251 parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
252 parent_layer_->SetBounds(gfx::Size(15, 15)); 252 parent_layer_->SetBounds(gfx::Size(15, 15));
253 parent_layer_->SetForceRenderSurface(true); 253 parent_layer_->SetForceRenderSurface(true);
254 grand_parent_layer_->AddChild(parent_layer_); 254 grand_parent_layer_->AddChild(parent_layer_);
255 255
256 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 256 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
257 copy_layer_->SetBounds(gfx::Size(10, 10)); 257 copy_layer_->SetBounds(gfx::Size(10, 10));
258 parent_layer_->AddChild(copy_layer_); 258 parent_layer_->AddChild(copy_layer_);
259 259
260 layer_tree_host()->SetRootLayer(root_); 260 layer_tree_host()->SetRootLayer(root_);
261 LayerTreeHostCopyRequestTest::SetupTree(); 261 LayerTreeHostCopyRequestTest::SetupTree();
262 } 262 }
263 263
264 void AddCopyRequest(Layer* layer) { 264 void AddCopyRequest(Layer* layer) {
265 layer->RequestCopyOfOutput( 265 layer->RequestCopyOfOutput(
266 CopyOutputRequest::CreateBitmapRequest(base::Bind( 266 CopyOutputRequest::CreateBitmapRequest(base::Bind(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 case 6: 319 case 6:
320 EndTest(); 320 EndTest();
321 break; 321 break;
322 } 322 }
323 } 323 }
324 324
325 void AfterTest() override {} 325 void AfterTest() override {}
326 326
327 int callback_count_; 327 int callback_count_;
328 FakeContentLayerClient client_; 328 FakeContentLayerClient client_;
329 scoped_refptr<FakeContentLayer> root_; 329 scoped_refptr<FakePictureLayer> root_;
330 scoped_refptr<FakeContentLayer> grand_parent_layer_; 330 scoped_refptr<FakePictureLayer> grand_parent_layer_;
331 scoped_refptr<FakeContentLayer> parent_layer_; 331 scoped_refptr<FakePictureLayer> parent_layer_;
332 scoped_refptr<FakeContentLayer> copy_layer_; 332 scoped_refptr<FakePictureLayer> copy_layer_;
333 }; 333 };
334 334
335 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 335 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_IMPL_TEST_F(
336 LayerTreeHostCopyRequestTestInHiddenSubtree); 336 LayerTreeHostCopyRequestTestInHiddenSubtree);
337 337
338 class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest 338 class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
339 : public LayerTreeHostCopyRequestTest { 339 : public LayerTreeHostCopyRequestTest {
340 protected: 340 protected:
341 void SetupTree() override { 341 void SetupTree() override {
342 root_ = FakeContentLayer::Create(layer_settings(), &client_); 342 root_ = FakePictureLayer::Create(layer_settings(), &client_);
343 root_->SetBounds(gfx::Size(20, 20)); 343 root_->SetBounds(gfx::Size(20, 20));
344 344
345 grand_parent_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 345 grand_parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
346 grand_parent_layer_->SetBounds(gfx::Size(15, 15)); 346 grand_parent_layer_->SetBounds(gfx::Size(15, 15));
347 grand_parent_layer_->SetHideLayerAndSubtree(true); 347 grand_parent_layer_->SetHideLayerAndSubtree(true);
348 root_->AddChild(grand_parent_layer_); 348 root_->AddChild(grand_parent_layer_);
349 349
350 // parent_layer_ owns a render surface. 350 // parent_layer_ owns a render surface.
351 parent_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 351 parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
352 parent_layer_->SetBounds(gfx::Size(15, 15)); 352 parent_layer_->SetBounds(gfx::Size(15, 15));
353 parent_layer_->SetForceRenderSurface(true); 353 parent_layer_->SetForceRenderSurface(true);
354 grand_parent_layer_->AddChild(parent_layer_); 354 grand_parent_layer_->AddChild(parent_layer_);
355 355
356 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 356 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
357 copy_layer_->SetBounds(gfx::Size(10, 10)); 357 copy_layer_->SetBounds(gfx::Size(10, 10));
358 parent_layer_->AddChild(copy_layer_); 358 parent_layer_->AddChild(copy_layer_);
359 359
360 layer_tree_host()->SetRootLayer(root_); 360 layer_tree_host()->SetRootLayer(root_);
361 LayerTreeHostCopyRequestTest::SetupTree(); 361 LayerTreeHostCopyRequestTest::SetupTree();
362 } 362 }
363 363
364 void BeginTest() override { 364 void BeginTest() override {
365 did_draw_ = false; 365 did_draw_ = false;
366 PostSetNeedsCommitToMainThread(); 366 PostSetNeedsCommitToMainThread();
(...skipping 29 matching lines...) Expand all
396 EXPECT_TRUE(renderer->HasAllocatedResourcesForTesting( 396 EXPECT_TRUE(renderer->HasAllocatedResourcesForTesting(
397 copy_layer->render_surface()->GetRenderPassId())); 397 copy_layer->render_surface()->GetRenderPassId()));
398 398
399 did_draw_ = true; 399 did_draw_ = true;
400 } 400 }
401 401
402 void AfterTest() override { EXPECT_TRUE(did_draw_); } 402 void AfterTest() override { EXPECT_TRUE(did_draw_); }
403 403
404 FakeContentLayerClient client_; 404 FakeContentLayerClient client_;
405 bool did_draw_; 405 bool did_draw_;
406 scoped_refptr<FakeContentLayer> root_; 406 scoped_refptr<FakePictureLayer> root_;
407 scoped_refptr<FakeContentLayer> grand_parent_layer_; 407 scoped_refptr<FakePictureLayer> grand_parent_layer_;
408 scoped_refptr<FakeContentLayer> parent_layer_; 408 scoped_refptr<FakePictureLayer> parent_layer_;
409 scoped_refptr<FakeContentLayer> copy_layer_; 409 scoped_refptr<FakePictureLayer> copy_layer_;
410 }; 410 };
411 411
412 // No output to copy for delegated renderers. 412 // No output to copy for delegated renderers.
413 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 413 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
414 LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest); 414 LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest);
415 415
416 class LayerTreeHostCopyRequestTestClippedOut 416 class LayerTreeHostCopyRequestTestClippedOut
417 : public LayerTreeHostCopyRequestTest { 417 : public LayerTreeHostCopyRequestTest {
418 protected: 418 protected:
419 void SetupTree() override { 419 void SetupTree() override {
420 root_ = FakeContentLayer::Create(layer_settings(), &client_); 420 root_ = FakePictureLayer::Create(layer_settings(), &client_);
421 root_->SetBounds(gfx::Size(20, 20)); 421 root_->SetBounds(gfx::Size(20, 20));
422 422
423 parent_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 423 parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
424 parent_layer_->SetBounds(gfx::Size(15, 15)); 424 parent_layer_->SetBounds(gfx::Size(15, 15));
425 parent_layer_->SetMasksToBounds(true); 425 parent_layer_->SetMasksToBounds(true);
426 root_->AddChild(parent_layer_); 426 root_->AddChild(parent_layer_);
427 427
428 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 428 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
429 copy_layer_->SetPosition(gfx::Point(15, 15)); 429 copy_layer_->SetPosition(gfx::Point(15, 15));
430 copy_layer_->SetBounds(gfx::Size(10, 10)); 430 copy_layer_->SetBounds(gfx::Size(10, 10));
431 parent_layer_->AddChild(copy_layer_); 431 parent_layer_->AddChild(copy_layer_);
432 432
433 layer_tree_host()->SetRootLayer(root_); 433 layer_tree_host()->SetRootLayer(root_);
434 LayerTreeHostCopyRequestTest::SetupTree(); 434 LayerTreeHostCopyRequestTest::SetupTree();
435 } 435 }
436 436
437 void BeginTest() override { 437 void BeginTest() override {
438 PostSetNeedsCommitToMainThread(); 438 PostSetNeedsCommitToMainThread();
439 439
440 copy_layer_->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( 440 copy_layer_->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
441 base::Bind(&LayerTreeHostCopyRequestTestClippedOut::CopyOutputCallback, 441 base::Bind(&LayerTreeHostCopyRequestTestClippedOut::CopyOutputCallback,
442 base::Unretained(this)))); 442 base::Unretained(this))));
443 } 443 }
444 444
445 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { 445 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
446 // We should still get a callback with no output if the copy requested layer 446 // We should still get a callback with no output if the copy requested layer
447 // was completely clipped away. 447 // was completely clipped away.
448 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); 448 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
449 EXPECT_EQ(gfx::Size().ToString(), result->size().ToString()); 449 EXPECT_EQ(gfx::Size().ToString(), result->size().ToString());
450 EndTest(); 450 EndTest();
451 } 451 }
452 452
453 void AfterTest() override {} 453 void AfterTest() override {}
454 454
455 FakeContentLayerClient client_; 455 FakeContentLayerClient client_;
456 scoped_refptr<FakeContentLayer> root_; 456 scoped_refptr<FakePictureLayer> root_;
457 scoped_refptr<FakeContentLayer> parent_layer_; 457 scoped_refptr<FakePictureLayer> parent_layer_;
458 scoped_refptr<FakeContentLayer> copy_layer_; 458 scoped_refptr<FakePictureLayer> copy_layer_;
459 }; 459 };
460 460
461 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 461 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
462 LayerTreeHostCopyRequestTestClippedOut); 462 LayerTreeHostCopyRequestTestClippedOut);
463 463
464 class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw 464 class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
465 : public LayerTreeHostCopyRequestTest { 465 : public LayerTreeHostCopyRequestTest {
466 protected: 466 protected:
467 void SetupTree() override { 467 void SetupTree() override {
468 root_ = FakeContentLayer::Create(layer_settings(), &client_); 468 root_ = FakePictureLayer::Create(layer_settings(), &client_);
469 root_->SetBounds(gfx::Size(20, 20)); 469 root_->SetBounds(gfx::Size(20, 20));
470 470
471 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 471 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
472 copy_layer_->SetBounds(gfx::Size(10, 10)); 472 copy_layer_->SetBounds(gfx::Size(10, 10));
473 root_->AddChild(copy_layer_); 473 root_->AddChild(copy_layer_);
474 474
475 layer_tree_host()->SetRootLayer(root_); 475 layer_tree_host()->SetRootLayer(root_);
476 LayerTreeHostCopyRequestTest::SetupTree(); 476 LayerTreeHostCopyRequestTest::SetupTree();
477 } 477 }
478 478
479 void AddCopyRequest(Layer* layer) { 479 void AddCopyRequest(Layer* layer) {
480 layer->RequestCopyOfOutput( 480 layer->RequestCopyOfOutput(
481 CopyOutputRequest::CreateBitmapRequest(base::Bind( 481 CopyOutputRequest::CreateBitmapRequest(base::Bind(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 518
519 if (callback_count_ == 2) 519 if (callback_count_ == 2)
520 EndTest(); 520 EndTest();
521 } 521 }
522 522
523 void AfterTest() override { EXPECT_TRUE(saw_copy_request_); } 523 void AfterTest() override { EXPECT_TRUE(saw_copy_request_); }
524 524
525 bool saw_copy_request_; 525 bool saw_copy_request_;
526 int callback_count_; 526 int callback_count_;
527 FakeContentLayerClient client_; 527 FakeContentLayerClient client_;
528 scoped_refptr<FakeContentLayer> root_; 528 scoped_refptr<FakePictureLayer> root_;
529 scoped_refptr<FakeContentLayer> copy_layer_; 529 scoped_refptr<FakePictureLayer> copy_layer_;
530 }; 530 };
531 531
532 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 532 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_IMPL_TEST_F(
533 LayerTreeHostTestAsyncTwoReadbacksWithoutDraw); 533 LayerTreeHostTestAsyncTwoReadbacksWithoutDraw);
534 534
535 class LayerTreeHostCopyRequestTestLostOutputSurface 535 class LayerTreeHostCopyRequestTestLostOutputSurface
536 : public LayerTreeHostCopyRequestTest { 536 : public LayerTreeHostCopyRequestTest {
537 protected: 537 protected:
538 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 538 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
539 if (!first_context_provider_.get()) { 539 if (!first_context_provider_.get()) {
540 first_context_provider_ = TestContextProvider::Create(); 540 first_context_provider_ = TestContextProvider::Create();
541 return FakeOutputSurface::Create3d(first_context_provider_); 541 return FakeOutputSurface::Create3d(first_context_provider_);
542 } 542 }
543 543
544 EXPECT_FALSE(second_context_provider_.get()); 544 EXPECT_FALSE(second_context_provider_.get());
545 second_context_provider_ = TestContextProvider::Create(); 545 second_context_provider_ = TestContextProvider::Create();
546 return FakeOutputSurface::Create3d(second_context_provider_); 546 return FakeOutputSurface::Create3d(second_context_provider_);
547 } 547 }
548 548
549 void SetupTree() override { 549 void SetupTree() override {
550 root_ = FakeContentLayer::Create(layer_settings(), &client_); 550 root_ = FakePictureLayer::Create(layer_settings(), &client_);
551 root_->SetBounds(gfx::Size(20, 20)); 551 root_->SetBounds(gfx::Size(20, 20));
552 552
553 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 553 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
554 copy_layer_->SetBounds(gfx::Size(10, 10)); 554 copy_layer_->SetBounds(gfx::Size(10, 10));
555 root_->AddChild(copy_layer_); 555 root_->AddChild(copy_layer_);
556 556
557 layer_tree_host()->SetRootLayer(root_); 557 layer_tree_host()->SetRootLayer(root_);
558 LayerTreeHostCopyRequestTest::SetupTree(); 558 LayerTreeHostCopyRequestTest::SetupTree();
559 } 559 }
560 560
561 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 561 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
562 562
563 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { 563 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 EndTest(); 645 EndTest();
646 } 646 }
647 647
648 void AfterTest() override {} 648 void AfterTest() override {}
649 649
650 scoped_refptr<TestContextProvider> first_context_provider_; 650 scoped_refptr<TestContextProvider> first_context_provider_;
651 scoped_refptr<TestContextProvider> second_context_provider_; 651 scoped_refptr<TestContextProvider> second_context_provider_;
652 size_t num_textures_without_readback_; 652 size_t num_textures_without_readback_;
653 size_t num_textures_after_loss_; 653 size_t num_textures_after_loss_;
654 FakeContentLayerClient client_; 654 FakeContentLayerClient client_;
655 scoped_refptr<FakeContentLayer> root_; 655 scoped_refptr<FakePictureLayer> root_;
656 scoped_refptr<FakeContentLayer> copy_layer_; 656 scoped_refptr<FakePictureLayer> copy_layer_;
657 scoped_ptr<CopyOutputResult> result_; 657 scoped_ptr<CopyOutputResult> result_;
658 }; 658 };
659 659
660 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 660 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_IMPL_TEST_F(
661 LayerTreeHostCopyRequestTestLostOutputSurface); 661 LayerTreeHostCopyRequestTestLostOutputSurface);
662 662
663 class LayerTreeHostCopyRequestTestCountTextures 663 class LayerTreeHostCopyRequestTestCountTextures
664 : public LayerTreeHostCopyRequestTest { 664 : public LayerTreeHostCopyRequestTest {
665 protected: 665 protected:
666 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 666 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
667 context_provider_ = TestContextProvider::Create(); 667 context_provider_ = TestContextProvider::Create();
668 return FakeOutputSurface::Create3d(context_provider_); 668 return FakeOutputSurface::Create3d(context_provider_);
669 } 669 }
670 670
671 void SetupTree() override { 671 void SetupTree() override {
672 root_ = FakeContentLayer::Create(layer_settings(), &client_); 672 client_.set_fill_with_nonsolid_color(true);
673
674 root_ = FakePictureLayer::Create(layer_settings(), &client_);
673 root_->SetBounds(gfx::Size(20, 20)); 675 root_->SetBounds(gfx::Size(20, 20));
674 676
675 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 677 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
676 copy_layer_->SetBounds(gfx::Size(10, 10)); 678 copy_layer_->SetBounds(gfx::Size(10, 10));
677 root_->AddChild(copy_layer_); 679 root_->AddChild(copy_layer_);
678 680
679 layer_tree_host()->SetRootLayer(root_); 681 layer_tree_host()->SetRootLayer(root_);
680 LayerTreeHostCopyRequestTest::SetupTree(); 682 LayerTreeHostCopyRequestTest::SetupTree();
681 } 683 }
682 684
683 void BeginTest() override { 685 void BeginTest() override {
684 num_textures_without_readback_ = 0; 686 num_textures_without_readback_ = 0;
685 num_textures_with_readback_ = 0; 687 num_textures_with_readback_ = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } 723 }
722 } 724 }
723 725
724 virtual void DoEndTest() { EndTest(); } 726 virtual void DoEndTest() { EndTest(); }
725 727
726 scoped_refptr<TestContextProvider> context_provider_; 728 scoped_refptr<TestContextProvider> context_provider_;
727 size_t num_textures_without_readback_; 729 size_t num_textures_without_readback_;
728 size_t num_textures_with_readback_; 730 size_t num_textures_with_readback_;
729 unsigned waited_sync_point_after_readback_; 731 unsigned waited_sync_point_after_readback_;
730 FakeContentLayerClient client_; 732 FakeContentLayerClient client_;
731 scoped_refptr<FakeContentLayer> root_; 733 scoped_refptr<FakePictureLayer> root_;
732 scoped_refptr<FakeContentLayer> copy_layer_; 734 scoped_refptr<FakePictureLayer> copy_layer_;
733 }; 735 };
734 736
735 class LayerTreeHostCopyRequestTestCreatesTexture 737 class LayerTreeHostCopyRequestTestCreatesTexture
736 : public LayerTreeHostCopyRequestTestCountTextures { 738 : public LayerTreeHostCopyRequestTestCountTextures {
737 protected: 739 protected:
738 void RequestCopy(Layer* layer) override { 740 void RequestCopy(Layer* layer) override {
739 // Request a normal texture copy. This should create a new texture. 741 // Request a normal texture copy. This should create a new texture.
740 copy_layer_->RequestCopyOfOutput( 742 copy_layer_->RequestCopyOfOutput(
741 CopyOutputRequest::CreateRequest(base::Bind( 743 CopyOutputRequest::CreateRequest(base::Bind(
742 &LayerTreeHostCopyRequestTestCreatesTexture::CopyOutputCallback, 744 &LayerTreeHostCopyRequestTestCreatesTexture::CopyOutputCallback,
(...skipping 13 matching lines...) Expand all
756 } 758 }
757 759
758 void AfterTest() override { 760 void AfterTest() override {
759 // No sync point was needed. 761 // No sync point was needed.
760 EXPECT_EQ(0u, waited_sync_point_after_readback_); 762 EXPECT_EQ(0u, waited_sync_point_after_readback_);
761 // Except the copy to have made another texture. 763 // Except the copy to have made another texture.
762 EXPECT_EQ(num_textures_without_readback_ + 1, num_textures_with_readback_); 764 EXPECT_EQ(num_textures_without_readback_ + 1, num_textures_with_readback_);
763 } 765 }
764 }; 766 };
765 767
766 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 768 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_IMPL_TEST_F(
767 LayerTreeHostCopyRequestTestCreatesTexture); 769 LayerTreeHostCopyRequestTestCreatesTexture);
768 770
769 class LayerTreeHostCopyRequestTestProvideTexture 771 class LayerTreeHostCopyRequestTestProvideTexture
770 : public LayerTreeHostCopyRequestTestCountTextures { 772 : public LayerTreeHostCopyRequestTestCountTextures {
771 protected: 773 protected:
772 void BeginTest() override { 774 void BeginTest() override {
773 external_context_provider_ = TestContextProvider::Create(); 775 external_context_provider_ = TestContextProvider::Create();
774 EXPECT_TRUE(external_context_provider_->BindToCurrentThread()); 776 EXPECT_TRUE(external_context_provider_->BindToCurrentThread());
775 LayerTreeHostCopyRequestTestCountTextures::BeginTest(); 777 LayerTreeHostCopyRequestTestCountTextures::BeginTest();
776 } 778 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 // TextureMailbox. 811 // TextureMailbox.
810 EXPECT_EQ(sync_point_, waited_sync_point_after_readback_); 812 EXPECT_EQ(sync_point_, waited_sync_point_after_readback_);
811 // Except the copy to have *not* made another texture. 813 // Except the copy to have *not* made another texture.
812 EXPECT_EQ(num_textures_without_readback_, num_textures_with_readback_); 814 EXPECT_EQ(num_textures_without_readback_, num_textures_with_readback_);
813 } 815 }
814 816
815 scoped_refptr<TestContextProvider> external_context_provider_; 817 scoped_refptr<TestContextProvider> external_context_provider_;
816 unsigned sync_point_; 818 unsigned sync_point_;
817 }; 819 };
818 820
819 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 821 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_IMPL_TEST_F(
820 LayerTreeHostCopyRequestTestProvideTexture); 822 LayerTreeHostCopyRequestTestProvideTexture);
821 823
822 class LayerTreeHostCopyRequestTestDestroyBeforeCopy 824 class LayerTreeHostCopyRequestTestDestroyBeforeCopy
823 : public LayerTreeHostCopyRequestTest { 825 : public LayerTreeHostCopyRequestTest {
824 protected: 826 protected:
825 void SetupTree() override { 827 void SetupTree() override {
826 root_ = FakeContentLayer::Create(layer_settings(), &client_); 828 root_ = FakePictureLayer::Create(layer_settings(), &client_);
827 root_->SetBounds(gfx::Size(20, 20)); 829 root_->SetBounds(gfx::Size(20, 20));
828 830
829 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 831 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
830 copy_layer_->SetBounds(gfx::Size(10, 10)); 832 copy_layer_->SetBounds(gfx::Size(10, 10));
831 root_->AddChild(copy_layer_); 833 root_->AddChild(copy_layer_);
832 834
833 layer_tree_host()->SetRootLayer(root_); 835 layer_tree_host()->SetRootLayer(root_);
834 LayerTreeHostCopyRequestTest::SetupTree(); 836 LayerTreeHostCopyRequestTest::SetupTree();
835 } 837 }
836 838
837 void BeginTest() override { 839 void BeginTest() override {
838 callback_count_ = 0; 840 callback_count_ = 0;
839 PostSetNeedsCommitToMainThread(); 841 PostSetNeedsCommitToMainThread();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 EXPECT_EQ(1, callback_count_); 884 EXPECT_EQ(1, callback_count_);
883 // We should not have crashed. 885 // We should not have crashed.
884 EndTest(); 886 EndTest();
885 } 887 }
886 } 888 }
887 889
888 void AfterTest() override {} 890 void AfterTest() override {}
889 891
890 int callback_count_; 892 int callback_count_;
891 FakeContentLayerClient client_; 893 FakeContentLayerClient client_;
892 scoped_refptr<FakeContentLayer> root_; 894 scoped_refptr<FakePictureLayer> root_;
893 scoped_refptr<FakeContentLayer> copy_layer_; 895 scoped_refptr<FakePictureLayer> copy_layer_;
894 }; 896 };
895 897
896 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 898 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
897 LayerTreeHostCopyRequestTestDestroyBeforeCopy); 899 LayerTreeHostCopyRequestTestDestroyBeforeCopy);
898 900
899 class LayerTreeHostCopyRequestTestShutdownBeforeCopy 901 class LayerTreeHostCopyRequestTestShutdownBeforeCopy
900 : public LayerTreeHostCopyRequestTest { 902 : public LayerTreeHostCopyRequestTest {
901 protected: 903 protected:
902 void SetupTree() override { 904 void SetupTree() override {
903 root_ = FakeContentLayer::Create(layer_settings(), &client_); 905 root_ = FakePictureLayer::Create(layer_settings(), &client_);
904 root_->SetBounds(gfx::Size(20, 20)); 906 root_->SetBounds(gfx::Size(20, 20));
905 907
906 copy_layer_ = FakeContentLayer::Create(layer_settings(), &client_); 908 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
907 copy_layer_->SetBounds(gfx::Size(10, 10)); 909 copy_layer_->SetBounds(gfx::Size(10, 10));
908 root_->AddChild(copy_layer_); 910 root_->AddChild(copy_layer_);
909 911
910 layer_tree_host()->SetRootLayer(root_); 912 layer_tree_host()->SetRootLayer(root_);
911 LayerTreeHostCopyRequestTest::SetupTree(); 913 LayerTreeHostCopyRequestTest::SetupTree();
912 } 914 }
913 915
914 void BeginTest() override { 916 void BeginTest() override {
915 callback_count_ = 0; 917 callback_count_ = 0;
916 PostSetNeedsCommitToMainThread(); 918 PostSetNeedsCommitToMainThread();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 base::Bind(&LayerTreeHostCopyRequestTestShutdownBeforeCopy::EndTest, 955 base::Bind(&LayerTreeHostCopyRequestTestShutdownBeforeCopy::EndTest,
954 base::Unretained(this))); 956 base::Unretained(this)));
955 break; 957 break;
956 } 958 }
957 } 959 }
958 960
959 void AfterTest() override { EXPECT_EQ(1, callback_count_); } 961 void AfterTest() override { EXPECT_EQ(1, callback_count_); }
960 962
961 int callback_count_; 963 int callback_count_;
962 FakeContentLayerClient client_; 964 FakeContentLayerClient client_;
963 scoped_refptr<FakeContentLayer> root_; 965 scoped_refptr<FakePictureLayer> root_;
964 scoped_refptr<FakeContentLayer> copy_layer_; 966 scoped_refptr<FakePictureLayer> copy_layer_;
965 }; 967 };
966 968
967 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 969 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
968 LayerTreeHostCopyRequestTestShutdownBeforeCopy); 970 LayerTreeHostCopyRequestTestShutdownBeforeCopy);
969 971
970 class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest 972 class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
971 : public LayerTreeHostCopyRequestTest { 973 : public LayerTreeHostCopyRequestTest {
972 protected: 974 protected:
973 void SetupTree() override { 975 void SetupTree() override {
974 scoped_refptr<FakeContentLayer> root = 976 scoped_refptr<FakePictureLayer> root =
975 FakeContentLayer::Create(layer_settings(), &client_); 977 FakePictureLayer::Create(layer_settings(), &client_);
976 root->SetBounds(gfx::Size(20, 20)); 978 root->SetBounds(gfx::Size(20, 20));
977 979
978 child_ = FakeContentLayer::Create(layer_settings(), &client_); 980 child_ = FakePictureLayer::Create(layer_settings(), &client_);
979 child_->SetBounds(gfx::Size(10, 10)); 981 child_->SetBounds(gfx::Size(10, 10));
980 root->AddChild(child_); 982 root->AddChild(child_);
981 child_->SetHideLayerAndSubtree(true); 983 child_->SetHideLayerAndSubtree(true);
982 984
983 layer_tree_host()->SetRootLayer(root); 985 layer_tree_host()->SetRootLayer(root);
984 LayerTreeHostCopyRequestTest::SetupTree(); 986 LayerTreeHostCopyRequestTest::SetupTree();
985 } 987 }
986 988
987 void BeginTest() override { 989 void BeginTest() override {
988 num_draws_ = 0; 990 num_draws_ = 0;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 TryEndTest(); 1069 TryEndTest();
1068 } 1070 }
1069 1071
1070 void TryEndTest() { 1072 void TryEndTest() {
1071 if (draw_happened_ && copy_happened_) 1073 if (draw_happened_ && copy_happened_)
1072 EndTest(); 1074 EndTest();
1073 } 1075 }
1074 1076
1075 void AfterTest() override {} 1077 void AfterTest() override {}
1076 1078
1077 scoped_refptr<FakeContentLayer> child_; 1079 scoped_refptr<FakePictureLayer> child_;
1078 FakeContentLayerClient client_; 1080 FakeContentLayerClient client_;
1079 int num_draws_; 1081 int num_draws_;
1080 bool copy_happened_; 1082 bool copy_happened_;
1081 bool draw_happened_; 1083 bool draw_happened_;
1082 }; 1084 };
1083 1085
1084 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1086 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1085 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); 1087 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest);
1086 1088
1087 } // namespace 1089 } // namespace
1088 } // namespace cc 1090 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698