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

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

Issue 17204002: Revert 206020 "cc: Emulate BeginFrame in OutputSurfaces that don..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 2042
2043 private: 2043 private:
2044 gfx::Size bounds_; 2044 gfx::Size bounds_;
2045 FillRectContentLayerClient content_client_; 2045 FillRectContentLayerClient content_client_;
2046 scoped_refptr<PictureLayer> layer_; 2046 scoped_refptr<PictureLayer> layer_;
2047 skia::RefPtr<SkPicture> picture_; 2047 skia::RefPtr<SkPicture> picture_;
2048 }; 2048 };
2049 2049
2050 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture); 2050 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicture);
2051 2051
2052 class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest {
2053 public:
2054 LayerTreeHostTestMaxPendingFrames() : LayerTreeHostTest() {}
2055
2056 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2057
2058 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2059 DCHECK(host_impl->proxy()->HasImplThread());
2060
2061 const ThreadProxy* proxy = static_cast<ThreadProxy*>(host_impl->proxy());
2062 if (delegating_renderer()) {
2063 EXPECT_EQ(1, proxy->MaxFramesPendingForTesting());
2064 } else {
2065 EXPECT_EQ(FrameRateController::DEFAULT_MAX_FRAMES_PENDING,
2066 proxy->MaxFramesPendingForTesting());
2067 }
2068 EndTest();
2069 }
2070
2071 virtual void AfterTest() OVERRIDE {}
2072 };
2073
2074 TEST_F(LayerTreeHostTestMaxPendingFrames, DelegatingRenderer) {
2075 RunTest(true, true, true);
2076 }
2077
2078 TEST_F(LayerTreeHostTestMaxPendingFrames, GLRenderer) {
2079 RunTest(true, false, true);
2080 }
2081
2052 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted 2082 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
2053 : public LayerTreeHostTest { 2083 : public LayerTreeHostTest {
2054 public: 2084 public:
2055 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() 2085 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted()
2056 : root_layer_(FakeContentLayer::Create(&client_)), 2086 : root_layer_(FakeContentLayer::Create(&client_)),
2057 child_layer1_(FakeContentLayer::Create(&client_)), 2087 child_layer1_(FakeContentLayer::Create(&client_)),
2058 child_layer2_(FakeContentLayer::Create(&client_)), 2088 child_layer2_(FakeContentLayer::Create(&client_)),
2059 num_commits_(0) {} 2089 num_commits_(0) {}
2060 2090
2061 virtual void BeginTest() OVERRIDE { 2091 virtual void BeginTest() OVERRIDE {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); 2246 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
2217 2247
2218 // Verify that the BeginFrame notification is used to initiate rendering. 2248 // Verify that the BeginFrame notification is used to initiate rendering.
2219 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { 2249 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
2220 public: 2250 public:
2221 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2251 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2222 settings->begin_frame_scheduling_enabled = true; 2252 settings->begin_frame_scheduling_enabled = true;
2223 } 2253 }
2224 2254
2225 virtual void BeginTest() OVERRIDE { 2255 virtual void BeginTest() OVERRIDE {
2226 // This will trigger a SetNeedsBeginFrame which will trigger a BeginFrame.
2227 PostSetNeedsCommitToMainThread(); 2256 PostSetNeedsCommitToMainThread();
2228 } 2257 }
2229 2258
2259 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2260 FakeOutputSurface* fake_output_surface =
2261 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface());
2262
2263 // The BeginFrame notification is turned off now but will get
2264 // enabled once we return, so post a task to trigger it.
2265 ASSERT_FALSE(fake_output_surface->needs_begin_frame());
2266 PostBeginFrameOnImplThread(fake_output_surface);
2267 }
2268
2269 void PostBeginFrameOnImplThread(FakeOutputSurface* fake_output_surface) {
2270 DCHECK(ImplThread());
2271 ImplThread()->PostTask(
2272 base::Bind(&LayerTreeHostTestBeginFrameNotification::BeginFrame,
2273 base::Unretained(this),
2274 base::Unretained(fake_output_surface)));
2275 }
2276
2277 void BeginFrame(FakeOutputSurface* fake_output_surface) {
2278 ASSERT_TRUE(fake_output_surface->needs_begin_frame());
2279 fake_output_surface->BeginFrame(frame_time_);
2280 }
2281
2230 virtual bool PrepareToDrawOnThread( 2282 virtual bool PrepareToDrawOnThread(
2231 LayerTreeHostImpl* host_impl, 2283 LayerTreeHostImpl* host_impl,
2232 LayerTreeHostImpl::FrameData* frame, 2284 LayerTreeHostImpl::FrameData* frame,
2233 bool result) OVERRIDE { 2285 bool result) OVERRIDE {
2234 EndTest(); 2286 EndTest();
2235 return true; 2287 return true;
2236 } 2288 }
2237 2289
2238 virtual void AfterTest() OVERRIDE {} 2290 virtual void AfterTest() OVERRIDE {}
2239 2291
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(0, 0, 1, 1)); 2817 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(0, 0, 1, 1));
2766 break; 2818 break;
2767 case 3: 2819 case 3:
2768 // Round 5 done. 2820 // Round 5 done.
2769 EXPECT_EQ(5, commit); 2821 EXPECT_EQ(5, commit);
2770 EndTest(); 2822 EndTest();
2771 break; 2823 break;
2772 } 2824 }
2773 } 2825 }
2774 2826
2827 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
2828 const ThreadProxy* proxy = static_cast<ThreadProxy*>(impl->proxy());
2829 EXPECT_EQ(0, proxy->NumFramesPendingForTesting());
2830 }
2831
2775 virtual void AfterTest() OVERRIDE {} 2832 virtual void AfterTest() OVERRIDE {}
2776 2833
2777 protected: 2834 protected:
2778 int frame_; 2835 int frame_;
2779 }; 2836 };
2780 2837
2781 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 2838 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2782 RunTest(true, true, true); 2839 RunTest(true, true, true);
2783 } 2840 }
2784 2841
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 } 2888 }
2832 } 2889 }
2833 2890
2834 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { 2891 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) {
2835 EXPECT_TRUE( 2892 EXPECT_TRUE(
2836 host_impl->DeferredInitialize(scoped_refptr<ContextProvider>())); 2893 host_impl->DeferredInitialize(scoped_refptr<ContextProvider>()));
2837 initialized_gl_ = true; 2894 initialized_gl_ = true;
2838 2895
2839 // Force redraw again. 2896 // Force redraw again.
2840 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1)); 2897 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1));
2841
2842 // If we didn't swap this begin frame, we need to request another one.
2843 host_impl->SetNeedsBeginFrame(true);
2844 } 2898 }
2845 2899
2846 virtual void AfterTest() OVERRIDE { 2900 virtual void AfterTest() OVERRIDE {
2847 EXPECT_TRUE(initialized_gl_); 2901 EXPECT_TRUE(initialized_gl_);
2848 } 2902 }
2849 2903
2850 private: 2904 private:
2851 FakeContentLayerClient client_; 2905 FakeContentLayerClient client_;
2852 scoped_refptr<FakePictureLayer> layer_; 2906 scoped_refptr<FakePictureLayer> layer_;
2853 bool initialized_gl_; 2907 bool initialized_gl_;
2854 }; 2908 };
2855 2909
2856 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); 2910 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2857 2911
2858 } // namespace 2912 } // namespace
2859 } // namespace cc 2913 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host_impl_unittest.cc ('k') | trunk/src/cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698