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 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 break; | 2342 break; |
2343 } | 2343 } |
2344 } | 2344 } |
2345 | 2345 |
2346 private: | 2346 private: |
2347 NotificationClient client_; | 2347 NotificationClient client_; |
2348 }; | 2348 }; |
2349 | 2349 |
2350 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification) | 2350 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification) |
2351 | 2351 |
| 2352 // Verify that the vsync notification is used to initiate rendering. |
| 2353 class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest { |
| 2354 public: |
| 2355 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2356 settings->render_vsync_notification_enabled = true; |
| 2357 } |
| 2358 |
| 2359 virtual void BeginTest() OVERRIDE { |
| 2360 PostSetNeedsCommitToMainThread(); |
| 2361 } |
| 2362 |
| 2363 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2364 FakeOutputSurface* fake_output_surface = |
| 2365 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); |
| 2366 |
| 2367 // The vsync notification is turned off now but will get enabled once we |
| 2368 // return, so post a task to trigger it. |
| 2369 ASSERT_FALSE(fake_output_surface->vsync_notification_enabled()); |
| 2370 PostVSyncOnImplThread(fake_output_surface); |
| 2371 } |
| 2372 |
| 2373 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) { |
| 2374 DCHECK(ImplThread()); |
| 2375 ImplThread()->PostTask( |
| 2376 base::Bind(&LayerTreeHostTestVSyncNotification::DidVSync, |
| 2377 base::Unretained(this), |
| 2378 base::Unretained(fake_output_surface))); |
| 2379 } |
| 2380 |
| 2381 void DidVSync(FakeOutputSurface* fake_output_surface) { |
| 2382 ASSERT_TRUE(fake_output_surface->vsync_notification_enabled()); |
| 2383 fake_output_surface->DidVSync(frame_time_); |
| 2384 } |
| 2385 |
| 2386 virtual bool PrepareToDrawOnThread( |
| 2387 LayerTreeHostImpl* host_impl, |
| 2388 LayerTreeHostImpl::FrameData* frame, |
| 2389 bool result) OVERRIDE { |
| 2390 EndTest(); |
| 2391 return true; |
| 2392 } |
| 2393 |
| 2394 virtual void AfterTest() OVERRIDE { |
| 2395 } |
| 2396 |
| 2397 private: |
| 2398 base::TimeTicks frame_time_; |
| 2399 }; |
| 2400 |
| 2401 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); |
| 2402 |
2352 } // namespace | 2403 } // namespace |
2353 } // namespace cc | 2404 } // namespace cc |
OLD | NEW |