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

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 85693007: cc: Defer first OutputSurface creation until client is ready (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/layer_tree_test.h" 5 #include "cc/test/layer_tree_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/animation/animation.h" 8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 286 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
287 class LayerTreeHostForTesting : public LayerTreeHost { 287 class LayerTreeHostForTesting : public LayerTreeHost {
288 public: 288 public:
289 static scoped_ptr<LayerTreeHostForTesting> Create( 289 static scoped_ptr<LayerTreeHostForTesting> Create(
290 TestHooks* test_hooks, 290 TestHooks* test_hooks,
291 LayerTreeHostClientForTesting* client, 291 LayerTreeHostClientForTesting* client,
292 const LayerTreeSettings& settings, 292 const LayerTreeSettings& settings,
293 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 293 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
294 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 294 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
295 new LayerTreeHostForTesting(test_hooks, client, settings)); 295 new LayerTreeHostForTesting(test_hooks, client, settings));
296 bool success;
297 if (impl_task_runner.get()) 296 if (impl_task_runner.get())
298 success = layer_tree_host->InitializeThreaded(impl_task_runner); 297 layer_tree_host->InitializeThreaded(impl_task_runner);
299 else 298 else
300 success = layer_tree_host->InitializeSingleThreaded(client); 299 layer_tree_host->InitializeSingleThreaded(client);
301 EXPECT_TRUE(success);
302 return layer_tree_host.Pass(); 300 return layer_tree_host.Pass();
303 } 301 }
304 302
305 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 303 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
306 LayerTreeHostImplClient* host_impl_client) OVERRIDE { 304 LayerTreeHostImplClient* host_impl_client) OVERRIDE {
307 return LayerTreeHostImplForTesting::Create( 305 return LayerTreeHostImplForTesting::Create(
308 test_hooks_, 306 test_hooks_,
309 settings(), 307 settings(),
310 host_impl_client, 308 host_impl_client,
311 proxy(), 309 proxy(),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 &LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible)); 454 &LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible));
457 } 455 }
458 456
459 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() { 457 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() {
460 main_task_runner_->PostTask( 458 main_task_runner_->PostTask(
461 FROM_HERE, 459 FROM_HERE,
462 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw, 460 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw,
463 main_thread_weak_ptr_)); 461 main_thread_weak_ptr_));
464 } 462 }
465 463
464 void LayerTreeTest::WillBeginTest() {
465 layer_tree_host_->SetLayerTreeHostClientReady();
466 }
467
466 void LayerTreeTest::DoBeginTest() { 468 void LayerTreeTest::DoBeginTest() {
467 client_ = LayerTreeHostClientForTesting::Create(this); 469 client_ = LayerTreeHostClientForTesting::Create(this);
468 470
469 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); 471 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get());
470 layer_tree_host_ = LayerTreeHostForTesting::Create( 472 layer_tree_host_ = LayerTreeHostForTesting::Create(
471 this, 473 this,
472 client_.get(), 474 client_.get(),
473 settings_, 475 settings_,
474 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); 476 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL);
475 ASSERT_TRUE(layer_tree_host_); 477 ASSERT_TRUE(layer_tree_host_);
476 478
477 started_ = true; 479 started_ = true;
478 beginning_ = true; 480 beginning_ = true;
479 SetupTree(); 481 SetupTree();
480 layer_tree_host_->SetLayerTreeHostClientReady(); 482 WillBeginTest();
481 BeginTest(); 483 BeginTest();
482 beginning_ = false; 484 beginning_ = false;
483 if (end_when_begin_returns_) 485 if (end_when_begin_returns_)
484 RealEndTest(); 486 RealEndTest();
485 487
486 // Allow commits to happen once BeginTest() has had a chance to post tasks 488 // Allow commits to happen once BeginTest() has had a chance to post tasks
487 // so that those tasks will happen before the first commit. 489 // so that those tasks will happen before the first commit.
488 if (layer_tree_host_) { 490 if (layer_tree_host_) {
489 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> 491 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())->
490 set_test_started(true); 492 set_test_started(true);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 694 }
693 695
694 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { 696 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() {
695 if (!compositor_contexts_.get() || 697 if (!compositor_contexts_.get() ||
696 compositor_contexts_->DestroyedOnMainThread()) 698 compositor_contexts_->DestroyedOnMainThread())
697 compositor_contexts_ = TestContextProvider::Create(); 699 compositor_contexts_ = TestContextProvider::Create();
698 return compositor_contexts_; 700 return compositor_contexts_;
699 } 701 }
700 702
701 } // namespace cc 703 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698