| OLD | NEW |
| 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 "base/containers/hash_tables.h" | 5 #include "base/containers/hash_tables.h" |
| 6 #include "cc/animation/scrollbar_animation_controller.h" | 6 #include "cc/animation/scrollbar_animation_controller.h" |
| 7 #include "cc/debug/test_web_graphics_context_3d.h" | 7 #include "cc/debug/test_web_graphics_context_3d.h" |
| 8 #include "cc/layers/append_quads_data.h" | 8 #include "cc/layers/append_quads_data.h" |
| 9 #include "cc/layers/painted_scrollbar_layer.h" | 9 #include "cc/layers/painted_scrollbar_layer.h" |
| 10 #include "cc/layers/painted_scrollbar_layer_impl.h" | 10 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 bool reverse_order, | 38 bool reverse_order, |
| 39 bool use_solid_color_scrollbar, | 39 bool use_solid_color_scrollbar, |
| 40 int thumb_thickness) { | 40 int thumb_thickness) { |
| 41 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 41 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 42 scoped_refptr<Layer> child1 = Layer::Create(); | 42 scoped_refptr<Layer> child1 = Layer::Create(); |
| 43 scoped_refptr<Layer> child2; | 43 scoped_refptr<Layer> child2; |
| 44 if (use_solid_color_scrollbar) { | 44 if (use_solid_color_scrollbar) { |
| 45 const bool kIsLeftSideVerticalScrollbar = false; | 45 const bool kIsLeftSideVerticalScrollbar = false; |
| 46 child2 = SolidColorScrollbarLayer::Create( | 46 child2 = SolidColorScrollbarLayer::Create( |
| 47 scrollbar->Orientation(), thumb_thickness, | 47 scrollbar->Orientation(), thumb_thickness, |
| 48 kIsLeftSideVerticalScrollbar, child1->id()); | 48 kIsLeftSideVerticalScrollbar, child1.get()); |
| 49 } else { | 49 } else { |
| 50 child2 = PaintedScrollbarLayer::Create(scrollbar.Pass(), child1->id()); | 50 child2 = PaintedScrollbarLayer::Create(scrollbar.Pass(), child1.get()); |
| 51 } | 51 } |
| 52 layer_tree_root->AddChild(child1); | 52 layer_tree_root->AddChild(child1); |
| 53 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); | 53 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); |
| 54 host->SetRootLayer(layer_tree_root); | 54 host->SetRootLayer(layer_tree_root); |
| 55 return host->CommitAndCreateLayerImplTree(); | 55 return host->CommitAndCreateLayerImplTree(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 TEST(ScrollbarLayerTest, ResolveScrollLayerPointer) { | 58 TEST(ScrollbarLayerTest, ResolveScrollLayerPointer) { |
| 59 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 59 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| 60 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 60 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 61 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 61 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 62 host.get(), scrollbar.Pass(), false, false, 0); | 62 host.get(), scrollbar.Pass(), false, false, 0); |
| 63 | 63 |
| 64 LayerImpl* cc_child1 = layer_impl_tree_root->children()[0]; | 64 LayerImpl* cc_child1 = layer_impl_tree_root->children()[0]; |
| 65 PaintedScrollbarLayerImpl* cc_child2 = | 65 PaintedScrollbarLayerImpl* cc_child2 = |
| 66 static_cast<PaintedScrollbarLayerImpl*>( | 66 static_cast<PaintedScrollbarLayerImpl*>( |
| 67 layer_impl_tree_root->children()[1]); | 67 layer_impl_tree_root->children()[1]); |
| 68 | 68 |
| 69 EXPECT_EQ(cc_child1->horizontal_scrollbar_layer(), cc_child2); | 69 EXPECT_EQ(cc_child1->scrollbars()->size(), 1UL); |
| 70 EXPECT_EQ(*(cc_child1->scrollbars()->begin()), cc_child2); |
| 70 } | 71 } |
| 71 | 72 |
| 72 TEST(ScrollbarLayerTest, ResolveScrollLayerPointer_ReverseOrder) { | 73 TEST(ScrollbarLayerTest, ResolveScrollLayerPointer_ReverseOrder) { |
| 73 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 74 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| 74 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 75 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 75 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 76 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 76 host.get(), scrollbar.Pass(), true, false, 0); | 77 host.get(), scrollbar.Pass(), true, false, 0); |
| 77 | 78 |
| 78 PaintedScrollbarLayerImpl* cc_child1 = | 79 PaintedScrollbarLayerImpl* cc_child1 = |
| 79 static_cast<PaintedScrollbarLayerImpl*>( | 80 static_cast<PaintedScrollbarLayerImpl*>( |
| 80 layer_impl_tree_root->children()[0]); | 81 layer_impl_tree_root->children()[0]); |
| 81 LayerImpl* cc_child2 = layer_impl_tree_root->children()[1]; | 82 LayerImpl* cc_child2 = layer_impl_tree_root->children()[1]; |
| 82 | 83 |
| 83 EXPECT_EQ(cc_child2->horizontal_scrollbar_layer(), cc_child1); | 84 EXPECT_EQ(cc_child2->scrollbars()->size(), 1UL); |
| 85 EXPECT_EQ(*(cc_child2->scrollbars()->begin()), cc_child1); |
| 84 } | 86 } |
| 85 | 87 |
| 86 TEST(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { | 88 TEST(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { |
| 87 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 89 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| 88 | 90 |
| 89 // Create and attach a non-overlay scrollbar. | 91 // Create and attach a non-overlay scrollbar. |
| 90 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 92 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 91 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 93 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 92 host.get(), scrollbar.Pass(), false, false, 0); | 94 host.get(), scrollbar.Pass(), false, false, 0); |
| 93 PaintedScrollbarLayerImpl* scrollbar_layer_impl = | 95 PaintedScrollbarLayerImpl* scrollbar_layer_impl = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 116 InputHandler::Gesture)); | 118 InputHandler::Gesture)); |
| 117 } | 119 } |
| 118 | 120 |
| 119 TEST(PaintedScrollbarLayerTest, ScrollOffsetSynchronization) { | 121 TEST(PaintedScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 120 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 122 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| 121 | 123 |
| 122 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 124 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 123 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 125 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 124 scoped_refptr<Layer> content_layer = Layer::Create(); | 126 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 125 scoped_refptr<Layer> scrollbar_layer = | 127 scoped_refptr<Layer> scrollbar_layer = |
| 126 PaintedScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id()); | 128 PaintedScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root.get()); |
| 127 | 129 |
| 128 layer_tree_root->SetScrollable(true); | 130 layer_tree_root->SetScrollable(layer_tree_root.get()); // WJM |
| 129 layer_tree_root->SetScrollOffset(gfx::Vector2d(10, 20)); | 131 layer_tree_root->SetScrollOffset(gfx::Vector2d(10, 20)); |
| 130 layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(30, 50)); | 132 // layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(30, 50)); // WJM |
| 131 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 133 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| 132 content_layer->SetBounds(gfx::Size(100, 200)); | 134 content_layer->SetBounds(gfx::Size(100, 200)); |
| 133 | 135 |
| 134 host->SetRootLayer(layer_tree_root); | 136 host->SetRootLayer(layer_tree_root); |
| 135 layer_tree_root->AddChild(content_layer); | 137 layer_tree_root->AddChild(content_layer); |
| 136 layer_tree_root->AddChild(scrollbar_layer); | 138 layer_tree_root->AddChild(scrollbar_layer); |
| 137 | 139 |
| 138 layer_tree_root->SavePaintProperties(); | 140 layer_tree_root->SavePaintProperties(); |
| 139 content_layer->SavePaintProperties(); | 141 content_layer->SavePaintProperties(); |
| 140 | 142 |
| 141 LayerImpl* layer_impl_tree_root = host->CommitAndCreateLayerImplTree(); | 143 LayerImpl* layer_impl_tree_root = host->CommitAndCreateLayerImplTree(); |
| 142 | 144 |
| 143 ScrollbarLayerImplBase* cc_scrollbar_layer = | 145 ScrollbarLayerImplBase* cc_scrollbar_layer = |
| 144 static_cast<PaintedScrollbarLayerImpl*>( | 146 static_cast<PaintedScrollbarLayerImpl*>( |
| 145 layer_impl_tree_root->children()[1]); | 147 layer_impl_tree_root->children()[1]); |
| 146 | 148 |
| 147 EXPECT_EQ(10.f, cc_scrollbar_layer->current_pos()); | 149 EXPECT_EQ(10.f, cc_scrollbar_layer->current_pos()); |
| 148 EXPECT_EQ(30, cc_scrollbar_layer->maximum()); | 150 EXPECT_EQ(30, cc_scrollbar_layer->maximum()); |
| 149 | 151 |
| 150 layer_tree_root->SetScrollOffset(gfx::Vector2d(100, 200)); | 152 layer_tree_root->SetScrollOffset(gfx::Vector2d(100, 200)); |
| 151 layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(300, 500)); | 153 // layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(300, 500)); // WJM |
| 152 layer_tree_root->SetBounds(gfx::Size(1000, 2000)); | 154 layer_tree_root->SetBounds(gfx::Size(1000, 2000)); |
| 153 layer_tree_root->SavePaintProperties(); | 155 layer_tree_root->SavePaintProperties(); |
| 154 content_layer->SetBounds(gfx::Size(1000, 2000)); | 156 content_layer->SetBounds(gfx::Size(1000, 2000)); |
| 155 content_layer->SavePaintProperties(); | 157 content_layer->SavePaintProperties(); |
| 156 | 158 |
| 157 ScrollbarAnimationController* scrollbar_controller = | 159 ScrollbarAnimationController* scrollbar_controller = |
| 158 layer_impl_tree_root->scrollbar_animation_controller(); | 160 layer_impl_tree_root->scrollbar_animation_controller(); |
| 159 layer_impl_tree_root = host->CommitAndCreateLayerImplTree(); | 161 layer_impl_tree_root = host->CommitAndCreateLayerImplTree(); |
| 160 EXPECT_EQ(scrollbar_controller, | 162 EXPECT_EQ(scrollbar_controller, |
| 161 layer_impl_tree_root->scrollbar_animation_controller()); | 163 layer_impl_tree_root->scrollbar_animation_controller()); |
| 162 | 164 |
| 163 EXPECT_EQ(100.f, cc_scrollbar_layer->current_pos()); | 165 EXPECT_EQ(100.f, cc_scrollbar_layer->current_pos()); |
| 164 EXPECT_EQ(300, cc_scrollbar_layer->maximum()); | 166 EXPECT_EQ(300, cc_scrollbar_layer->maximum()); |
| 165 | 167 |
| 166 layer_impl_tree_root->ScrollBy(gfx::Vector2d(12, 34)); | 168 layer_impl_tree_root->ScrollBy(gfx::Vector2d(12, 34)); |
| 167 | 169 |
| 168 EXPECT_EQ(112.f, cc_scrollbar_layer->current_pos()); | 170 EXPECT_EQ(112.f, cc_scrollbar_layer->current_pos()); |
| 169 EXPECT_EQ(300, cc_scrollbar_layer->maximum()); | 171 EXPECT_EQ(300, cc_scrollbar_layer->maximum()); |
| 170 } | 172 } |
| 171 | 173 |
| 172 TEST(ScrollbarLayerTest, ThumbRect) { | 174 TEST(ScrollbarLayerTest, ThumbRect) { |
| 173 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 175 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| 174 scoped_refptr<Layer> root_layer = Layer::Create(); | 176 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 175 scoped_refptr<Layer> content_layer = Layer::Create(); | 177 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 176 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 178 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 177 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); | 179 FakePaintedScrollbarLayer::Create(false, true, root_layer.get()); |
| 178 | 180 |
| 179 root_layer->SetScrollable(true); | 181 root_layer->SetScrollable(root_layer.get()); // WJM |
| 180 root_layer->SetMaxScrollOffset(gfx::Vector2d(80, 0)); | 182 // root_layer->SetMaxScrollOffset(gfx::Vector2d(80, 0)); |
| 181 root_layer->SetBounds(gfx::Size(100, 50)); | 183 root_layer->SetBounds(gfx::Size(100, 50)); |
| 182 content_layer->SetBounds(gfx::Size(100, 50)); | 184 content_layer->SetBounds(gfx::Size(100, 50)); |
| 183 | 185 |
| 184 host->SetRootLayer(root_layer); | 186 host->SetRootLayer(root_layer); |
| 185 root_layer->AddChild(content_layer); | 187 root_layer->AddChild(content_layer); |
| 186 root_layer->AddChild(scrollbar_layer); | 188 root_layer->AddChild(scrollbar_layer); |
| 187 | 189 |
| 188 root_layer->SetScrollOffset(gfx::Vector2d(0, 0)); | 190 root_layer->SetScrollOffset(gfx::Vector2d(0, 0)); |
| 189 scrollbar_layer->SetBounds(gfx::Size(70, 10)); | 191 scrollbar_layer->SetBounds(gfx::Size(70, 10)); |
| 190 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); | 192 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 337 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
| 336 host.get(), scrollbar.Pass(), false, true, kThumbThickness); | 338 host.get(), scrollbar.Pass(), false, true, kThumbThickness); |
| 337 ScrollbarLayerImplBase* scrollbar_layer_impl = | 339 ScrollbarLayerImplBase* scrollbar_layer_impl = |
| 338 static_cast<PaintedScrollbarLayerImpl*>( | 340 static_cast<PaintedScrollbarLayerImpl*>( |
| 339 layer_impl_tree_root->children()[1]); | 341 layer_impl_tree_root->children()[1]); |
| 340 | 342 |
| 341 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); | 343 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); |
| 342 scrollbar_layer_impl->SetCurrentPos(4.f); | 344 scrollbar_layer_impl->SetCurrentPos(4.f); |
| 343 scrollbar_layer_impl->SetMaximum(8); | 345 scrollbar_layer_impl->SetMaximum(8); |
| 344 | 346 |
| 345 layer_impl_tree_root->SetScrollable(true); | 347 layer_impl_tree_root->SetScrollable(42); // WJM |
| 346 layer_impl_tree_root->SetHorizontalScrollbarLayer(scrollbar_layer_impl); | 348 layer_impl_tree_root->AddScrollbar(scrollbar_layer_impl); |
| 347 layer_impl_tree_root->SetMaxScrollOffset(gfx::Vector2d(8, 8)); | 349 // layer_impl_tree_root->SetMaxScrollOffset(gfx::Vector2d(8, 8)); // WJM |
| 348 layer_impl_tree_root->SetBounds(gfx::Size(2, 2)); | 350 layer_impl_tree_root->SetBounds(gfx::Size(2, 2)); |
| 349 layer_impl_tree_root->ScrollBy(gfx::Vector2dF(4.f, 0.f)); | 351 layer_impl_tree_root->ScrollBy(gfx::Vector2dF(4.f, 0.f)); |
| 350 | 352 |
| 351 { | 353 { |
| 352 MockQuadCuller quad_culler; | 354 MockQuadCuller quad_culler; |
| 353 AppendQuadsData data; | 355 AppendQuadsData data; |
| 354 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); | 356 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); |
| 355 | 357 |
| 356 const QuadList& quads = quad_culler.quad_list(); | 358 const QuadList& quads = quad_culler.quad_list(); |
| 357 ASSERT_EQ(1u, quads.size()); | 359 ASSERT_EQ(1u, quads.size()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 vertical_scrollbar_layer_->ComputeThumbQuadRect()); | 451 vertical_scrollbar_layer_->ComputeThumbQuadRect()); |
| 450 } | 452 } |
| 451 | 453 |
| 452 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { | 454 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { |
| 453 public: | 455 public: |
| 454 ScrollbarLayerTestMaxTextureSize() {} | 456 ScrollbarLayerTestMaxTextureSize() {} |
| 455 | 457 |
| 456 void SetScrollbarBounds(gfx::Size bounds) { bounds_ = bounds; } | 458 void SetScrollbarBounds(gfx::Size bounds) { bounds_ = bounds; } |
| 457 | 459 |
| 458 virtual void BeginTest() OVERRIDE { | 460 virtual void BeginTest() OVERRIDE { |
| 461 scroll_layer_ = Layer::Create(); |
| 462 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 463 |
| 459 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 464 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 460 scrollbar_layer_ = PaintedScrollbarLayer::Create(scrollbar.Pass(), 1); | 465 scrollbar_layer_ = |
| 466 PaintedScrollbarLayer::Create(scrollbar.Pass(), scroll_layer_.get()); |
| 467 scrollbar_layer_->SetScrollLayer(scroll_layer_); |
| 461 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); | 468 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); |
| 462 scrollbar_layer_->SetBounds(bounds_); | 469 scrollbar_layer_->SetBounds(bounds_); |
| 463 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); | 470 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
| 464 | 471 |
| 465 scroll_layer_ = Layer::Create(); | |
| 466 scrollbar_layer_->SetScrollLayerId(scroll_layer_->id()); | |
| 467 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | |
| 468 | |
| 469 PostSetNeedsCommitToMainThread(); | 472 PostSetNeedsCommitToMainThread(); |
| 470 } | 473 } |
| 471 | 474 |
| 472 virtual void DidCommitAndDrawFrame() OVERRIDE { | 475 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 473 const int kMaxTextureSize = | 476 const int kMaxTextureSize = |
| 474 layer_tree_host()->GetRendererCapabilities().max_texture_size; | 477 layer_tree_host()->GetRendererCapabilities().max_texture_size; |
| 475 | 478 |
| 476 // Check first that we're actually testing something. | 479 // Check first that we're actually testing something. |
| 477 EXPECT_GT(scrollbar_layer_->bounds().width(), kMaxTextureSize); | 480 EXPECT_GT(scrollbar_layer_->bounds().width(), kMaxTextureSize); |
| 478 | 481 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 580 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 578 scoped_refptr<Layer> content_layer = Layer::Create(); | 581 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 579 scoped_refptr<Layer> scrollbar_layer; | 582 scoped_refptr<Layer> scrollbar_layer; |
| 580 if (use_solid_color_scrollbar) { | 583 if (use_solid_color_scrollbar) { |
| 581 const int kThumbThickness = 3; | 584 const int kThumbThickness = 3; |
| 582 const bool kIsLeftSideVerticalScrollbar = false; | 585 const bool kIsLeftSideVerticalScrollbar = false; |
| 583 scrollbar_layer = | 586 scrollbar_layer = |
| 584 SolidColorScrollbarLayer::Create(scrollbar->Orientation(), | 587 SolidColorScrollbarLayer::Create(scrollbar->Orientation(), |
| 585 kThumbThickness, | 588 kThumbThickness, |
| 586 kIsLeftSideVerticalScrollbar, | 589 kIsLeftSideVerticalScrollbar, |
| 587 layer_tree_root->id()); | 590 layer_tree_root.get()); |
| 588 } else { | 591 } else { |
| 589 scrollbar_layer = PaintedScrollbarLayer::Create(scrollbar.Pass(), | 592 scrollbar_layer = PaintedScrollbarLayer::Create(scrollbar.Pass(), |
| 590 layer_tree_root->id()); | 593 layer_tree_root.get()); |
| 591 } | 594 } |
| 592 layer_tree_root->AddChild(content_layer); | 595 layer_tree_root->AddChild(content_layer); |
| 593 layer_tree_root->AddChild(scrollbar_layer); | 596 layer_tree_root->AddChild(scrollbar_layer); |
| 594 | 597 |
| 595 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); | 598 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); |
| 596 layer_tree_host_->SetRootLayer(layer_tree_root); | 599 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 597 | 600 |
| 598 scrollbar_layer->SetIsDrawable(true); | 601 scrollbar_layer->SetIsDrawable(true); |
| 599 scrollbar_layer->SetBounds(gfx::Size(100, 100)); | 602 scrollbar_layer->SetBounds(gfx::Size(100, 100)); |
| 600 layer_tree_root->SetScrollOffset(gfx::Vector2d(10, 20)); | 603 layer_tree_root->SetScrollOffset(gfx::Vector2d(10, 20)); |
| 601 layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(30, 50)); | 604 // layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(30, 50)); // WJM |
| 602 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 605 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| 603 content_layer->SetBounds(gfx::Size(100, 200)); | 606 content_layer->SetBounds(gfx::Size(100, 200)); |
| 604 scrollbar_layer->draw_properties().content_bounds = gfx::Size(100, 200); | 607 scrollbar_layer->draw_properties().content_bounds = gfx::Size(100, 200); |
| 605 scrollbar_layer->draw_properties().visible_content_rect = | 608 scrollbar_layer->draw_properties().visible_content_rect = |
| 606 gfx::Rect(0, 0, 100, 200); | 609 gfx::Rect(0, 0, 100, 200); |
| 607 scrollbar_layer->CreateRenderSurface(); | 610 scrollbar_layer->CreateRenderSurface(); |
| 608 scrollbar_layer->draw_properties().render_target = scrollbar_layer.get(); | 611 scrollbar_layer->draw_properties().render_target = scrollbar_layer.get(); |
| 609 | 612 |
| 610 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 613 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 611 EXPECT_EQ(scrollbar_layer->layer_tree_host(), layer_tree_host_.get()); | 614 EXPECT_EQ(scrollbar_layer->layer_tree_host(), layer_tree_host_.get()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} | 661 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} |
| 659 | 662 |
| 660 void TestResourceUpload(const float test_scale) { | 663 void TestResourceUpload(const float test_scale) { |
| 661 layer_tree_host_.reset( | 664 layer_tree_host_.reset( |
| 662 new MockLayerTreeHost(&fake_client_, layer_tree_settings_)); | 665 new MockLayerTreeHost(&fake_client_, layer_tree_settings_)); |
| 663 | 666 |
| 664 gfx::Point scrollbar_location(0, 185); | 667 gfx::Point scrollbar_location(0, 185); |
| 665 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 668 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 666 scoped_refptr<Layer> content_layer = Layer::Create(); | 669 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 667 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 670 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 668 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); | 671 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root.get()); |
| 669 | 672 |
| 670 layer_tree_root->AddChild(content_layer); | 673 layer_tree_root->AddChild(content_layer); |
| 671 layer_tree_root->AddChild(scrollbar_layer); | 674 layer_tree_root->AddChild(scrollbar_layer); |
| 672 | 675 |
| 673 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); | 676 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); |
| 674 layer_tree_host_->SetRootLayer(layer_tree_root); | 677 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 675 | 678 |
| 676 scrollbar_layer->SetIsDrawable(true); | 679 scrollbar_layer->SetIsDrawable(true); |
| 677 scrollbar_layer->SetBounds(gfx::Size(100, 15)); | 680 scrollbar_layer->SetBounds(gfx::Size(100, 15)); |
| 678 scrollbar_layer->SetPosition(scrollbar_location); | 681 scrollbar_layer->SetPosition(scrollbar_location); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { | 732 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { |
| 730 // Pick a test scale that moves the scrollbar's (non-zero) position to | 733 // Pick a test scale that moves the scrollbar's (non-zero) position to |
| 731 // a non-pixel-aligned location. | 734 // a non-pixel-aligned location. |
| 732 TestResourceUpload(.041f); | 735 TestResourceUpload(.041f); |
| 733 TestResourceUpload(1.41f); | 736 TestResourceUpload(1.41f); |
| 734 TestResourceUpload(4.1f); | 737 TestResourceUpload(4.1f); |
| 735 } | 738 } |
| 736 | 739 |
| 737 } // namespace | 740 } // namespace |
| 738 } // namespace cc | 741 } // namespace cc |
| OLD | NEW |