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

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

Issue 17351017: Re-land: cc: Add raster finished signals to RasterWorkerPool. (Closed) Base URL: http://git.chromium.org/chromium/src.git@new-graph-build
Patch Set: fix flaky unit tests Created 7 years, 5 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); 743 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
744 EndTest(); 744 EndTest();
745 return; 745 return;
746 } 746 }
747 747
748 EXPECT_FALSE(impl->settings().impl_side_painting); 748 EXPECT_FALSE(impl->settings().impl_side_painting);
749 EndTest(); 749 EndTest();
750 } 750 }
751 751
752 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { 752 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
753 if (frame_ >= 1)
754 return true;
755
756 return false;
757 }
758
759 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl)
760 OVERRIDE {
753 frame_++; 761 frame_++;
754 if (frame_ == 1) { 762 if (frame_ == 1) {
755 first_frame_time_ = impl->CurrentFrameTimeTicks(); 763 first_frame_time_ = impl->CurrentFrameTimeTicks();
756 764
757 // Since base::TimeTicks::Now() uses a low-resolution clock on 765 // Since base::TimeTicks::Now() uses a low-resolution clock on
758 // Windows, we need to make sure that the clock has incremented past 766 // Windows, we need to make sure that the clock has incremented past
759 // first_frame_time_. 767 // first_frame_time_.
760 while (first_frame_time_ == base::TimeTicks::Now()) {} 768 while (first_frame_time_ == base::TimeTicks::Now()) {}
761 769
762 return false; 770 return false;
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 } 2899 }
2892 2900
2893 virtual void SetupTree() OVERRIDE { 2901 virtual void SetupTree() OVERRIDE {
2894 layer_ = FakePictureLayer::Create(&client_); 2902 layer_ = FakePictureLayer::Create(&client_);
2895 layer_tree_host()->SetRootLayer(layer_); 2903 layer_tree_host()->SetRootLayer(layer_);
2896 LayerTreeHostTest::SetupTree(); 2904 LayerTreeHostTest::SetupTree();
2897 } 2905 }
2898 2906
2899 virtual void BeginTest() OVERRIDE { 2907 virtual void BeginTest() OVERRIDE {
2900 initialized_gl_ = false; 2908 initialized_gl_ = false;
2909 num_draws_ = 0;
2901 PostSetNeedsCommitToMainThread(); 2910 PostSetNeedsCommitToMainThread();
2902 } 2911 }
2903 2912
2904 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { 2913 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
2905 scoped_ptr<TestWebGraphicsContext3D> context3d( 2914 scoped_ptr<TestWebGraphicsContext3D> context3d(
2906 TestWebGraphicsContext3D::Create()); 2915 TestWebGraphicsContext3D::Create());
2907 context3d->set_support_swapbuffers_complete_callback(false); 2916 context3d->set_support_swapbuffers_complete_callback(false);
2908 2917
2909 return FakeOutputSurface::CreateDeferredGL( 2918 return FakeOutputSurface::CreateDeferredGL(
2910 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) 2919 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))
2911 .PassAs<OutputSurface>(); 2920 .PassAs<OutputSurface>();
2912 } 2921 }
2913 2922
2914 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2923 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2915 ASSERT_TRUE(host_impl->RootLayer()); 2924 ASSERT_TRUE(host_impl->RootLayer());
2916 FakePictureLayerImpl* layer_impl = 2925 FakePictureLayerImpl* layer_impl =
2917 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); 2926 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer());
2918 if (!initialized_gl_) { 2927 if (!initialized_gl_) {
2919 EXPECT_EQ(1u, layer_impl->append_quads_count()); 2928 EXPECT_EQ(1u, layer_impl->append_quads_count());
2920 ImplThreadTaskRunner()->PostTask(FROM_HERE, base::Bind( 2929 ImplThreadTaskRunner()->PostTask(FROM_HERE, base::Bind(
2921 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw, 2930 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw,
2922 base::Unretained(this), 2931 base::Unretained(this),
2923 base::Unretained(host_impl))); 2932 base::Unretained(host_impl)));
2924 } else { 2933 } else {
2925 EXPECT_EQ(2u, layer_impl->append_quads_count()); 2934 if (!num_draws_) {
2926 EndTest(); 2935 EXPECT_EQ(2u, layer_impl->append_quads_count());
2936 EndTest();
2937 }
2938 num_draws_++;
2927 } 2939 }
2928 } 2940 }
2929 2941
2930 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { 2942 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) {
2931 EXPECT_TRUE(static_cast<FakeOutputSurface*>(host_impl->output_surface()) 2943 EXPECT_TRUE(static_cast<FakeOutputSurface*>(host_impl->output_surface())
2932 ->SetAndInitializeContext3D( 2944 ->SetAndInitializeContext3D(
2933 scoped_ptr<WebKit::WebGraphicsContext3D>( 2945 scoped_ptr<WebKit::WebGraphicsContext3D>(
2934 TestWebGraphicsContext3D::Create()))); 2946 TestWebGraphicsContext3D::Create())));
2935 initialized_gl_ = true; 2947 initialized_gl_ = true;
2936 2948
2937 // Force redraw again. 2949 // Force redraw again.
2938 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1)); 2950 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1));
2939 2951
2940 // If we didn't swap this begin frame, we need to request another one. 2952 // If we didn't swap this begin frame, we need to request another one.
2941 host_impl->SetNeedsBeginFrame(true); 2953 host_impl->SetNeedsBeginFrame(true);
2942 } 2954 }
2943 2955
2944 virtual void AfterTest() OVERRIDE { 2956 virtual void AfterTest() OVERRIDE {
2945 EXPECT_TRUE(initialized_gl_); 2957 EXPECT_TRUE(initialized_gl_);
2946 } 2958 }
2947 2959
2948 private: 2960 private:
2949 FakeContentLayerClient client_; 2961 FakeContentLayerClient client_;
2950 scoped_refptr<FakePictureLayer> layer_; 2962 scoped_refptr<FakePictureLayer> layer_;
2951 bool initialized_gl_; 2963 bool initialized_gl_;
2964 int num_draws_;
2952 }; 2965 };
2953 2966
2954 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); 2967 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2955 2968
2956 } // namespace 2969 } // namespace
2957 } // namespace cc 2970 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698