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

Side by Side Diff: cc/layers/scrollbar_layer_unittest.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/layers/picture_layer_unittest.cc ('k') | cc/layers/surface_layer_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 fake_ui_resource_manager = 124 fake_ui_resource_manager =
125 base::MakeUnique<FakeResourceTrackingUIResourceManager>(); 125 base::MakeUnique<FakeResourceTrackingUIResourceManager>();
126 fake_ui_resource_manager_ = fake_ui_resource_manager.get(); 126 fake_ui_resource_manager_ = fake_ui_resource_manager.get();
127 127
128 layer_tree_host_.reset(new FakeLayerTreeHost( 128 layer_tree_host_.reset(new FakeLayerTreeHost(
129 &fake_client_, &params, CompositorMode::SINGLE_THREADED)); 129 &fake_client_, &params, CompositorMode::SINGLE_THREADED));
130 layer_tree_host_->SetUIResourceManagerForTesting( 130 layer_tree_host_->SetUIResourceManagerForTesting(
131 std::move(fake_ui_resource_manager)); 131 std::move(fake_ui_resource_manager));
132 layer_tree_host_->InitializeSingleThreaded( 132 layer_tree_host_->InitializeSingleThreaded(
133 &single_thread_client_, base::ThreadTaskRunnerHandle::Get()); 133 &single_thread_client_, base::ThreadTaskRunnerHandle::Get());
134 layer_tree_ = layer_tree_host_->GetLayerTree();
135 layer_tree_host_->SetVisible(true); 134 layer_tree_host_->SetVisible(true);
136 fake_client_.SetLayerTreeHost(layer_tree_host_.get()); 135 fake_client_.SetLayerTreeHost(layer_tree_host_.get());
137 } 136 }
138 137
139 LayerImpl* LayerImplForScrollAreaAndScrollbar( 138 LayerImpl* LayerImplForScrollAreaAndScrollbar(
140 FakeLayerTreeHost* host, 139 FakeLayerTreeHost* host,
141 std::unique_ptr<Scrollbar> scrollbar, 140 std::unique_ptr<Scrollbar> scrollbar,
142 bool reverse_order, 141 bool reverse_order,
143 bool use_solid_color_scrollbar, 142 bool use_solid_color_scrollbar,
144 int thumb_thickness, 143 int thumb_thickness,
(...skipping 19 matching lines...) Expand all
164 } 163 }
165 164
166 protected: 165 protected:
167 FakeResourceTrackingUIResourceManager* fake_ui_resource_manager_; 166 FakeResourceTrackingUIResourceManager* fake_ui_resource_manager_;
168 FakeLayerTreeHostClient fake_client_; 167 FakeLayerTreeHostClient fake_client_;
169 StubLayerTreeHostSingleThreadClient single_thread_client_; 168 StubLayerTreeHostSingleThreadClient single_thread_client_;
170 TestTaskGraphRunner task_graph_runner_; 169 TestTaskGraphRunner task_graph_runner_;
171 LayerTreeSettings layer_tree_settings_; 170 LayerTreeSettings layer_tree_settings_;
172 std::unique_ptr<AnimationHost> animation_host_; 171 std::unique_ptr<AnimationHost> animation_host_;
173 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; 172 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_;
174 LayerTree* layer_tree_;
175 int scrollbar_layer_id_; 173 int scrollbar_layer_id_;
176 }; 174 };
177 175
178 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { 176 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) {
179 // Create and attach a non-overlay scrollbar. 177 // Create and attach a non-overlay scrollbar.
180 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); 178 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar);
181 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( 179 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar(
182 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); 180 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0);
183 PaintedScrollbarLayerImpl* scrollbar_layer_impl = 181 PaintedScrollbarLayerImpl* scrollbar_layer_impl =
184 static_cast<PaintedScrollbarLayerImpl*>( 182 static_cast<PaintedScrollbarLayerImpl*>(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( 224 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create(
227 std::move(scrollbar), layer_tree_root->id()); 225 std::move(scrollbar), layer_tree_root->id());
228 226
229 // Choose bounds to give max_scroll_offset = (30, 50). 227 // Choose bounds to give max_scroll_offset = (30, 50).
230 layer_tree_root->SetBounds(gfx::Size(70, 150)); 228 layer_tree_root->SetBounds(gfx::Size(70, 150));
231 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); 229 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
232 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); 230 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
233 scroll_layer->SetBounds(gfx::Size(100, 200)); 231 scroll_layer->SetBounds(gfx::Size(100, 200));
234 content_layer->SetBounds(gfx::Size(100, 200)); 232 content_layer->SetBounds(gfx::Size(100, 200));
235 233
236 layer_tree_->SetRootLayer(layer_tree_root); 234 layer_tree_host_->SetRootLayer(layer_tree_root);
237 layer_tree_root->AddChild(scroll_layer); 235 layer_tree_root->AddChild(scroll_layer);
238 scroll_layer->AddChild(content_layer); 236 scroll_layer->AddChild(content_layer);
239 layer_tree_root->AddChild(scrollbar_layer); 237 layer_tree_root->AddChild(scrollbar_layer);
240 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); 238 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
241 239
242 layer_tree_root->SavePaintProperties(); 240 layer_tree_root->SavePaintProperties();
243 content_layer->SavePaintProperties(); 241 content_layer->SavePaintProperties();
244 layer_tree_host_->UpdateLayers(); 242 layer_tree_host_->UpdateLayers();
245 LayerImpl* layer_impl_tree_root = 243 LayerImpl* layer_impl_tree_root =
246 layer_tree_host_->CommitAndCreateLayerImplTree(); 244 layer_tree_host_->CommitAndCreateLayerImplTree();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 scoped_refptr<Layer> content_layer = Layer::Create(); 292 scoped_refptr<Layer> content_layer = Layer::Create();
295 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 293 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
296 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); 294 FakePaintedScrollbarLayer::Create(false, true, root_layer->id());
297 295
298 root_layer->SetScrollClipLayerId(root_clip_layer->id()); 296 root_layer->SetScrollClipLayerId(root_clip_layer->id());
299 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). 297 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0).
300 root_clip_layer->SetBounds(gfx::Size(20, 50)); 298 root_clip_layer->SetBounds(gfx::Size(20, 50));
301 root_layer->SetBounds(gfx::Size(100, 50)); 299 root_layer->SetBounds(gfx::Size(100, 50));
302 content_layer->SetBounds(gfx::Size(100, 50)); 300 content_layer->SetBounds(gfx::Size(100, 50));
303 301
304 layer_tree_->SetRootLayer(root_clip_layer); 302 layer_tree_host_->SetRootLayer(root_clip_layer);
305 root_clip_layer->AddChild(root_layer); 303 root_clip_layer->AddChild(root_layer);
306 root_layer->AddChild(content_layer); 304 root_layer->AddChild(content_layer);
307 root_layer->AddChild(scrollbar_layer); 305 root_layer->AddChild(scrollbar_layer);
308 306
309 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); 307 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0));
310 scrollbar_layer->SetBounds(gfx::Size(70, 10)); 308 scrollbar_layer->SetBounds(gfx::Size(70, 10));
311 scrollbar_layer->SetScrollLayer(root_layer->id()); 309 scrollbar_layer->SetScrollLayer(root_layer->id());
312 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); 310 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10));
313 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); 311 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10));
314 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); 312 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10);
(...skipping 18 matching lines...) Expand all
333 scoped_refptr<Layer> content_layer = Layer::Create(); 331 scoped_refptr<Layer> content_layer = Layer::Create();
334 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 332 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
335 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); 333 FakePaintedScrollbarLayer::Create(false, true, root_layer->id());
336 334
337 root_layer->SetScrollClipLayerId(root_clip_layer->id()); 335 root_layer->SetScrollClipLayerId(root_clip_layer->id());
338 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). 336 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0).
339 root_clip_layer->SetBounds(gfx::Size(20, 50)); 337 root_clip_layer->SetBounds(gfx::Size(20, 50));
340 root_layer->SetBounds(gfx::Size(100, 50)); 338 root_layer->SetBounds(gfx::Size(100, 50));
341 content_layer->SetBounds(gfx::Size(100, 50)); 339 content_layer->SetBounds(gfx::Size(100, 50));
342 340
343 layer_tree_->SetRootLayer(root_clip_layer); 341 layer_tree_host_->SetRootLayer(root_clip_layer);
344 root_clip_layer->AddChild(root_layer); 342 root_clip_layer->AddChild(root_layer);
345 root_layer->AddChild(content_layer); 343 root_layer->AddChild(content_layer);
346 root_layer->AddChild(scrollbar_layer); 344 root_layer->AddChild(scrollbar_layer);
347 345
348 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); 346 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0));
349 scrollbar_layer->SetBounds(gfx::Size(70, 10)); 347 scrollbar_layer->SetBounds(gfx::Size(70, 10));
350 scrollbar_layer->SetScrollLayer(root_layer->id()); 348 scrollbar_layer->SetScrollLayer(root_layer->id());
351 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); 349 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10));
352 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); 350 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10));
353 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); 351 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 scoped_refptr<Layer> root_clip_layer = Layer::Create(); 406 scoped_refptr<Layer> root_clip_layer = Layer::Create();
409 scoped_refptr<Layer> root_layer = Layer::Create(); 407 scoped_refptr<Layer> root_layer = Layer::Create();
410 // Create an overlay left side vertical scrollbar. 408 // Create an overlay left side vertical scrollbar.
411 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 409 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
412 FakePaintedScrollbarLayer::Create(false, true, VERTICAL, true, true, 410 FakePaintedScrollbarLayer::Create(false, true, VERTICAL, true, true,
413 root_layer->id()); 411 root_layer->id());
414 root_layer->SetScrollClipLayerId(root_clip_layer->id()); 412 root_layer->SetScrollClipLayerId(root_clip_layer->id());
415 root_clip_layer->SetBounds(gfx::Size(50, 20)); 413 root_clip_layer->SetBounds(gfx::Size(50, 20));
416 root_layer->SetBounds(gfx::Size(50, 100)); 414 root_layer->SetBounds(gfx::Size(50, 100));
417 415
418 layer_tree_->SetRootLayer(root_clip_layer); 416 layer_tree_host_->SetRootLayer(root_clip_layer);
419 root_clip_layer->AddChild(root_layer); 417 root_clip_layer->AddChild(root_layer);
420 root_layer->AddChild(scrollbar_layer); 418 root_layer->AddChild(scrollbar_layer);
421 419
422 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); 420 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0));
423 scrollbar_layer->SetBounds(gfx::Size(10, 20)); 421 scrollbar_layer->SetBounds(gfx::Size(10, 20));
424 scrollbar_layer->SetScrollLayer(root_layer->id()); 422 scrollbar_layer->SetScrollLayer(root_layer->id());
425 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(0, 0, 10, 20)); 423 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(0, 0, 10, 20));
426 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); 424 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10);
427 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); 425 scrollbar_layer->fake_scrollbar()->set_thumb_length(4);
428 layer_tree_host_->UpdateLayers(); 426 layer_tree_host_->UpdateLayers();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 scoped_refptr<Layer> child1 = Layer::Create(); 526 scoped_refptr<Layer> child1 = Layer::Create();
529 scoped_refptr<Layer> child2; 527 scoped_refptr<Layer> child2;
530 const bool kIsLeftSideVerticalScrollbar = false; 528 const bool kIsLeftSideVerticalScrollbar = false;
531 child2 = SolidColorScrollbarLayer::Create( 529 child2 = SolidColorScrollbarLayer::Create(
532 scrollbar->Orientation(), kThumbThickness, kTrackStart, 530 scrollbar->Orientation(), kThumbThickness, kTrackStart,
533 kIsLeftSideVerticalScrollbar, child1->id()); 531 kIsLeftSideVerticalScrollbar, child1->id());
534 child2->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); 532 child2->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
535 scroll_layer->AddChild(child1); 533 scroll_layer->AddChild(child1);
536 scroll_layer->InsertChild(child2, 1); 534 scroll_layer->InsertChild(child2, 1);
537 layer_tree_root->AddChild(scroll_layer); 535 layer_tree_root->AddChild(scroll_layer);
538 layer_tree_->SetRootLayer(layer_tree_root); 536 layer_tree_host_->SetRootLayer(layer_tree_root);
539 537
540 // Choose layer bounds to give max_scroll_offset = (8, 8). 538 // Choose layer bounds to give max_scroll_offset = (8, 8).
541 layer_tree_root->SetBounds(gfx::Size(2, 2)); 539 layer_tree_root->SetBounds(gfx::Size(2, 2));
542 scroll_layer->SetBounds(gfx::Size(10, 10)); 540 scroll_layer->SetBounds(gfx::Size(10, 10));
543 541
544 layer_tree_host_->UpdateLayers(); 542 layer_tree_host_->UpdateLayers();
545 543
546 LayerImpl* layer_impl_tree_root = 544 LayerImpl* layer_impl_tree_root =
547 layer_tree_host_->CommitAndCreateLayerImplTree(); 545 layer_tree_host_->CommitAndCreateLayerImplTree();
548 LayerImpl* scroll_layer_impl = 546 LayerImpl* scroll_layer_impl =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 scoped_refptr<Layer> child1 = Layer::Create(); 579 scoped_refptr<Layer> child1 = Layer::Create();
582 scoped_refptr<Layer> scrollbar_layer; 580 scoped_refptr<Layer> scrollbar_layer;
583 const bool kIsLeftSideVerticalScrollbar = false; 581 const bool kIsLeftSideVerticalScrollbar = false;
584 scrollbar_layer = SolidColorScrollbarLayer::Create( 582 scrollbar_layer = SolidColorScrollbarLayer::Create(
585 scrollbar->Orientation(), kThumbThickness, kTrackStart, 583 scrollbar->Orientation(), kThumbThickness, kTrackStart,
586 kIsLeftSideVerticalScrollbar, child1->id()); 584 kIsLeftSideVerticalScrollbar, child1->id());
587 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); 585 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
588 scroll_layer->AddChild(child1); 586 scroll_layer->AddChild(child1);
589 scroll_layer->InsertChild(scrollbar_layer, 1); 587 scroll_layer->InsertChild(scrollbar_layer, 1);
590 layer_tree_root->AddChild(scroll_layer); 588 layer_tree_root->AddChild(scroll_layer);
591 layer_tree_->SetRootLayer(layer_tree_root); 589 layer_tree_host_->SetRootLayer(layer_tree_root);
592 590
593 // Choose layer bounds to give max_scroll_offset = (8, 8). 591 // Choose layer bounds to give max_scroll_offset = (8, 8).
594 layer_tree_root->SetBounds(gfx::Size(2, 2)); 592 layer_tree_root->SetBounds(gfx::Size(2, 2));
595 scroll_layer->SetBounds(gfx::Size(10, 10)); 593 scroll_layer->SetBounds(gfx::Size(10, 10));
596 594
597 // Building property trees twice shouldn't change the size of 595 // Building property trees twice shouldn't change the size of
598 // PropertyTrees::always_use_active_tree_opacity_effect_ids. 596 // PropertyTrees::always_use_active_tree_opacity_effect_ids.
599 layer_tree_host_->BuildPropertyTreesForTesting(); 597 layer_tree_host_->BuildPropertyTreesForTesting();
600 EXPECT_EQ(layer_tree_->property_trees() 598 EXPECT_EQ(layer_tree_host_->property_trees()
601 ->always_use_active_tree_opacity_effect_ids.size(), 599 ->always_use_active_tree_opacity_effect_ids.size(),
602 1u); 600 1u);
603 layer_tree_->property_trees()->needs_rebuild = true; 601 layer_tree_host_->property_trees()->needs_rebuild = true;
604 layer_tree_host_->BuildPropertyTreesForTesting(); 602 layer_tree_host_->BuildPropertyTreesForTesting();
605 EXPECT_EQ(layer_tree_->property_trees() 603 EXPECT_EQ(layer_tree_host_->property_trees()
606 ->always_use_active_tree_opacity_effect_ids.size(), 604 ->always_use_active_tree_opacity_effect_ids.size(),
607 1u); 605 1u);
608 606
609 // A solid color scrollbar layer's opacity is initialized to 0 on main thread 607 // A solid color scrollbar layer's opacity is initialized to 0 on main thread
610 layer_tree_host_->UpdateLayers(); 608 layer_tree_host_->UpdateLayers();
611 EffectNode* node = layer_tree_->property_trees()->effect_tree.Node( 609 EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node(
612 scrollbar_layer->effect_tree_index()); 610 scrollbar_layer->effect_tree_index());
613 EXPECT_EQ(node->opacity, 0.f); 611 EXPECT_EQ(node->opacity, 0.f);
614 612
615 // This tests that the initial opacity(0) of the scrollbar gets pushed onto 613 // This tests that the initial opacity(0) of the scrollbar gets pushed onto
616 // the pending tree and then onto the active tree. 614 // the pending tree and then onto the active tree.
617 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); 615 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
618 host_impl->CreatePendingTree(); 616 host_impl->CreatePendingTree();
619 LayerImpl* layer_impl_tree_root = 617 LayerImpl* layer_impl_tree_root =
620 layer_tree_host_->CommitAndCreatePendingTree(); 618 layer_tree_host_->CommitAndCreatePendingTree();
621 LayerTreeImpl* layer_tree_impl = layer_impl_tree_root->layer_tree_impl(); 619 LayerTreeImpl* layer_tree_impl = layer_impl_tree_root->layer_tree_impl();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 scoped_refptr<Layer> scrollbar_layer; 662 scoped_refptr<Layer> scrollbar_layer;
665 const bool kIsLeftSideVerticalScrollbar = false; 663 const bool kIsLeftSideVerticalScrollbar = false;
666 scrollbar_layer = SolidColorScrollbarLayer::Create( 664 scrollbar_layer = SolidColorScrollbarLayer::Create(
667 scrollbar->Orientation(), kThumbThickness, kTrackStart, 665 scrollbar->Orientation(), kThumbThickness, kTrackStart,
668 kIsLeftSideVerticalScrollbar, child1->id()); 666 kIsLeftSideVerticalScrollbar, child1->id());
669 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); 667 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
670 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); 668 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
671 scroll_layer->AddChild(child1); 669 scroll_layer->AddChild(child1);
672 scroll_layer->InsertChild(scrollbar_layer, 1); 670 scroll_layer->InsertChild(scrollbar_layer, 1);
673 layer_tree_root->AddChild(scroll_layer); 671 layer_tree_root->AddChild(scroll_layer);
674 layer_tree_->SetRootLayer(layer_tree_root); 672 layer_tree_host_->SetRootLayer(layer_tree_root);
675 673
676 layer_tree_root->SetBounds(gfx::Size(2, 2)); 674 layer_tree_root->SetBounds(gfx::Size(2, 2));
677 scroll_layer->SetBounds(gfx::Size(10, 10)); 675 scroll_layer->SetBounds(gfx::Size(10, 10));
678 layer_tree_host_->UpdateLayers(); 676 layer_tree_host_->UpdateLayers();
679 layer_tree_host_->CommitAndCreateLayerImplTree(); 677 layer_tree_host_->CommitAndCreateLayerImplTree();
680 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); 678 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
681 EXPECT_TRUE(host_impl->ScrollbarAnimationControllerForId(scroll_layer->id())); 679 EXPECT_TRUE(host_impl->ScrollbarAnimationControllerForId(scroll_layer->id()));
682 680
683 scroll_layer->SetBounds(gfx::Size(20, 20)); 681 scroll_layer->SetBounds(gfx::Size(20, 20));
684 scroll_layer->SetForceRenderSurfaceForTesting(true); 682 scroll_layer->SetForceRenderSurfaceForTesting(true);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 scrollbar_layer = SolidColorScrollbarLayer::Create( 813 scrollbar_layer = SolidColorScrollbarLayer::Create(
816 scrollbar->Orientation(), kThumbThickness, kTrackStart, 814 scrollbar->Orientation(), kThumbThickness, kTrackStart,
817 kIsLeftSideVerticalScrollbar, layer_tree_root->id()); 815 kIsLeftSideVerticalScrollbar, layer_tree_root->id());
818 } else { 816 } else {
819 scrollbar_layer = PaintedScrollbarLayer::Create(std::move(scrollbar), 817 scrollbar_layer = PaintedScrollbarLayer::Create(std::move(scrollbar),
820 layer_tree_root->id()); 818 layer_tree_root->id());
821 } 819 }
822 layer_tree_root->AddChild(content_layer); 820 layer_tree_root->AddChild(content_layer);
823 layer_tree_root->AddChild(scrollbar_layer); 821 layer_tree_root->AddChild(scrollbar_layer);
824 822
825 layer_tree_->SetRootLayer(layer_tree_root); 823 layer_tree_host_->SetRootLayer(layer_tree_root);
826 824
827 scrollbar_layer->SetIsDrawable(true); 825 scrollbar_layer->SetIsDrawable(true);
828 scrollbar_layer->SetBounds(gfx::Size(100, 100)); 826 scrollbar_layer->SetBounds(gfx::Size(100, 100));
829 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20)); 827 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20));
830 layer_tree_root->SetBounds(gfx::Size(100, 200)); 828 layer_tree_root->SetBounds(gfx::Size(100, 200));
831 content_layer->SetBounds(gfx::Size(100, 200)); 829 content_layer->SetBounds(gfx::Size(100, 200));
832 scrollbar_layer->set_visible_layer_rect(gfx::Rect(0, 0, 100, 200)); 830 scrollbar_layer->set_visible_layer_rect(gfx::Rect(0, 0, 100, 200));
833 831
834 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 832 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get());
835 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(), 833 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TestResourceUpdate) { 872 TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TestResourceUpdate) {
875 gfx::Point scrollbar_location(0, 185); 873 gfx::Point scrollbar_location(0, 185);
876 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 874 scoped_refptr<Layer> layer_tree_root = Layer::Create();
877 scoped_refptr<Layer> content_layer = Layer::Create(); 875 scoped_refptr<Layer> content_layer = Layer::Create();
878 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 876 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
879 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); 877 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id());
880 878
881 layer_tree_root->AddChild(content_layer); 879 layer_tree_root->AddChild(content_layer);
882 layer_tree_root->AddChild(scrollbar_layer); 880 layer_tree_root->AddChild(scrollbar_layer);
883 881
884 layer_tree_->SetRootLayer(layer_tree_root); 882 layer_tree_host_->SetRootLayer(layer_tree_root);
885 883
886 scrollbar_layer->SetIsDrawable(true); 884 scrollbar_layer->SetIsDrawable(true);
887 scrollbar_layer->SetBounds(gfx::Size(100, 15)); 885 scrollbar_layer->SetBounds(gfx::Size(100, 15));
888 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location)); 886 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location));
889 layer_tree_root->SetBounds(gfx::Size(100, 200)); 887 layer_tree_root->SetBounds(gfx::Size(100, 200));
890 content_layer->SetBounds(gfx::Size(100, 200)); 888 content_layer->SetBounds(gfx::Size(100, 200));
891 scrollbar_layer->set_visible_layer_rect(gfx::Rect(0, 0, 100, 200)); 889 scrollbar_layer->set_visible_layer_rect(gfx::Rect(0, 0, 100, 200));
892 890
893 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 891 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get());
894 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(), 892 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(),
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 void TestResourceUpload(const float test_scale) { 1032 void TestResourceUpload(const float test_scale) {
1035 gfx::Point scrollbar_location(0, 185); 1033 gfx::Point scrollbar_location(0, 185);
1036 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 1034 scoped_refptr<Layer> layer_tree_root = Layer::Create();
1037 scoped_refptr<Layer> content_layer = Layer::Create(); 1035 scoped_refptr<Layer> content_layer = Layer::Create();
1038 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 1036 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
1039 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); 1037 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id());
1040 1038
1041 layer_tree_root->AddChild(content_layer); 1039 layer_tree_root->AddChild(content_layer);
1042 layer_tree_root->AddChild(scrollbar_layer); 1040 layer_tree_root->AddChild(scrollbar_layer);
1043 1041
1044 layer_tree_->SetRootLayer(layer_tree_root); 1042 layer_tree_host_->SetRootLayer(layer_tree_root);
1045 1043
1046 scrollbar_layer->SetIsDrawable(true); 1044 scrollbar_layer->SetIsDrawable(true);
1047 scrollbar_layer->SetBounds(gfx::Size(100, 15)); 1045 scrollbar_layer->SetBounds(gfx::Size(100, 15));
1048 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location)); 1046 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location));
1049 layer_tree_root->SetBounds(gfx::Size(100, 200)); 1047 layer_tree_root->SetBounds(gfx::Size(100, 200));
1050 content_layer->SetBounds(gfx::Size(100, 200)); 1048 content_layer->SetBounds(gfx::Size(100, 200));
1051 scrollbar_layer->set_visible_layer_rect( 1049 scrollbar_layer->set_visible_layer_rect(
1052 gfx::Rect(scrollbar_location, scrollbar_layer->bounds())); 1050 gfx::Rect(scrollbar_location, scrollbar_layer->bounds()));
1053 1051
1054 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(), 1052 EXPECT_EQ(scrollbar_layer->GetLayerTreeHostForTesting(),
1055 layer_tree_host_.get()); 1053 layer_tree_host_.get());
1056 1054
1057 layer_tree_->SetDeviceScaleFactor(test_scale); 1055 layer_tree_host_->SetDeviceScaleFactor(test_scale);
1058 1056
1059 scrollbar_layer->SavePaintProperties(); 1057 scrollbar_layer->SavePaintProperties();
1060 scrollbar_layer->Update(); 1058 scrollbar_layer->Update();
1061 1059
1062 // Verify that we have not generated any content uploads that are larger 1060 // Verify that we have not generated any content uploads that are larger
1063 // than their destination textures. 1061 // than their destination textures.
1064 1062
1065 gfx::Size track_size = fake_ui_resource_manager_->ui_resource_size( 1063 gfx::Size track_size = fake_ui_resource_manager_->ui_resource_size(
1066 scrollbar_layer->track_resource_id()); 1064 scrollbar_layer->track_resource_id());
1067 gfx::Size thumb_size = fake_ui_resource_manager_->ui_resource_size( 1065 gfx::Size thumb_size = fake_ui_resource_manager_->ui_resource_size(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 void TestScale(const gfx::Rect scrollbar_rect, const float test_scale) { 1101 void TestScale(const gfx::Rect scrollbar_rect, const float test_scale) {
1104 bool paint_during_update = true; 1102 bool paint_during_update = true;
1105 bool has_thumb = false; 1103 bool has_thumb = false;
1106 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 1104 scoped_refptr<Layer> layer_tree_root = Layer::Create();
1107 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 1105 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
1108 FakePaintedScrollbarLayer::Create(paint_during_update, has_thumb, 1106 FakePaintedScrollbarLayer::Create(paint_during_update, has_thumb,
1109 layer_tree_root->id()); 1107 layer_tree_root->id());
1110 1108
1111 layer_tree_root->AddChild(scrollbar_layer); 1109 layer_tree_root->AddChild(scrollbar_layer);
1112 1110
1113 layer_tree_->SetRootLayer(layer_tree_root); 1111 layer_tree_host_->SetRootLayer(layer_tree_root);
1114 1112
1115 scrollbar_layer->SetBounds(scrollbar_rect.size()); 1113 scrollbar_layer->SetBounds(scrollbar_rect.size());
1116 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_rect.origin())); 1114 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_rect.origin()));
1117 scrollbar_layer->fake_scrollbar()->set_location(scrollbar_rect.origin()); 1115 scrollbar_layer->fake_scrollbar()->set_location(scrollbar_rect.origin());
1118 scrollbar_layer->fake_scrollbar()->set_track_rect(scrollbar_rect); 1116 scrollbar_layer->fake_scrollbar()->set_track_rect(scrollbar_rect);
1119 scrollbar_layer->set_visible_layer_rect(scrollbar_rect); 1117 scrollbar_layer->set_visible_layer_rect(scrollbar_rect);
1120 1118
1121 layer_tree_->SetDeviceScaleFactor(test_scale); 1119 layer_tree_host_->SetDeviceScaleFactor(test_scale);
1122 1120
1123 gfx::Rect screen_space_clip_rect; 1121 gfx::Rect screen_space_clip_rect;
1124 scrollbar_layer->SavePaintProperties(); 1122 scrollbar_layer->SavePaintProperties();
1125 1123
1126 scrollbar_layer->Update(); 1124 scrollbar_layer->Update();
1127 1125
1128 UIResourceBitmap* bitmap = fake_ui_resource_manager_->ui_resource_bitmap( 1126 UIResourceBitmap* bitmap = fake_ui_resource_manager_->ui_resource_bitmap(
1129 scrollbar_layer->track_resource_id()); 1127 scrollbar_layer->track_resource_id());
1130 1128
1131 DCHECK(bitmap); 1129 DCHECK(bitmap);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 1168 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1171 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1169 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1172 1170
1173 // Horizontal Scrollbars. 1171 // Horizontal Scrollbars.
1174 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1172 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1175 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1173 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1176 } 1174 }
1177 1175
1178 } // namespace 1176 } // namespace
1179 } // namespace cc 1177 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_unittest.cc ('k') | cc/layers/surface_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698