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 "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "cc/animation/timing_function.h" | 8 #include "cc/animation/timing_function.h" |
9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 } | 2241 } |
2242 | 2242 |
2243 private: | 2243 private: |
2244 FakeContentLayerClient client_; | 2244 FakeContentLayerClient client_; |
2245 scoped_refptr<ContentLayer> m_rootLayer; | 2245 scoped_refptr<ContentLayer> m_rootLayer; |
2246 int m_numCommits; | 2246 int m_numCommits; |
2247 }; | 2247 }; |
2248 | 2248 |
2249 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarNewRootLayer) | 2249 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarNewRootLayer) |
2250 | 2250 |
| 2251 // Verify that the vsync notification is used to initiate rendering. |
| 2252 class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest { |
| 2253 public: |
| 2254 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2255 settings->render_vsync_notification_enabled = true; |
| 2256 } |
| 2257 |
| 2258 virtual void BeginTest() OVERRIDE { |
| 2259 PostSetNeedsCommitToMainThread(); |
| 2260 } |
| 2261 |
| 2262 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2263 FakeOutputSurface* fake_output_surface = |
| 2264 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); |
| 2265 |
| 2266 // The vsync notification is turned off now but will get enabled once we |
| 2267 // return, so post a task to trigger it. |
| 2268 ASSERT_FALSE(fake_output_surface->vsync_notification_enabled()); |
| 2269 PostVSyncOnImplThread(fake_output_surface); |
| 2270 } |
| 2271 |
| 2272 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) { |
| 2273 DCHECK(ImplThread()); |
| 2274 ImplThread()->PostTask( |
| 2275 base::Bind(&LayerTreeHostTestVSyncNotification::DidVSync, |
| 2276 base::Unretained(this), |
| 2277 base::Unretained(fake_output_surface))); |
| 2278 } |
| 2279 |
| 2280 void DidVSync(FakeOutputSurface* fake_output_surface) { |
| 2281 ASSERT_TRUE(fake_output_surface->vsync_notification_enabled()); |
| 2282 fake_output_surface->DidVSync(frame_time_); |
| 2283 } |
| 2284 |
| 2285 virtual bool PrepareToDrawOnThread( |
| 2286 LayerTreeHostImpl* host_impl, |
| 2287 LayerTreeHostImpl::FrameData* frame, |
| 2288 bool result) OVERRIDE { |
| 2289 EndTest(); |
| 2290 return true; |
| 2291 } |
| 2292 |
| 2293 virtual void AfterTest() OVERRIDE { |
| 2294 } |
| 2295 |
| 2296 private: |
| 2297 base::TimeTicks frame_time_; |
| 2298 }; |
| 2299 |
| 2300 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); |
| 2301 |
2251 } // namespace | 2302 } // namespace |
2252 } // namespace cc | 2303 } // namespace cc |
OLD | NEW |