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 11 matching lines...) Expand all Loading... | |
22 #include "cc/test/layer_tree_test.h" | 22 #include "cc/test/layer_tree_test.h" |
23 #include "cc/test/mock_quad_culler.h" | 23 #include "cc/test/mock_quad_culler.h" |
24 #include "cc/test/test_web_graphics_context_3d.h" | 24 #include "cc/test/test_web_graphics_context_3d.h" |
25 #include "cc/trees/layer_tree_host.h" | 25 #include "cc/trees/layer_tree_host.h" |
26 #include "cc/trees/layer_tree_impl.h" | 26 #include "cc/trees/layer_tree_impl.h" |
27 #include "cc/trees/single_thread_proxy.h" | 27 #include "cc/trees/single_thread_proxy.h" |
28 #include "cc/trees/tree_synchronizer.h" | 28 #include "cc/trees/tree_synchronizer.h" |
29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 using ::testing::_; | |
33 using ::testing::Invoke; | |
34 | |
32 namespace cc { | 35 namespace cc { |
33 namespace { | 36 namespace { |
34 | 37 |
35 LayerImpl* LayerImplForScrollAreaAndScrollbar( | 38 LayerImpl* LayerImplForScrollAreaAndScrollbar( |
36 FakeLayerTreeHost* host, | 39 FakeLayerTreeHost* host, |
37 scoped_ptr<Scrollbar> scrollbar, | 40 scoped_ptr<Scrollbar> scrollbar, |
38 bool reverse_order, | 41 bool reverse_order, |
39 bool use_solid_color_scrollbar, | 42 bool use_solid_color_scrollbar, |
40 int thumb_thickness) { | 43 int thumb_thickness) { |
41 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 44 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 }; | 762 }; |
760 | 763 |
761 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { | 764 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { |
762 // Pick a test scale that moves the scrollbar's (non-zero) position to | 765 // Pick a test scale that moves the scrollbar's (non-zero) position to |
763 // a non-pixel-aligned location. | 766 // a non-pixel-aligned location. |
764 TestResourceUpload(.041f); | 767 TestResourceUpload(.041f); |
765 TestResourceUpload(1.41f); | 768 TestResourceUpload(1.41f); |
766 TestResourceUpload(4.1f); | 769 TestResourceUpload(4.1f); |
767 } | 770 } |
768 | 771 |
772 class ScaledScrollbarLayerTestScaledRasterization : public testing::Test { | |
773 class MockScrollbar : public FakeScrollbar { | |
774 public: | |
775 MockScrollbar(bool paint, bool has_thumb, bool is_overlay) | |
776 : FakeScrollbar(paint, has_thumb, is_overlay) | |
777 {} | |
778 | |
779 MOCK_METHOD3(PaintPart, void(SkCanvas* canvas, | |
780 ScrollbarPart part, | |
781 const gfx::Rect& content_rect)); | |
782 }; | |
783 | |
784 public: | |
785 ScaledScrollbarLayerTestScaledRasterization() | |
786 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} | |
787 | |
788 void TestScale(const gfx::Rect scrollbar_rect, const float test_scale) { | |
789 layer_tree_host_.reset( | |
790 new MockLayerTreeHost(&fake_client_, layer_tree_settings_)); | |
791 | |
792 MockScrollbar* mock_scrollbar = new MockScrollbar(false, false, false); | |
793 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | |
794 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | |
795 FakePaintedScrollbarLayer::Create(false, false, layer_tree_root->id(), | |
796 mock_scrollbar); | |
797 | |
798 layer_tree_root->AddChild(scrollbar_layer); | |
799 | |
800 layer_tree_host_->SetRootLayer(layer_tree_root); | |
801 | |
802 scrollbar_layer->SetBounds(scrollbar_rect.size()); | |
803 scrollbar_layer->SetPosition(scrollbar_rect.origin()); | |
804 scrollbar_layer->fake_scrollbar()->set_location(scrollbar_rect.origin()); | |
805 gfx::SizeF scaled_size = | |
806 gfx::ScaleSize(scrollbar_layer->bounds(), test_scale, test_scale); | |
807 gfx::PointF scaled_location = | |
808 gfx::ScalePoint(scrollbar_layer->position(), test_scale, test_scale); | |
809 scrollbar_layer->draw_properties().content_bounds = | |
810 gfx::Size(scaled_size.width(), scaled_size.height()); | |
811 scrollbar_layer->draw_properties().contents_scale_x = test_scale; | |
812 scrollbar_layer->draw_properties().contents_scale_y = test_scale; | |
813 scrollbar_layer->draw_properties().visible_content_rect = | |
814 gfx::Rect(scaled_location.x(), | |
815 scaled_location.y(), | |
816 scaled_size.width(), | |
817 scaled_size.height()); | |
818 | |
819 ResourceUpdateQueue queue; | |
820 OcclusionTracker occlusion_tracker(gfx::Rect(), false); | |
821 scrollbar_layer->SavePaintProperties(); | |
822 | |
823 EXPECT_CALL(*mock_scrollbar, PaintPart(_, TRACK, scrollbar_rect)); | |
824 | |
825 scrollbar_layer->Update(&queue, &occlusion_tracker); | |
826 scrollbar_layer->ClearRenderSurface(); | |
827 } | |
828 | |
829 protected: | |
830 FakeLayerTreeHostClient fake_client_; | |
831 LayerTreeSettings layer_tree_settings_; | |
832 scoped_ptr<MockLayerTreeHost> layer_tree_host_; | |
833 }; | |
834 | |
835 TEST_F(ScaledScrollbarLayerTestScaledRasterization, TestLostPrecisionInClip) { | |
836 // Try rasterization at a scale that caused problematic floating point | |
837 // clamping causing a black line on scrollbar edges. | |
838 TestScale(gfx::Rect(1117, 0, 15, 677), 7.301320); | |
danakj
2014/02/10 19:17:28
7.301320f
| |
839 } | |
840 | |
769 } // namespace | 841 } // namespace |
770 } // namespace cc | 842 } // namespace cc |
OLD | NEW |