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

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: Rebase 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 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 break; 2251 break;
2252 } 2252 }
2253 } 2253 }
2254 2254
2255 private: 2255 private:
2256 NotificationClient client_; 2256 NotificationClient client_;
2257 }; 2257 };
2258 2258
2259 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); 2259 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
2260 2260
2261 // Verify that the vsync notification is used to initiate rendering. 2261 // Verify that the BeginFrame notification is used to initiate rendering.
2262 class LayerTreeHostTestVSyncNotification : public LayerTreeHostTest { 2262 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
2263 public: 2263 public:
2264 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2264 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2265 settings->render_vsync_notification_enabled = true; 2265 settings->render_parent_drives_begin_frame_ = true;
2266 } 2266 }
2267 2267
2268 virtual void BeginTest() OVERRIDE { 2268 virtual void BeginTest() OVERRIDE {
2269 PostSetNeedsCommitToMainThread(); 2269 PostSetNeedsCommitToMainThread();
2270 } 2270 }
2271 2271
2272 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2272 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2273 FakeOutputSurface* fake_output_surface = 2273 FakeOutputSurface* fake_output_surface =
2274 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); 2274 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface());
2275 2275
2276 // The vsync notification is turned off now but will get enabled once we 2276 // The BeginFrame notification is turned off now but will get
2277 // return, so post a task to trigger it. 2277 // enabled once we return, so post a task to trigger it.
2278 ASSERT_FALSE(fake_output_surface->vsync_notification_enabled()); 2278 ASSERT_FALSE(fake_output_surface->needs_begin_frame());
2279 PostVSyncOnImplThread(fake_output_surface); 2279 PostBeginFrameOnImplThread(fake_output_surface);
2280 } 2280 }
2281 2281
2282 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) { 2282 void PostBeginFrameOnImplThread(FakeOutputSurface* fake_output_surface) {
2283 DCHECK(ImplThread()); 2283 DCHECK(ImplThread());
2284 ImplThread()->PostTask( 2284 ImplThread()->PostTask(
2285 base::Bind(&LayerTreeHostTestVSyncNotification::DidVSync, 2285 base::Bind(&LayerTreeHostTestBeginFrameNotification::BeginFrame,
2286 base::Unretained(this), 2286 base::Unretained(this),
2287 base::Unretained(fake_output_surface))); 2287 base::Unretained(fake_output_surface)));
2288 } 2288 }
2289 2289
2290 void DidVSync(FakeOutputSurface* fake_output_surface) { 2290 void BeginFrame(FakeOutputSurface* fake_output_surface) {
2291 ASSERT_TRUE(fake_output_surface->vsync_notification_enabled()); 2291 ASSERT_TRUE(fake_output_surface->needs_begin_frame());
2292 fake_output_surface->DidVSync(frame_time_); 2292 fake_output_surface->BeginFrame(frame_time_);
2293 } 2293 }
2294 2294
2295 virtual bool PrepareToDrawOnThread( 2295 virtual bool PrepareToDrawOnThread(
2296 LayerTreeHostImpl* host_impl, 2296 LayerTreeHostImpl* host_impl,
2297 LayerTreeHostImpl::FrameData* frame, 2297 LayerTreeHostImpl::FrameData* frame,
2298 bool result) OVERRIDE { 2298 bool result) OVERRIDE {
2299 EndTest(); 2299 EndTest();
2300 return true; 2300 return true;
2301 } 2301 }
2302 2302
2303 virtual void AfterTest() OVERRIDE {} 2303 virtual void AfterTest() OVERRIDE {}
2304 2304
2305 private: 2305 private:
2306 base::TimeTicks frame_time_; 2306 base::TimeTicks frame_time_;
2307 }; 2307 };
2308 2308
2309 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); 2309 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification);
2310 2310
2311 class LayerTreeHostTestVSyncNotificationShutdownWhileEnabled 2311 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
2312 : public LayerTreeHostTest { 2312 : public LayerTreeHostTest {
2313 public: 2313 public:
2314 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2314 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2315 settings->render_vsync_notification_enabled = true; 2315 settings->render_parent_drives_begin_frame_ = true;
2316 settings->synchronously_disable_vsync = true; 2316 settings->using_synchronous_renderer_compositor = true;
2317 } 2317 }
2318 2318
2319 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2319 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2320 2320
2321 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2321 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2322 // The vsync notification is turned off now but will get enabled once we 2322 // The BeginFrame notification is turned off now but will get enabled
2323 // return. End test while it's enabled. 2323 // once we return. End test while it's enabled.
2324 ImplThread()->PostTask(base::Bind( 2324 ImplThread()->PostTask(base::Bind(
2325 &LayerTreeHostTestVSyncNotification::EndTest, base::Unretained(this))); 2325 &LayerTreeHostTestBeginFrameNotification::EndTest,
2326 base::Unretained(this)));
2326 } 2327 }
2327 2328
2328 virtual void AfterTest() OVERRIDE {} 2329 virtual void AfterTest() OVERRIDE {}
2329 }; 2330 };
2330 2331
2331 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotificationShutdownWhileEnabled); 2332 MULTI_THREAD_TEST_F(
2333 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled);
2332 2334
2333 class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest { 2335 class LayerTreeHostTestInputDrivenRendering : public LayerTreeHostTest {
2334 public: 2336 public:
2335 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2337 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2336 settings->render_vsync_notification_enabled = true; 2338 settings->render_parent_drives_begin_frame_ = true;
2337 } 2339 }
2338 2340
2339 virtual void BeginTest() OVERRIDE { 2341 virtual void BeginTest() OVERRIDE {
2340 frame_time_ = base::TimeTicks::Now(); 2342 frame_time_ = base::TimeTicks::Now();
2341 PostSetNeedsCommitToMainThread(); 2343 PostSetNeedsCommitToMainThread();
2342 } 2344 }
2343 2345
2344 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2346 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2345 // Post a task to send the final input event for the current vsync; it 2347 // Post a task to send the final input event for the current BeginFrame;
2346 // should trigger rendering. 2348 // it should trigger rendering.
2347 ImplThread()->PostTask( 2349 ImplThread()->PostTask(
2348 base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent, 2350 base::Bind(&LayerTreeHostTestInputDrivenRendering::SendFinalInputEvent,
2349 base::Unretained(this), 2351 base::Unretained(this),
2350 base::Unretained(host_impl))); 2352 base::Unretained(host_impl)));
2351 } 2353 }
2352 2354
2353 void SendFinalInputEvent(LayerTreeHostImpl* host_impl) { 2355 void SendFinalInputEvent(LayerTreeHostImpl* host_impl) {
2354 host_impl->DidReceiveLastInputEventForVSync(frame_time_); 2356 host_impl->DidReceiveLastInputEventForBeginFrame(frame_time_);
2355 } 2357 }
2356 2358
2357 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2359 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2358 EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin()); 2360 EXPECT_EQ(frame_time_, **host_impl->fps_counter()->begin());
2359 EndTest(); 2361 EndTest();
2360 } 2362 }
2361 2363
2362 virtual void AfterTest() OVERRIDE {} 2364 virtual void AfterTest() OVERRIDE {}
2363 2365
2364 private: 2366 private:
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 2886 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2885 RunTest(true, true, true); 2887 RunTest(true, true, true);
2886 } 2888 }
2887 2889
2888 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 2890 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2889 RunTest(true, false, true); 2891 RunTest(true, false, true);
2890 } 2892 }
2891 2893
2892 } // namespace 2894 } // namespace
2893 } // namespace cc 2895 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698