Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 14925009: Run all LayerTreeHost tests with a delegating renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix context tests Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 default: 949 default:
950 NOTREACHED(); 950 NOTREACHED();
951 break; 951 break;
952 } 952 }
953 } 953 }
954 954
955 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 955 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
956 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 956 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(
957 impl->output_surface()->context3d()); 957 impl->output_surface()->context3d());
958 958
959 // Number of textures used for draw should always be one for each layer. 959 // We draw/ship one texture each frame for each layer.
960 EXPECT_EQ(2u, context->NumUsedTextures()); 960 EXPECT_EQ(2u, context->NumUsedTextures());
961 context->ResetUsedTextures(); 961 context->ResetUsedTextures();
962 } 962 }
963 963
964 virtual void Layout() OVERRIDE { 964 virtual void Layout() OVERRIDE {
965 layer_->SetNeedsDisplay(); 965 layer_->SetNeedsDisplay();
966 scrollbar_->SetNeedsDisplay(); 966 scrollbar_->SetNeedsDisplay();
967 } 967 }
968 968
969 virtual void AfterTest() OVERRIDE {} 969 virtual void AfterTest() OVERRIDE {}
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1176
1177 private: 1177 private:
1178 FakeContentLayerClient client_; 1178 FakeContentLayerClient client_;
1179 scoped_refptr<FakeContentLayer> parent_; 1179 scoped_refptr<FakeContentLayer> parent_;
1180 scoped_refptr<FakeContentLayer> child_; 1180 scoped_refptr<FakeContentLayer> child_;
1181 scoped_refptr<FakeScrollbarLayer> scrollbar_with_paints_; 1181 scoped_refptr<FakeScrollbarLayer> scrollbar_with_paints_;
1182 scoped_refptr<FakeScrollbarLayer> scrollbar_without_paints_; 1182 scoped_refptr<FakeScrollbarLayer> scrollbar_without_paints_;
1183 int num_commits_; 1183 int num_commits_;
1184 }; 1184 };
1185 1185
1186 MULTI_THREAD_TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate); 1186 // Partial updates are not possible with a delegating renderer.
1187 MULTI_THREAD_TEST_DIRECT_RENDERER_F(
1188 LayerTreeHostTestAtomicCommitWithPartialUpdate);
1187 1189
1188 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { 1190 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
1189 public: 1191 public:
1190 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {} 1192 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {}
1191 1193
1192 virtual void BeginTest() OVERRIDE { 1194 virtual void BeginTest() OVERRIDE {
1193 layer_tree_host()->SetNeedsRedraw(); 1195 layer_tree_host()->SetNeedsRedraw();
1194 PostSetNeedsCommitToMainThread(); 1196 PostSetNeedsCommitToMainThread();
1195 } 1197 }
1196 1198
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 1331
1330 private: 1332 private:
1331 FakeContentLayerClient client_; 1333 FakeContentLayerClient client_;
1332 scoped_refptr<FakeContentLayer> root_layer_; 1334 scoped_refptr<FakeContentLayer> root_layer_;
1333 scoped_refptr<FakeContentLayer> surface_layer1_; 1335 scoped_refptr<FakeContentLayer> surface_layer1_;
1334 scoped_refptr<FakeContentLayer> replica_layer1_; 1336 scoped_refptr<FakeContentLayer> replica_layer1_;
1335 scoped_refptr<FakeContentLayer> surface_layer2_; 1337 scoped_refptr<FakeContentLayer> surface_layer2_;
1336 scoped_refptr<FakeContentLayer> replica_layer2_; 1338 scoped_refptr<FakeContentLayer> replica_layer2_;
1337 }; 1339 };
1338 1340
1339 SINGLE_AND_MULTI_THREAD_TEST_F( 1341 // Surfaces don't exist with a delegated renderer.
1342 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1340 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit); 1343 LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit);
1341 1344
1342 class EvictionTestLayer : public Layer { 1345 class EvictionTestLayer : public Layer {
1343 public: 1346 public:
1344 static scoped_refptr<EvictionTestLayer> Create() { 1347 static scoped_refptr<EvictionTestLayer> Create() {
1345 return make_scoped_refptr(new EvictionTestLayer()); 1348 return make_scoped_refptr(new EvictionTestLayer());
1346 } 1349 }
1347 1350
1348 virtual void Update(ResourceUpdateQueue*, 1351 virtual void Update(ResourceUpdateQueue*,
1349 const OcclusionTracker*, 1352 const OcclusionTracker*,
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 scoped_refptr<PictureLayer> layer_; 1882 scoped_refptr<PictureLayer> layer_;
1880 skia::RefPtr<SkPicture> picture_; 1883 skia::RefPtr<SkPicture> picture_;
1881 }; 1884 };
1882 1885
1883 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture); 1886 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture);
1884 1887
1885 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest { 1888 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest {
1886 public: 1889 public:
1887 LayerTreeHostTestMaxPendingFrames() : LayerTreeHostTest() {} 1890 LayerTreeHostTestMaxPendingFrames() : LayerTreeHostTest() {}
1888 1891
1889 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
1890 if (delegating_renderer_)
1891 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
1892 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
1893 }
1894
1895 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1892 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
1896 1893
1897 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1894 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1898 DCHECK(host_impl->proxy()->HasImplThread()); 1895 DCHECK(host_impl->proxy()->HasImplThread());
1899 1896
1900 const ThreadProxy* proxy = static_cast<ThreadProxy*>(host_impl->proxy()); 1897 const ThreadProxy* proxy = static_cast<ThreadProxy*>(host_impl->proxy());
1901 if (delegating_renderer_) { 1898 if (delegating_renderer()) {
1902 EXPECT_EQ(1, proxy->MaxFramesPendingForTesting()); 1899 EXPECT_EQ(1, proxy->MaxFramesPendingForTesting());
1903 } else { 1900 } else {
1904 EXPECT_EQ(FrameRateController::DEFAULT_MAX_FRAMES_PENDING, 1901 EXPECT_EQ(FrameRateController::DEFAULT_MAX_FRAMES_PENDING,
1905 proxy->MaxFramesPendingForTesting()); 1902 proxy->MaxFramesPendingForTesting());
1906 } 1903 }
1907 EndTest(); 1904 EndTest();
1908 } 1905 }
1909 1906
1910 virtual void AfterTest() OVERRIDE {} 1907 virtual void AfterTest() OVERRIDE {}
1911
1912 protected:
1913 bool delegating_renderer_;
1914 }; 1908 };
1915 1909
1916 TEST_F(LayerTreeHostTestMaxPendingFrames, DelegatingRenderer) { 1910 TEST_F(LayerTreeHostTestMaxPendingFrames, DelegatingRenderer) {
1917 delegating_renderer_ = true; 1911 RunTest(true, true);
1918 RunTest(true);
1919 } 1912 }
1920 1913
1921 TEST_F(LayerTreeHostTestMaxPendingFrames, GLRenderer) { 1914 TEST_F(LayerTreeHostTestMaxPendingFrames, GLRenderer) {
1922 delegating_renderer_ = false; 1915 RunTest(true, false);
1923 RunTest(true);
1924 } 1916 }
1925 1917
1926 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted 1918 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
1927 : public LayerTreeHostTest { 1919 : public LayerTreeHostTest {
1928 public: 1920 public:
1929 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() 1921 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted()
1930 : root_layer_(FakeContentLayer::Create(&client_)), 1922 : root_layer_(FakeContentLayer::Create(&client_)),
1931 child_layer1_(FakeContentLayer::Create(&client_)), 1923 child_layer1_(FakeContentLayer::Create(&client_)),
1932 child_layer2_(FakeContentLayer::Create(&client_)), 1924 child_layer2_(FakeContentLayer::Create(&client_)),
1933 num_commits_(0) {} 1925 num_commits_(0) {}
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>(); 2646 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>();
2655 } 2647 }
2656 2648
2657 bool use_gl_renderer_; 2649 bool use_gl_renderer_;
2658 std::vector<gfx::Size> callbacks_; 2650 std::vector<gfx::Size> callbacks_;
2659 FakeContentLayerClient client_; 2651 FakeContentLayerClient client_;
2660 scoped_refptr<FakeContentLayer> root; 2652 scoped_refptr<FakeContentLayer> root;
2661 scoped_refptr<FakeContentLayer> child; 2653 scoped_refptr<FakeContentLayer> child;
2662 }; 2654 };
2663 2655
2656 // Readback can't be done with a delegating renderer.
2664 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunSingleThread) { 2657 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunSingleThread) {
2665 use_gl_renderer_ = true; 2658 use_gl_renderer_ = true;
2666 RunTest(false); 2659 RunTest(false, false);
2667 } 2660 }
2668 2661
2669 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunMultiThread) { 2662 TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunMultiThread) {
2670 use_gl_renderer_ = true; 2663 use_gl_renderer_ = true;
2671 RunTest(true); 2664 RunTest(true, false);
2672 } 2665 }
2673 2666
2674 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunSingleThread) { 2667 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunSingleThread) {
2675 use_gl_renderer_ = false; 2668 use_gl_renderer_ = false;
2676 RunTest(false); 2669 RunTest(false, false);
2677 } 2670 }
2678 2671
2679 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunMultiThread) { 2672 TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunMultiThread) {
2680 use_gl_renderer_ = false; 2673 use_gl_renderer_ = false;
2681 RunTest(true); 2674 RunTest(true, false);
2682 } 2675 }
2683 2676
2684 class LayerTreeHostTestAsyncReadbackLayerDestroyed : public LayerTreeHostTest { 2677 class LayerTreeHostTestAsyncReadbackLayerDestroyed : public LayerTreeHostTest {
2685 protected: 2678 protected:
2686 virtual void SetupTree() OVERRIDE { 2679 virtual void SetupTree() OVERRIDE {
2687 root_ = FakeContentLayer::Create(&client_); 2680 root_ = FakeContentLayer::Create(&client_);
2688 root_->SetBounds(gfx::Size(20, 20)); 2681 root_->SetBounds(gfx::Size(20, 20));
2689 2682
2690 main_destroyed_ = FakeContentLayer::Create(&client_); 2683 main_destroyed_ = FakeContentLayer::Create(&client_);
2691 main_destroyed_->SetBounds(gfx::Size(15, 15)); 2684 main_destroyed_->SetBounds(gfx::Size(15, 15));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 FakeContentLayerClient client_; 2758 FakeContentLayerClient client_;
2766 scoped_refptr<FakeContentLayer> root_; 2759 scoped_refptr<FakeContentLayer> root_;
2767 scoped_refptr<FakeContentLayer> main_destroyed_; 2760 scoped_refptr<FakeContentLayer> main_destroyed_;
2768 scoped_refptr<FakeContentLayer> impl_destroyed_; 2761 scoped_refptr<FakeContentLayer> impl_destroyed_;
2769 }; 2762 };
2770 2763
2771 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed); 2764 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed);
2772 2765
2773 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { 2766 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
2774 public: 2767 public:
2775 LayerTreeHostTestNumFramesPending() 2768 virtual void BeginTest() OVERRIDE {
2776 : delegating_renderer_(false), 2769 frame_ = 0;
2777 frame_(0) {} 2770 PostSetNeedsCommitToMainThread();
2778
2779 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
2780 if (delegating_renderer_)
2781 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
2782 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
2783 } 2771 }
2784 2772
2785 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2786
2787 // Round 1: commit + draw 2773 // Round 1: commit + draw
2788 // Round 2: commit only (no draw/swap) 2774 // Round 2: commit only (no draw/swap)
2789 // Round 3: draw only (no commit) 2775 // Round 3: draw only (no commit)
2790 // Round 4: composite & readback (2 commits, no draw/swap) 2776 // Round 4: composite & readback (2 commits, no draw/swap)
2791 // Round 5: commit + draw 2777 // Round 5: commit + draw
2792 2778
2793 virtual void DidCommit() OVERRIDE { 2779 virtual void DidCommit() OVERRIDE {
2794 int commit = layer_tree_host()->commit_number(); 2780 int commit = layer_tree_host()->commit_number();
2795 switch (commit) { 2781 switch (commit) {
2796 case 2: 2782 case 2:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 } 2821 }
2836 2822
2837 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 2823 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
2838 const ThreadProxy* proxy = static_cast<ThreadProxy*>(impl->proxy()); 2824 const ThreadProxy* proxy = static_cast<ThreadProxy*>(impl->proxy());
2839 EXPECT_EQ(0, proxy->NumFramesPendingForTesting()); 2825 EXPECT_EQ(0, proxy->NumFramesPendingForTesting());
2840 } 2826 }
2841 2827
2842 virtual void AfterTest() OVERRIDE {} 2828 virtual void AfterTest() OVERRIDE {}
2843 2829
2844 protected: 2830 protected:
2845 bool delegating_renderer_;
2846 int frame_; 2831 int frame_;
2847 }; 2832 };
2848 2833
2849 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 2834 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2850 delegating_renderer_ = true; 2835 RunTest(true, true);
2851 RunTest(true);
2852 } 2836 }
2853 2837
2854 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 2838 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2855 delegating_renderer_ = false; 2839 RunTest(true, false);
2856 RunTest(true);
2857 } 2840 }
2858 2841
2859 } // namespace 2842 } // namespace
2860 } // namespace cc 2843 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698