| 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/layers/append_quads_data.h" | 7 #include "cc/layers/append_quads_data.h" |
| 8 #include "cc/layers/painted_scrollbar_layer.h" | 8 #include "cc/layers/painted_scrollbar_layer.h" |
| 9 #include "cc/layers/painted_scrollbar_layer_impl.h" | 9 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 10 #include "cc/layers/scrollbar_layer_interface.h" | 10 #include "cc/layers/scrollbar_layer_interface.h" |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 EXPECT_RECT_EQ(gfx::Rect(0.f, 22, 3.f, 22.f), | 571 EXPECT_RECT_EQ(gfx::Rect(0.f, 22, 3.f, 22.f), |
| 572 vertical_scrollbar_layer_->ComputeThumbQuadRect()); | 572 vertical_scrollbar_layer_->ComputeThumbQuadRect()); |
| 573 } | 573 } |
| 574 | 574 |
| 575 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { | 575 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { |
| 576 public: | 576 public: |
| 577 ScrollbarLayerTestMaxTextureSize() {} | 577 ScrollbarLayerTestMaxTextureSize() {} |
| 578 | 578 |
| 579 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } | 579 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } |
| 580 | 580 |
| 581 virtual void BeginTest() OVERRIDE { | 581 virtual void BeginTest() override { |
| 582 scroll_layer_ = Layer::Create(); | 582 scroll_layer_ = Layer::Create(); |
| 583 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 583 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 584 | 584 |
| 585 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 585 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 586 scrollbar_layer_ = | 586 scrollbar_layer_ = |
| 587 PaintedScrollbarLayer::Create(scrollbar.Pass(), scroll_layer_->id()); | 587 PaintedScrollbarLayer::Create(scrollbar.Pass(), scroll_layer_->id()); |
| 588 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); | 588 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); |
| 589 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); | 589 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); |
| 590 scrollbar_layer_->SetBounds(bounds_); | 590 scrollbar_layer_->SetBounds(bounds_); |
| 591 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); | 591 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
| 592 | 592 |
| 593 PostSetNeedsCommitToMainThread(); | 593 PostSetNeedsCommitToMainThread(); |
| 594 } | 594 } |
| 595 | 595 |
| 596 virtual void DidCommitAndDrawFrame() OVERRIDE { | 596 virtual void DidCommitAndDrawFrame() override { |
| 597 const int kMaxTextureSize = | 597 const int kMaxTextureSize = |
| 598 layer_tree_host()->GetRendererCapabilities().max_texture_size; | 598 layer_tree_host()->GetRendererCapabilities().max_texture_size; |
| 599 | 599 |
| 600 // Check first that we're actually testing something. | 600 // Check first that we're actually testing something. |
| 601 EXPECT_GT(scrollbar_layer_->bounds().width(), kMaxTextureSize); | 601 EXPECT_GT(scrollbar_layer_->bounds().width(), kMaxTextureSize); |
| 602 | 602 |
| 603 EXPECT_EQ(scrollbar_layer_->content_bounds().width(), | 603 EXPECT_EQ(scrollbar_layer_->content_bounds().width(), |
| 604 kMaxTextureSize - 1); | 604 kMaxTextureSize - 1); |
| 605 EXPECT_EQ(scrollbar_layer_->content_bounds().height(), | 605 EXPECT_EQ(scrollbar_layer_->content_bounds().height(), |
| 606 kMaxTextureSize - 1); | 606 kMaxTextureSize - 1); |
| 607 | 607 |
| 608 EndTest(); | 608 EndTest(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 virtual void AfterTest() OVERRIDE {} | 611 virtual void AfterTest() override {} |
| 612 | 612 |
| 613 private: | 613 private: |
| 614 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer_; | 614 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer_; |
| 615 scoped_refptr<Layer> scroll_layer_; | 615 scoped_refptr<Layer> scroll_layer_; |
| 616 gfx::Size bounds_; | 616 gfx::Size bounds_; |
| 617 }; | 617 }; |
| 618 | 618 |
| 619 TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) { | 619 TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) { |
| 620 scoped_ptr<TestWebGraphicsContext3D> context = | 620 scoped_ptr<TestWebGraphicsContext3D> context = |
| 621 TestWebGraphicsContext3D::Create(); | 621 TestWebGraphicsContext3D::Create(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 638 public: | 638 public: |
| 639 FakeLayerTreeHost(FakeLayerTreeHostClient* client, | 639 FakeLayerTreeHost(FakeLayerTreeHostClient* client, |
| 640 const LayerTreeSettings& settings) | 640 const LayerTreeSettings& settings) |
| 641 : LayerTreeHost(client, NULL, settings), | 641 : LayerTreeHost(client, NULL, settings), |
| 642 next_id_(1), | 642 next_id_(1), |
| 643 total_ui_resource_created_(0), | 643 total_ui_resource_created_(0), |
| 644 total_ui_resource_deleted_(0) { | 644 total_ui_resource_deleted_(0) { |
| 645 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); | 645 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); |
| 646 } | 646 } |
| 647 | 647 |
| 648 virtual UIResourceId CreateUIResource(UIResourceClient* content) OVERRIDE { | 648 virtual UIResourceId CreateUIResource(UIResourceClient* content) override { |
| 649 total_ui_resource_created_++; | 649 total_ui_resource_created_++; |
| 650 UIResourceId nid = next_id_++; | 650 UIResourceId nid = next_id_++; |
| 651 ui_resource_bitmap_map_.insert( | 651 ui_resource_bitmap_map_.insert( |
| 652 std::make_pair(nid, content->GetBitmap(nid, false))); | 652 std::make_pair(nid, content->GetBitmap(nid, false))); |
| 653 return nid; | 653 return nid; |
| 654 } | 654 } |
| 655 | 655 |
| 656 // Deletes a UI resource. May safely be called more than once. | 656 // Deletes a UI resource. May safely be called more than once. |
| 657 virtual void DeleteUIResource(UIResourceId id) OVERRIDE { | 657 virtual void DeleteUIResource(UIResourceId id) override { |
| 658 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); | 658 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); |
| 659 if (iter != ui_resource_bitmap_map_.end()) { | 659 if (iter != ui_resource_bitmap_map_.end()) { |
| 660 ui_resource_bitmap_map_.erase(iter); | 660 ui_resource_bitmap_map_.erase(iter); |
| 661 total_ui_resource_deleted_++; | 661 total_ui_resource_deleted_++; |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 | 664 |
| 665 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); } | 665 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); } |
| 666 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; } | 666 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; } |
| 667 int TotalUIResourceCreated() { return total_ui_resource_created_; } | 667 int TotalUIResourceCreated() { return total_ui_resource_created_; } |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1103 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1104 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1104 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1105 | 1105 |
| 1106 // Horizontal Scrollbars. | 1106 // Horizontal Scrollbars. |
| 1107 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1107 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1108 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1108 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 } // namespace | 1111 } // namespace |
| 1112 } // namespace cc | 1112 } // namespace cc |
| OLD | NEW |