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 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2937 } | 2937 } |
2938 } | 2938 } |
2939 | 2939 |
2940 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { | 2940 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { |
2941 EXPECT_FALSE(did_initialize_gl_); | 2941 EXPECT_FALSE(did_initialize_gl_); |
2942 // SetAndInitializeContext3D calls SetNeedsCommit. | 2942 // SetAndInitializeContext3D calls SetNeedsCommit. |
2943 FakeOutputSurface* fake_output_surface = | 2943 FakeOutputSurface* fake_output_surface = |
2944 static_cast<FakeOutputSurface*>(host_impl->output_surface()); | 2944 static_cast<FakeOutputSurface*>(host_impl->output_surface()); |
2945 scoped_refptr<TestContextProvider> context_provider = | 2945 scoped_refptr<TestContextProvider> context_provider = |
2946 TestContextProvider::Create(); // Not bound to thread. | 2946 TestContextProvider::Create(); // Not bound to thread. |
2947 EXPECT_TRUE( | 2947 scoped_refptr<TestContextProvider> worker_context_provider = |
2948 fake_output_surface->InitializeAndSetContext3d(context_provider)); | 2948 TestContextProvider::Create(); // Not bound to thread. |
| 2949 EXPECT_TRUE(fake_output_surface->InitializeAndSetContext3d( |
| 2950 context_provider, worker_context_provider)); |
2949 did_initialize_gl_ = true; | 2951 did_initialize_gl_ = true; |
2950 } | 2952 } |
2951 | 2953 |
2952 void ReleaseGLAndRedraw(LayerTreeHostImpl* host_impl) { | 2954 void ReleaseGLAndRedraw(LayerTreeHostImpl* host_impl) { |
2953 EXPECT_TRUE(did_initialize_gl_); | 2955 EXPECT_TRUE(did_initialize_gl_); |
2954 EXPECT_FALSE(did_release_gl_); | 2956 EXPECT_FALSE(did_release_gl_); |
2955 // ReleaseGL calls SetNeedsCommit. | 2957 // ReleaseGL calls SetNeedsCommit. |
2956 static_cast<FakeOutputSurface*>(host_impl->output_surface())->ReleaseGL(); | 2958 static_cast<FakeOutputSurface*>(host_impl->output_surface())->ReleaseGL(); |
2957 did_release_gl_ = true; | 2959 did_release_gl_ = true; |
2958 } | 2960 } |
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5816 EndTest(); | 5818 EndTest(); |
5817 return draw_result; | 5819 return draw_result; |
5818 } | 5820 } |
5819 void AfterTest() override {} | 5821 void AfterTest() override {} |
5820 | 5822 |
5821 FakeContentLayerClient client_; | 5823 FakeContentLayerClient client_; |
5822 }; | 5824 }; |
5823 | 5825 |
5824 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); | 5826 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); |
5825 | 5827 |
5826 class GpuRasterizationRasterizesVisibleOnly : public LayerTreeHostTest { | 5828 class SynchronousGpuRasterizationRasterizesVisibleOnly |
| 5829 : public LayerTreeHostTest { |
5827 protected: | 5830 protected: |
5828 GpuRasterizationRasterizesVisibleOnly() : viewport_size_(1024, 2048) {} | 5831 SynchronousGpuRasterizationRasterizesVisibleOnly() |
| 5832 : viewport_size_(1024, 2048) {} |
5829 | 5833 |
5830 void InitializeSettings(LayerTreeSettings* settings) override { | 5834 void InitializeSettings(LayerTreeSettings* settings) override { |
5831 settings->impl_side_painting = true; | 5835 settings->impl_side_painting = true; |
5832 settings->gpu_rasterization_enabled = true; | 5836 settings->gpu_rasterization_enabled = true; |
5833 settings->gpu_rasterization_forced = true; | 5837 settings->gpu_rasterization_forced = true; |
| 5838 settings->threaded_gpu_rasterization_enabled = false; |
5834 } | 5839 } |
5835 | 5840 |
5836 void SetupTree() override { | 5841 void SetupTree() override { |
5837 client_.set_fill_with_nonsolid_color(true); | 5842 client_.set_fill_with_nonsolid_color(true); |
5838 | 5843 |
5839 scoped_ptr<FakePicturePile> pile( | 5844 scoped_ptr<FakePicturePile> pile( |
5840 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, | 5845 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
5841 ImplSidePaintingSettings().default_tile_grid_size)); | 5846 ImplSidePaintingSettings().default_tile_grid_size)); |
5842 scoped_refptr<FakePictureLayer> root = | 5847 scoped_refptr<FakePictureLayer> root = |
5843 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5848 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5875 return draw_result; | 5880 return draw_result; |
5876 } | 5881 } |
5877 | 5882 |
5878 void AfterTest() override {} | 5883 void AfterTest() override {} |
5879 | 5884 |
5880 private: | 5885 private: |
5881 FakeContentLayerClient client_; | 5886 FakeContentLayerClient client_; |
5882 gfx::Size viewport_size_; | 5887 gfx::Size viewport_size_; |
5883 }; | 5888 }; |
5884 | 5889 |
5885 MULTI_THREAD_IMPL_TEST_F(GpuRasterizationRasterizesVisibleOnly); | 5890 MULTI_THREAD_IMPL_TEST_F(SynchronousGpuRasterizationRasterizesVisibleOnly); |
| 5891 |
| 5892 class ThreadedGpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest { |
| 5893 protected: |
| 5894 ThreadedGpuRasterizationRasterizesBorderTiles() |
| 5895 : viewport_size_(1024, 2048) {} |
| 5896 |
| 5897 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5898 settings->impl_side_painting = true; |
| 5899 settings->gpu_rasterization_enabled = true; |
| 5900 settings->gpu_rasterization_forced = true; |
| 5901 settings->threaded_gpu_rasterization_enabled = true; |
| 5902 } |
| 5903 |
| 5904 void SetupTree() override { |
| 5905 client_.set_fill_with_nonsolid_color(true); |
| 5906 |
| 5907 scoped_ptr<FakePicturePile> pile( |
| 5908 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
| 5909 ImplSidePaintingSettings().default_tile_grid_size)); |
| 5910 scoped_refptr<FakePictureLayer> root = |
| 5911 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
| 5912 root->SetBounds(gfx::Size(10000, 10000)); |
| 5913 root->SetContentsOpaque(true); |
| 5914 |
| 5915 layer_tree_host()->SetRootLayer(root); |
| 5916 LayerTreeHostTest::SetupTree(); |
| 5917 layer_tree_host()->SetViewportSize(viewport_size_); |
| 5918 } |
| 5919 |
| 5920 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 5921 |
| 5922 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 5923 LayerTreeHostImpl::FrameData* frame_data, |
| 5924 DrawResult draw_result) override { |
| 5925 EXPECT_EQ(10u, host_impl->resource_provider()->num_resources()); |
| 5926 EndTest(); |
| 5927 return draw_result; |
| 5928 } |
| 5929 |
| 5930 void AfterTest() override {} |
| 5931 |
| 5932 private: |
| 5933 FakeContentLayerClient client_; |
| 5934 gfx::Size viewport_size_; |
| 5935 }; |
| 5936 |
| 5937 MULTI_THREAD_IMPL_TEST_F(ThreadedGpuRasterizationRasterizesBorderTiles); |
5886 | 5938 |
5887 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 5939 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
5888 : public LayerTreeHostTest { | 5940 : public LayerTreeHostTest { |
5889 protected: | 5941 protected: |
5890 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 5942 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
5891 : playback_allowed_event_(true, true) {} | 5943 : playback_allowed_event_(true, true) {} |
5892 | 5944 |
5893 void InitializeSettings(LayerTreeSettings* settings) override { | 5945 void InitializeSettings(LayerTreeSettings* settings) override { |
5894 settings->impl_side_painting = true; | 5946 settings->impl_side_painting = true; |
5895 } | 5947 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6261 | 6313 |
6262 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6314 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6263 | 6315 |
6264 private: | 6316 private: |
6265 bool did_commit_; | 6317 bool did_commit_; |
6266 }; | 6318 }; |
6267 | 6319 |
6268 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6320 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6269 | 6321 |
6270 } // namespace cc | 6322 } // namespace cc |
OLD | NEW |