OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "ui/gfx/geometry/vector2d_conversions.h" | 62 #include "ui/gfx/geometry/vector2d_conversions.h" |
63 | 63 |
64 using testing::_; | 64 using testing::_; |
65 using testing::AnyNumber; | 65 using testing::AnyNumber; |
66 using testing::AtLeast; | 66 using testing::AtLeast; |
67 using testing::Mock; | 67 using testing::Mock; |
68 | 68 |
69 namespace cc { | 69 namespace cc { |
70 namespace { | 70 namespace { |
71 | 71 |
72 class LayerTreeHostTest : public LayerTreeTest { | 72 class LayerTreeHostTest : public LayerTreeTest {}; |
73 public: | |
74 LayerTreeHostTest() : contents_texture_manager_(nullptr) {} | |
75 | |
76 void DidInitializeOutputSurface() override { | |
77 contents_texture_manager_ = layer_tree_host()->contents_texture_manager(); | |
78 } | |
79 | |
80 protected: | |
81 PrioritizedResourceManager* contents_texture_manager_; | |
82 }; | |
83 | 73 |
84 class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest { | 74 class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest { |
85 public: | 75 public: |
86 LayerTreeHostTestHasImplThreadTest() : threaded_(false) {} | 76 LayerTreeHostTestHasImplThreadTest() : threaded_(false) {} |
87 | 77 |
88 void RunTest(bool threaded, bool delegating_renderer) override { | 78 void RunTest(bool threaded, bool delegating_renderer) override { |
89 threaded_ = threaded; | 79 threaded_ = threaded; |
90 LayerTreeHostTest::RunTest(threaded, delegating_renderer); | 80 LayerTreeHostTest::RunTest(threaded, delegating_renderer); |
91 } | 81 } |
92 | 82 |
(...skipping 3433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3526 } | 3516 } |
3527 | 3517 |
3528 void AfterTest() override {} | 3518 void AfterTest() override {} |
3529 | 3519 |
3530 FakeContentLayerClient client_; | 3520 FakeContentLayerClient client_; |
3531 scoped_refptr<FakePictureLayer> root_layer_; | 3521 scoped_refptr<FakePictureLayer> root_layer_; |
3532 }; | 3522 }; |
3533 | 3523 |
3534 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); | 3524 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); |
3535 | 3525 |
3536 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { | |
3537 public: | |
3538 LayerTreeHostTestAbortEvictedTextures() | |
3539 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} | |
3540 | |
3541 protected: | |
3542 void SetupTree() override { | |
3543 scoped_refptr<SolidColorLayer> root_layer = | |
3544 SolidColorLayer::Create(layer_settings()); | |
3545 root_layer->SetBounds(gfx::Size(200, 200)); | |
3546 root_layer->SetIsDrawable(true); | |
3547 root_layer->CreateRenderSurface(); | |
3548 | |
3549 layer_tree_host()->SetRootLayer(root_layer); | |
3550 LayerTreeHostTest::SetupTree(); | |
3551 } | |
3552 | |
3553 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
3554 | |
3555 void WillBeginMainFrame() override { | |
3556 num_will_begin_main_frames_++; | |
3557 switch (num_will_begin_main_frames_) { | |
3558 case 2: | |
3559 // Send a redraw to the compositor thread. This will (wrongly) be | |
3560 // ignored unless aborting resets the texture state. | |
3561 layer_tree_host()->SetNeedsRedraw(); | |
3562 break; | |
3563 } | |
3564 } | |
3565 | |
3566 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { | |
3567 num_impl_commits_++; | |
3568 } | |
3569 | |
3570 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
3571 switch (impl->SourceAnimationFrameNumberForTesting()) { | |
3572 case 1: | |
3573 // Prevent draws until commit. | |
3574 impl->active_tree()->SetContentsTexturesPurged(); | |
3575 EXPECT_FALSE(impl->CanDraw()); | |
3576 // Trigger an abortable commit. | |
3577 impl->SetNeedsCommit(); | |
3578 break; | |
3579 case 2: | |
3580 EndTest(); | |
3581 break; | |
3582 } | |
3583 } | |
3584 | |
3585 void AfterTest() override { | |
3586 // Ensure that the commit was truly aborted. | |
3587 EXPECT_EQ(2, num_will_begin_main_frames_); | |
3588 EXPECT_EQ(1, num_impl_commits_); | |
3589 } | |
3590 | |
3591 private: | |
3592 int num_will_begin_main_frames_; | |
3593 int num_impl_commits_; | |
3594 }; | |
3595 | |
3596 // Commits can only be aborted when using the thread proxy. | |
3597 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); | |
3598 | |
3599 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { | 3526 class LayerTreeHostTestMaxTransferBufferUsageBytes : public LayerTreeHostTest { |
3600 protected: | 3527 protected: |
3601 void InitializeSettings(LayerTreeSettings* settings) override { | 3528 void InitializeSettings(LayerTreeSettings* settings) override { |
3602 // Testing async uploads. | 3529 // Testing async uploads. |
3603 settings->use_zero_copy = false; | 3530 settings->use_zero_copy = false; |
3604 settings->use_one_copy = false; | 3531 settings->use_one_copy = false; |
3605 } | 3532 } |
3606 | 3533 |
3607 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 3534 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
3608 scoped_refptr<TestContextProvider> context_provider = | 3535 scoped_refptr<TestContextProvider> context_provider = |
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5959 | 5886 |
5960 scoped_refptr<FakePictureLayer> content_child_layer_; | 5887 scoped_refptr<FakePictureLayer> content_child_layer_; |
5961 FakeContentLayerClient client_; | 5888 FakeContentLayerClient client_; |
5962 }; | 5889 }; |
5963 | 5890 |
5964 SINGLE_AND_MULTI_THREAD_TEST_F( | 5891 SINGLE_AND_MULTI_THREAD_TEST_F( |
5965 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); | 5892 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); |
5966 | 5893 |
5967 } // namespace | 5894 } // namespace |
5968 } // namespace cc | 5895 } // namespace cc |
OLD | NEW |