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

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

Issue 132163004: Remove WebGraphicsContext3D getter from cc::ContextProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. 47 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
48 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { 48 class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
49 public: 49 public:
50 static scoped_ptr<LayerTreeHostImplForTesting> Create( 50 static scoped_ptr<LayerTreeHostImplForTesting> Create(
51 TestHooks* test_hooks, 51 TestHooks* test_hooks,
52 const LayerTreeSettings& settings, 52 const LayerTreeSettings& settings,
53 LayerTreeHostImplClient* host_impl_client, 53 LayerTreeHostImplClient* host_impl_client,
54 Proxy* proxy, 54 Proxy* proxy,
55 RenderingStatsInstrumentation* stats_instrumentation) { 55 RenderingStatsInstrumentation* stats_instrumentation) {
56 return make_scoped_ptr( 56 return make_scoped_ptr(new LayerTreeHostImplForTesting(
57 new LayerTreeHostImplForTesting(test_hooks, 57 test_hooks, settings, host_impl_client, proxy, stats_instrumentation));
58 settings,
59 host_impl_client,
60 proxy,
61 stats_instrumentation));
62 } 58 }
63 59
64 protected: 60 protected:
65 LayerTreeHostImplForTesting( 61 LayerTreeHostImplForTesting(
66 TestHooks* test_hooks, 62 TestHooks* test_hooks,
67 const LayerTreeSettings& settings, 63 const LayerTreeSettings& settings,
68 LayerTreeHostImplClient* host_impl_client, 64 LayerTreeHostImplClient* host_impl_client,
69 Proxy* proxy, 65 Proxy* proxy,
70 RenderingStatsInstrumentation* stats_instrumentation) 66 RenderingStatsInstrumentation* stats_instrumentation)
71 : LayerTreeHostImpl(settings, 67 : LayerTreeHostImpl(settings,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 214
219 virtual void DidBeginMainFrame() OVERRIDE { 215 virtual void DidBeginMainFrame() OVERRIDE {
220 test_hooks_->DidBeginMainFrame(); 216 test_hooks_->DidBeginMainFrame();
221 } 217 }
222 218
223 virtual void Animate(double monotonic_time) OVERRIDE { 219 virtual void Animate(double monotonic_time) OVERRIDE {
224 test_hooks_->Animate(base::TimeTicks::FromInternalValue( 220 test_hooks_->Animate(base::TimeTicks::FromInternalValue(
225 monotonic_time * base::Time::kMicrosecondsPerSecond)); 221 monotonic_time * base::Time::kMicrosecondsPerSecond));
226 } 222 }
227 223
228 virtual void Layout() OVERRIDE { 224 virtual void Layout() OVERRIDE { test_hooks_->Layout(); }
229 test_hooks_->Layout();
230 }
231 225
232 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 226 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta,
233 float scale) OVERRIDE { 227 float scale) OVERRIDE {
234 test_hooks_->ApplyScrollAndScale(scroll_delta, scale); 228 test_hooks_->ApplyScrollAndScale(scroll_delta, scale);
235 } 229 }
236 230
237 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) 231 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
238 OVERRIDE { 232 OVERRIDE {
239 return test_hooks_->CreateOutputSurface(fallback); 233 return test_hooks_->CreateOutputSurface(fallback);
240 } 234 }
241 235
242 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { 236 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE {
243 test_hooks_->DidInitializeOutputSurface(succeeded); 237 test_hooks_->DidInitializeOutputSurface(succeeded);
244 } 238 }
245 239
246 virtual void DidFailToInitializeOutputSurface() OVERRIDE { 240 virtual void DidFailToInitializeOutputSurface() OVERRIDE {
247 test_hooks_->DidFailToInitializeOutputSurface(); 241 test_hooks_->DidFailToInitializeOutputSurface();
248 } 242 }
249 243
250 virtual void WillCommit() OVERRIDE { test_hooks_->WillCommit(); } 244 virtual void WillCommit() OVERRIDE { test_hooks_->WillCommit(); }
251 245
252 virtual void DidCommit() OVERRIDE { 246 virtual void DidCommit() OVERRIDE { test_hooks_->DidCommit(); }
253 test_hooks_->DidCommit();
254 }
255 247
256 virtual void DidCommitAndDrawFrame() OVERRIDE { 248 virtual void DidCommitAndDrawFrame() OVERRIDE {
257 test_hooks_->DidCommitAndDrawFrame(); 249 test_hooks_->DidCommitAndDrawFrame();
258 } 250 }
259 251
260 virtual void DidCompleteSwapBuffers() OVERRIDE { 252 virtual void DidCompleteSwapBuffers() OVERRIDE {
261 test_hooks_->DidCompleteSwapBuffers(); 253 test_hooks_->DidCompleteSwapBuffers();
262 } 254 }
263 255
264 virtual void ScheduleComposite() OVERRIDE { 256 virtual void ScheduleComposite() OVERRIDE {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 303 }
312 304
313 virtual void SetNeedsCommit() OVERRIDE { 305 virtual void SetNeedsCommit() OVERRIDE {
314 if (!test_started_) 306 if (!test_started_)
315 return; 307 return;
316 LayerTreeHost::SetNeedsCommit(); 308 LayerTreeHost::SetNeedsCommit();
317 } 309 }
318 310
319 void set_test_started(bool started) { test_started_ = started; } 311 void set_test_started(bool started) { test_started_ = started; }
320 312
321 virtual void DidDeferCommit() OVERRIDE { 313 virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); }
322 test_hooks_->DidDeferCommit();
323 }
324 314
325 private: 315 private:
326 LayerTreeHostForTesting(TestHooks* test_hooks, 316 LayerTreeHostForTesting(TestHooks* test_hooks,
327 LayerTreeHostClient* client, 317 LayerTreeHostClient* client,
328 const LayerTreeSettings& settings) 318 const LayerTreeSettings& settings)
329 : LayerTreeHost(client, NULL, settings), 319 : LayerTreeHost(client, NULL, settings),
330 test_hooks_(test_hooks), 320 test_hooks_(test_hooks),
331 test_started_(false) {} 321 test_started_(false) {}
332 322
333 TestHooks* test_hooks_; 323 TestHooks* test_hooks_;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 SetupTree(); 471 SetupTree();
482 WillBeginTest(); 472 WillBeginTest();
483 BeginTest(); 473 BeginTest();
484 beginning_ = false; 474 beginning_ = false;
485 if (end_when_begin_returns_) 475 if (end_when_begin_returns_)
486 RealEndTest(); 476 RealEndTest();
487 477
488 // Allow commits to happen once BeginTest() has had a chance to post tasks 478 // Allow commits to happen once BeginTest() has had a chance to post tasks
489 // so that those tasks will happen before the first commit. 479 // so that those tasks will happen before the first commit.
490 if (layer_tree_host_) { 480 if (layer_tree_host_) {
491 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> 481 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())
492 set_test_started(true); 482 ->set_test_started(true);
493 } 483 }
494 } 484 }
495 485
496 void LayerTreeTest::SetupTree() { 486 void LayerTreeTest::SetupTree() {
497 if (!layer_tree_host_->root_layer()) { 487 if (!layer_tree_host_->root_layer()) {
498 scoped_refptr<Layer> root_layer = Layer::Create(); 488 scoped_refptr<Layer> root_layer = Layer::Create();
499 root_layer->SetAnchorPoint(gfx::PointF()); 489 root_layer->SetAnchorPoint(gfx::PointF());
500 root_layer->SetBounds(gfx::Size(1, 1)); 490 root_layer->SetBounds(gfx::Size(1, 1));
501 root_layer->SetIsDrawable(true); 491 root_layer->SetIsDrawable(true);
502 layer_tree_host_->SetRootLayer(root_layer); 492 layer_tree_host_->SetRootLayer(root_layer);
(...skipping 28 matching lines...) Expand all
531 } 521 }
532 522
533 base::MessageLoop::current()->Quit(); 523 base::MessageLoop::current()->Quit();
534 } 524 }
535 525
536 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, 526 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation,
537 double animation_duration) { 527 double animation_duration) {
538 DCHECK(!proxy() || proxy()->IsMainThread()); 528 DCHECK(!proxy() || proxy()->IsMainThread());
539 529
540 if (layer_to_receive_animation) { 530 if (layer_to_receive_animation) {
541 AddOpacityTransitionToLayer(layer_to_receive_animation, 531 AddOpacityTransitionToLayer(
542 animation_duration, 532 layer_to_receive_animation, animation_duration, 0, 0.5, true);
543 0,
544 0.5,
545 true);
546 } 533 }
547 } 534 }
548 535
549 void LayerTreeTest::DispatchSetNeedsCommit() { 536 void LayerTreeTest::DispatchSetNeedsCommit() {
550 DCHECK(!proxy() || proxy()->IsMainThread()); 537 DCHECK(!proxy() || proxy()->IsMainThread());
551 538
552 if (layer_tree_host_) 539 if (layer_tree_host_)
553 layer_tree_host_->SetNeedsCommit(); 540 layer_tree_host_->SetNeedsCommit();
554 } 541 }
555 542
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 } 625 }
639 626
640 main_task_runner_ = base::MessageLoopProxy::current(); 627 main_task_runner_ = base::MessageLoopProxy::current();
641 628
642 delegating_renderer_ = delegating_renderer; 629 delegating_renderer_ = delegating_renderer;
643 630
644 // Spend less time waiting for BeginImplFrame because the output is 631 // Spend less time waiting for BeginImplFrame because the output is
645 // mocked out. 632 // mocked out.
646 settings_.refresh_rate = 200.0; 633 settings_.refresh_rate = 200.0;
647 if (impl_side_painting) { 634 if (impl_side_painting) {
648 DCHECK(threaded) << 635 DCHECK(threaded)
649 "Don't run single thread + impl side painting, it doesn't exist."; 636 << "Don't run single thread + impl side painting, it doesn't exist.";
650 settings_.impl_side_painting = true; 637 settings_.impl_side_painting = true;
651 } 638 }
652 InitializeSettings(&settings_); 639 InitializeSettings(&settings_);
653 640
654 main_task_runner_->PostTask( 641 main_task_runner_->PostTask(
655 FROM_HERE, 642 FROM_HERE,
656 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); 643 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this)));
657 644
658 if (timeout_seconds_) { 645 if (timeout_seconds_) {
659 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); 646 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this)));
(...skipping 17 matching lines...) Expand all
677 return; 664 return;
678 } 665 }
679 AfterTest(); 666 AfterTest();
680 } 667 }
681 668
682 void LayerTreeTest::RunTestWithImplSidePainting() { 669 void LayerTreeTest::RunTestWithImplSidePainting() {
683 RunTest(true, false, true); 670 RunTest(true, false, true);
684 } 671 }
685 672
686 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { 673 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) {
687 scoped_ptr<FakeOutputSurface> output_surface; 674 scoped_ptr<FakeOutputSurface> output_surface =
688 if (delegating_renderer_) 675 CreateFakeOutputSurfaceForTest(fallback);
689 output_surface = FakeOutputSurface::CreateDelegating3d(); 676
690 else
691 output_surface = FakeOutputSurface::Create3d();
692 output_surface_ = output_surface.get(); 677 output_surface_ = output_surface.get();
693 return output_surface.PassAs<OutputSurface>(); 678 return output_surface.PassAs<OutputSurface>();
694 } 679 }
695 680
681 scoped_ptr<FakeOutputSurface> LayerTreeTest::CreateFakeOutputSurfaceForTest(
682 bool fallback) {
683 if (delegating_renderer_)
684 return FakeOutputSurface::CreateDelegating3d();
685 else
686 return FakeOutputSurface::Create3d();
687 }
688
696 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { 689 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() {
697 if (!compositor_contexts_.get() || 690 if (!compositor_contexts_.get() ||
698 compositor_contexts_->DestroyedOnMainThread()) 691 compositor_contexts_->DestroyedOnMainThread())
699 compositor_contexts_ = TestContextProvider::Create(); 692 compositor_contexts_ = TestContextProvider::Create();
700 return compositor_contexts_; 693 return compositor_contexts_;
701 } 694 }
702 695
696 TestWebGraphicsContext3D* LayerTreeTest::TestContext() {
697 return static_cast<TestContextProvider*>(
danakj 2014/01/09 21:23:34 can you DCHECK we're on the impl side here? or ma
jamesr 2014/01/10 00:12:34 That'd mean downcasting here instead of relying on
danakj 2014/01/13 19:36:42 I see, that's a good point.
698 output_surface_->context_provider().get())->TestContext3d();
699 }
700
703 } // namespace cc 701 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698