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

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: add tests 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
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 280 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
281 class LayerTreeHostForTesting : public LayerTreeHost { 281 class LayerTreeHostForTesting : public LayerTreeHost {
282 public: 282 public:
283 static scoped_ptr<LayerTreeHostForTesting> Create( 283 static scoped_ptr<LayerTreeHostForTesting> Create(
284 TestHooks* test_hooks, 284 TestHooks* test_hooks,
285 LayerTreeHostClientForTesting* client, 285 LayerTreeHostClientForTesting* client,
286 const LayerTreeSettings& settings, 286 const LayerTreeSettings& settings,
287 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 287 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
288 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 288 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
289 new LayerTreeHostForTesting(test_hooks, client, settings)); 289 new LayerTreeHostForTesting(test_hooks, client, settings));
290 bool success;
291 if (impl_task_runner.get()) 290 if (impl_task_runner.get())
292 success = layer_tree_host->InitializeThreaded(impl_task_runner); 291 layer_tree_host->InitializeThreaded(impl_task_runner);
293 else 292 else
294 success = layer_tree_host->InitializeSingleThreaded(client); 293 layer_tree_host->InitializeSingleThreaded(client);
295 EXPECT_TRUE(success);
296 return layer_tree_host.Pass(); 294 return layer_tree_host.Pass();
297 } 295 }
298 296
299 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 297 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
300 LayerTreeHostImplClient* host_impl_client) OVERRIDE { 298 LayerTreeHostImplClient* host_impl_client) OVERRIDE {
301 return LayerTreeHostImplForTesting::Create( 299 return LayerTreeHostImplForTesting::Create(
302 test_hooks_, 300 test_hooks_,
303 settings(), 301 settings(),
304 host_impl_client, 302 host_impl_client,
305 proxy(), 303 proxy(),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 &LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible)); 441 &LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible));
444 } 442 }
445 443
446 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() { 444 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() {
447 main_task_runner_->PostTask( 445 main_task_runner_->PostTask(
448 FROM_HERE, 446 FROM_HERE,
449 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw, 447 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw,
450 main_thread_weak_ptr_)); 448 main_thread_weak_ptr_));
451 } 449 }
452 450
451 void LayerTreeTest::WillBeginTest() {
452 layer_tree_host_->SetLayerTreeHostClientReady();
453 }
454
453 void LayerTreeTest::DoBeginTest() { 455 void LayerTreeTest::DoBeginTest() {
454 client_ = LayerTreeHostClientForTesting::Create(this); 456 client_ = LayerTreeHostClientForTesting::Create(this);
455 457
456 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); 458 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get());
457 layer_tree_host_ = LayerTreeHostForTesting::Create( 459 layer_tree_host_ = LayerTreeHostForTesting::Create(
458 this, 460 this,
459 client_.get(), 461 client_.get(),
460 settings_, 462 settings_,
461 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); 463 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL);
462 ASSERT_TRUE(layer_tree_host_); 464 ASSERT_TRUE(layer_tree_host_);
463 465
464 started_ = true; 466 started_ = true;
465 beginning_ = true; 467 beginning_ = true;
466 SetupTree(); 468 SetupTree();
467 layer_tree_host_->SetLayerTreeHostClientReady(); 469 WillBeginTest();
468 BeginTest(); 470 BeginTest();
469 beginning_ = false; 471 beginning_ = false;
470 if (end_when_begin_returns_) 472 if (end_when_begin_returns_)
471 RealEndTest(); 473 RealEndTest();
472 474
473 // Allow commits to happen once BeginTest() has had a chance to post tasks 475 // Allow commits to happen once BeginTest() has had a chance to post tasks
474 // so that those tasks will happen before the first commit. 476 // so that those tasks will happen before the first commit.
475 if (layer_tree_host_) { 477 if (layer_tree_host_) {
476 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> 478 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())->
477 set_test_started(true); 479 set_test_started(true);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 } 674 }
673 675
674 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { 676 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() {
675 if (!compositor_contexts_.get() || 677 if (!compositor_contexts_.get() ||
676 compositor_contexts_->DestroyedOnMainThread()) 678 compositor_contexts_->DestroyedOnMainThread())
677 compositor_contexts_ = TestContextProvider::Create(); 679 compositor_contexts_ = TestContextProvider::Create();
678 return compositor_contexts_; 680 return compositor_contexts_;
679 } 681 }
680 682
681 } // namespace cc 683 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698