| 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/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 default: | 971 default: |
| 972 NOTREACHED(); | 972 NOTREACHED(); |
| 973 break; | 973 break; |
| 974 } | 974 } |
| 975 } | 975 } |
| 976 | 976 |
| 977 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 977 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 978 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( | 978 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( |
| 979 impl->output_surface()->context3d()); | 979 impl->output_surface()->context3d()); |
| 980 | 980 |
| 981 // Number of textures used for draw should always be one for each layer. | 981 // We draw/ship one texture each frame for each layer. |
| 982 EXPECT_EQ(2u, context->NumUsedTextures()); | 982 EXPECT_EQ(2u, context->NumUsedTextures()); |
| 983 context->ResetUsedTextures(); | 983 context->ResetUsedTextures(); |
| 984 } | 984 } |
| 985 | 985 |
| 986 virtual void Layout() OVERRIDE { | 986 virtual void Layout() OVERRIDE { |
| 987 layer_->SetNeedsDisplay(); | 987 layer_->SetNeedsDisplay(); |
| 988 scrollbar_->SetNeedsDisplay(); | 988 scrollbar_->SetNeedsDisplay(); |
| 989 } | 989 } |
| 990 | 990 |
| 991 virtual void AfterTest() OVERRIDE {} | 991 virtual void AfterTest() OVERRIDE {} |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 | 1198 |
| 1199 private: | 1199 private: |
| 1200 FakeContentLayerClient client_; | 1200 FakeContentLayerClient client_; |
| 1201 scoped_refptr<FakeContentLayer> parent_; | 1201 scoped_refptr<FakeContentLayer> parent_; |
| 1202 scoped_refptr<FakeContentLayer> child_; | 1202 scoped_refptr<FakeContentLayer> child_; |
| 1203 scoped_refptr<FakeScrollbarLayer> scrollbar_with_paints_; | 1203 scoped_refptr<FakeScrollbarLayer> scrollbar_with_paints_; |
| 1204 scoped_refptr<FakeScrollbarLayer> scrollbar_without_paints_; | 1204 scoped_refptr<FakeScrollbarLayer> scrollbar_without_paints_; |
| 1205 int num_commits_; | 1205 int num_commits_; |
| 1206 }; | 1206 }; |
| 1207 | 1207 |
| 1208 MULTI_THREAD_TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate); | 1208 // Partial updates are not possible with a delegating renderer. |
| 1209 MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1210 LayerTreeHostTestAtomicCommitWithPartialUpdate); |
| 1209 | 1211 |
| 1210 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { | 1212 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { |
| 1211 public: | 1213 public: |
| 1212 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {} | 1214 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {} |
| 1213 | 1215 |
| 1214 virtual void BeginTest() OVERRIDE { | 1216 virtual void BeginTest() OVERRIDE { |
| 1215 layer_tree_host()->SetNeedsRedraw(); | 1217 layer_tree_host()->SetNeedsRedraw(); |
| 1216 PostSetNeedsCommitToMainThread(); | 1218 PostSetNeedsCommitToMainThread(); |
| 1217 } | 1219 } |
| 1218 | 1220 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 | 1353 |
| 1352 private: | 1354 private: |
| 1353 FakeContentLayerClient client_; | 1355 FakeContentLayerClient client_; |
| 1354 scoped_refptr<FakeContentLayer> root_layer_; | 1356 scoped_refptr<FakeContentLayer> root_layer_; |
| 1355 scoped_refptr<FakeContentLayer> surface_layer1_; | 1357 scoped_refptr<FakeContentLayer> surface_layer1_; |
| 1356 scoped_refptr<FakeContentLayer> replica_layer1_; | 1358 scoped_refptr<FakeContentLayer> replica_layer1_; |
| 1357 scoped_refptr<FakeContentLayer> surface_layer2_; | 1359 scoped_refptr<FakeContentLayer> surface_layer2_; |
| 1358 scoped_refptr<FakeContentLayer> replica_layer2_; | 1360 scoped_refptr<FakeContentLayer> replica_layer2_; |
| 1359 }; | 1361 }; |
| 1360 | 1362 |
| 1361 SINGLE_AND_MULTI_THREAD_TEST_F( | 1363 // Surfaces don't exist with a delegated renderer. |
| 1364 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1362 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit); | 1365 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit); |
| 1363 | 1366 |
| 1364 class EvictionTestLayer : public Layer { | 1367 class EvictionTestLayer : public Layer { |
| 1365 public: | 1368 public: |
| 1366 static scoped_refptr<EvictionTestLayer> Create() { | 1369 static scoped_refptr<EvictionTestLayer> Create() { |
| 1367 return make_scoped_refptr(new EvictionTestLayer()); | 1370 return make_scoped_refptr(new EvictionTestLayer()); |
| 1368 } | 1371 } |
| 1369 | 1372 |
| 1370 virtual void Update(ResourceUpdateQueue*, | 1373 virtual void Update(ResourceUpdateQueue*, |
| 1371 const OcclusionTracker*, | 1374 const OcclusionTracker*, |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 scoped_refptr<PictureLayer> layer_; | 1904 scoped_refptr<PictureLayer> layer_; |
| 1902 skia::RefPtr<SkPicture> picture_; | 1905 skia::RefPtr<SkPicture> picture_; |
| 1903 }; | 1906 }; |
| 1904 | 1907 |
| 1905 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture); | 1908 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture); |
| 1906 | 1909 |
| 1907 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest { | 1910 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest { |
| 1908 public: | 1911 public: |
| 1909 LayerTreeHostTestMaxPendingFrames() : LayerTreeHostTest() {} | 1912 LayerTreeHostTestMaxPendingFrames() : LayerTreeHostTest() {} |
| 1910 | 1913 |
| 1911 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | |
| 1912 if (delegating_renderer_) | |
| 1913 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); | |
| 1914 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); | |
| 1915 } | |
| 1916 | |
| 1917 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1914 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 1918 | 1915 |
| 1919 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 1916 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 1920 DCHECK(host_impl->proxy()->HasImplThread()); | 1917 DCHECK(host_impl->proxy()->HasImplThread()); |
| 1921 | 1918 |
| 1922 const ThreadProxy* proxy = static_cast<ThreadProxy*>(host_impl->proxy()); | 1919 const ThreadProxy* proxy = static_cast<ThreadProxy*>(host_impl->proxy()); |
| 1923 if (delegating_renderer_) { | 1920 if (delegating_renderer()) { |
| 1924 EXPECT_EQ(1, proxy->MaxFramesPendingForTesting()); | 1921 EXPECT_EQ(1, proxy->MaxFramesPendingForTesting()); |
| 1925 } else { | 1922 } else { |
| 1926 EXPECT_EQ(FrameRateController::DEFAULT_MAX_FRAMES_PENDING, | 1923 EXPECT_EQ(FrameRateController::DEFAULT_MAX_FRAMES_PENDING, |
| 1927 proxy->MaxFramesPendingForTesting()); | 1924 proxy->MaxFramesPendingForTesting()); |
| 1928 } | 1925 } |
| 1929 EndTest(); | 1926 EndTest(); |
| 1930 } | 1927 } |
| 1931 | 1928 |
| 1932 virtual void AfterTest() OVERRIDE {} | 1929 virtual void AfterTest() OVERRIDE {} |
| 1933 | |
| 1934 protected: | |
| 1935 bool delegating_renderer_; | |
| 1936 }; | 1930 }; |
| 1937 | 1931 |
| 1938 TEST_F(LayerTreeHostTestMaxPendingFrames, DelegatingRenderer) { | 1932 TEST_F(LayerTreeHostTestMaxPendingFrames, DelegatingRenderer) { |
| 1939 delegating_renderer_ = true; | 1933 RunTest(true, true); |
| 1940 RunTest(true); | |
| 1941 } | 1934 } |
| 1942 | 1935 |
| 1943 TEST_F(LayerTreeHostTestMaxPendingFrames, GLRenderer) { | 1936 TEST_F(LayerTreeHostTestMaxPendingFrames, GLRenderer) { |
| 1944 delegating_renderer_ = false; | 1937 RunTest(true, false); |
| 1945 RunTest(true); | |
| 1946 } | 1938 } |
| 1947 | 1939 |
| 1948 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 1940 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
| 1949 : public LayerTreeHostTest { | 1941 : public LayerTreeHostTest { |
| 1950 public: | 1942 public: |
| 1951 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 1943 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
| 1952 : root_layer_(FakeContentLayer::Create(&client_)), | 1944 : root_layer_(FakeContentLayer::Create(&client_)), |
| 1953 child_layer1_(FakeContentLayer::Create(&client_)), | 1945 child_layer1_(FakeContentLayer::Create(&client_)), |
| 1954 child_layer2_(FakeContentLayer::Create(&client_)), | 1946 child_layer2_(FakeContentLayer::Create(&client_)), |
| 1955 num_commits_(0) {} | 1947 num_commits_(0) {} |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 EndTest(); | 2568 EndTest(); |
| 2577 } | 2569 } |
| 2578 | 2570 |
| 2579 virtual void AfterTest() OVERRIDE {} | 2571 virtual void AfterTest() OVERRIDE {} |
| 2580 | 2572 |
| 2581 int io_surface_id_; | 2573 int io_surface_id_; |
| 2582 MockIOSurfaceWebGraphicsContext3D* mock_context_; | 2574 MockIOSurfaceWebGraphicsContext3D* mock_context_; |
| 2583 gfx::Size io_surface_size_; | 2575 gfx::Size io_surface_size_; |
| 2584 }; | 2576 }; |
| 2585 | 2577 |
| 2586 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestIOSurfaceDrawing); | 2578 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 |
| 2579 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 2580 LayerTreeHostTestIOSurfaceDrawing); |
| 2587 | 2581 |
| 2588 class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest { | 2582 class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest { |
| 2589 protected: | 2583 protected: |
| 2590 virtual void SetupTree() OVERRIDE { | 2584 virtual void SetupTree() OVERRIDE { |
| 2591 root = FakeContentLayer::Create(&client_); | 2585 root = FakeContentLayer::Create(&client_); |
| 2592 root->SetBounds(gfx::Size(20, 20)); | 2586 root->SetBounds(gfx::Size(20, 20)); |
| 2593 | 2587 |
| 2594 child = FakeContentLayer::Create(&client_); | 2588 child = FakeContentLayer::Create(&client_); |
| 2595 child->SetBounds(gfx::Size(10, 10)); | 2589 child->SetBounds(gfx::Size(10, 10)); |
| 2596 root->AddChild(child); | 2590 root->AddChild(child); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); | 2670 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); |
| 2677 } | 2671 } |
| 2678 | 2672 |
| 2679 bool use_gl_renderer_; | 2673 bool use_gl_renderer_; |
| 2680 std::vector<gfx::Size> callbacks_; | 2674 std::vector<gfx::Size> callbacks_; |
| 2681 FakeContentLayerClient client_; | 2675 FakeContentLayerClient client_; |
| 2682 scoped_refptr<FakeContentLayer> root; | 2676 scoped_refptr<FakeContentLayer> root; |
| 2683 scoped_refptr<FakeContentLayer> child; | 2677 scoped_refptr<FakeContentLayer> child; |
| 2684 }; | 2678 }; |
| 2685 | 2679 |
| 2680 // Readback can't be done with a delegating renderer. |
| 2686 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunSingleThread) { | 2681 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunSingleThread) { |
| 2687 use_gl_renderer_ = true; | 2682 use_gl_renderer_ = true; |
| 2688 RunTest(false); | 2683 RunTest(false, false); |
| 2689 } | 2684 } |
| 2690 | 2685 |
| 2691 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunMultiThread) { | 2686 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunMultiThread) { |
| 2692 use_gl_renderer_ = true; | 2687 use_gl_renderer_ = true; |
| 2693 RunTest(true); | 2688 RunTest(true, false); |
| 2694 } | 2689 } |
| 2695 | 2690 |
| 2696 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunSingleThread) { | 2691 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunSingleThread) { |
| 2697 use_gl_renderer_ = false; | 2692 use_gl_renderer_ = false; |
| 2698 RunTest(false); | 2693 RunTest(false, false); |
| 2699 } | 2694 } |
| 2700 | 2695 |
| 2701 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunMultiThread) { | 2696 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunMultiThread) { |
| 2702 use_gl_renderer_ = false; | 2697 use_gl_renderer_ = false; |
| 2703 RunTest(true); | 2698 RunTest(true, false); |
| 2704 } | 2699 } |
| 2705 | 2700 |
| 2706 class LayerTreeHostTestAsyncReadbackLayerDestroyed : public LayerTreeHostTest { | 2701 class LayerTreeHostTestAsyncReadbackLayerDestroyed : public LayerTreeHostTest { |
| 2707 protected: | 2702 protected: |
| 2708 virtual void SetupTree() OVERRIDE { | 2703 virtual void SetupTree() OVERRIDE { |
| 2709 root_ = FakeContentLayer::Create(&client_); | 2704 root_ = FakeContentLayer::Create(&client_); |
| 2710 root_->SetBounds(gfx::Size(20, 20)); | 2705 root_->SetBounds(gfx::Size(20, 20)); |
| 2711 | 2706 |
| 2712 main_destroyed_ = FakeContentLayer::Create(&client_); | 2707 main_destroyed_ = FakeContentLayer::Create(&client_); |
| 2713 main_destroyed_->SetBounds(gfx::Size(15, 15)); | 2708 main_destroyed_->SetBounds(gfx::Size(15, 15)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 FakeContentLayerClient client_; | 2782 FakeContentLayerClient client_; |
| 2788 scoped_refptr<FakeContentLayer> root_; | 2783 scoped_refptr<FakeContentLayer> root_; |
| 2789 scoped_refptr<FakeContentLayer> main_destroyed_; | 2784 scoped_refptr<FakeContentLayer> main_destroyed_; |
| 2790 scoped_refptr<FakeContentLayer> impl_destroyed_; | 2785 scoped_refptr<FakeContentLayer> impl_destroyed_; |
| 2791 }; | 2786 }; |
| 2792 | 2787 |
| 2793 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); | 2788 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); |
| 2794 | 2789 |
| 2795 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { | 2790 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { |
| 2796 public: | 2791 public: |
| 2797 LayerTreeHostTestNumFramesPending() | 2792 virtual void BeginTest() OVERRIDE { |
| 2798 : delegating_renderer_(false), | 2793 frame_ = 0; |
| 2799 frame_(0) {} | 2794 PostSetNeedsCommitToMainThread(); |
| 2800 | |
| 2801 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | |
| 2802 if (delegating_renderer_) | |
| 2803 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); | |
| 2804 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); | |
| 2805 } | 2795 } |
| 2806 | 2796 |
| 2807 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 2808 | |
| 2809 // Round 1: commit + draw | 2797 // Round 1: commit + draw |
| 2810 // Round 2: commit only (no draw/swap) | 2798 // Round 2: commit only (no draw/swap) |
| 2811 // Round 3: draw only (no commit) | 2799 // Round 3: draw only (no commit) |
| 2812 // Round 4: composite & readback (2 commits, no draw/swap) | 2800 // Round 4: composite & readback (2 commits, no draw/swap) |
| 2813 // Round 5: commit + draw | 2801 // Round 5: commit + draw |
| 2814 | 2802 |
| 2815 virtual void DidCommit() OVERRIDE { | 2803 virtual void DidCommit() OVERRIDE { |
| 2816 int commit = layer_tree_host()->commit_number(); | 2804 int commit = layer_tree_host()->commit_number(); |
| 2817 switch (commit) { | 2805 switch (commit) { |
| 2818 case 2: | 2806 case 2: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2857 } | 2845 } |
| 2858 | 2846 |
| 2859 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 2847 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 2860 const ThreadProxy* proxy = static_cast<ThreadProxy*>(impl->proxy()); | 2848 const ThreadProxy* proxy = static_cast<ThreadProxy*>(impl->proxy()); |
| 2861 EXPECT_EQ(0, proxy->NumFramesPendingForTesting()); | 2849 EXPECT_EQ(0, proxy->NumFramesPendingForTesting()); |
| 2862 } | 2850 } |
| 2863 | 2851 |
| 2864 virtual void AfterTest() OVERRIDE {} | 2852 virtual void AfterTest() OVERRIDE {} |
| 2865 | 2853 |
| 2866 protected: | 2854 protected: |
| 2867 bool delegating_renderer_; | |
| 2868 int frame_; | 2855 int frame_; |
| 2869 }; | 2856 }; |
| 2870 | 2857 |
| 2871 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { | 2858 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { |
| 2872 delegating_renderer_ = true; | 2859 RunTest(true, true); |
| 2873 RunTest(true); | |
| 2874 } | 2860 } |
| 2875 | 2861 |
| 2876 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { | 2862 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { |
| 2877 delegating_renderer_ = false; | 2863 RunTest(true, false); |
| 2878 RunTest(true); | |
| 2879 } | 2864 } |
| 2880 | 2865 |
| 2881 } // namespace | 2866 } // namespace |
| 2882 } // namespace cc | 2867 } // namespace cc |
| OLD | NEW |