| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
| 10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 75 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 76 GL_INNOCENT_CONTEXT_RESET_ARB); | 76 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 77 context3d_ = NULL; | 77 context3d_ = NULL; |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { | 80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { |
| 81 return TestWebGraphicsContext3D::Create(); | 81 return TestWebGraphicsContext3D::Create(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 84 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| 85 OVERRIDE { | 85 override { |
| 86 if (times_to_fail_create_) { | 86 if (times_to_fail_create_) { |
| 87 --times_to_fail_create_; | 87 --times_to_fail_create_; |
| 88 ExpectCreateToFail(); | 88 ExpectCreateToFail(); |
| 89 return nullptr; | 89 return nullptr; |
| 90 } | 90 } |
| 91 | 91 |
| 92 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); | 92 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); |
| 93 context3d_ = context3d.get(); | 93 context3d_ = context3d.get(); |
| 94 | 94 |
| 95 if (context_should_support_io_surface_) { | 95 if (context_should_support_io_surface_) { |
| 96 context3d_->set_have_extension_io_surface(true); | 96 context3d_->set_have_extension_io_surface(true); |
| 97 context3d_->set_have_extension_egl_image(true); | 97 context3d_->set_have_extension_egl_image(true); |
| 98 } | 98 } |
| 99 | 99 |
| 100 if (delegating_renderer()) | 100 if (delegating_renderer()) |
| 101 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 101 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| 102 else | 102 else |
| 103 return FakeOutputSurface::Create3d(context3d.Pass()); | 103 return FakeOutputSurface::Create3d(context3d.Pass()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual DrawResult PrepareToDrawOnThread( | 106 virtual DrawResult PrepareToDrawOnThread( |
| 107 LayerTreeHostImpl* host_impl, | 107 LayerTreeHostImpl* host_impl, |
| 108 LayerTreeHostImpl::FrameData* frame, | 108 LayerTreeHostImpl::FrameData* frame, |
| 109 DrawResult draw_result) OVERRIDE { | 109 DrawResult draw_result) override { |
| 110 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 110 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 111 if (!times_to_lose_during_draw_) | 111 if (!times_to_lose_during_draw_) |
| 112 return draw_result; | 112 return draw_result; |
| 113 | 113 |
| 114 --times_to_lose_during_draw_; | 114 --times_to_lose_during_draw_; |
| 115 LoseContext(); | 115 LoseContext(); |
| 116 | 116 |
| 117 times_to_fail_create_ = times_to_fail_recreate_; | 117 times_to_fail_create_ = times_to_fail_recreate_; |
| 118 times_to_fail_recreate_ = 0; | 118 times_to_fail_recreate_ = 0; |
| 119 | 119 |
| 120 return draw_result; | 120 return draw_result; |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 123 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 124 committed_at_least_once_ = true; | 124 committed_at_least_once_ = true; |
| 125 | 125 |
| 126 if (!times_to_lose_during_commit_) | 126 if (!times_to_lose_during_commit_) |
| 127 return; | 127 return; |
| 128 --times_to_lose_during_commit_; | 128 --times_to_lose_during_commit_; |
| 129 LoseContext(); | 129 LoseContext(); |
| 130 | 130 |
| 131 times_to_fail_create_ = times_to_fail_recreate_; | 131 times_to_fail_create_ = times_to_fail_recreate_; |
| 132 times_to_fail_recreate_ = 0; | 132 times_to_fail_recreate_ = 0; |
| 133 } | 133 } |
| 134 | 134 |
| 135 virtual void DidFailToInitializeOutputSurface() OVERRIDE { | 135 virtual void DidFailToInitializeOutputSurface() override { |
| 136 ++times_create_failed_; | 136 ++times_create_failed_; |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual void TearDown() OVERRIDE { | 139 virtual void TearDown() override { |
| 140 LayerTreeTest::TearDown(); | 140 LayerTreeTest::TearDown(); |
| 141 EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); | 141 EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ExpectCreateToFail() { ++times_to_expect_create_failed_; } | 144 void ExpectCreateToFail() { ++times_to_expect_create_failed_; } |
| 145 | 145 |
| 146 protected: | 146 protected: |
| 147 TestWebGraphicsContext3D* context3d_; | 147 TestWebGraphicsContext3D* context3d_; |
| 148 int times_to_fail_create_; | 148 int times_to_fail_create_; |
| 149 int times_to_lose_during_commit_; | 149 int times_to_lose_during_commit_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 161 : public LayerTreeHostContextTest { | 161 : public LayerTreeHostContextTest { |
| 162 public: | 162 public: |
| 163 LayerTreeHostContextTestLostContextSucceeds() | 163 LayerTreeHostContextTestLostContextSucceeds() |
| 164 : LayerTreeHostContextTest(), | 164 : LayerTreeHostContextTest(), |
| 165 test_case_(0), | 165 test_case_(0), |
| 166 num_losses_(0), | 166 num_losses_(0), |
| 167 num_losses_last_test_case_(-1), | 167 num_losses_last_test_case_(-1), |
| 168 recovered_context_(true), | 168 recovered_context_(true), |
| 169 first_initialized_(false) {} | 169 first_initialized_(false) {} |
| 170 | 170 |
| 171 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 171 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 172 | 172 |
| 173 virtual void RequestNewOutputSurface(bool fallback) OVERRIDE { | 173 virtual void RequestNewOutputSurface(bool fallback) override { |
| 174 if (async_output_surface_creation_) { | 174 if (async_output_surface_creation_) { |
| 175 MainThreadTaskRunner()->PostTask( | 175 MainThreadTaskRunner()->PostTask( |
| 176 FROM_HERE, | 176 FROM_HERE, |
| 177 base::Bind(&LayerTreeHostContextTestLostContextSucceeds:: | 177 base::Bind(&LayerTreeHostContextTestLostContextSucceeds:: |
| 178 CreateAndSetOutputSurface, | 178 CreateAndSetOutputSurface, |
| 179 base::Unretained(this), | 179 base::Unretained(this), |
| 180 fallback)); | 180 fallback)); |
| 181 } else { | 181 } else { |
| 182 CreateAndSetOutputSurface(fallback); | 182 CreateAndSetOutputSurface(fallback); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void CreateAndSetOutputSurface(bool fallback) { | 186 void CreateAndSetOutputSurface(bool fallback) { |
| 187 layer_tree_host()->SetOutputSurface( | 187 layer_tree_host()->SetOutputSurface( |
| 188 LayerTreeHostContextTest::CreateOutputSurface(fallback)); | 188 LayerTreeHostContextTest::CreateOutputSurface(fallback)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 virtual void DidInitializeOutputSurface() OVERRIDE { | 191 virtual void DidInitializeOutputSurface() override { |
| 192 if (first_initialized_) | 192 if (first_initialized_) |
| 193 ++num_losses_; | 193 ++num_losses_; |
| 194 else | 194 else |
| 195 first_initialized_ = true; | 195 first_initialized_ = true; |
| 196 | 196 |
| 197 recovered_context_ = true; | 197 recovered_context_ = true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 virtual void AfterTest() OVERRIDE { EXPECT_EQ(11u, test_case_); } | 200 virtual void AfterTest() override { EXPECT_EQ(11u, test_case_); } |
| 201 | 201 |
| 202 virtual void DidCommitAndDrawFrame() OVERRIDE { | 202 virtual void DidCommitAndDrawFrame() override { |
| 203 // If the last frame had a context loss, then we'll commit again to | 203 // If the last frame had a context loss, then we'll commit again to |
| 204 // recover. | 204 // recover. |
| 205 if (!recovered_context_) | 205 if (!recovered_context_) |
| 206 return; | 206 return; |
| 207 if (times_to_lose_during_commit_) | 207 if (times_to_lose_during_commit_) |
| 208 return; | 208 return; |
| 209 if (times_to_lose_during_draw_) | 209 if (times_to_lose_during_draw_) |
| 210 return; | 210 return; |
| 211 | 211 |
| 212 recovered_context_ = false; | 212 recovered_context_ = false; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 }; | 344 }; |
| 345 | 345 |
| 346 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLostContextSucceeds); | 346 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLostContextSucceeds); |
| 347 | 347 |
| 348 class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface | 348 class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface |
| 349 : public LayerTreeHostContextTest { | 349 : public LayerTreeHostContextTest { |
| 350 public: | 350 public: |
| 351 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface() | 351 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface() |
| 352 : LayerTreeHostContextTest() {} | 352 : LayerTreeHostContextTest() {} |
| 353 | 353 |
| 354 virtual void WillBeginTest() OVERRIDE { | 354 virtual void WillBeginTest() override { |
| 355 // Override and do not signal SetLayerTreeHostClientReady. | 355 // Override and do not signal SetLayerTreeHostClientReady. |
| 356 } | 356 } |
| 357 | 357 |
| 358 virtual void BeginTest() OVERRIDE { | 358 virtual void BeginTest() override { |
| 359 PostSetNeedsCommitToMainThread(); | 359 PostSetNeedsCommitToMainThread(); |
| 360 EndTest(); | 360 EndTest(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) | 363 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) |
| 364 OVERRIDE { | 364 override { |
| 365 EXPECT_TRUE(false); | 365 EXPECT_TRUE(false); |
| 366 return nullptr; | 366 return nullptr; |
| 367 } | 367 } |
| 368 | 368 |
| 369 virtual void DidInitializeOutputSurface() OVERRIDE { EXPECT_TRUE(false); } | 369 virtual void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } |
| 370 | 370 |
| 371 virtual void AfterTest() OVERRIDE { | 371 virtual void AfterTest() override { |
| 372 } | 372 } |
| 373 }; | 373 }; |
| 374 | 374 |
| 375 SINGLE_AND_MULTI_THREAD_TEST_F( | 375 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 376 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); | 376 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); |
| 377 | 377 |
| 378 class LayerTreeHostContextTestLostContextSucceedsWithContent | 378 class LayerTreeHostContextTestLostContextSucceedsWithContent |
| 379 : public LayerTreeHostContextTestLostContextSucceeds { | 379 : public LayerTreeHostContextTestLostContextSucceeds { |
| 380 public: | 380 public: |
| 381 virtual void SetupTree() OVERRIDE { | 381 virtual void SetupTree() override { |
| 382 root_ = Layer::Create(); | 382 root_ = Layer::Create(); |
| 383 root_->SetBounds(gfx::Size(10, 10)); | 383 root_->SetBounds(gfx::Size(10, 10)); |
| 384 root_->SetIsDrawable(true); | 384 root_->SetIsDrawable(true); |
| 385 | 385 |
| 386 // Paint non-solid color. | 386 // Paint non-solid color. |
| 387 SkPaint paint; | 387 SkPaint paint; |
| 388 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); | 388 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 389 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); | 389 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); |
| 390 | 390 |
| 391 if (layer_tree_host()->settings().impl_side_painting) | 391 if (layer_tree_host()->settings().impl_side_painting) |
| 392 layer_ = FakePictureLayer::Create(&client_); | 392 layer_ = FakePictureLayer::Create(&client_); |
| 393 else | 393 else |
| 394 layer_ = FakeContentLayer::Create(&client_); | 394 layer_ = FakeContentLayer::Create(&client_); |
| 395 layer_->SetBounds(gfx::Size(10, 10)); | 395 layer_->SetBounds(gfx::Size(10, 10)); |
| 396 layer_->SetIsDrawable(true); | 396 layer_->SetIsDrawable(true); |
| 397 | 397 |
| 398 root_->AddChild(layer_); | 398 root_->AddChild(layer_); |
| 399 | 399 |
| 400 layer_tree_host()->SetRootLayer(root_); | 400 layer_tree_host()->SetRootLayer(root_); |
| 401 LayerTreeHostContextTest::SetupTree(); | 401 LayerTreeHostContextTest::SetupTree(); |
| 402 } | 402 } |
| 403 | 403 |
| 404 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { | 404 virtual void InvalidateAndSetNeedsCommit() override { |
| 405 // Invalidate the render surface so we don't try to use a cached copy of the | 405 // Invalidate the render surface so we don't try to use a cached copy of the |
| 406 // surface. We want to make sure to test the drawing paths for drawing to | 406 // surface. We want to make sure to test the drawing paths for drawing to |
| 407 // a child surface. | 407 // a child surface. |
| 408 layer_->SetNeedsDisplay(); | 408 layer_->SetNeedsDisplay(); |
| 409 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); | 409 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 412 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 413 if (!host_impl->settings().impl_side_painting) { | 413 if (!host_impl->settings().impl_side_painting) { |
| 414 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( | 414 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
| 415 host_impl->active_tree()->root_layer()->children()[0]); | 415 host_impl->active_tree()->root_layer()->children()[0]); |
| 416 // Even though the context was lost, we should have a resource. The | 416 // Even though the context was lost, we should have a resource. The |
| 417 // TestWebGraphicsContext3D ensures that this resource is created with | 417 // TestWebGraphicsContext3D ensures that this resource is created with |
| 418 // the active context. | 418 // the active context. |
| 419 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | 419 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
| 420 } else { | 420 } else { |
| 421 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( | 421 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( |
| 422 host_impl->active_tree()->root_layer()->children()[0]); | 422 host_impl->active_tree()->root_layer()->children()[0]); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 442 // fallback/software OutputSurface is expected to occur. | 442 // fallback/software OutputSurface is expected to occur. |
| 443 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, | 443 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, |
| 444 bool expect_fallback_attempt) | 444 bool expect_fallback_attempt) |
| 445 : times_to_fail_(times_to_fail), | 445 : times_to_fail_(times_to_fail), |
| 446 expect_fallback_attempt_(expect_fallback_attempt), | 446 expect_fallback_attempt_(expect_fallback_attempt), |
| 447 did_attempt_fallback_(false), | 447 did_attempt_fallback_(false), |
| 448 times_initialized_(0) { | 448 times_initialized_(0) { |
| 449 times_to_fail_create_ = times_to_fail_; | 449 times_to_fail_create_ = times_to_fail_; |
| 450 } | 450 } |
| 451 | 451 |
| 452 virtual void BeginTest() OVERRIDE { | 452 virtual void BeginTest() override { |
| 453 PostSetNeedsCommitToMainThread(); | 453 PostSetNeedsCommitToMainThread(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 456 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| 457 OVERRIDE { | 457 override { |
| 458 scoped_ptr<FakeOutputSurface> surface = | 458 scoped_ptr<FakeOutputSurface> surface = |
| 459 LayerTreeHostContextTest::CreateFakeOutputSurface(fallback); | 459 LayerTreeHostContextTest::CreateFakeOutputSurface(fallback); |
| 460 | 460 |
| 461 if (surface) | 461 if (surface) |
| 462 EXPECT_EQ(times_to_fail_, times_create_failed_); | 462 EXPECT_EQ(times_to_fail_, times_create_failed_); |
| 463 | 463 |
| 464 did_attempt_fallback_ = fallback; | 464 did_attempt_fallback_ = fallback; |
| 465 return surface.Pass(); | 465 return surface.Pass(); |
| 466 } | 466 } |
| 467 | 467 |
| 468 virtual void DidInitializeOutputSurface() OVERRIDE { times_initialized_++; } | 468 virtual void DidInitializeOutputSurface() override { times_initialized_++; } |
| 469 | 469 |
| 470 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 470 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 471 EndTest(); | 471 EndTest(); |
| 472 } | 472 } |
| 473 | 473 |
| 474 virtual void AfterTest() OVERRIDE { | 474 virtual void AfterTest() override { |
| 475 EXPECT_EQ(times_to_fail_, times_create_failed_); | 475 EXPECT_EQ(times_to_fail_, times_create_failed_); |
| 476 EXPECT_NE(0, times_initialized_); | 476 EXPECT_NE(0, times_initialized_); |
| 477 EXPECT_EQ(expect_fallback_attempt_, did_attempt_fallback_); | 477 EXPECT_EQ(expect_fallback_attempt_, did_attempt_fallback_); |
| 478 } | 478 } |
| 479 | 479 |
| 480 private: | 480 private: |
| 481 int times_to_fail_; | 481 int times_to_fail_; |
| 482 bool expect_fallback_attempt_; | 482 bool expect_fallback_attempt_; |
| 483 bool did_attempt_fallback_; | 483 bool did_attempt_fallback_; |
| 484 int times_initialized_; | 484 int times_initialized_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 508 | 508 |
| 509 class LayerTreeHostContextTestLostContextAndEvictTextures | 509 class LayerTreeHostContextTestLostContextAndEvictTextures |
| 510 : public LayerTreeHostContextTest { | 510 : public LayerTreeHostContextTest { |
| 511 public: | 511 public: |
| 512 LayerTreeHostContextTestLostContextAndEvictTextures() | 512 LayerTreeHostContextTestLostContextAndEvictTextures() |
| 513 : LayerTreeHostContextTest(), | 513 : LayerTreeHostContextTest(), |
| 514 impl_host_(0), | 514 impl_host_(0), |
| 515 num_commits_(0), | 515 num_commits_(0), |
| 516 lost_context_(false) {} | 516 lost_context_(false) {} |
| 517 | 517 |
| 518 virtual void SetupTree() OVERRIDE { | 518 virtual void SetupTree() override { |
| 519 // Paint non-solid color. | 519 // Paint non-solid color. |
| 520 SkPaint paint; | 520 SkPaint paint; |
| 521 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); | 521 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 522 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); | 522 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); |
| 523 | 523 |
| 524 if (layer_tree_host()->settings().impl_side_painting) { | 524 if (layer_tree_host()->settings().impl_side_painting) { |
| 525 picture_layer_ = FakePictureLayer::Create(&client_); | 525 picture_layer_ = FakePictureLayer::Create(&client_); |
| 526 picture_layer_->SetBounds(gfx::Size(10, 20)); | 526 picture_layer_->SetBounds(gfx::Size(10, 20)); |
| 527 layer_tree_host()->SetRootLayer(picture_layer_); | 527 layer_tree_host()->SetRootLayer(picture_layer_); |
| 528 } else { | 528 } else { |
| 529 content_layer_ = FakeContentLayer::Create(&client_); | 529 content_layer_ = FakeContentLayer::Create(&client_); |
| 530 content_layer_->SetBounds(gfx::Size(10, 20)); | 530 content_layer_->SetBounds(gfx::Size(10, 20)); |
| 531 layer_tree_host()->SetRootLayer(content_layer_); | 531 layer_tree_host()->SetRootLayer(content_layer_); |
| 532 } | 532 } |
| 533 | 533 |
| 534 LayerTreeHostContextTest::SetupTree(); | 534 LayerTreeHostContextTest::SetupTree(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 537 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 538 | 538 |
| 539 void PostEvictTextures() { | 539 void PostEvictTextures() { |
| 540 if (HasImplThread()) { | 540 if (HasImplThread()) { |
| 541 ImplThreadTaskRunner()->PostTask( | 541 ImplThreadTaskRunner()->PostTask( |
| 542 FROM_HERE, | 542 FROM_HERE, |
| 543 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: | 543 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: |
| 544 EvictTexturesOnImplThread, | 544 EvictTexturesOnImplThread, |
| 545 base::Unretained(this))); | 545 base::Unretained(this))); |
| 546 } else { | 546 } else { |
| 547 DebugScopedSetImplThread impl(proxy()); | 547 DebugScopedSetImplThread impl(proxy()); |
| 548 EvictTexturesOnImplThread(); | 548 EvictTexturesOnImplThread(); |
| 549 } | 549 } |
| 550 } | 550 } |
| 551 | 551 |
| 552 void EvictTexturesOnImplThread() { | 552 void EvictTexturesOnImplThread() { |
| 553 impl_host_->EvictTexturesForTesting(); | 553 impl_host_->EvictTexturesForTesting(); |
| 554 | 554 |
| 555 if (lose_after_evict_) { | 555 if (lose_after_evict_) { |
| 556 LoseContext(); | 556 LoseContext(); |
| 557 lost_context_ = true; | 557 lost_context_ = true; |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 | 560 |
| 561 virtual void DidCommitAndDrawFrame() OVERRIDE { | 561 virtual void DidCommitAndDrawFrame() override { |
| 562 if (num_commits_ > 1) | 562 if (num_commits_ > 1) |
| 563 return; | 563 return; |
| 564 if (!layer_tree_host()->settings().impl_side_painting) { | 564 if (!layer_tree_host()->settings().impl_side_painting) { |
| 565 EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0)); | 565 EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0)); |
| 566 } | 566 } |
| 567 PostEvictTextures(); | 567 PostEvictTextures(); |
| 568 } | 568 } |
| 569 | 569 |
| 570 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 570 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 571 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 571 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 572 if (num_commits_ > 1) | 572 if (num_commits_ > 1) |
| 573 return; | 573 return; |
| 574 ++num_commits_; | 574 ++num_commits_; |
| 575 if (!lose_after_evict_) { | 575 if (!lose_after_evict_) { |
| 576 LoseContext(); | 576 LoseContext(); |
| 577 lost_context_ = true; | 577 lost_context_ = true; |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 | 580 |
| 581 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 581 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 582 if (impl->settings().impl_side_painting) { | 582 if (impl->settings().impl_side_painting) { |
| 583 FakePictureLayerImpl* picture_impl = | 583 FakePictureLayerImpl* picture_impl = |
| 584 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); | 584 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
| 585 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); | 585 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); |
| 586 } else { | 586 } else { |
| 587 FakeContentLayerImpl* content_impl = | 587 FakeContentLayerImpl* content_impl = |
| 588 static_cast<FakeContentLayerImpl*>(impl->active_tree()->root_layer()); | 588 static_cast<FakeContentLayerImpl*>(impl->active_tree()->root_layer()); |
| 589 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | 589 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
| 590 } | 590 } |
| 591 | 591 |
| 592 impl_host_ = impl; | 592 impl_host_ = impl; |
| 593 if (lost_context_) | 593 if (lost_context_) |
| 594 EndTest(); | 594 EndTest(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 virtual void DidInitializeOutputSurface() OVERRIDE {} | 597 virtual void DidInitializeOutputSurface() override {} |
| 598 | 598 |
| 599 virtual void AfterTest() OVERRIDE {} | 599 virtual void AfterTest() override {} |
| 600 | 600 |
| 601 protected: | 601 protected: |
| 602 bool lose_after_evict_; | 602 bool lose_after_evict_; |
| 603 FakeContentLayerClient client_; | 603 FakeContentLayerClient client_; |
| 604 scoped_refptr<FakeContentLayer> content_layer_; | 604 scoped_refptr<FakeContentLayer> content_layer_; |
| 605 scoped_refptr<FakePictureLayer> picture_layer_; | 605 scoped_refptr<FakePictureLayer> picture_layer_; |
| 606 LayerTreeHostImpl* impl_host_; | 606 LayerTreeHostImpl* impl_host_; |
| 607 int num_commits_; | 607 int num_commits_; |
| 608 bool lost_context_; | 608 bool lost_context_; |
| 609 }; | 609 }; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 lose_after_evict_ = false; | 674 lose_after_evict_ = false; |
| 675 RunTest(true, true, true); | 675 RunTest(true, true, true); |
| 676 } | 676 } |
| 677 | 677 |
| 678 class LayerTreeHostContextTestLostContextWhileUpdatingResources | 678 class LayerTreeHostContextTestLostContextWhileUpdatingResources |
| 679 : public LayerTreeHostContextTest { | 679 : public LayerTreeHostContextTest { |
| 680 public: | 680 public: |
| 681 LayerTreeHostContextTestLostContextWhileUpdatingResources() | 681 LayerTreeHostContextTestLostContextWhileUpdatingResources() |
| 682 : num_children_(50), times_to_lose_on_end_query_(3) {} | 682 : num_children_(50), times_to_lose_on_end_query_(3) {} |
| 683 | 683 |
| 684 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { | 684 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() override { |
| 685 scoped_ptr<TestWebGraphicsContext3D> context = | 685 scoped_ptr<TestWebGraphicsContext3D> context = |
| 686 LayerTreeHostContextTest::CreateContext3d(); | 686 LayerTreeHostContextTest::CreateContext3d(); |
| 687 if (times_to_lose_on_end_query_) { | 687 if (times_to_lose_on_end_query_) { |
| 688 --times_to_lose_on_end_query_; | 688 --times_to_lose_on_end_query_; |
| 689 context->set_times_end_query_succeeds(5); | 689 context->set_times_end_query_succeeds(5); |
| 690 } | 690 } |
| 691 return context.Pass(); | 691 return context.Pass(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 virtual void SetupTree() OVERRIDE { | 694 virtual void SetupTree() override { |
| 695 if (layer_tree_host()->settings().impl_side_painting) | 695 if (layer_tree_host()->settings().impl_side_painting) |
| 696 parent_ = FakePictureLayer::Create(&client_); | 696 parent_ = FakePictureLayer::Create(&client_); |
| 697 else | 697 else |
| 698 parent_ = FakeContentLayer::Create(&client_); | 698 parent_ = FakeContentLayer::Create(&client_); |
| 699 | 699 |
| 700 parent_->SetBounds(gfx::Size(num_children_, 1)); | 700 parent_->SetBounds(gfx::Size(num_children_, 1)); |
| 701 | 701 |
| 702 for (int i = 0; i < num_children_; i++) { | 702 for (int i = 0; i < num_children_; i++) { |
| 703 scoped_refptr<Layer> child; | 703 scoped_refptr<Layer> child; |
| 704 if (layer_tree_host()->settings().impl_side_painting) | 704 if (layer_tree_host()->settings().impl_side_painting) |
| 705 child = FakePictureLayer::Create(&client_); | 705 child = FakePictureLayer::Create(&client_); |
| 706 else | 706 else |
| 707 child = FakeContentLayer::Create(&client_); | 707 child = FakeContentLayer::Create(&client_); |
| 708 child->SetPosition(gfx::PointF(i, 0.f)); | 708 child->SetPosition(gfx::PointF(i, 0.f)); |
| 709 child->SetBounds(gfx::Size(1, 1)); | 709 child->SetBounds(gfx::Size(1, 1)); |
| 710 parent_->AddChild(child); | 710 parent_->AddChild(child); |
| 711 } | 711 } |
| 712 | 712 |
| 713 layer_tree_host()->SetRootLayer(parent_); | 713 layer_tree_host()->SetRootLayer(parent_); |
| 714 LayerTreeHostContextTest::SetupTree(); | 714 LayerTreeHostContextTest::SetupTree(); |
| 715 } | 715 } |
| 716 | 716 |
| 717 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 717 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 718 | 718 |
| 719 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 719 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 720 EXPECT_EQ(0, times_to_lose_on_end_query_); | 720 EXPECT_EQ(0, times_to_lose_on_end_query_); |
| 721 EndTest(); | 721 EndTest(); |
| 722 } | 722 } |
| 723 | 723 |
| 724 virtual void AfterTest() OVERRIDE { | 724 virtual void AfterTest() override { |
| 725 EXPECT_EQ(0, times_to_lose_on_end_query_); | 725 EXPECT_EQ(0, times_to_lose_on_end_query_); |
| 726 } | 726 } |
| 727 | 727 |
| 728 private: | 728 private: |
| 729 FakeContentLayerClient client_; | 729 FakeContentLayerClient client_; |
| 730 scoped_refptr<Layer> parent_; | 730 scoped_refptr<Layer> parent_; |
| 731 int num_children_; | 731 int num_children_; |
| 732 int times_to_lose_on_end_query_; | 732 int times_to_lose_on_end_query_; |
| 733 }; | 733 }; |
| 734 | 734 |
| 735 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 735 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( |
| 736 LayerTreeHostContextTestLostContextWhileUpdatingResources); | 736 LayerTreeHostContextTestLostContextWhileUpdatingResources); |
| 737 | 737 |
| 738 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { | 738 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
| 739 public: | 739 public: |
| 740 LayerTreeHostContextTestLayersNotified() | 740 LayerTreeHostContextTestLayersNotified() |
| 741 : LayerTreeHostContextTest(), num_commits_(0) {} | 741 : LayerTreeHostContextTest(), num_commits_(0) {} |
| 742 | 742 |
| 743 virtual void SetupTree() OVERRIDE { | 743 virtual void SetupTree() override { |
| 744 if (layer_tree_host()->settings().impl_side_painting) { | 744 if (layer_tree_host()->settings().impl_side_painting) { |
| 745 root_ = FakePictureLayer::Create(&client_); | 745 root_ = FakePictureLayer::Create(&client_); |
| 746 child_ = FakePictureLayer::Create(&client_); | 746 child_ = FakePictureLayer::Create(&client_); |
| 747 grandchild_ = FakePictureLayer::Create(&client_); | 747 grandchild_ = FakePictureLayer::Create(&client_); |
| 748 } else { | 748 } else { |
| 749 root_ = FakeContentLayer::Create(&client_); | 749 root_ = FakeContentLayer::Create(&client_); |
| 750 child_ = FakeContentLayer::Create(&client_); | 750 child_ = FakeContentLayer::Create(&client_); |
| 751 grandchild_ = FakeContentLayer::Create(&client_); | 751 grandchild_ = FakeContentLayer::Create(&client_); |
| 752 } | 752 } |
| 753 | 753 |
| 754 root_->AddChild(child_); | 754 root_->AddChild(child_); |
| 755 child_->AddChild(grandchild_); | 755 child_->AddChild(grandchild_); |
| 756 | 756 |
| 757 layer_tree_host()->SetRootLayer(root_); | 757 layer_tree_host()->SetRootLayer(root_); |
| 758 LayerTreeHostContextTest::SetupTree(); | 758 LayerTreeHostContextTest::SetupTree(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 761 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 762 | 762 |
| 763 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 763 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 764 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); | 764 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
| 765 | 765 |
| 766 FakePictureLayerImpl* root_picture = NULL; | 766 FakePictureLayerImpl* root_picture = NULL; |
| 767 FakePictureLayerImpl* child_picture = NULL; | 767 FakePictureLayerImpl* child_picture = NULL; |
| 768 FakePictureLayerImpl* grandchild_picture = NULL; | 768 FakePictureLayerImpl* grandchild_picture = NULL; |
| 769 FakeContentLayerImpl* root_content = NULL; | 769 FakeContentLayerImpl* root_content = NULL; |
| 770 FakeContentLayerImpl* child_content = NULL; | 770 FakeContentLayerImpl* child_content = NULL; |
| 771 FakeContentLayerImpl* grandchild_content = NULL; | 771 FakeContentLayerImpl* grandchild_content = NULL; |
| 772 | 772 |
| 773 if (layer_tree_host()->settings().impl_side_painting) { | 773 if (layer_tree_host()->settings().impl_side_painting) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); | 815 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); |
| 816 } | 816 } |
| 817 | 817 |
| 818 EndTest(); | 818 EndTest(); |
| 819 break; | 819 break; |
| 820 default: | 820 default: |
| 821 NOTREACHED(); | 821 NOTREACHED(); |
| 822 } | 822 } |
| 823 } | 823 } |
| 824 | 824 |
| 825 virtual void AfterTest() OVERRIDE {} | 825 virtual void AfterTest() override {} |
| 826 | 826 |
| 827 private: | 827 private: |
| 828 int num_commits_; | 828 int num_commits_; |
| 829 | 829 |
| 830 FakeContentLayerClient client_; | 830 FakeContentLayerClient client_; |
| 831 scoped_refptr<Layer> root_; | 831 scoped_refptr<Layer> root_; |
| 832 scoped_refptr<Layer> child_; | 832 scoped_refptr<Layer> child_; |
| 833 scoped_refptr<Layer> grandchild_; | 833 scoped_refptr<Layer> grandchild_; |
| 834 }; | 834 }; |
| 835 | 835 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 849 shared_bitmap_manager_.get(), | 849 shared_bitmap_manager_.get(), |
| 850 NULL, | 850 NULL, |
| 851 0, | 851 0, |
| 852 false, | 852 false, |
| 853 1, | 853 1, |
| 854 false); | 854 false); |
| 855 } | 855 } |
| 856 | 856 |
| 857 static void EmptyReleaseCallback(unsigned sync_point, bool lost) {} | 857 static void EmptyReleaseCallback(unsigned sync_point, bool lost) {} |
| 858 | 858 |
| 859 virtual void SetupTree() OVERRIDE { | 859 virtual void SetupTree() override { |
| 860 gpu::gles2::GLES2Interface* gl = | 860 gpu::gles2::GLES2Interface* gl = |
| 861 child_output_surface_->context_provider()->ContextGL(); | 861 child_output_surface_->context_provider()->ContextGL(); |
| 862 | 862 |
| 863 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 863 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 864 | 864 |
| 865 scoped_ptr<TestRenderPass> pass_for_quad = TestRenderPass::Create(); | 865 scoped_ptr<TestRenderPass> pass_for_quad = TestRenderPass::Create(); |
| 866 pass_for_quad->SetNew( | 866 pass_for_quad->SetNew( |
| 867 // AppendOneOfEveryQuadType() makes a RenderPass quad with this id. | 867 // AppendOneOfEveryQuadType() makes a RenderPass quad with this id. |
| 868 RenderPassId(2, 1), | 868 RenderPassId(2, 1), |
| 869 gfx::Rect(0, 0, 10, 10), | 869 gfx::Rect(0, 0, 10, 10), |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 PaintedScrollbarLayer::Create( | 1005 PaintedScrollbarLayer::Create( |
| 1006 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id()); | 1006 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id()); |
| 1007 scrollbar->SetBounds(gfx::Size(10, 10)); | 1007 scrollbar->SetBounds(gfx::Size(10, 10)); |
| 1008 scrollbar->SetIsDrawable(true); | 1008 scrollbar->SetIsDrawable(true); |
| 1009 root->AddChild(scrollbar); | 1009 root->AddChild(scrollbar); |
| 1010 | 1010 |
| 1011 layer_tree_host()->SetRootLayer(root); | 1011 layer_tree_host()->SetRootLayer(root); |
| 1012 LayerTreeHostContextTest::SetupTree(); | 1012 LayerTreeHostContextTest::SetupTree(); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1015 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1016 | 1016 |
| 1017 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 1017 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1018 LayerTreeHostContextTest::CommitCompleteOnThread(host_impl); | 1018 LayerTreeHostContextTest::CommitCompleteOnThread(host_impl); |
| 1019 | 1019 |
| 1020 if (host_impl->active_tree()->source_frame_number() == 3) { | 1020 if (host_impl->active_tree()->source_frame_number() == 3) { |
| 1021 // On the third commit we're recovering from context loss. Hardware | 1021 // On the third commit we're recovering from context loss. Hardware |
| 1022 // video frames should not be reused by the VideoFrameProvider, but | 1022 // video frames should not be reused by the VideoFrameProvider, but |
| 1023 // software frames can be. | 1023 // software frames can be. |
| 1024 hw_frame_provider_.set_frame(NULL); | 1024 hw_frame_provider_.set_frame(NULL); |
| 1025 scaled_hw_frame_provider_.set_frame(NULL); | 1025 scaled_hw_frame_provider_.set_frame(NULL); |
| 1026 } | 1026 } |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 virtual DrawResult PrepareToDrawOnThread( | 1029 virtual DrawResult PrepareToDrawOnThread( |
| 1030 LayerTreeHostImpl* host_impl, | 1030 LayerTreeHostImpl* host_impl, |
| 1031 LayerTreeHostImpl::FrameData* frame, | 1031 LayerTreeHostImpl::FrameData* frame, |
| 1032 DrawResult draw_result) OVERRIDE { | 1032 DrawResult draw_result) override { |
| 1033 if (host_impl->active_tree()->source_frame_number() == 2) { | 1033 if (host_impl->active_tree()->source_frame_number() == 2) { |
| 1034 // Lose the context during draw on the second commit. This will cause | 1034 // Lose the context during draw on the second commit. This will cause |
| 1035 // a third commit to recover. | 1035 // a third commit to recover. |
| 1036 context3d_->set_times_bind_texture_succeeds(0); | 1036 context3d_->set_times_bind_texture_succeeds(0); |
| 1037 } | 1037 } |
| 1038 return draw_result; | 1038 return draw_result; |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 1041 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| 1042 OVERRIDE { | 1042 override { |
| 1043 // This will get called twice: | 1043 // This will get called twice: |
| 1044 // First when we create the initial output surface... | 1044 // First when we create the initial output surface... |
| 1045 if (layer_tree_host()->source_frame_number() > 0) { | 1045 if (layer_tree_host()->source_frame_number() > 0) { |
| 1046 // ... and then again after we forced the context to be lost. | 1046 // ... and then again after we forced the context to be lost. |
| 1047 lost_context_ = true; | 1047 lost_context_ = true; |
| 1048 } | 1048 } |
| 1049 return LayerTreeHostContextTest::CreateFakeOutputSurface(fallback); | 1049 return LayerTreeHostContextTest::CreateFakeOutputSurface(fallback); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1052 virtual void DidCommitAndDrawFrame() override { |
| 1053 ASSERT_TRUE(layer_tree_host()->hud_layer()); | 1053 ASSERT_TRUE(layer_tree_host()->hud_layer()); |
| 1054 // End the test once we know the 3nd frame drew. | 1054 // End the test once we know the 3nd frame drew. |
| 1055 if (layer_tree_host()->source_frame_number() < 5) { | 1055 if (layer_tree_host()->source_frame_number() < 5) { |
| 1056 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 1056 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
| 1057 layer_tree_host()->SetNeedsCommit(); | 1057 layer_tree_host()->SetNeedsCommit(); |
| 1058 } else { | 1058 } else { |
| 1059 EndTest(); | 1059 EndTest(); |
| 1060 } | 1060 } |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 virtual void AfterTest() OVERRIDE { EXPECT_TRUE(lost_context_); } | 1063 virtual void AfterTest() override { EXPECT_TRUE(lost_context_); } |
| 1064 | 1064 |
| 1065 private: | 1065 private: |
| 1066 FakeContentLayerClient client_; | 1066 FakeContentLayerClient client_; |
| 1067 bool lost_context_; | 1067 bool lost_context_; |
| 1068 | 1068 |
| 1069 FakeOutputSurfaceClient output_surface_client_; | 1069 FakeOutputSurfaceClient output_surface_client_; |
| 1070 scoped_ptr<FakeOutputSurface> child_output_surface_; | 1070 scoped_ptr<FakeOutputSurface> child_output_surface_; |
| 1071 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 1071 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 1072 scoped_ptr<ResourceProvider> child_resource_provider_; | 1072 scoped_ptr<ResourceProvider> child_resource_provider_; |
| 1073 | 1073 |
| 1074 scoped_refptr<DelegatedFrameResourceCollection> | 1074 scoped_refptr<DelegatedFrameResourceCollection> |
| 1075 delegated_resource_collection_; | 1075 delegated_resource_collection_; |
| 1076 scoped_refptr<DelegatedFrameProvider> delegated_frame_provider_; | 1076 scoped_refptr<DelegatedFrameProvider> delegated_frame_provider_; |
| 1077 | 1077 |
| 1078 scoped_refptr<VideoFrame> color_video_frame_; | 1078 scoped_refptr<VideoFrame> color_video_frame_; |
| 1079 scoped_refptr<VideoFrame> hw_video_frame_; | 1079 scoped_refptr<VideoFrame> hw_video_frame_; |
| 1080 scoped_refptr<VideoFrame> scaled_hw_video_frame_; | 1080 scoped_refptr<VideoFrame> scaled_hw_video_frame_; |
| 1081 | 1081 |
| 1082 FakeVideoFrameProvider color_frame_provider_; | 1082 FakeVideoFrameProvider color_frame_provider_; |
| 1083 FakeVideoFrameProvider hw_frame_provider_; | 1083 FakeVideoFrameProvider hw_frame_provider_; |
| 1084 FakeVideoFrameProvider scaled_hw_frame_provider_; | 1084 FakeVideoFrameProvider scaled_hw_frame_provider_; |
| 1085 }; | 1085 }; |
| 1086 | 1086 |
| 1087 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources); | 1087 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources); |
| 1088 | 1088 |
| 1089 class ImplSidePaintingLayerTreeHostContextTest | 1089 class ImplSidePaintingLayerTreeHostContextTest |
| 1090 : public LayerTreeHostContextTest { | 1090 : public LayerTreeHostContextTest { |
| 1091 public: | 1091 public: |
| 1092 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1092 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 1093 settings->impl_side_painting = true; | 1093 settings->impl_side_painting = true; |
| 1094 } | 1094 } |
| 1095 }; | 1095 }; |
| 1096 | 1096 |
| 1097 class LayerTreeHostContextTestImplSidePainting | 1097 class LayerTreeHostContextTestImplSidePainting |
| 1098 : public ImplSidePaintingLayerTreeHostContextTest { | 1098 : public ImplSidePaintingLayerTreeHostContextTest { |
| 1099 public: | 1099 public: |
| 1100 virtual void SetupTree() OVERRIDE { | 1100 virtual void SetupTree() override { |
| 1101 scoped_refptr<Layer> root = Layer::Create(); | 1101 scoped_refptr<Layer> root = Layer::Create(); |
| 1102 root->SetBounds(gfx::Size(10, 10)); | 1102 root->SetBounds(gfx::Size(10, 10)); |
| 1103 root->SetIsDrawable(true); | 1103 root->SetIsDrawable(true); |
| 1104 | 1104 |
| 1105 scoped_refptr<PictureLayer> picture = PictureLayer::Create(&client_); | 1105 scoped_refptr<PictureLayer> picture = PictureLayer::Create(&client_); |
| 1106 picture->SetBounds(gfx::Size(10, 10)); | 1106 picture->SetBounds(gfx::Size(10, 10)); |
| 1107 picture->SetIsDrawable(true); | 1107 picture->SetIsDrawable(true); |
| 1108 root->AddChild(picture); | 1108 root->AddChild(picture); |
| 1109 | 1109 |
| 1110 layer_tree_host()->SetRootLayer(root); | 1110 layer_tree_host()->SetRootLayer(root); |
| 1111 LayerTreeHostContextTest::SetupTree(); | 1111 LayerTreeHostContextTest::SetupTree(); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 virtual void BeginTest() OVERRIDE { | 1114 virtual void BeginTest() override { |
| 1115 times_to_lose_during_commit_ = 1; | 1115 times_to_lose_during_commit_ = 1; |
| 1116 PostSetNeedsCommitToMainThread(); | 1116 PostSetNeedsCommitToMainThread(); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 virtual void AfterTest() OVERRIDE {} | 1119 virtual void AfterTest() override {} |
| 1120 | 1120 |
| 1121 virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } | 1121 virtual void DidInitializeOutputSurface() override { EndTest(); } |
| 1122 | 1122 |
| 1123 private: | 1123 private: |
| 1124 FakeContentLayerClient client_; | 1124 FakeContentLayerClient client_; |
| 1125 }; | 1125 }; |
| 1126 | 1126 |
| 1127 MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); | 1127 MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); |
| 1128 | 1128 |
| 1129 class ScrollbarLayerLostContext : public LayerTreeHostContextTest { | 1129 class ScrollbarLayerLostContext : public LayerTreeHostContextTest { |
| 1130 public: | 1130 public: |
| 1131 ScrollbarLayerLostContext() : commits_(0) {} | 1131 ScrollbarLayerLostContext() : commits_(0) {} |
| 1132 | 1132 |
| 1133 virtual void BeginTest() OVERRIDE { | 1133 virtual void BeginTest() override { |
| 1134 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 1134 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 1135 scrollbar_layer_ = | 1135 scrollbar_layer_ = |
| 1136 FakePaintedScrollbarLayer::Create(false, true, scroll_layer->id()); | 1136 FakePaintedScrollbarLayer::Create(false, true, scroll_layer->id()); |
| 1137 scrollbar_layer_->SetBounds(gfx::Size(10, 100)); | 1137 scrollbar_layer_->SetBounds(gfx::Size(10, 100)); |
| 1138 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); | 1138 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
| 1139 layer_tree_host()->root_layer()->AddChild(scroll_layer); | 1139 layer_tree_host()->root_layer()->AddChild(scroll_layer); |
| 1140 PostSetNeedsCommitToMainThread(); | 1140 PostSetNeedsCommitToMainThread(); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 virtual void AfterTest() OVERRIDE {} | 1143 virtual void AfterTest() override {} |
| 1144 | 1144 |
| 1145 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1145 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1146 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1146 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1147 | 1147 |
| 1148 ++commits_; | 1148 ++commits_; |
| 1149 switch (commits_) { | 1149 switch (commits_) { |
| 1150 case 1: | 1150 case 1: |
| 1151 // First (regular) update, we should upload 2 resources (thumb, and | 1151 // First (regular) update, we should upload 2 resources (thumb, and |
| 1152 // backtrack). | 1152 // backtrack). |
| 1153 EXPECT_EQ(1, scrollbar_layer_->update_count()); | 1153 EXPECT_EQ(1, scrollbar_layer_->update_count()); |
| 1154 LoseContext(); | 1154 LoseContext(); |
| 1155 break; | 1155 break; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1167 private: | 1167 private: |
| 1168 int commits_; | 1168 int commits_; |
| 1169 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; | 1169 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; |
| 1170 }; | 1170 }; |
| 1171 | 1171 |
| 1172 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); | 1172 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); |
| 1173 | 1173 |
| 1174 class UIResourceLostTest : public LayerTreeHostContextTest { | 1174 class UIResourceLostTest : public LayerTreeHostContextTest { |
| 1175 public: | 1175 public: |
| 1176 UIResourceLostTest() : time_step_(0) {} | 1176 UIResourceLostTest() : time_step_(0) {} |
| 1177 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1177 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 1178 settings->texture_id_allocation_chunk_size = 1; | 1178 settings->texture_id_allocation_chunk_size = 1; |
| 1179 } | 1179 } |
| 1180 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1180 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1181 virtual void AfterTest() OVERRIDE {} | 1181 virtual void AfterTest() override {} |
| 1182 | 1182 |
| 1183 // This is called on the main thread after each commit and | 1183 // This is called on the main thread after each commit and |
| 1184 // DidActivateTreeOnThread, with the value of time_step_ at the time | 1184 // DidActivateTreeOnThread, with the value of time_step_ at the time |
| 1185 // of the call to DidActivateTreeOnThread. Similar tests will do | 1185 // of the call to DidActivateTreeOnThread. Similar tests will do |
| 1186 // work on the main thread in DidCommit but that is unsuitable because | 1186 // work on the main thread in DidCommit but that is unsuitable because |
| 1187 // the main thread work for these tests must happen after | 1187 // the main thread work for these tests must happen after |
| 1188 // DidActivateTreeOnThread, which happens after DidCommit with impl-side | 1188 // DidActivateTreeOnThread, which happens after DidCommit with impl-side |
| 1189 // painting. | 1189 // painting. |
| 1190 virtual void StepCompleteOnMainThread(int time_step) = 0; | 1190 virtual void StepCompleteOnMainThread(int time_step) = 0; |
| 1191 | 1191 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1218 StepCompleteOnMainThread(step); | 1218 StepCompleteOnMainThread(step); |
| 1219 } | 1219 } |
| 1220 }; | 1220 }; |
| 1221 | 1221 |
| 1222 class UIResourceLostTestSimple : public UIResourceLostTest { | 1222 class UIResourceLostTestSimple : public UIResourceLostTest { |
| 1223 public: | 1223 public: |
| 1224 // This is called when the commit is complete and the new layer tree has been | 1224 // This is called when the commit is complete and the new layer tree has been |
| 1225 // activated. | 1225 // activated. |
| 1226 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; | 1226 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; |
| 1227 | 1227 |
| 1228 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1228 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1229 if (!layer_tree_host()->settings().impl_side_painting) { | 1229 if (!layer_tree_host()->settings().impl_side_painting) { |
| 1230 StepCompleteOnImplThread(impl); | 1230 StepCompleteOnImplThread(impl); |
| 1231 PostStepCompleteToMainThread(); | 1231 PostStepCompleteToMainThread(); |
| 1232 ++time_step_; | 1232 ++time_step_; |
| 1233 } | 1233 } |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1236 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 1237 if (layer_tree_host()->settings().impl_side_painting) { | 1237 if (layer_tree_host()->settings().impl_side_painting) { |
| 1238 StepCompleteOnImplThread(impl); | 1238 StepCompleteOnImplThread(impl); |
| 1239 PostStepCompleteToMainThread(); | 1239 PostStepCompleteToMainThread(); |
| 1240 ++time_step_; | 1240 ++time_step_; |
| 1241 } | 1241 } |
| 1242 } | 1242 } |
| 1243 }; | 1243 }; |
| 1244 | 1244 |
| 1245 // Losing context after an UI resource has been created. | 1245 // Losing context after an UI resource has been created. |
| 1246 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { | 1246 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
| 1247 public: | 1247 public: |
| 1248 virtual void StepCompleteOnMainThread(int step) OVERRIDE { | 1248 virtual void StepCompleteOnMainThread(int step) override { |
| 1249 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1249 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 1250 switch (step) { | 1250 switch (step) { |
| 1251 case 0: | 1251 case 0: |
| 1252 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1252 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
| 1253 // Expects a valid UIResourceId. | 1253 // Expects a valid UIResourceId. |
| 1254 EXPECT_NE(0, ui_resource_->id()); | 1254 EXPECT_NE(0, ui_resource_->id()); |
| 1255 PostSetNeedsCommitToMainThread(); | 1255 PostSetNeedsCommitToMainThread(); |
| 1256 break; | 1256 break; |
| 1257 case 4: | 1257 case 4: |
| 1258 // Release resource before ending the test. | 1258 // Release resource before ending the test. |
| 1259 ui_resource_ = nullptr; | 1259 ui_resource_ = nullptr; |
| 1260 EndTest(); | 1260 EndTest(); |
| 1261 break; | 1261 break; |
| 1262 case 5: | 1262 case 5: |
| 1263 NOTREACHED(); | 1263 NOTREACHED(); |
| 1264 break; | 1264 break; |
| 1265 } | 1265 } |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1268 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) override { |
| 1269 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1269 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1270 switch (time_step_) { | 1270 switch (time_step_) { |
| 1271 case 1: | 1271 case 1: |
| 1272 // The resource should have been created on LTHI after the commit. | 1272 // The resource should have been created on LTHI after the commit. |
| 1273 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1273 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1274 PostSetNeedsCommitToMainThread(); | 1274 PostSetNeedsCommitToMainThread(); |
| 1275 break; | 1275 break; |
| 1276 case 2: | 1276 case 2: |
| 1277 LoseContext(); | 1277 LoseContext(); |
| 1278 break; | 1278 break; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1297 // created. | 1297 // created. |
| 1298 // 2. Delete an exisiting resource (test_id0_) -> create a second resource | 1298 // 2. Delete an exisiting resource (test_id0_) -> create a second resource |
| 1299 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and | 1299 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and |
| 1300 // test_id1_ to have been created. | 1300 // test_id1_ to have been created. |
| 1301 // 3. Create one resource -> Delete that same resource -> Context Lost => Expect | 1301 // 3. Create one resource -> Delete that same resource -> Context Lost => Expect |
| 1302 // the resource to not exist in the manager. | 1302 // the resource to not exist in the manager. |
| 1303 class UIResourceLostBeforeCommit : public UIResourceLostTestSimple { | 1303 class UIResourceLostBeforeCommit : public UIResourceLostTestSimple { |
| 1304 public: | 1304 public: |
| 1305 UIResourceLostBeforeCommit() : test_id0_(0), test_id1_(0) {} | 1305 UIResourceLostBeforeCommit() : test_id0_(0), test_id1_(0) {} |
| 1306 | 1306 |
| 1307 virtual void StepCompleteOnMainThread(int step) OVERRIDE { | 1307 virtual void StepCompleteOnMainThread(int step) override { |
| 1308 switch (step) { | 1308 switch (step) { |
| 1309 case 0: | 1309 case 0: |
| 1310 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1310 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
| 1311 // Lose the context on the impl thread before the commit. | 1311 // Lose the context on the impl thread before the commit. |
| 1312 PostLoseContextToImplThread(); | 1312 PostLoseContextToImplThread(); |
| 1313 break; | 1313 break; |
| 1314 case 2: | 1314 case 2: |
| 1315 // Sequence 2: | 1315 // Sequence 2: |
| 1316 // Currently one resource has been created. | 1316 // Currently one resource has been created. |
| 1317 test_id0_ = ui_resource_->id(); | 1317 test_id0_ = ui_resource_->id(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1347 // Release resource before ending the test. | 1347 // Release resource before ending the test. |
| 1348 ui_resource_ = nullptr; | 1348 ui_resource_ = nullptr; |
| 1349 EndTest(); | 1349 EndTest(); |
| 1350 break; | 1350 break; |
| 1351 case 6: | 1351 case 6: |
| 1352 NOTREACHED(); | 1352 NOTREACHED(); |
| 1353 break; | 1353 break; |
| 1354 } | 1354 } |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1357 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) override { |
| 1358 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1358 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1359 switch (time_step_) { | 1359 switch (time_step_) { |
| 1360 case 1: | 1360 case 1: |
| 1361 // Sequence 1 (continued): | 1361 // Sequence 1 (continued): |
| 1362 // The first context lost happens before the resources were created, | 1362 // The first context lost happens before the resources were created, |
| 1363 // and because it resulted in no resources being destroyed, it does not | 1363 // and because it resulted in no resources being destroyed, it does not |
| 1364 // trigger resource re-creation. | 1364 // trigger resource re-creation. |
| 1365 EXPECT_EQ(1, ui_resource_->resource_create_count); | 1365 EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1366 EXPECT_EQ(0, ui_resource_->lost_resource_count); | 1366 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1367 // Resource Id on the impl-side has been created. | 1367 // Resource Id on the impl-side has been created. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1393 private: | 1393 private: |
| 1394 UIResourceId test_id0_; | 1394 UIResourceId test_id0_; |
| 1395 UIResourceId test_id1_; | 1395 UIResourceId test_id1_; |
| 1396 }; | 1396 }; |
| 1397 | 1397 |
| 1398 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostBeforeCommit); | 1398 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostBeforeCommit); |
| 1399 | 1399 |
| 1400 // Losing UI resource before the pending trees is activated but after the | 1400 // Losing UI resource before the pending trees is activated but after the |
| 1401 // commit. Impl-side-painting only. | 1401 // commit. Impl-side-painting only. |
| 1402 class UIResourceLostBeforeActivateTree : public UIResourceLostTest { | 1402 class UIResourceLostBeforeActivateTree : public UIResourceLostTest { |
| 1403 virtual void StepCompleteOnMainThread(int step) OVERRIDE { | 1403 virtual void StepCompleteOnMainThread(int step) override { |
| 1404 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1404 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 1405 switch (step) { | 1405 switch (step) { |
| 1406 case 0: | 1406 case 0: |
| 1407 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1407 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
| 1408 PostSetNeedsCommitToMainThread(); | 1408 PostSetNeedsCommitToMainThread(); |
| 1409 break; | 1409 break; |
| 1410 case 3: | 1410 case 3: |
| 1411 test_id_ = ui_resource_->id(); | 1411 test_id_ = ui_resource_->id(); |
| 1412 ui_resource_ = nullptr; | 1412 ui_resource_ = nullptr; |
| 1413 PostSetNeedsCommitToMainThread(); | 1413 PostSetNeedsCommitToMainThread(); |
| 1414 break; | 1414 break; |
| 1415 case 5: | 1415 case 5: |
| 1416 // Release resource before ending the test. | 1416 // Release resource before ending the test. |
| 1417 ui_resource_ = nullptr; | 1417 ui_resource_ = nullptr; |
| 1418 EndTest(); | 1418 EndTest(); |
| 1419 break; | 1419 break; |
| 1420 case 6: | 1420 case 6: |
| 1421 // Make sure no extra commits happened. | 1421 // Make sure no extra commits happened. |
| 1422 NOTREACHED(); | 1422 NOTREACHED(); |
| 1423 } | 1423 } |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1426 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1427 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1427 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1428 switch (time_step_) { | 1428 switch (time_step_) { |
| 1429 case 2: | 1429 case 2: |
| 1430 PostSetNeedsCommitToMainThread(); | 1430 PostSetNeedsCommitToMainThread(); |
| 1431 break; | 1431 break; |
| 1432 case 4: | 1432 case 4: |
| 1433 PostSetNeedsCommitToMainThread(); | 1433 PostSetNeedsCommitToMainThread(); |
| 1434 break; | 1434 break; |
| 1435 } | 1435 } |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1438 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 1439 switch (time_step_) { | 1439 switch (time_step_) { |
| 1440 case 1: | 1440 case 1: |
| 1441 // The resource creation callback has been called. | 1441 // The resource creation callback has been called. |
| 1442 EXPECT_EQ(1, ui_resource_->resource_create_count); | 1442 EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1443 // The resource is not yet lost (sanity check). | 1443 // The resource is not yet lost (sanity check). |
| 1444 EXPECT_EQ(0, ui_resource_->lost_resource_count); | 1444 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1445 // The resource should not have been created yet on the impl-side. | 1445 // The resource should not have been created yet on the impl-side. |
| 1446 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1446 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1447 LoseContext(); | 1447 LoseContext(); |
| 1448 break; | 1448 break; |
| 1449 case 3: | 1449 case 3: |
| 1450 LoseContext(); | 1450 LoseContext(); |
| 1451 break; | 1451 break; |
| 1452 } | 1452 } |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1455 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 1456 LayerTreeHostContextTest::DidActivateTreeOnThread(impl); | 1456 LayerTreeHostContextTest::DidActivateTreeOnThread(impl); |
| 1457 switch (time_step_) { | 1457 switch (time_step_) { |
| 1458 case 1: | 1458 case 1: |
| 1459 // The pending requests on the impl-side should have been processed. | 1459 // The pending requests on the impl-side should have been processed. |
| 1460 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1460 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1461 break; | 1461 break; |
| 1462 case 2: | 1462 case 2: |
| 1463 // The "lost resource" callback should have been called once. | 1463 // The "lost resource" callback should have been called once. |
| 1464 EXPECT_EQ(1, ui_resource_->lost_resource_count); | 1464 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
| 1465 break; | 1465 break; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 TEST_F(UIResourceLostBeforeActivateTree, | 1486 TEST_F(UIResourceLostBeforeActivateTree, |
| 1487 RunMultiThread_DelegatingRenderer_ImplSidePaint) { | 1487 RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
| 1488 RunTest(true, true, true); | 1488 RunTest(true, true, true); |
| 1489 } | 1489 } |
| 1490 | 1490 |
| 1491 // Resources evicted explicitly and by visibility changes. | 1491 // Resources evicted explicitly and by visibility changes. |
| 1492 class UIResourceLostEviction : public UIResourceLostTestSimple { | 1492 class UIResourceLostEviction : public UIResourceLostTestSimple { |
| 1493 public: | 1493 public: |
| 1494 virtual void StepCompleteOnMainThread(int step) OVERRIDE { | 1494 virtual void StepCompleteOnMainThread(int step) override { |
| 1495 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1495 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 1496 switch (step) { | 1496 switch (step) { |
| 1497 case 0: | 1497 case 0: |
| 1498 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1498 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
| 1499 EXPECT_NE(0, ui_resource_->id()); | 1499 EXPECT_NE(0, ui_resource_->id()); |
| 1500 PostSetNeedsCommitToMainThread(); | 1500 PostSetNeedsCommitToMainThread(); |
| 1501 break; | 1501 break; |
| 1502 case 2: | 1502 case 2: |
| 1503 // Make the tree not visible. | 1503 // Make the tree not visible. |
| 1504 PostSetVisibleToMainThread(false); | 1504 PostSetVisibleToMainThread(false); |
| 1505 break; | 1505 break; |
| 1506 case 3: | 1506 case 3: |
| 1507 // Release resource before ending the test. | 1507 // Release resource before ending the test. |
| 1508 ui_resource_ = nullptr; | 1508 ui_resource_ = nullptr; |
| 1509 EndTest(); | 1509 EndTest(); |
| 1510 break; | 1510 break; |
| 1511 case 4: | 1511 case 4: |
| 1512 NOTREACHED(); | 1512 NOTREACHED(); |
| 1513 } | 1513 } |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, | 1516 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, |
| 1517 bool visible) OVERRIDE { | 1517 bool visible) override { |
| 1518 TestWebGraphicsContext3D* context = TestContext(); | 1518 TestWebGraphicsContext3D* context = TestContext(); |
| 1519 if (!visible) { | 1519 if (!visible) { |
| 1520 // All resources should have been evicted. | 1520 // All resources should have been evicted. |
| 1521 ASSERT_EQ(0u, context->NumTextures()); | 1521 ASSERT_EQ(0u, context->NumTextures()); |
| 1522 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1522 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1523 EXPECT_EQ(2, ui_resource_->resource_create_count); | 1523 EXPECT_EQ(2, ui_resource_->resource_create_count); |
| 1524 EXPECT_EQ(1, ui_resource_->lost_resource_count); | 1524 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
| 1525 // Drawing is disabled both because of the evicted resources and | 1525 // Drawing is disabled both because of the evicted resources and |
| 1526 // because the renderer is not visible. | 1526 // because the renderer is not visible. |
| 1527 EXPECT_FALSE(impl->CanDraw()); | 1527 EXPECT_FALSE(impl->CanDraw()); |
| 1528 // Make the renderer visible again. | 1528 // Make the renderer visible again. |
| 1529 PostSetVisibleToMainThread(true); | 1529 PostSetVisibleToMainThread(true); |
| 1530 } | 1530 } |
| 1531 } | 1531 } |
| 1532 | 1532 |
| 1533 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1533 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) override { |
| 1534 TestWebGraphicsContext3D* context = TestContext(); | 1534 TestWebGraphicsContext3D* context = TestContext(); |
| 1535 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1535 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1536 switch (time_step_) { | 1536 switch (time_step_) { |
| 1537 case 1: | 1537 case 1: |
| 1538 // The resource should have been created on LTHI after the commit. | 1538 // The resource should have been created on LTHI after the commit. |
| 1539 ASSERT_EQ(1u, context->NumTextures()); | 1539 ASSERT_EQ(1u, context->NumTextures()); |
| 1540 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1540 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1541 EXPECT_EQ(1, ui_resource_->resource_create_count); | 1541 EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1542 EXPECT_EQ(0, ui_resource_->lost_resource_count); | 1542 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1543 EXPECT_TRUE(impl->CanDraw()); | 1543 EXPECT_TRUE(impl->CanDraw()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1571 }; | 1571 }; |
| 1572 | 1572 |
| 1573 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); | 1573 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); |
| 1574 | 1574 |
| 1575 class LayerTreeHostContextTestSurfaceCreateCallback | 1575 class LayerTreeHostContextTestSurfaceCreateCallback |
| 1576 : public LayerTreeHostContextTest { | 1576 : public LayerTreeHostContextTest { |
| 1577 public: | 1577 public: |
| 1578 LayerTreeHostContextTestSurfaceCreateCallback() | 1578 LayerTreeHostContextTestSurfaceCreateCallback() |
| 1579 : LayerTreeHostContextTest() {} | 1579 : LayerTreeHostContextTest() {} |
| 1580 | 1580 |
| 1581 virtual void SetupTree() OVERRIDE { | 1581 virtual void SetupTree() override { |
| 1582 if (layer_tree_host()->settings().impl_side_painting) { | 1582 if (layer_tree_host()->settings().impl_side_painting) { |
| 1583 picture_layer_ = FakePictureLayer::Create(&client_); | 1583 picture_layer_ = FakePictureLayer::Create(&client_); |
| 1584 picture_layer_->SetBounds(gfx::Size(10, 20)); | 1584 picture_layer_->SetBounds(gfx::Size(10, 20)); |
| 1585 layer_tree_host()->SetRootLayer(picture_layer_); | 1585 layer_tree_host()->SetRootLayer(picture_layer_); |
| 1586 } else { | 1586 } else { |
| 1587 content_layer_ = FakeContentLayer::Create(&client_); | 1587 content_layer_ = FakeContentLayer::Create(&client_); |
| 1588 content_layer_->SetBounds(gfx::Size(10, 20)); | 1588 content_layer_->SetBounds(gfx::Size(10, 20)); |
| 1589 layer_tree_host()->SetRootLayer(content_layer_); | 1589 layer_tree_host()->SetRootLayer(content_layer_); |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 LayerTreeHostContextTest::SetupTree(); | 1592 LayerTreeHostContextTest::SetupTree(); |
| 1593 } | 1593 } |
| 1594 | 1594 |
| 1595 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1595 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1596 | 1596 |
| 1597 virtual void DidCommit() OVERRIDE { | 1597 virtual void DidCommit() override { |
| 1598 switch (layer_tree_host()->source_frame_number()) { | 1598 switch (layer_tree_host()->source_frame_number()) { |
| 1599 case 1: | 1599 case 1: |
| 1600 if (layer_tree_host()->settings().impl_side_painting) | 1600 if (layer_tree_host()->settings().impl_side_painting) |
| 1601 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); | 1601 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); |
| 1602 else | 1602 else |
| 1603 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); | 1603 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); |
| 1604 layer_tree_host()->SetNeedsCommit(); | 1604 layer_tree_host()->SetNeedsCommit(); |
| 1605 break; | 1605 break; |
| 1606 case 2: | 1606 case 2: |
| 1607 if (layer_tree_host()->settings().impl_side_painting) | 1607 if (layer_tree_host()->settings().impl_side_painting) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1619 case 4: | 1619 case 4: |
| 1620 if (layer_tree_host()->settings().impl_side_painting) | 1620 if (layer_tree_host()->settings().impl_side_painting) |
| 1621 EXPECT_EQ(2u, picture_layer_->output_surface_created_count()); | 1621 EXPECT_EQ(2u, picture_layer_->output_surface_created_count()); |
| 1622 else | 1622 else |
| 1623 EXPECT_EQ(2u, content_layer_->output_surface_created_count()); | 1623 EXPECT_EQ(2u, content_layer_->output_surface_created_count()); |
| 1624 layer_tree_host()->SetNeedsCommit(); | 1624 layer_tree_host()->SetNeedsCommit(); |
| 1625 break; | 1625 break; |
| 1626 } | 1626 } |
| 1627 } | 1627 } |
| 1628 | 1628 |
| 1629 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1629 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 1630 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1630 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1631 switch (LastCommittedSourceFrameNumber(impl)) { | 1631 switch (LastCommittedSourceFrameNumber(impl)) { |
| 1632 case 0: | 1632 case 0: |
| 1633 break; | 1633 break; |
| 1634 case 1: | 1634 case 1: |
| 1635 break; | 1635 break; |
| 1636 case 2: | 1636 case 2: |
| 1637 LoseContext(); | 1637 LoseContext(); |
| 1638 break; | 1638 break; |
| 1639 case 3: | 1639 case 3: |
| 1640 EndTest(); | 1640 EndTest(); |
| 1641 break; | 1641 break; |
| 1642 } | 1642 } |
| 1643 } | 1643 } |
| 1644 | 1644 |
| 1645 virtual void AfterTest() OVERRIDE {} | 1645 virtual void AfterTest() override {} |
| 1646 | 1646 |
| 1647 protected: | 1647 protected: |
| 1648 FakeContentLayerClient client_; | 1648 FakeContentLayerClient client_; |
| 1649 scoped_refptr<FakePictureLayer> picture_layer_; | 1649 scoped_refptr<FakePictureLayer> picture_layer_; |
| 1650 scoped_refptr<FakeContentLayer> content_layer_; | 1650 scoped_refptr<FakeContentLayer> content_layer_; |
| 1651 }; | 1651 }; |
| 1652 | 1652 |
| 1653 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); | 1653 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); |
| 1654 | 1654 |
| 1655 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame | 1655 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame |
| 1656 : public LayerTreeHostContextTest { | 1656 : public LayerTreeHostContextTest { |
| 1657 protected: | 1657 protected: |
| 1658 virtual void BeginTest() OVERRIDE { | 1658 virtual void BeginTest() override { |
| 1659 deferred_ = false; | 1659 deferred_ = false; |
| 1660 PostSetNeedsCommitToMainThread(); | 1660 PostSetNeedsCommitToMainThread(); |
| 1661 } | 1661 } |
| 1662 | 1662 |
| 1663 virtual void ScheduledActionWillSendBeginMainFrame() OVERRIDE { | 1663 virtual void ScheduledActionWillSendBeginMainFrame() override { |
| 1664 if (deferred_) | 1664 if (deferred_) |
| 1665 return; | 1665 return; |
| 1666 deferred_ = true; | 1666 deferred_ = true; |
| 1667 | 1667 |
| 1668 // Defer commits before the BeginFrame arrives, causing it to be delayed. | 1668 // Defer commits before the BeginFrame arrives, causing it to be delayed. |
| 1669 MainThreadTaskRunner()->PostTask( | 1669 MainThreadTaskRunner()->PostTask( |
| 1670 FROM_HERE, | 1670 FROM_HERE, |
| 1671 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | 1671 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
| 1672 DeferCommitsOnMainThread, | 1672 DeferCommitsOnMainThread, |
| 1673 base::Unretained(this), | 1673 base::Unretained(this), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1689 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | 1689 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
| 1690 DeferCommitsOnMainThread, | 1690 DeferCommitsOnMainThread, |
| 1691 base::Unretained(this), | 1691 base::Unretained(this), |
| 1692 false)); | 1692 false)); |
| 1693 } | 1693 } |
| 1694 | 1694 |
| 1695 void DeferCommitsOnMainThread(bool defer_commits) { | 1695 void DeferCommitsOnMainThread(bool defer_commits) { |
| 1696 layer_tree_host()->SetDeferCommits(defer_commits); | 1696 layer_tree_host()->SetDeferCommits(defer_commits); |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 virtual void WillBeginMainFrame() OVERRIDE { | 1699 virtual void WillBeginMainFrame() override { |
| 1700 // Don't begin a frame with a lost surface. | 1700 // Don't begin a frame with a lost surface. |
| 1701 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); | 1701 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); |
| 1702 } | 1702 } |
| 1703 | 1703 |
| 1704 virtual void DidCommitAndDrawFrame() OVERRIDE { EndTest(); } | 1704 virtual void DidCommitAndDrawFrame() override { EndTest(); } |
| 1705 | 1705 |
| 1706 virtual void AfterTest() OVERRIDE {} | 1706 virtual void AfterTest() override {} |
| 1707 | 1707 |
| 1708 bool deferred_; | 1708 bool deferred_; |
| 1709 }; | 1709 }; |
| 1710 | 1710 |
| 1711 SINGLE_AND_MULTI_THREAD_TEST_F( | 1711 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1712 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1712 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
| 1713 | 1713 |
| 1714 } // namespace | 1714 } // namespace |
| 1715 } // namespace cc | 1715 } // namespace cc |
| OLD | NEW |