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 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 break; | 2295 break; |
2296 } | 2296 } |
2297 } | 2297 } |
2298 | 2298 |
2299 private: | 2299 private: |
2300 NotificationClient client_; | 2300 NotificationClient client_; |
2301 }; | 2301 }; |
2302 | 2302 |
2303 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2303 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2304 | 2304 |
2305 // Verify that the vsync notification is used to initiate rendering. | 2305 // Verify that the BeginFrame notification is used to initiate rendering. |
2306 class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest { | 2306 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2307 public: | 2307 public: |
2308 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2308 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2309 settings->render_vsync_notification_enabled = true; | 2309 settings->render_begin_frame_notification_enabled = true; |
2310 } | 2310 } |
2311 | 2311 |
2312 virtual void BeginTest() OVERRIDE { | 2312 virtual void BeginTest() OVERRIDE { |
2313 PostSetNeedsCommitToMainThread(); | 2313 PostSetNeedsCommitToMainThread(); |
2314 } | 2314 } |
2315 | 2315 |
2316 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2316 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2317 FakeOutputSurface* fake_output_surface = | 2317 FakeOutputSurface* fake_output_surface = |
2318 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); | 2318 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); |
2319 | 2319 |
2320 // The vsync notification is turned off now but will get enabled once we | 2320 // The BeginFrame notification is turned off now but will get enabled once |
2321 // return, so post a task to trigger it. | 2321 // we return, so post a task to trigger it. |
2322 ASSERT_FALSE(fake_output_surface->vsync_notification_enabled()); | 2322 ASSERT_FALSE(fake_output_surface->begin_frame_notification_enabled()); |
2323 PostVSyncOnImplThread(fake_output_surface); | 2323 PostBeginFrameOnImplThread(fake_output_surface); |
2324 } | 2324 } |
2325 | 2325 |
2326 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) { | 2326 void PostBeginFrameOnImplThread(FakeOutputSurface* fake_output_surface) { |
2327 DCHECK(ImplThread()); | 2327 DCHECK(ImplThread()); |
2328 ImplThread()->PostTask( | 2328 ImplThread()->PostTask( |
2329 base::Bind(&LayerTreeHostTestVSyncNotification::DidVSync, | 2329 base::Bind(&LayerTreeHostTestBeginFrameNotification::BeginFrame, |
2330 base::Unretained(this), | 2330 base::Unretained(this), |
2331 base::Unretained(fake_output_surface))); | 2331 base::Unretained(fake_output_surface))); |
2332 } | 2332 } |
2333 | 2333 |
2334 void DidVSync(FakeOutputSurface* fake_output_surface) { | 2334 void BeginFrame(FakeOutputSurface* fake_output_surface) { |
2335 ASSERT_TRUE(fake_output_surface->vsync_notification_enabled()); | 2335 ASSERT_TRUE(fake_output_surface->begin_frame_notification_enabled()); |
2336 fake_output_surface->DidVSync(frame_time_); | 2336 fake_output_surface->BeginFrame(frame_time_); |
2337 } | 2337 } |
2338 | 2338 |
2339 virtual bool PrepareToDrawOnThread( | 2339 virtual bool PrepareToDrawOnThread( |
2340 LayerTreeHostImpl* host_impl, | 2340 LayerTreeHostImpl* host_impl, |
2341 LayerTreeHostImpl::FrameData* frame, | 2341 LayerTreeHostImpl::FrameData* frame, |
2342 bool result) OVERRIDE { | 2342 bool result) OVERRIDE { |
2343 EndTest(); | 2343 EndTest(); |
2344 return true; | 2344 return true; |
2345 } | 2345 } |
2346 | 2346 |
2347 virtual void AfterTest() OVERRIDE {} | 2347 virtual void AfterTest() OVERRIDE {} |
2348 | 2348 |
2349 private: | 2349 private: |
2350 base::TimeTicks frame_time_; | 2350 base::TimeTicks frame_time_; |
2351 }; | 2351 }; |
2352 | 2352 |
2353 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); | 2353 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); |
2354 | 2354 |
2355 class LayerTreeHostTestVSyncNotificationShutdownWhileEnabled | 2355 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
2356 : public LayerTreeHostTest { | 2356 : public LayerTreeHostTest { |
2357 public: | 2357 public: |
2358 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2358 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2359 settings->render_vsync_notification_enabled = true; | 2359 settings->render_begin_frame_notification_enabled = true; |
2360 settings->synchronously_disable_vsync = true; | 2360 settings->using_synchronous_renderer_compositor = true; |
2361 } | 2361 } |
2362 | 2362 |
2363 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2363 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2364 | 2364 |
2365 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2365 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2366 // The vsync notification is turned off now but will get enabled once we | 2366 // The BeginFrame notification is turned off now but will get enabled once |
2367 // return. End test while it's enabled. | 2367 // we return. End test while it's enabled. |
2368 ImplThread()->PostTask(base::Bind( | 2368 ImplThread()->PostTask(base::Bind( |
2369 &LayerTreeHostTestVSyncNotification::EndTest, base::Unretained(this))); | 2369 &LayerTreeHostTestBeginFrameNotification::EndTest, |
| 2370 base::Unretained(this))); |
2370 } | 2371 } |
2371 | 2372 |
2372 virtual void AfterTest() OVERRIDE {} | 2373 virtual void AfterTest() OVERRIDE {} |
2373 }; | 2374 }; |
2374 | 2375 |
2375 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotificationShutdownWhileEnabled); | 2376 MULTI_THREAD_TEST_F( |
| 2377 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
2376 | 2378 |
2377 class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest { | 2379 class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest { |
2378 public: | 2380 public: |
2379 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2381 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2380 settings->render_vsync_notification_enabled = true; | 2382 settings->render_begin_frame_notification_enabled = true; |
2381 } | 2383 } |
2382 | 2384 |
2383 virtual void BeginTest() OVERRIDE { | 2385 virtual void BeginTest() OVERRIDE { |
2384 frame_time_ = base::TimeTicks::Now(); | 2386 frame_time_ = base::TimeTicks::Now(); |
2385 PostSetNeedsCommitToMainThread(); | 2387 PostSetNeedsCommitToMainThread(); |
2386 } | 2388 } |
2387 | 2389 |
2388 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2390 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2389 // Post a task to send the final input event for the current vsync; it | 2391 // Post a task to send the final input event for the current BeginFrame; it |
2390 // should trigger rendering. | 2392 // should trigger rendering. |
2391 ImplThread()->PostTask( | 2393 ImplThread()->PostTask( |
2392 base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent, | 2394 base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent, |
2393 base::Unretained(this), | 2395 base::Unretained(this), |
2394 base::Unretained(host_impl))); | 2396 base::Unretained(host_impl))); |
2395 } | 2397 } |
2396 | 2398 |
2397 void SendFinalInputEvent(LayerTreeHostImpl* host_impl) { | 2399 void SendFinalInputEvent(LayerTreeHostImpl* host_impl) { |
2398 host_impl->DidReceiveLastInputEventForVSync(frame_time_); | 2400 host_impl->DidReceiveLastInputEventForBeginFrame(frame_time_); |
2399 } | 2401 } |
2400 | 2402 |
2401 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2403 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2402 EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin()); | 2404 EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin()); |
2403 EndTest(); | 2405 EndTest(); |
2404 } | 2406 } |
2405 | 2407 |
2406 virtual void AfterTest() OVERRIDE {} | 2408 virtual void AfterTest() OVERRIDE {} |
2407 | 2409 |
2408 private: | 2410 private: |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2928 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { | 2930 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { |
2929 RunTest(true, true, true); | 2931 RunTest(true, true, true); |
2930 } | 2932 } |
2931 | 2933 |
2932 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { | 2934 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { |
2933 RunTest(true, false, true); | 2935 RunTest(true, false, true); |
2934 } | 2936 } |
2935 | 2937 |
2936 } // namespace | 2938 } // namespace |
2937 } // namespace cc | 2939 } // namespace cc |
OLD | NEW |