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 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | |
2082 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2052 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
2083 : public LayerTreeHostTest { | 2053 : public LayerTreeHostTest { |
2084 public: | 2054 public: |
2085 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2055 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
2086 : root_layer_(FakeContentLayer::Create(&client_)), | 2056 : root_layer_(FakeContentLayer::Create(&client_)), |
2087 child_layer1_(FakeContentLayer::Create(&client_)), | 2057 child_layer1_(FakeContentLayer::Create(&client_)), |
2088 child_layer2_(FakeContentLayer::Create(&client_)), | 2058 child_layer2_(FakeContentLayer::Create(&client_)), |
2089 num_commits_(0) {} | 2059 num_commits_(0) {} |
2090 | 2060 |
2091 virtual void BeginTest() OVERRIDE { | 2061 virtual void BeginTest() OVERRIDE { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2216 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2247 | 2217 |
2248 // Verify that the BeginFrame notification is used to initiate rendering. | 2218 // Verify that the BeginFrame notification is used to initiate rendering. |
2249 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | 2219 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2250 public: | 2220 public: |
2251 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2221 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2252 settings->begin_frame_scheduling_enabled = true; | 2222 settings->begin_frame_scheduling_enabled = true; |
2253 } | 2223 } |
2254 | 2224 |
2255 virtual void BeginTest() OVERRIDE { | 2225 virtual void BeginTest() OVERRIDE { |
| 2226 // This will trigger a SetNeedsBeginFrame which will trigger a BeginFrame. |
2256 PostSetNeedsCommitToMainThread(); | 2227 PostSetNeedsCommitToMainThread(); |
2257 } | 2228 } |
2258 | 2229 |
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 | |
2282 virtual bool PrepareToDrawOnThread( | 2230 virtual bool PrepareToDrawOnThread( |
2283 LayerTreeHostImpl* host_impl, | 2231 LayerTreeHostImpl* host_impl, |
2284 LayerTreeHostImpl::FrameData* frame, | 2232 LayerTreeHostImpl::FrameData* frame, |
2285 bool result) OVERRIDE { | 2233 bool result) OVERRIDE { |
2286 EndTest(); | 2234 EndTest(); |
2287 return true; | 2235 return true; |
2288 } | 2236 } |
2289 | 2237 |
2290 virtual void AfterTest() OVERRIDE {} | 2238 virtual void AfterTest() OVERRIDE {} |
2291 | 2239 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(0, 0, 1, 1)); | 2765 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(0, 0, 1, 1)); |
2818 break; | 2766 break; |
2819 case 3: | 2767 case 3: |
2820 // Round 5 done. | 2768 // Round 5 done. |
2821 EXPECT_EQ(5, commit); | 2769 EXPECT_EQ(5, commit); |
2822 EndTest(); | 2770 EndTest(); |
2823 break; | 2771 break; |
2824 } | 2772 } |
2825 } | 2773 } |
2826 | 2774 |
2827 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
2828 const ThreadProxy* proxy = static_cast<ThreadProxy*>(impl->proxy()); | |
2829 EXPECT_EQ(0, proxy->NumFramesPendingForTesting()); | |
2830 } | |
2831 | |
2832 virtual void AfterTest() OVERRIDE {} | 2775 virtual void AfterTest() OVERRIDE {} |
2833 | 2776 |
2834 protected: | 2777 protected: |
2835 int frame_; | 2778 int frame_; |
2836 }; | 2779 }; |
2837 | 2780 |
2838 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { | 2781 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { |
2839 RunTest(true, true, true); | 2782 RunTest(true, true, true); |
2840 } | 2783 } |
2841 | 2784 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 } | 2831 } |
2889 } | 2832 } |
2890 | 2833 |
2891 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { | 2834 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { |
2892 EXPECT_TRUE( | 2835 EXPECT_TRUE( |
2893 host_impl->DeferredInitialize(scoped_refptr<ContextProvider>())); | 2836 host_impl->DeferredInitialize(scoped_refptr<ContextProvider>())); |
2894 initialized_gl_ = true; | 2837 initialized_gl_ = true; |
2895 | 2838 |
2896 // Force redraw again. | 2839 // Force redraw again. |
2897 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1)); | 2840 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); |
2898 } | 2844 } |
2899 | 2845 |
2900 virtual void AfterTest() OVERRIDE { | 2846 virtual void AfterTest() OVERRIDE { |
2901 EXPECT_TRUE(initialized_gl_); | 2847 EXPECT_TRUE(initialized_gl_); |
2902 } | 2848 } |
2903 | 2849 |
2904 private: | 2850 private: |
2905 FakeContentLayerClient client_; | 2851 FakeContentLayerClient client_; |
2906 scoped_refptr<FakePictureLayer> layer_; | 2852 scoped_refptr<FakePictureLayer> layer_; |
2907 bool initialized_gl_; | 2853 bool initialized_gl_; |
2908 }; | 2854 }; |
2909 | 2855 |
2910 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | 2856 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
2911 | 2857 |
2912 } // namespace | 2858 } // namespace |
2913 } // namespace cc | 2859 } // namespace cc |
OLD | NEW |