| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 EXPECT_RECT_EQ(gfx::Rect(0.f, 22, 3.f, 22.f), | 561 EXPECT_RECT_EQ(gfx::Rect(0.f, 22, 3.f, 22.f), |
| 562 vertical_scrollbar_layer_->ComputeThumbQuadRect()); | 562 vertical_scrollbar_layer_->ComputeThumbQuadRect()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { | 565 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { |
| 566 public: | 566 public: |
| 567 ScrollbarLayerTestMaxTextureSize() {} | 567 ScrollbarLayerTestMaxTextureSize() {} |
| 568 | 568 |
| 569 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } | 569 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } |
| 570 | 570 |
| 571 virtual void BeginTest() override { | 571 void BeginTest() override { |
| 572 scroll_layer_ = Layer::Create(); | 572 scroll_layer_ = Layer::Create(); |
| 573 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 573 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 574 | 574 |
| 575 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 575 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 576 scrollbar_layer_ = | 576 scrollbar_layer_ = |
| 577 PaintedScrollbarLayer::Create(scrollbar.Pass(), scroll_layer_->id()); | 577 PaintedScrollbarLayer::Create(scrollbar.Pass(), scroll_layer_->id()); |
| 578 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); | 578 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); |
| 579 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); | 579 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); |
| 580 scrollbar_layer_->SetBounds(bounds_); | 580 scrollbar_layer_->SetBounds(bounds_); |
| 581 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); | 581 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); |
| 582 | 582 |
| 583 PostSetNeedsCommitToMainThread(); | 583 PostSetNeedsCommitToMainThread(); |
| 584 } | 584 } |
| 585 | 585 |
| 586 virtual void DidCommitAndDrawFrame() override { | 586 void DidCommitAndDrawFrame() override { |
| 587 const int kMaxTextureSize = | 587 const int kMaxTextureSize = |
| 588 layer_tree_host()->GetRendererCapabilities().max_texture_size; | 588 layer_tree_host()->GetRendererCapabilities().max_texture_size; |
| 589 | 589 |
| 590 // Check first that we're actually testing something. | 590 // Check first that we're actually testing something. |
| 591 EXPECT_GT(scrollbar_layer_->bounds().width(), kMaxTextureSize); | 591 EXPECT_GT(scrollbar_layer_->bounds().width(), kMaxTextureSize); |
| 592 | 592 |
| 593 EXPECT_EQ(scrollbar_layer_->content_bounds().width(), | 593 EXPECT_EQ(scrollbar_layer_->content_bounds().width(), |
| 594 kMaxTextureSize - 1); | 594 kMaxTextureSize - 1); |
| 595 EXPECT_EQ(scrollbar_layer_->content_bounds().height(), | 595 EXPECT_EQ(scrollbar_layer_->content_bounds().height(), |
| 596 kMaxTextureSize - 1); | 596 kMaxTextureSize - 1); |
| 597 | 597 |
| 598 EndTest(); | 598 EndTest(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 virtual void AfterTest() override {} | 601 void AfterTest() override {} |
| 602 | 602 |
| 603 private: | 603 private: |
| 604 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer_; | 604 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer_; |
| 605 scoped_refptr<Layer> scroll_layer_; | 605 scoped_refptr<Layer> scroll_layer_; |
| 606 gfx::Size bounds_; | 606 gfx::Size bounds_; |
| 607 }; | 607 }; |
| 608 | 608 |
| 609 TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) { | 609 TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) { |
| 610 scoped_ptr<TestWebGraphicsContext3D> context = | 610 scoped_ptr<TestWebGraphicsContext3D> context = |
| 611 TestWebGraphicsContext3D::Create(); | 611 TestWebGraphicsContext3D::Create(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 628 public: | 628 public: |
| 629 FakeLayerTreeHost(FakeLayerTreeHostClient* client, | 629 FakeLayerTreeHost(FakeLayerTreeHostClient* client, |
| 630 const LayerTreeSettings& settings) | 630 const LayerTreeSettings& settings) |
| 631 : LayerTreeHost(client, nullptr, nullptr, settings), | 631 : LayerTreeHost(client, nullptr, nullptr, settings), |
| 632 next_id_(1), | 632 next_id_(1), |
| 633 total_ui_resource_created_(0), | 633 total_ui_resource_created_(0), |
| 634 total_ui_resource_deleted_(0) { | 634 total_ui_resource_deleted_(0) { |
| 635 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); | 635 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); |
| 636 } | 636 } |
| 637 | 637 |
| 638 virtual UIResourceId CreateUIResource(UIResourceClient* content) override { | 638 UIResourceId CreateUIResource(UIResourceClient* content) override { |
| 639 total_ui_resource_created_++; | 639 total_ui_resource_created_++; |
| 640 UIResourceId nid = next_id_++; | 640 UIResourceId nid = next_id_++; |
| 641 ui_resource_bitmap_map_.insert( | 641 ui_resource_bitmap_map_.insert( |
| 642 std::make_pair(nid, content->GetBitmap(nid, false))); | 642 std::make_pair(nid, content->GetBitmap(nid, false))); |
| 643 return nid; | 643 return nid; |
| 644 } | 644 } |
| 645 | 645 |
| 646 // Deletes a UI resource. May safely be called more than once. | 646 // Deletes a UI resource. May safely be called more than once. |
| 647 virtual void DeleteUIResource(UIResourceId id) override { | 647 void DeleteUIResource(UIResourceId id) override { |
| 648 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); | 648 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); |
| 649 if (iter != ui_resource_bitmap_map_.end()) { | 649 if (iter != ui_resource_bitmap_map_.end()) { |
| 650 ui_resource_bitmap_map_.erase(iter); | 650 ui_resource_bitmap_map_.erase(iter); |
| 651 total_ui_resource_deleted_++; | 651 total_ui_resource_deleted_++; |
| 652 } | 652 } |
| 653 } | 653 } |
| 654 | 654 |
| 655 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); } | 655 size_t UIResourceCount() { return ui_resource_bitmap_map_.size(); } |
| 656 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; } | 656 int TotalUIResourceDeleted() { return total_ui_resource_deleted_; } |
| 657 int TotalUIResourceCreated() { return total_ui_resource_created_; } | 657 int TotalUIResourceCreated() { return total_ui_resource_created_; } |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1093 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1094 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1094 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1095 | 1095 |
| 1096 // Horizontal Scrollbars. | 1096 // Horizontal Scrollbars. |
| 1097 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1097 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1098 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1098 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 } // namespace | 1101 } // namespace |
| 1102 } // namespace cc | 1102 } // namespace cc |
| OLD | NEW |