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

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

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 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
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/push_properties_counting_layer.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 "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 inner_viewport_container_layer->id()); 60 inner_viewport_container_layer->id());
61 outer_scroll_layer->SetScrollClipLayerId( 61 outer_scroll_layer->SetScrollClipLayerId(
62 outer_viewport_container_layer->id()); 62 outer_viewport_container_layer->id());
63 63
64 inner_viewport_container_layer->SetBounds(inner_bounds); 64 inner_viewport_container_layer->SetBounds(inner_bounds);
65 inner_viewport_scroll_layer->SetBounds(outer_bounds); 65 inner_viewport_scroll_layer->SetBounds(outer_bounds);
66 outer_viewport_container_layer->SetBounds(outer_bounds); 66 outer_viewport_container_layer->SetBounds(outer_bounds);
67 67
68 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); 68 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
69 outer_scroll_layer->SetIsContainerForFixedPositionLayers(true); 69 outer_scroll_layer->SetIsContainerForFixedPositionLayers(true);
70 host->GetLayerTree()->RegisterViewportLayers( 70 host->RegisterViewportLayers(overscroll_elasticity_layer, page_scale_layer,
71 overscroll_elasticity_layer, page_scale_layer, 71 inner_viewport_scroll_layer, outer_scroll_layer);
72 inner_viewport_scroll_layer, outer_scroll_layer);
73 } 72 }
74 73
75 void CreateVirtualViewportLayers(Layer* root_layer, 74 void CreateVirtualViewportLayers(Layer* root_layer,
76 const gfx::Size& inner_bounds, 75 const gfx::Size& inner_bounds,
77 const gfx::Size& outer_bounds, 76 const gfx::Size& outer_bounds,
78 const gfx::Size& scroll_bounds, 77 const gfx::Size& scroll_bounds,
79 LayerTreeHost* host) { 78 LayerTreeHost* host) {
80 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); 79 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create();
81 80
82 outer_viewport_scroll_layer->SetBounds(scroll_bounds); 81 outer_viewport_scroll_layer->SetBounds(scroll_bounds);
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 626
628 // Allow commits to happen once BeginTest() has had a chance to post tasks 627 // Allow commits to happen once BeginTest() has had a chance to post tasks
629 // so that those tasks will happen before the first commit. 628 // so that those tasks will happen before the first commit.
630 if (layer_tree_host_) { 629 if (layer_tree_host_) {
631 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get()) 630 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())
632 ->set_test_started(true); 631 ->set_test_started(true);
633 } 632 }
634 } 633 }
635 634
636 void LayerTreeTest::SetupTree() { 635 void LayerTreeTest::SetupTree() {
637 if (!layer_tree()->root_layer()) { 636 if (!layer_tree_host()->root_layer()) {
638 scoped_refptr<Layer> root_layer = Layer::Create(); 637 scoped_refptr<Layer> root_layer = Layer::Create();
639 root_layer->SetBounds(gfx::Size(1, 1)); 638 root_layer->SetBounds(gfx::Size(1, 1));
640 layer_tree()->SetRootLayer(root_layer); 639 layer_tree_host()->SetRootLayer(root_layer);
641 } 640 }
642 641
643 gfx::Size root_bounds = layer_tree()->root_layer()->bounds(); 642 gfx::Size root_bounds = layer_tree_host()->root_layer()->bounds();
644 gfx::Size device_root_bounds = 643 gfx::Size device_root_bounds = gfx::ScaleToCeiledSize(
645 gfx::ScaleToCeiledSize(root_bounds, layer_tree()->device_scale_factor()); 644 root_bounds, layer_tree_host()->device_scale_factor());
646 layer_tree()->SetViewportSize(device_root_bounds); 645 layer_tree_host()->SetViewportSize(device_root_bounds);
647 layer_tree()->root_layer()->SetIsDrawable(true); 646 layer_tree_host()->root_layer()->SetIsDrawable(true);
648 } 647 }
649 648
650 void LayerTreeTest::Timeout() { 649 void LayerTreeTest::Timeout() {
651 timed_out_ = true; 650 timed_out_ = true;
652 EndTest(); 651 EndTest();
653 } 652 }
654 653
655 void LayerTreeTest::RealEndTest() { 654 void LayerTreeTest::RealEndTest() {
656 // TODO(mithro): Make this method only end when not inside an impl frame. 655 // TODO(mithro): Make this method only end when not inside an impl frame.
657 bool main_frame_will_happen = 656 bool main_frame_will_happen =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 void LayerTreeTest::DispatchSetNeedsUpdateLayers() { 694 void LayerTreeTest::DispatchSetNeedsUpdateLayers() {
696 DCHECK(main_task_runner_->BelongsToCurrentThread()); 695 DCHECK(main_task_runner_->BelongsToCurrentThread());
697 if (layer_tree_host_) 696 if (layer_tree_host_)
698 layer_tree_host_->SetNeedsUpdateLayers(); 697 layer_tree_host_->SetNeedsUpdateLayers();
699 } 698 }
700 699
701 void LayerTreeTest::DispatchSetNeedsRedraw() { 700 void LayerTreeTest::DispatchSetNeedsRedraw() {
702 DCHECK(main_task_runner_->BelongsToCurrentThread()); 701 DCHECK(main_task_runner_->BelongsToCurrentThread());
703 if (layer_tree_host_) 702 if (layer_tree_host_)
704 DispatchSetNeedsRedrawRect( 703 DispatchSetNeedsRedrawRect(
705 gfx::Rect(layer_tree_host_->GetLayerTree()->device_viewport_size())); 704 gfx::Rect(layer_tree_host_->device_viewport_size()));
706 } 705 }
707 706
708 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) { 707 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) {
709 DCHECK(main_task_runner_->BelongsToCurrentThread()); 708 DCHECK(main_task_runner_->BelongsToCurrentThread());
710 if (layer_tree_host_) 709 if (layer_tree_host_)
711 layer_tree_host_->SetNeedsRedrawRect(damage_rect); 710 layer_tree_host_->SetNeedsRedrawRect(damage_rect);
712 } 711 }
713 712
714 void LayerTreeTest::DispatchSetVisible(bool visible) { 713 void LayerTreeTest::DispatchSetVisible(bool visible) {
715 DCHECK(main_task_runner_->BelongsToCurrentThread()); 714 DCHECK(main_task_runner_->BelongsToCurrentThread());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 805 }
807 806
808 std::unique_ptr<OutputSurface> 807 std::unique_ptr<OutputSurface>
809 LayerTreeTest::CreateDisplayOutputSurfaceOnThread( 808 LayerTreeTest::CreateDisplayOutputSurfaceOnThread(
810 scoped_refptr<ContextProvider> compositor_context_provider) { 809 scoped_refptr<ContextProvider> compositor_context_provider) {
811 // By default the Display shares a context with the LayerTreeHostImpl. 810 // By default the Display shares a context with the LayerTreeHostImpl.
812 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); 811 return FakeOutputSurface::Create3d(std::move(compositor_context_provider));
813 } 812 }
814 813
815 void LayerTreeTest::DestroyLayerTreeHost() { 814 void LayerTreeTest::DestroyLayerTreeHost() {
816 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer()) 815 if (layer_tree_host_ && layer_tree_host_->root_layer())
817 layer_tree_host_->GetLayerTree()->root_layer()->SetLayerTreeHost(NULL); 816 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
818 layer_tree_host_ = nullptr; 817 layer_tree_host_ = nullptr;
819 } 818 }
820 819
821 TaskRunnerProvider* LayerTreeTest::task_runner_provider() const { 820 TaskRunnerProvider* LayerTreeTest::task_runner_provider() const {
822 LayerTreeHost* host = layer_tree_host_.get(); 821 LayerTreeHost* host = layer_tree_host_.get();
823 822
824 // If this fails, the test has ended and there is no task runners to find 823 // If this fails, the test has ended and there is no task runners to find
825 // anymore. 824 // anymore.
826 DCHECK(host); 825 DCHECK(host);
827 826
828 return host->GetTaskRunnerProvider(); 827 return host->GetTaskRunnerProvider();
829 } 828 }
830 829
831 LayerTreeHost* LayerTreeTest::layer_tree_host() { 830 LayerTreeHost* LayerTreeTest::layer_tree_host() {
832 DCHECK(task_runner_provider()->IsMainThread() || 831 DCHECK(task_runner_provider()->IsMainThread() ||
833 task_runner_provider()->IsMainThreadBlocked()); 832 task_runner_provider()->IsMainThreadBlocked());
834 return layer_tree_host_.get(); 833 return layer_tree_host_.get();
835 } 834 }
836 835
837 Proxy* LayerTreeTest::proxy() { 836 Proxy* LayerTreeTest::proxy() {
838 return layer_tree_host() ? layer_tree_host()->proxy() : NULL; 837 return layer_tree_host() ? layer_tree_host()->proxy() : NULL;
839 } 838 }
840 839
841 } // namespace cc 840 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/push_properties_counting_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698