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/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 5719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5730 | 5730 |
5731 if (delegating_renderer()) | 5731 if (delegating_renderer()) |
5732 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 5732 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
5733 else | 5733 else |
5734 return FakeOutputSurface::Create3d(context3d.Pass()); | 5734 return FakeOutputSurface::Create3d(context3d.Pass()); |
5735 } | 5735 } |
5736 }; | 5736 }; |
5737 | 5737 |
5738 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); | 5738 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); |
5739 | 5739 |
| 5740 class RasterizeWithGpuRasterizationCreatesResources : public LayerTreeHostTest { |
| 5741 protected: |
| 5742 RasterizeWithGpuRasterizationCreatesResources() {} |
| 5743 |
| 5744 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5745 settings->impl_side_painting = true; |
| 5746 settings->gpu_rasterization_forced = true; |
| 5747 } |
| 5748 |
| 5749 void SetupTree() override { |
| 5750 client_.set_fill_with_nonsolid_color(true); |
| 5751 |
| 5752 scoped_refptr<Layer> root = Layer::Create(); |
| 5753 root->SetBounds(gfx::Size(500, 500)); |
| 5754 |
| 5755 scoped_ptr<FakePicturePile> pile(new FakePicturePile); |
| 5756 scoped_refptr<FakePictureLayer> layer = |
| 5757 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
| 5758 layer->SetBounds(gfx::Size(500, 500)); |
| 5759 layer->SetContentsOpaque(true); |
| 5760 root->AddChild(layer); |
| 5761 |
| 5762 layer_tree_host()->SetRootLayer(root); |
| 5763 LayerTreeHostTest::SetupTree(); |
| 5764 } |
| 5765 |
| 5766 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 5767 |
| 5768 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 5769 LayerTreeHostImpl::FrameData* frame_data, |
| 5770 DrawResult draw_result) override { |
| 5771 EXPECT_NE(0u, host_impl->resource_provider()->num_resources()); |
| 5772 EndTest(); |
| 5773 return draw_result; |
| 5774 } |
| 5775 void AfterTest() override {} |
| 5776 |
| 5777 FakeContentLayerClient client_; |
| 5778 }; |
| 5779 |
| 5780 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); |
| 5781 |
5740 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 5782 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
5741 : public LayerTreeHostTest { | 5783 : public LayerTreeHostTest { |
5742 protected: | 5784 protected: |
5743 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 5785 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
5744 : playback_allowed_event_(true, true) {} | 5786 : playback_allowed_event_(true, true) {} |
5745 | 5787 |
5746 void InitializeSettings(LayerTreeSettings* settings) override { | 5788 void InitializeSettings(LayerTreeSettings* settings) override { |
5747 settings->impl_side_painting = true; | 5789 settings->impl_side_painting = true; |
5748 } | 5790 } |
5749 | 5791 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5963 } | 6005 } |
5964 | 6006 |
5965 protected: | 6007 protected: |
5966 FakeContentLayerClient client_; | 6008 FakeContentLayerClient client_; |
5967 size_t notify_ready_to_activate_count_; | 6009 size_t notify_ready_to_activate_count_; |
5968 size_t scheduled_prepare_tiles_count_; | 6010 size_t scheduled_prepare_tiles_count_; |
5969 }; | 6011 }; |
5970 | 6012 |
5971 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); | 6013 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
5972 | 6014 |
| 6015 class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { |
| 6016 public: |
| 6017 LayerTreeHostTestActivationCausesPrepareTiles() |
| 6018 : scheduled_prepare_tiles_count_(0) {} |
| 6019 |
| 6020 void SetupTree() override { |
| 6021 client_.set_fill_with_nonsolid_color(true); |
| 6022 scoped_refptr<FakePictureLayer> root_layer = |
| 6023 FakePictureLayer::Create(&client_); |
| 6024 root_layer->SetBounds(gfx::Size(150, 150)); |
| 6025 root_layer->SetIsDrawable(true); |
| 6026 |
| 6027 layer_tree_host()->SetRootLayer(root_layer); |
| 6028 LayerTreeHostTest::SetupTree(); |
| 6029 } |
| 6030 |
| 6031 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 6032 |
| 6033 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { |
| 6034 // Ensure we've already activated. |
| 6035 EXPECT_FALSE(impl->pending_tree()); |
| 6036 |
| 6037 // After activating, we either need to prepare tiles, or we've already |
| 6038 // called a scheduled prepare tiles. This is done because activation might |
| 6039 // cause us to have to memory available (old active tree is gone), so we |
| 6040 // need to ensure we will get a PrepareTiles call. |
| 6041 if (!impl->prepare_tiles_needed()) |
| 6042 EXPECT_GE(scheduled_prepare_tiles_count_, 1); |
| 6043 EndTest(); |
| 6044 } |
| 6045 |
| 6046 void ScheduledActionPrepareTiles() override { |
| 6047 ++scheduled_prepare_tiles_count_; |
| 6048 } |
| 6049 |
| 6050 void AfterTest() override {} |
| 6051 |
| 6052 protected: |
| 6053 FakeContentLayerClient client_; |
| 6054 int scheduled_prepare_tiles_count_; |
| 6055 }; |
| 6056 |
| 6057 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestActivationCausesPrepareTiles); |
| 6058 |
5973 // This tests an assertion that DidCommit and WillCommit happen in the same | 6059 // This tests an assertion that DidCommit and WillCommit happen in the same |
5974 // stack frame with no tasks that run between them. Various embedders of | 6060 // stack frame with no tasks that run between them. Various embedders of |
5975 // cc depend on this logic. ui::Compositor holds a compositor lock between | 6061 // cc depend on this logic. ui::Compositor holds a compositor lock between |
5976 // these events and the inspector timeline wants begin/end CompositeLayers | 6062 // these events and the inspector timeline wants begin/end CompositeLayers |
5977 // to be properly nested with other begin/end events. | 6063 // to be properly nested with other begin/end events. |
5978 class LayerTreeHostTestNoTasksBetweenWillAndDidCommit | 6064 class LayerTreeHostTestNoTasksBetweenWillAndDidCommit |
5979 : public LayerTreeHostTest { | 6065 : public LayerTreeHostTest { |
5980 public: | 6066 public: |
5981 LayerTreeHostTestNoTasksBetweenWillAndDidCommit() : did_commit_(false) {} | 6067 LayerTreeHostTestNoTasksBetweenWillAndDidCommit() : did_commit_(false) {} |
5982 | 6068 |
(...skipping 18 matching lines...) Expand all Loading... |
6001 | 6087 |
6002 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6088 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6003 | 6089 |
6004 private: | 6090 private: |
6005 bool did_commit_; | 6091 bool did_commit_; |
6006 }; | 6092 }; |
6007 | 6093 |
6008 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6094 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6009 | 6095 |
6010 } // namespace cc | 6096 } // namespace cc |
OLD | NEW |