| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 scoped_refptr<ContextProvider> compositor_context_provider) override { | 133 scoped_refptr<ContextProvider> compositor_context_provider) override { |
| 134 if (!use_gl_renderer_) { | 134 if (!use_gl_renderer_) { |
| 135 return FakeOutputSurface::CreateSoftware( | 135 return FakeOutputSurface::CreateSoftware( |
| 136 base::WrapUnique(new SoftwareOutputDevice)); | 136 base::WrapUnique(new SoftwareOutputDevice)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 scoped_refptr<TestContextProvider> display_context_provider = | 139 scoped_refptr<TestContextProvider> display_context_provider = |
| 140 TestContextProvider::Create(); | 140 TestContextProvider::Create(); |
| 141 TestContextSupport* context_support = display_context_provider->support(); | 141 TestContextSupport* context_support = display_context_provider->support(); |
| 142 context_support->set_out_of_order_callbacks(out_of_order_callbacks_); | 142 context_support->set_out_of_order_callbacks(out_of_order_callbacks_); |
| 143 display_context_provider->BindToCurrentThread(); |
| 143 | 144 |
| 144 return FakeOutputSurface::Create3d(std::move(display_context_provider)); | 145 return FakeOutputSurface::Create3d(std::move(display_context_provider)); |
| 145 } | 146 } |
| 146 | 147 |
| 147 bool use_gl_renderer_; | 148 bool use_gl_renderer_; |
| 148 bool out_of_order_callbacks_ = false; | 149 bool out_of_order_callbacks_ = false; |
| 149 std::map<size_t, gfx::Size> callbacks_; | 150 std::map<size_t, gfx::Size> callbacks_; |
| 150 FakeContentLayerClient client_; | 151 FakeContentLayerClient client_; |
| 151 scoped_refptr<FakePictureLayer> root; | 152 scoped_refptr<FakePictureLayer> root; |
| 152 scoped_refptr<FakePictureLayer> child; | 153 scoped_refptr<FakePictureLayer> child; |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 }; | 728 }; |
| 728 | 729 |
| 729 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncTwoReadbacksWithoutDraw); | 730 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncTwoReadbacksWithoutDraw); |
| 730 | 731 |
| 731 class LayerTreeHostCopyRequestTestDeleteTexture | 732 class LayerTreeHostCopyRequestTestDeleteTexture |
| 732 : public LayerTreeHostCopyRequestTest { | 733 : public LayerTreeHostCopyRequestTest { |
| 733 protected: | 734 protected: |
| 734 std::unique_ptr<OutputSurface> CreateDisplayOutputSurfaceOnThread( | 735 std::unique_ptr<OutputSurface> CreateDisplayOutputSurfaceOnThread( |
| 735 scoped_refptr<ContextProvider> compositor_context_provider) override { | 736 scoped_refptr<ContextProvider> compositor_context_provider) override { |
| 736 display_context_provider_ = TestContextProvider::Create(); | 737 display_context_provider_ = TestContextProvider::Create(); |
| 738 display_context_provider_->BindToCurrentThread(); |
| 737 return FakeOutputSurface::Create3d(display_context_provider_); | 739 return FakeOutputSurface::Create3d(display_context_provider_); |
| 738 } | 740 } |
| 739 | 741 |
| 740 void SetupTree() override { | 742 void SetupTree() override { |
| 741 root_ = FakePictureLayer::Create(&client_); | 743 root_ = FakePictureLayer::Create(&client_); |
| 742 root_->SetBounds(gfx::Size(20, 20)); | 744 root_->SetBounds(gfx::Size(20, 20)); |
| 743 | 745 |
| 744 copy_layer_ = FakePictureLayer::Create(&client_); | 746 copy_layer_ = FakePictureLayer::Create(&client_); |
| 745 copy_layer_->SetBounds(gfx::Size(10, 10)); | 747 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 746 root_->AddChild(copy_layer_); | 748 root_->AddChild(copy_layer_); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 CheckNumTexturesAfterReadbackDestroyed, | 784 CheckNumTexturesAfterReadbackDestroyed, |
| 783 base::Unretained(this))); | 785 base::Unretained(this))); |
| 784 } | 786 } |
| 785 | 787 |
| 786 void CheckNumTexturesAfterReadbackDestroyed() { | 788 void CheckNumTexturesAfterReadbackDestroyed() { |
| 787 // After the copy we had |num_textures_after_readback_| many textures, but | 789 // After the copy we had |num_textures_after_readback_| many textures, but |
| 788 // releasing the copy output request should cause the texture in the request | 790 // releasing the copy output request should cause the texture in the request |
| 789 // to be destroyed by the compositor, so we should have 1 less by now. | 791 // to be destroyed by the compositor, so we should have 1 less by now. |
| 790 EXPECT_EQ(num_textures_after_readback_ - 1, | 792 EXPECT_EQ(num_textures_after_readback_ - 1, |
| 791 display_context_provider_->TestContext3d()->NumTextures()); | 793 display_context_provider_->TestContext3d()->NumTextures()); |
| 794 |
| 795 // Unref the context provider on the compositor thread. |
| 796 display_context_provider_ = nullptr; |
| 792 EndTest(); | 797 EndTest(); |
| 793 } | 798 } |
| 794 | 799 |
| 795 void DisplayDidDrawAndSwapOnThread() override { | 800 void DisplayDidDrawAndSwapOnThread() override { |
| 796 switch (num_swaps_++) { | 801 switch (num_swaps_++) { |
| 797 case 0: | 802 case 0: |
| 798 // The layers have been drawn, so any textures required for drawing have | 803 // The layers have been drawn, so any textures required for drawing have |
| 799 // been allocated. | 804 // been allocated. |
| 800 EXPECT_FALSE(result_); | 805 EXPECT_FALSE(result_); |
| 801 num_textures_without_readback_ = | 806 num_textures_without_readback_ = |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 int num_draws_; | 1290 int num_draws_; |
| 1286 bool copy_happened_; | 1291 bool copy_happened_; |
| 1287 bool draw_happened_; | 1292 bool draw_happened_; |
| 1288 }; | 1293 }; |
| 1289 | 1294 |
| 1290 SINGLE_AND_MULTI_THREAD_TEST_F( | 1295 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1291 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); | 1296 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); |
| 1292 | 1297 |
| 1293 } // namespace | 1298 } // namespace |
| 1294 } // namespace cc | 1299 } // namespace cc |
| OLD | NEW |