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

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

Issue 15058004: cc: Rename VSync to BeginFrame (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Android Created 7 years, 7 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
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 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 // didCommitAndDrawFrame may be called anyway). 1557 // didCommitAndDrawFrame may be called anyway).
1558 // Commit 4: Triggered by the eviction, let it go through and then set 1558 // Commit 4: Triggered by the eviction, let it go through and then set
1559 // needsCommit. 1559 // needsCommit.
1560 // Commit 5: Triggered by the setNeedsCommit, post an eviction task in 1560 // Commit 5: Triggered by the setNeedsCommit, post an eviction task in
1561 // Layout(), a frame should not be drawn but a commit will be posted. 1561 // Layout(), a frame should not be drawn but a commit will be posted.
1562 // Commit 6: Triggered by the eviction, post an eviction task in 1562 // Commit 6: Triggered by the eviction, post an eviction task in
1563 // Layout(), which will be a noop, letting the commit (which recreates the 1563 // Layout(), which will be a noop, letting the commit (which recreates the
1564 // textures) go through and draw a frame, then end the test. 1564 // textures) go through and draw a frame, then end the test.
1565 // 1565 //
1566 // Commits 1+2 test the eviction recovery path where eviction happens outside 1566 // Commits 1+2 test the eviction recovery path where eviction happens outside
1567 // of the beginFrame/commit pair. 1567 // of the beginMainFrame/commit pair.
1568 // Commits 3+4 test the eviction recovery path where eviction happens inside 1568 // Commits 3+4 test the eviction recovery path where eviction happens inside
1569 // the beginFrame/commit pair. 1569 // the beginMainFrame/commit pair.
1570 // Commits 5+6 test the path where an eviction happens during the eviction 1570 // Commits 5+6 test the path where an eviction happens during the eviction
1571 // recovery path. 1571 // recovery path.
1572 virtual void DidCommit() OVERRIDE { 1572 virtual void DidCommit() OVERRIDE {
1573 switch (num_commits_) { 1573 switch (num_commits_) {
1574 case 1: 1574 case 1:
1575 EXPECT_TRUE(layer_->HaveBackingTexture()); 1575 EXPECT_TRUE(layer_->HaveBackingTexture());
1576 PostEvictTextures(); 1576 PostEvictTextures();
1577 break; 1577 break;
1578 case 2: 1578 case 2:
1579 EXPECT_TRUE(layer_->HaveBackingTexture()); 1579 EXPECT_TRUE(layer_->HaveBackingTexture());
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 break; 2314 break;
2315 } 2315 }
2316 } 2316 }
2317 2317
2318 private: 2318 private:
2319 NotificationClient client_; 2319 NotificationClient client_;
2320 }; 2320 };
2321 2321
2322 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); 2322 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
2323 2323
2324 // Verify that the vsync notification is used to initiate rendering. 2324 // Verify that the BeginImplFrame notification is used to initiate rendering.
2325 class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest { 2325 class LayerTreeHostTestBeginImplFrameNotification : public LayerTreeHostTest {
2326 public: 2326 public:
2327 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2327 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2328 settings->render_vsync_notification_enabled = true; 2328 settings->render_parent_drives_begin_impl_frame_ = true;
2329 } 2329 }
2330 2330
2331 virtual void BeginTest() OVERRIDE { 2331 virtual void BeginTest() OVERRIDE {
2332 PostSetNeedsCommitToMainThread(); 2332 PostSetNeedsCommitToMainThread();
2333 } 2333 }
2334 2334
2335 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2335 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2336 FakeOutputSurface* fake_output_surface = 2336 FakeOutputSurface* fake_output_surface =
2337 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); 2337 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface());
2338 2338
2339 // The vsync notification is turned off now but will get enabled once we 2339 // The BeginImplFrame notification is turned off now but will get
2340 // return, so post a task to trigger it. 2340 // enabled once we return, so post a task to trigger it.
2341 ASSERT_FALSE(fake_output_surface->vsync_notification_enabled()); 2341 ASSERT_FALSE(fake_output_surface->needs_begin_impl_frame());
2342 PostVSyncOnImplThread(fake_output_surface); 2342 PostBeginImplFrameOnImplThread(fake_output_surface);
2343 } 2343 }
2344 2344
2345 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) { 2345 void PostBeginImplFrameOnImplThread(FakeOutputSurface* fake_output_surface) {
2346 DCHECK(ImplThread()); 2346 DCHECK(ImplThread());
2347 ImplThread()->PostTask( 2347 ImplThread()->PostTask(
2348 base::Bind(&LayerTreeHostTestVSyncNotification::DidVSync, 2348 base::Bind(&LayerTreeHostTestBeginImplFrameNotification::BeginImplFrame,
2349 base::Unretained(this), 2349 base::Unretained(this),
2350 base::Unretained(fake_output_surface))); 2350 base::Unretained(fake_output_surface)));
2351 } 2351 }
2352 2352
2353 void DidVSync(FakeOutputSurface* fake_output_surface) { 2353 void BeginImplFrame(FakeOutputSurface* fake_output_surface) {
2354 ASSERT_TRUE(fake_output_surface->vsync_notification_enabled()); 2354 ASSERT_TRUE(fake_output_surface->needs_begin_impl_frame());
2355 fake_output_surface->DidVSync(frame_time_); 2355 fake_output_surface->BeginImplFrame(frame_time_);
2356 } 2356 }
2357 2357
2358 virtual bool PrepareToDrawOnThread( 2358 virtual bool PrepareToDrawOnThread(
2359 LayerTreeHostImpl* host_impl, 2359 LayerTreeHostImpl* host_impl,
2360 LayerTreeHostImpl::FrameData* frame, 2360 LayerTreeHostImpl::FrameData* frame,
2361 bool result) OVERRIDE { 2361 bool result) OVERRIDE {
2362 EndTest(); 2362 EndTest();
2363 return true; 2363 return true;
2364 } 2364 }
2365 2365
2366 virtual void AfterTest() OVERRIDE {} 2366 virtual void AfterTest() OVERRIDE {}
2367 2367
2368 private: 2368 private:
2369 base::TimeTicks frame_time_; 2369 base::TimeTicks frame_time_;
2370 }; 2370 };
2371 2371
2372 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); 2372 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginImplFrameNotification);
2373 2373
2374 class LayerTreeHostTestVSyncNotificationShutdownWhileEnabled 2374 class LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled
2375 : public LayerTreeHostTest { 2375 : public LayerTreeHostTest {
2376 public: 2376 public:
2377 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2377 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2378 settings->render_vsync_notification_enabled = true; 2378 settings->render_parent_drives_begin_impl_frame_ = true;
2379 settings->synchronously_disable_vsync = true; 2379 settings->using_synchronous_renderer_compositor = true;
2380 } 2380 }
2381 2381
2382 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2382 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2383 2383
2384 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2384 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2385 // The vsync notification is turned off now but will get enabled once we 2385 // The BeginImplFrame notification is turned off now but will get enabled
2386 // return. End test while it's enabled. 2386 // once we return. End test while it's enabled.
2387 ImplThread()->PostTask(base::Bind( 2387 ImplThread()->PostTask(base::Bind(
2388 &LayerTreeHostTestVSyncNotification::EndTest, base::Unretained(this))); 2388 &LayerTreeHostTestBeginImplFrameNotification::EndTest,
2389 base::Unretained(this)));
2389 } 2390 }
2390 2391
2391 virtual void AfterTest() OVERRIDE {} 2392 virtual void AfterTest() OVERRIDE {}
2392 }; 2393 };
2393 2394
2394 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotificationShutdownWhileEnabled); 2395 MULTI_THREAD_TEST_F(
2396 LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled);
2395 2397
2396 class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest { 2398 class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest {
2397 public: 2399 public:
2398 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2400 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2399 settings->render_vsync_notification_enabled = true; 2401 settings->render_parent_drives_begin_impl_frame_ = true;
2400 } 2402 }
2401 2403
2402 virtual void BeginTest() OVERRIDE { 2404 virtual void BeginTest() OVERRIDE {
2403 frame_time_ = base::TimeTicks::Now(); 2405 frame_time_ = base::TimeTicks::Now();
2404 PostSetNeedsCommitToMainThread(); 2406 PostSetNeedsCommitToMainThread();
2405 } 2407 }
2406 2408
2407 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2409 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2408 // Post a task to send the final input event for the current vsync; it 2410 // Post a task to send the final input event for the current BeginImplFrame;
2409 // should trigger rendering. 2411 // it should trigger rendering.
2410 ImplThread()->PostTask( 2412 ImplThread()->PostTask(
2411 base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent, 2413 base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent,
2412 base::Unretained(this), 2414 base::Unretained(this),
2413 base::Unretained(host_impl))); 2415 base::Unretained(host_impl)));
2414 } 2416 }
2415 2417
2416 void SendFinalInputEvent(LayerTreeHostImpl* host_impl) { 2418 void SendFinalInputEvent(LayerTreeHostImpl* host_impl) {
2417 host_impl->DidReceiveLastInputEventForVSync(frame_time_); 2419 host_impl->DidReceiveLastInputEventForBeginImplFrame(frame_time_);
2418 } 2420 }
2419 2421
2420 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2422 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2421 EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin()); 2423 EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin());
2422 EndTest(); 2424 EndTest();
2423 } 2425 }
2424 2426
2425 virtual void AfterTest() OVERRIDE {} 2427 virtual void AfterTest() OVERRIDE {}
2426 2428
2427 private: 2429 private:
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 2949 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2948 RunTest(true, true, true); 2950 RunTest(true, true, true);
2949 } 2951 }
2950 2952
2951 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 2953 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2952 RunTest(true, false, true); 2954 RunTest(true, false, true);
2953 } 2955 }
2954 2956
2955 } // namespace 2957 } // namespace
2956 } // namespace cc 2958 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698