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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <unordered_map> | 7 #include <unordered_map> |
8 | 8 |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "cc/input/scrollbar_animation_controller.h" | 10 #include "cc/input/scrollbar_animation_controller.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "cc/trees/layer_tree_impl.h" | 30 #include "cc/trees/layer_tree_impl.h" |
31 #include "cc/trees/occlusion_tracker.h" | 31 #include "cc/trees/occlusion_tracker.h" |
32 #include "cc/trees/single_thread_proxy.h" | 32 #include "cc/trees/single_thread_proxy.h" |
33 #include "cc/trees/tree_synchronizer.h" | 33 #include "cc/trees/tree_synchronizer.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
36 | 36 |
37 namespace cc { | 37 namespace cc { |
38 namespace { | 38 namespace { |
39 | 39 |
40 LayerImpl* LayerImplForScrollAreaAndScrollbar(FakeLayerTreeHost* host, | 40 LayerImpl* LayerImplForScrollAreaAndScrollbar( |
41 scoped_ptr<Scrollbar> scrollbar, | 41 FakeLayerTreeHost* host, |
42 bool reverse_order, | 42 std::unique_ptr<Scrollbar> scrollbar, |
43 bool use_solid_color_scrollbar, | 43 bool reverse_order, |
44 int thumb_thickness, | 44 bool use_solid_color_scrollbar, |
45 int track_start) { | 45 int thumb_thickness, |
| 46 int track_start) { |
46 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 47 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
47 scoped_refptr<Layer> child1 = Layer::Create(); | 48 scoped_refptr<Layer> child1 = Layer::Create(); |
48 scoped_refptr<Layer> child2; | 49 scoped_refptr<Layer> child2; |
49 if (use_solid_color_scrollbar) { | 50 if (use_solid_color_scrollbar) { |
50 const bool kIsLeftSideVerticalScrollbar = false; | 51 const bool kIsLeftSideVerticalScrollbar = false; |
51 child2 = SolidColorScrollbarLayer::Create( | 52 child2 = SolidColorScrollbarLayer::Create( |
52 scrollbar->Orientation(), thumb_thickness, track_start, | 53 scrollbar->Orientation(), thumb_thickness, track_start, |
53 kIsLeftSideVerticalScrollbar, child1->id()); | 54 kIsLeftSideVerticalScrollbar, child1->id()); |
54 } else { | 55 } else { |
55 child2 = PaintedScrollbarLayer::Create(std::move(scrollbar), child1->id()); | 56 child2 = PaintedScrollbarLayer::Create(std::move(scrollbar), child1->id()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 fake_client_.SetLayerTreeHost(layer_tree_host_.get()); | 135 fake_client_.SetLayerTreeHost(layer_tree_host_.get()); |
135 // Force output surface creation for renderer capabilities. | 136 // Force output surface creation for renderer capabilities. |
136 layer_tree_host_->Composite(base::TimeTicks()); | 137 layer_tree_host_->Composite(base::TimeTicks()); |
137 EXPECT_FALSE(layer_tree_host_->output_surface_lost()); | 138 EXPECT_FALSE(layer_tree_host_->output_surface_lost()); |
138 } | 139 } |
139 | 140 |
140 protected: | 141 protected: |
141 FakeLayerTreeHostClient fake_client_; | 142 FakeLayerTreeHostClient fake_client_; |
142 TestTaskGraphRunner task_graph_runner_; | 143 TestTaskGraphRunner task_graph_runner_; |
143 LayerTreeSettings layer_tree_settings_; | 144 LayerTreeSettings layer_tree_settings_; |
144 scoped_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_; | 145 std::unique_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_; |
145 }; | 146 }; |
146 | 147 |
147 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { | 148 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { |
148 // Create and attach a non-overlay scrollbar. | 149 // Create and attach a non-overlay scrollbar. |
149 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 150 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
150 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 151 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
151 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); | 152 layer_tree_host_.get(), std::move(scrollbar), false, false, 0, 0); |
152 PaintedScrollbarLayerImpl* scrollbar_layer_impl = | 153 PaintedScrollbarLayerImpl* scrollbar_layer_impl = |
153 static_cast<PaintedScrollbarLayerImpl*>( | 154 static_cast<PaintedScrollbarLayerImpl*>( |
154 layer_impl_tree_root->children()[1]); | 155 layer_impl_tree_root->children()[1]); |
155 layer_impl_tree_root->layer_tree_impl()->BuildPropertyTreesForTesting(); | 156 layer_impl_tree_root->layer_tree_impl()->BuildPropertyTreesForTesting(); |
156 ScrollTree& scroll_tree = | 157 ScrollTree& scroll_tree = |
157 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; | 158 layer_impl_tree_root->layer_tree_impl()->property_trees()->scroll_tree; |
158 ScrollNode* scroll_node = | 159 ScrollNode* scroll_node = |
159 scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); | 160 scroll_tree.Node(scrollbar_layer_impl->scroll_tree_index()); |
(...skipping 22 matching lines...) Expand all Loading... |
182 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 183 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
183 // may be handled in the compositor. | 184 // may be handled in the compositor. |
184 status = layer_tree_host_->host_impl()->TryScroll( | 185 status = layer_tree_host_->host_impl()->TryScroll( |
185 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); | 186 gfx::PointF(), InputHandler::TOUCHSCREEN, scroll_tree, scroll_node); |
186 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 187 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
187 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 188 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
188 status.main_thread_scrolling_reasons); | 189 status.main_thread_scrolling_reasons); |
189 } | 190 } |
190 | 191 |
191 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 192 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
192 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 193 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
193 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 194 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
194 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 195 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
195 scoped_refptr<Layer> content_layer = Layer::Create(); | 196 scoped_refptr<Layer> content_layer = Layer::Create(); |
196 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( | 197 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( |
197 std::move(scrollbar), layer_tree_root->id()); | 198 std::move(scrollbar), layer_tree_root->id()); |
198 | 199 |
199 // Choose bounds to give max_scroll_offset = (30, 50). | 200 // Choose bounds to give max_scroll_offset = (30, 50). |
200 layer_tree_root->SetBounds(gfx::Size(70, 150)); | 201 layer_tree_root->SetBounds(gfx::Size(70, 150)); |
201 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 202 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
202 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 203 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 374 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
374 EXPECT_EQ(gfx::Rect(44, 0, 6, 4).ToString(), | 375 EXPECT_EQ(gfx::Rect(44, 0, 6, 4).ToString(), |
375 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 376 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
376 } | 377 } |
377 | 378 |
378 TEST_F(ScrollbarLayerTest, SolidColorDrawQuads) { | 379 TEST_F(ScrollbarLayerTest, SolidColorDrawQuads) { |
379 const int kThumbThickness = 3; | 380 const int kThumbThickness = 3; |
380 const int kTrackStart = 1; | 381 const int kTrackStart = 1; |
381 const int kTrackLength = 100; | 382 const int kTrackLength = 100; |
382 | 383 |
383 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 384 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
384 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( | 385 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( |
385 layer_tree_host_.get(), std::move(scrollbar), false, true, | 386 layer_tree_host_.get(), std::move(scrollbar), false, true, |
386 kThumbThickness, kTrackStart); | 387 kThumbThickness, kTrackStart); |
387 ScrollbarLayerImplBase* scrollbar_layer_impl = | 388 ScrollbarLayerImplBase* scrollbar_layer_impl = |
388 static_cast<SolidColorScrollbarLayerImpl*>( | 389 static_cast<SolidColorScrollbarLayerImpl*>( |
389 layer_impl_tree_root->children()[1]); | 390 layer_impl_tree_root->children()[1]); |
390 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); | 391 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); |
391 scrollbar_layer_impl->SetCurrentPos(10.f); | 392 scrollbar_layer_impl->SetCurrentPos(10.f); |
392 scrollbar_layer_impl->SetClipLayerLength(200 / 3.f); | 393 scrollbar_layer_impl->SetClipLayerLength(200 / 3.f); |
393 scrollbar_layer_impl->SetScrollLayerLength(100 + 200 / 3.f); | 394 scrollbar_layer_impl->SetScrollLayerLength(100 + 200 / 3.f); |
394 | 395 |
395 // Thickness should be overridden to 3. | 396 // Thickness should be overridden to 3. |
396 { | 397 { |
397 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 398 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
398 AppendQuadsData data; | 399 AppendQuadsData data; |
399 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); | 400 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); |
400 | 401 |
401 const QuadList& quads = render_pass->quad_list; | 402 const QuadList& quads = render_pass->quad_list; |
402 ASSERT_EQ(1u, quads.size()); | 403 ASSERT_EQ(1u, quads.size()); |
403 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); | 404 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
404 EXPECT_EQ(gfx::Rect(6, 0, 39, 3), quads.front()->rect); | 405 EXPECT_EQ(gfx::Rect(6, 0, 39, 3), quads.front()->rect); |
405 } | 406 } |
406 | 407 |
407 // For solid color scrollbars, position and size should reflect the | 408 // For solid color scrollbars, position and size should reflect the |
408 // current viewport state. | 409 // current viewport state. |
409 scrollbar_layer_impl->SetClipLayerLength(25.f); | 410 scrollbar_layer_impl->SetClipLayerLength(25.f); |
410 scrollbar_layer_impl->SetScrollLayerLength(125.f); | 411 scrollbar_layer_impl->SetScrollLayerLength(125.f); |
411 { | 412 { |
412 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 413 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
413 AppendQuadsData data; | 414 AppendQuadsData data; |
414 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); | 415 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); |
415 | 416 |
416 const QuadList& quads = render_pass->quad_list; | 417 const QuadList& quads = render_pass->quad_list; |
417 ASSERT_EQ(1u, quads.size()); | 418 ASSERT_EQ(1u, quads.size()); |
418 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); | 419 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
419 EXPECT_EQ(gfx::Rect(8, 0, 19, 3), quads.front()->rect); | 420 EXPECT_EQ(gfx::Rect(8, 0, 19, 3), quads.front()->rect); |
420 } | 421 } |
421 | 422 |
422 // We shouldn't attempt div-by-zero when the maximum is zero. | 423 // We shouldn't attempt div-by-zero when the maximum is zero. |
423 scrollbar_layer_impl->SetCurrentPos(0.f); | 424 scrollbar_layer_impl->SetCurrentPos(0.f); |
424 scrollbar_layer_impl->SetClipLayerLength(125.f); | 425 scrollbar_layer_impl->SetClipLayerLength(125.f); |
425 scrollbar_layer_impl->SetScrollLayerLength(125.f); | 426 scrollbar_layer_impl->SetScrollLayerLength(125.f); |
426 { | 427 { |
427 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 428 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
428 AppendQuadsData data; | 429 AppendQuadsData data; |
429 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); | 430 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); |
430 | 431 |
431 const QuadList& quads = render_pass->quad_list; | 432 const QuadList& quads = render_pass->quad_list; |
432 ASSERT_EQ(1u, quads.size()); | 433 ASSERT_EQ(1u, quads.size()); |
433 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); | 434 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
434 EXPECT_EQ(gfx::Rect(1, 0, 98, 3), quads.front()->rect); | 435 EXPECT_EQ(gfx::Rect(1, 0, 98, 3), quads.front()->rect); |
435 } | 436 } |
436 } | 437 } |
437 | 438 |
438 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { | 439 TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { |
439 const int kThumbThickness = 3; | 440 const int kThumbThickness = 3; |
440 const int kTrackStart = 0; | 441 const int kTrackStart = 0; |
441 const int kTrackLength = 10; | 442 const int kTrackLength = 10; |
442 | 443 |
443 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 444 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
444 | 445 |
445 { | 446 { |
446 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 447 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
447 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 448 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
448 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 449 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
449 scoped_refptr<Layer> child1 = Layer::Create(); | 450 scoped_refptr<Layer> child1 = Layer::Create(); |
450 scoped_refptr<Layer> child2; | 451 scoped_refptr<Layer> child2; |
451 const bool kIsLeftSideVerticalScrollbar = false; | 452 const bool kIsLeftSideVerticalScrollbar = false; |
452 child2 = SolidColorScrollbarLayer::Create( | 453 child2 = SolidColorScrollbarLayer::Create( |
453 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 454 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
(...skipping 17 matching lines...) Expand all Loading... |
471 | 472 |
472 auto* scrollbar_layer_impl = | 473 auto* scrollbar_layer_impl = |
473 static_cast<ScrollbarLayerImplBase*>(scroll_layer_impl->children()[1]); | 474 static_cast<ScrollbarLayerImplBase*>(scroll_layer_impl->children()[1]); |
474 | 475 |
475 scroll_layer_impl->ScrollBy(gfx::Vector2dF(4.f, 0.f)); | 476 scroll_layer_impl->ScrollBy(gfx::Vector2dF(4.f, 0.f)); |
476 | 477 |
477 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); | 478 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); |
478 scrollbar_layer_impl->SetCurrentPos(4.f); | 479 scrollbar_layer_impl->SetCurrentPos(4.f); |
479 | 480 |
480 { | 481 { |
481 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 482 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
482 | 483 |
483 AppendQuadsData data; | 484 AppendQuadsData data; |
484 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); | 485 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); |
485 | 486 |
486 const QuadList& quads = render_pass->quad_list; | 487 const QuadList& quads = render_pass->quad_list; |
487 ASSERT_EQ(1u, quads.size()); | 488 ASSERT_EQ(1u, quads.size()); |
488 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); | 489 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
489 EXPECT_EQ(gfx::Rect(3, 0, 3, 3), quads.front()->rect); | 490 EXPECT_EQ(gfx::Rect(3, 0, 3, 3), quads.front()->rect); |
490 } | 491 } |
491 } | 492 } |
(...skipping 26 matching lines...) Expand all Loading... |
518 kThumbThickness, | 519 kThumbThickness, |
519 kTrackStart, | 520 kTrackStart, |
520 kIsLeftSideVerticalScrollbar, | 521 kIsLeftSideVerticalScrollbar, |
521 kIsOverlayScrollbar); | 522 kIsOverlayScrollbar); |
522 } | 523 } |
523 | 524 |
524 protected: | 525 protected: |
525 FakeImplTaskRunnerProvider task_runner_provider_; | 526 FakeImplTaskRunnerProvider task_runner_provider_; |
526 TestSharedBitmapManager shared_bitmap_manager_; | 527 TestSharedBitmapManager shared_bitmap_manager_; |
527 TestTaskGraphRunner task_graph_runner_; | 528 TestTaskGraphRunner task_graph_runner_; |
528 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; | 529 std::unique_ptr<FakeLayerTreeHostImpl> host_impl_; |
529 scoped_ptr<SolidColorScrollbarLayerImpl> horizontal_scrollbar_layer_; | 530 std::unique_ptr<SolidColorScrollbarLayerImpl> horizontal_scrollbar_layer_; |
530 scoped_ptr<SolidColorScrollbarLayerImpl> vertical_scrollbar_layer_; | 531 std::unique_ptr<SolidColorScrollbarLayerImpl> vertical_scrollbar_layer_; |
531 }; | 532 }; |
532 | 533 |
533 TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) { | 534 TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) { |
534 horizontal_scrollbar_layer_->SetCurrentPos(0); | 535 horizontal_scrollbar_layer_->SetCurrentPos(0); |
535 | 536 |
536 // Simple case - one third of the scrollable area is visible, so the thumb | 537 // Simple case - one third of the scrollable area is visible, so the thumb |
537 // should be one third as long as the track. | 538 // should be one third as long as the track. |
538 horizontal_scrollbar_layer_->SetClipLayerLength(5.f); | 539 horizontal_scrollbar_layer_->SetClipLayerLength(5.f); |
539 horizontal_scrollbar_layer_->SetScrollLayerLength(15.f); | 540 horizontal_scrollbar_layer_->SetScrollLayerLength(15.f); |
540 horizontal_scrollbar_layer_->SetBounds(gfx::Size(100, 3)); | 541 horizontal_scrollbar_layer_->SetBounds(gfx::Size(100, 3)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { | 600 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { |
600 public: | 601 public: |
601 ScrollbarLayerTestMaxTextureSize() {} | 602 ScrollbarLayerTestMaxTextureSize() {} |
602 | 603 |
603 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } | 604 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } |
604 | 605 |
605 void BeginTest() override { | 606 void BeginTest() override { |
606 scroll_layer_ = Layer::Create(); | 607 scroll_layer_ = Layer::Create(); |
607 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 608 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
608 | 609 |
609 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 610 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
610 scrollbar_layer_ = PaintedScrollbarLayer::Create(std::move(scrollbar), | 611 scrollbar_layer_ = PaintedScrollbarLayer::Create(std::move(scrollbar), |
611 scroll_layer_->id()); | 612 scroll_layer_->id()); |
612 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); | 613 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); |
613 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); | 614 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); |
614 scrollbar_layer_->SetBounds(bounds_); | 615 scrollbar_layer_->SetBounds(bounds_); |
615 scrollbar_layer_->SetIsDrawable(true); | 616 scrollbar_layer_->SetIsDrawable(true); |
616 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); | 617 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
617 | 618 |
618 PostSetNeedsCommitToMainThread(); | 619 PostSetNeedsCommitToMainThread(); |
619 } | 620 } |
(...skipping 15 matching lines...) Expand all Loading... |
635 | 636 |
636 void AfterTest() override {} | 637 void AfterTest() override {} |
637 | 638 |
638 private: | 639 private: |
639 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer_; | 640 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer_; |
640 scoped_refptr<Layer> scroll_layer_; | 641 scoped_refptr<Layer> scroll_layer_; |
641 gfx::Size bounds_; | 642 gfx::Size bounds_; |
642 }; | 643 }; |
643 | 644 |
644 TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) { | 645 TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) { |
645 scoped_ptr<TestWebGraphicsContext3D> context = | 646 std::unique_ptr<TestWebGraphicsContext3D> context = |
646 TestWebGraphicsContext3D::Create(); | 647 TestWebGraphicsContext3D::Create(); |
647 int max_size = 0; | 648 int max_size = 0; |
648 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); | 649 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); |
649 SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); | 650 SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); |
650 RunTest(CompositorMode::THREADED, false); | 651 RunTest(CompositorMode::THREADED, false); |
651 } | 652 } |
652 | 653 |
653 TEST_F(ScrollbarLayerTestMaxTextureSize, DelegatingRenderer) { | 654 TEST_F(ScrollbarLayerTestMaxTextureSize, DelegatingRenderer) { |
654 scoped_ptr<TestWebGraphicsContext3D> context = | 655 std::unique_ptr<TestWebGraphicsContext3D> context = |
655 TestWebGraphicsContext3D::Create(); | 656 TestWebGraphicsContext3D::Create(); |
656 int max_size = 0; | 657 int max_size = 0; |
657 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); | 658 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); |
658 SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); | 659 SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); |
659 RunTest(CompositorMode::THREADED, true); | 660 RunTest(CompositorMode::THREADED, true); |
660 } | 661 } |
661 | 662 |
662 class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest { | 663 class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest { |
663 public: | 664 public: |
664 void TestResourceUpload(int num_updates, | 665 void TestResourceUpload(int num_updates, |
665 size_t expected_resources, | 666 size_t expected_resources, |
666 int expected_created, | 667 int expected_created, |
667 int expected_deleted, | 668 int expected_deleted, |
668 bool use_solid_color_scrollbar) { | 669 bool use_solid_color_scrollbar) { |
669 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); | 670 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); |
670 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 671 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
671 scoped_refptr<Layer> content_layer = Layer::Create(); | 672 scoped_refptr<Layer> content_layer = Layer::Create(); |
672 scoped_refptr<Layer> scrollbar_layer; | 673 scoped_refptr<Layer> scrollbar_layer; |
673 if (use_solid_color_scrollbar) { | 674 if (use_solid_color_scrollbar) { |
674 const int kThumbThickness = 3; | 675 const int kThumbThickness = 3; |
675 const int kTrackStart = 0; | 676 const int kTrackStart = 0; |
676 const bool kIsLeftSideVerticalScrollbar = false; | 677 const bool kIsLeftSideVerticalScrollbar = false; |
677 scrollbar_layer = SolidColorScrollbarLayer::Create( | 678 scrollbar_layer = SolidColorScrollbarLayer::Create( |
678 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 679 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
679 kIsLeftSideVerticalScrollbar, layer_tree_root->id()); | 680 kIsLeftSideVerticalScrollbar, layer_tree_root->id()); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1013 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
1013 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1014 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
1014 | 1015 |
1015 // Horizontal Scrollbars. | 1016 // Horizontal Scrollbars. |
1016 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1017 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
1017 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1018 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
1018 } | 1019 } |
1019 | 1020 |
1020 } // namespace | 1021 } // namespace |
1021 } // namespace cc | 1022 } // namespace cc |
OLD | NEW |