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

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
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/test_context_provider.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 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 215
220 virtual void DidBeginMainFrame() OVERRIDE { 216 virtual void DidBeginMainFrame() OVERRIDE {
221 test_hooks_->DidBeginMainFrame(); 217 test_hooks_->DidBeginMainFrame();
222 } 218 }
223 219
224 virtual void Animate(double monotonic_time) OVERRIDE { 220 virtual void Animate(double monotonic_time) OVERRIDE {
225 test_hooks_->Animate(base::TimeTicks::FromInternalValue( 221 test_hooks_->Animate(base::TimeTicks::FromInternalValue(
226 monotonic_time * base::Time::kMicrosecondsPerSecond)); 222 monotonic_time * base::Time::kMicrosecondsPerSecond));
227 } 223 }
228 224
229 virtual void Layout() OVERRIDE { 225 virtual void Layout() OVERRIDE { test_hooks_->Layout(); }
230 test_hooks_->Layout();
231 }
232 226
233 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 227 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta,
234 float scale) OVERRIDE { 228 float scale) OVERRIDE {
235 test_hooks_->ApplyScrollAndScale(scroll_delta, scale); 229 test_hooks_->ApplyScrollAndScale(scroll_delta, scale);
236 } 230 }
237 231
238 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) 232 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
239 OVERRIDE { 233 OVERRIDE {
240 return test_hooks_->CreateOutputSurface(fallback); 234 return test_hooks_->CreateOutputSurface(fallback);
241 } 235 }
242 236
243 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { 237 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE {
244 test_hooks_->DidInitializeOutputSurface(succeeded); 238 test_hooks_->DidInitializeOutputSurface(succeeded);
245 } 239 }
246 240
247 virtual void DidFailToInitializeOutputSurface() OVERRIDE { 241 virtual void DidFailToInitializeOutputSurface() OVERRIDE {
248 test_hooks_->DidFailToInitializeOutputSurface(); 242 test_hooks_->DidFailToInitializeOutputSurface();
249 } 243 }
250 244
251 virtual void WillCommit() OVERRIDE { test_hooks_->WillCommit(); } 245 virtual void WillCommit() OVERRIDE { test_hooks_->WillCommit(); }
252 246
253 virtual void DidCommit() OVERRIDE { 247 virtual void DidCommit() OVERRIDE { test_hooks_->DidCommit(); }
254 test_hooks_->DidCommit();
255 }
256 248
257 virtual void DidCommitAndDrawFrame() OVERRIDE { 249 virtual void DidCommitAndDrawFrame() OVERRIDE {
258 test_hooks_->DidCommitAndDrawFrame(); 250 test_hooks_->DidCommitAndDrawFrame();
259 } 251 }
260 252
261 virtual void DidCompleteSwapBuffers() OVERRIDE { 253 virtual void DidCompleteSwapBuffers() OVERRIDE {
262 test_hooks_->DidCompleteSwapBuffers(); 254 test_hooks_->DidCompleteSwapBuffers();
263 } 255 }
264 256
265 virtual void ScheduleComposite() OVERRIDE { 257 virtual void ScheduleComposite() OVERRIDE {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 304 }
313 305
314 virtual void SetNeedsCommit() OVERRIDE { 306 virtual void SetNeedsCommit() OVERRIDE {
315 if (!test_started_) 307 if (!test_started_)
316 return; 308 return;
317 LayerTreeHost::SetNeedsCommit(); 309 LayerTreeHost::SetNeedsCommit();
318 } 310 }
319 311
320 void set_test_started(bool started) { test_started_ = started; } 312 void set_test_started(bool started) { test_started_ = started; }
321 313
322 virtual void DidDeferCommit() OVERRIDE { 314 virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); }
323 test_hooks_->DidDeferCommit();
324 }
325 315
326 private: 316 private:
327 LayerTreeHostForTesting(TestHooks* test_hooks, 317 LayerTreeHostForTesting(TestHooks* test_hooks,
328 LayerTreeHostClient* client, 318 LayerTreeHostClient* client,
329 const LayerTreeSettings& settings) 319 const LayerTreeSettings& settings)
330 : LayerTreeHost(client, NULL, settings), 320 : LayerTreeHost(client, NULL, settings),
331 test_hooks_(test_hooks), 321 test_hooks_(test_hooks),
332 test_started_(false) {} 322 test_started_(false) {}
333 323
334 TestHooks* test_hooks_; 324 TestHooks* test_hooks_;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 SetupTree(); 473 SetupTree();
484 WillBeginTest(); 474 WillBeginTest();
485 BeginTest(); 475 BeginTest();
486 beginning_ = false; 476 beginning_ = false;
487 if (end_when_begin_returns_) 477 if (end_when_begin_returns_)
488 RealEndTest(); 478 RealEndTest();
489 479
490 // Allow commits to happen once BeginTest() has had a chance to post tasks 480 // Allow commits to happen once BeginTest() has had a chance to post tasks
491 // so that those tasks will happen before the first commit. 481 // so that those tasks will happen before the first commit.
492 if (layer_tree_host_) { 482 if (layer_tree_host_) {
493 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> 483 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())
494 set_test_started(true); 484 ->set_test_started(true);
495 } 485 }
496 } 486 }
497 487
498 void LayerTreeTest::SetupTree() { 488 void LayerTreeTest::SetupTree() {
499 if (!layer_tree_host_->root_layer()) { 489 if (!layer_tree_host_->root_layer()) {
500 scoped_refptr<Layer> root_layer = Layer::Create(); 490 scoped_refptr<Layer> root_layer = Layer::Create();
501 root_layer->SetAnchorPoint(gfx::PointF()); 491 root_layer->SetAnchorPoint(gfx::PointF());
502 root_layer->SetBounds(gfx::Size(1, 1)); 492 root_layer->SetBounds(gfx::Size(1, 1));
503 root_layer->SetIsDrawable(true); 493 root_layer->SetIsDrawable(true);
504 layer_tree_host_->SetRootLayer(root_layer); 494 layer_tree_host_->SetRootLayer(root_layer);
(...skipping 28 matching lines...) Expand all
533 } 523 }
534 524
535 base::MessageLoop::current()->Quit(); 525 base::MessageLoop::current()->Quit();
536 } 526 }
537 527
538 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, 528 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation,
539 double animation_duration) { 529 double animation_duration) {
540 DCHECK(!proxy() || proxy()->IsMainThread()); 530 DCHECK(!proxy() || proxy()->IsMainThread());
541 531
542 if (layer_to_receive_animation) { 532 if (layer_to_receive_animation) {
543 AddOpacityTransitionToLayer(layer_to_receive_animation, 533 AddOpacityTransitionToLayer(
544 animation_duration, 534 layer_to_receive_animation, animation_duration, 0, 0.5, true);
545 0,
546 0.5,
547 true);
548 } 535 }
549 } 536 }
550 537
551 void LayerTreeTest::DispatchSetNeedsCommit() { 538 void LayerTreeTest::DispatchSetNeedsCommit() {
552 DCHECK(!proxy() || proxy()->IsMainThread()); 539 DCHECK(!proxy() || proxy()->IsMainThread());
553 540
554 if (layer_tree_host_) 541 if (layer_tree_host_)
555 layer_tree_host_->SetNeedsCommit(); 542 layer_tree_host_->SetNeedsCommit();
556 } 543 }
557 544
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 627 }
641 628
642 main_task_runner_ = base::MessageLoopProxy::current(); 629 main_task_runner_ = base::MessageLoopProxy::current();
643 630
644 delegating_renderer_ = delegating_renderer; 631 delegating_renderer_ = delegating_renderer;
645 632
646 // Spend less time waiting for BeginImplFrame because the output is 633 // Spend less time waiting for BeginImplFrame because the output is
647 // mocked out. 634 // mocked out.
648 settings_.refresh_rate = 200.0; 635 settings_.refresh_rate = 200.0;
649 if (impl_side_painting) { 636 if (impl_side_painting) {
650 DCHECK(threaded) << 637 DCHECK(threaded)
651 "Don't run single thread + impl side painting, it doesn't exist."; 638 << "Don't run single thread + impl side painting, it doesn't exist.";
652 settings_.impl_side_painting = true; 639 settings_.impl_side_painting = true;
653 } 640 }
654 InitializeSettings(&settings_); 641 InitializeSettings(&settings_);
655 642
656 main_task_runner_->PostTask( 643 main_task_runner_->PostTask(
657 FROM_HERE, 644 FROM_HERE,
658 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); 645 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this)));
659 646
660 if (timeout_seconds_) { 647 if (timeout_seconds_) {
661 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); 648 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this)));
(...skipping 17 matching lines...) Expand all
679 return; 666 return;
680 } 667 }
681 AfterTest(); 668 AfterTest();
682 } 669 }
683 670
684 void LayerTreeTest::RunTestWithImplSidePainting() { 671 void LayerTreeTest::RunTestWithImplSidePainting() {
685 RunTest(true, false, true); 672 RunTest(true, false, true);
686 } 673 }
687 674
688 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { 675 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) {
689 scoped_ptr<FakeOutputSurface> output_surface; 676 scoped_ptr<FakeOutputSurface> output_surface =
690 if (delegating_renderer_) 677 CreateFakeOutputSurfaceForTest(fallback);
691 output_surface = FakeOutputSurface::CreateDelegating3d(); 678
692 else
693 output_surface = FakeOutputSurface::Create3d();
694 output_surface_ = output_surface.get(); 679 output_surface_ = output_surface.get();
695 return output_surface.PassAs<OutputSurface>(); 680 return output_surface.PassAs<OutputSurface>();
696 } 681 }
697 682
683 scoped_ptr<FakeOutputSurface> LayerTreeTest::CreateFakeOutputSurfaceForTest(
684 bool fallback) {
685 if (delegating_renderer_)
686 return FakeOutputSurface::CreateDelegating3d();
687 else
688 return FakeOutputSurface::Create3d();
689 }
690
698 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { 691 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() {
699 if (!compositor_contexts_.get() || 692 if (!compositor_contexts_.get() ||
700 compositor_contexts_->DestroyedOnMainThread()) 693 compositor_contexts_->DestroyedOnMainThread())
701 compositor_contexts_ = TestContextProvider::Create(); 694 compositor_contexts_ = TestContextProvider::Create();
702 return compositor_contexts_; 695 return compositor_contexts_;
703 } 696 }
704 697
698 TestWebGraphicsContext3D* LayerTreeTest::TestContext() {
699 return static_cast<TestContextProvider*>(
700 output_surface_->context_provider().get())->TestContext3d();
701 }
702
705 } // namespace cc 703 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/test_context_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698