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

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

Issue 14925009: Run all LayerTreeHost tests with a delegating renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uber-unittests: for landing2 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host_perftest.cc » ('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"
11 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
12 #include "cc/base/switches.h" 12 #include "cc/base/switches.h"
13 #include "cc/base/thread_impl.h" 13 #include "cc/base/thread_impl.h"
14 #include "cc/input/input_handler.h" 14 #include "cc/input/input_handler.h"
15 #include "cc/layers/content_layer.h" 15 #include "cc/layers/content_layer.h"
16 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
17 #include "cc/layers/layer_impl.h" 17 #include "cc/layers/layer_impl.h"
18 #include "cc/test/animation_test_common.h" 18 #include "cc/test/animation_test_common.h"
19 #include "cc/test/fake_context_provider.h"
19 #include "cc/test/fake_layer_tree_host_client.h" 20 #include "cc/test/fake_layer_tree_host_client.h"
20 #include "cc/test/fake_output_surface.h" 21 #include "cc/test/fake_output_surface.h"
21 #include "cc/test/occlusion_tracker_test_common.h" 22 #include "cc/test/occlusion_tracker_test_common.h"
22 #include "cc/test/tiled_layer_test_common.h" 23 #include "cc/test/tiled_layer_test_common.h"
23 #include "cc/trees/layer_tree_host_impl.h" 24 #include "cc/trees/layer_tree_host_impl.h"
24 #include "cc/trees/single_thread_proxy.h" 25 #include "cc/trees/single_thread_proxy.h"
25 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
26 #include "ui/gfx/size_conversions.h" 27 #include "ui/gfx/size_conversions.h"
27 28
28 namespace cc { 29 namespace cc {
29 30
30 TestHooks::TestHooks() 31 TestHooks::TestHooks() {}
31 : fake_client_(
32 new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {}
33 32
34 TestHooks::~TestHooks() {} 33 TestHooks::~TestHooks() {}
35 34
36 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 35 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
37 LayerTreeHostImpl::FrameData* frame_data, 36 LayerTreeHostImpl::FrameData* frame_data,
38 bool result) { 37 bool result) {
39 return true; 38 return true;
40 } 39 }
41 40
42 bool TestHooks::CanActivatePendingTree() { 41 bool TestHooks::CanActivatePendingTree() {
43 return true; 42 return true;
44 } 43 }
45 44
46 scoped_ptr<OutputSurface> TestHooks::CreateOutputSurface() {
47 return CreateFakeOutputSurface();
48 }
49
50 scoped_refptr<cc::ContextProvider> TestHooks::
51 OffscreenContextProviderForMainThread() {
52 return fake_client_->OffscreenContextProviderForMainThread();
53 }
54
55 scoped_refptr<cc::ContextProvider> TestHooks::
56 OffscreenContextProviderForCompositorThread() {
57 return fake_client_->OffscreenContextProviderForCompositorThread();
58 }
59
60 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. 45 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
61 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { 46 class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
62 public: 47 public:
63 static scoped_ptr<LayerTreeHostImplForTesting> Create( 48 static scoped_ptr<LayerTreeHostImplForTesting> Create(
64 TestHooks* test_hooks, 49 TestHooks* test_hooks,
65 const LayerTreeSettings& settings, 50 const LayerTreeSettings& settings,
66 LayerTreeHostImplClient* host_impl_client, 51 LayerTreeHostImplClient* host_impl_client,
67 Proxy* proxy, 52 Proxy* proxy,
68 RenderingStatsInstrumentation* stats_instrumentation) { 53 RenderingStatsInstrumentation* stats_instrumentation) {
69 return make_scoped_ptr( 54 return make_scoped_ptr(
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (!layer_tree_host_->visible()) { 528 if (!layer_tree_host_->visible()) {
544 schedule_when_set_visible_true_ = true; 529 schedule_when_set_visible_true_ = true;
545 return; 530 return;
546 } 531 }
547 532
548 schedule_when_set_visible_true_ = false; 533 schedule_when_set_visible_true_ = false;
549 base::TimeTicks now = base::TimeTicks::Now(); 534 base::TimeTicks now = base::TimeTicks::Now();
550 layer_tree_host_->Composite(now); 535 layer_tree_host_->Composite(now);
551 } 536 }
552 537
553 void LayerTreeTest::RunTest(bool threaded) { 538 void LayerTreeTest::RunTest(bool threaded, bool delegating_renderer) {
554 if (threaded) { 539 if (threaded) {
555 impl_thread_.reset(new base::Thread("Compositor")); 540 impl_thread_.reset(new base::Thread("Compositor"));
556 ASSERT_TRUE(impl_thread_->Start()); 541 ASSERT_TRUE(impl_thread_->Start());
557 } 542 }
558 543
559 main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread(); 544 main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread();
560 545
546 delegating_renderer_ = delegating_renderer;
547
561 // Spend less time waiting for vsync because the output is mocked out. 548 // Spend less time waiting for vsync because the output is mocked out.
562 settings_.refresh_rate = 200.0; 549 settings_.refresh_rate = 200.0;
563 InitializeSettings(&settings_); 550 InitializeSettings(&settings_);
564 551
565 main_ccthread_->PostTask( 552 main_ccthread_->PostTask(
566 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); 553 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this)));
567 554
568 if (timeout_seconds_) { 555 if (timeout_seconds_) {
569 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); 556 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this)));
570 main_ccthread_->PostDelayedTask( 557 main_ccthread_->PostDelayedTask(
(...skipping 10 matching lines...) Expand all
581 568
582 ASSERT_FALSE(layer_tree_host_.get()); 569 ASSERT_FALSE(layer_tree_host_.get());
583 client_.reset(); 570 client_.reset();
584 if (timed_out_) { 571 if (timed_out_) {
585 FAIL() << "Test timed out"; 572 FAIL() << "Test timed out";
586 return; 573 return;
587 } 574 }
588 AfterTest(); 575 AfterTest();
589 } 576 }
590 577
578 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface() {
579 if (delegating_renderer_)
580 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
581 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
582 }
583
584 scoped_refptr<cc::ContextProvider> LayerTreeTest::
585 OffscreenContextProviderForMainThread() {
586 if (!main_thread_contexts_ ||
587 main_thread_contexts_->DestroyedOnMainThread()) {
588 main_thread_contexts_ = FakeContextProvider::Create();
589 if (!main_thread_contexts_->BindToCurrentThread())
590 main_thread_contexts_ = NULL;
591 }
592 return main_thread_contexts_;
593 }
594
595 scoped_refptr<cc::ContextProvider> LayerTreeTest::
596 OffscreenContextProviderForCompositorThread() {
597 if (!compositor_thread_contexts_ ||
598 compositor_thread_contexts_->DestroyedOnMainThread())
599 compositor_thread_contexts_ = FakeContextProvider::Create();
600 return compositor_thread_contexts_;
601 }
602
591 } // namespace cc 603 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698