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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 219 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); |
220 scrollbar_layer->SetBounds(gfx::Size(70, 10)); | 220 scrollbar_layer->SetBounds(gfx::Size(70, 10)); |
221 scrollbar_layer->SetScrollLayer(root_layer->id()); | 221 scrollbar_layer->SetScrollLayer(root_layer->id()); |
222 scrollbar_layer->SetClipLayer(root_clip_layer->id()); | 222 scrollbar_layer->SetClipLayer(root_clip_layer->id()); |
223 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); | 223 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); |
224 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); | 224 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); |
225 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); | 225 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); |
226 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); | 226 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); |
227 | 227 |
228 scrollbar_layer->UpdateThumbAndTrackGeometry(); | 228 scrollbar_layer->UpdateThumbAndTrackGeometry(); |
229 LayerImpl* root_clip_layer_impl = NULL; | 229 LayerImpl* root_clip_layer_impl = nullptr; |
230 LayerImpl* root_layer_impl = NULL; | 230 LayerImpl* root_layer_impl = nullptr; |
231 PaintedScrollbarLayerImpl* scrollbar_layer_impl = NULL; | 231 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; |
232 | 232 |
233 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 233 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
234 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), | 234 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), |
235 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 235 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
236 | 236 |
237 scrollbar_layer->fake_scrollbar()->set_has_thumb(false); | 237 scrollbar_layer->fake_scrollbar()->set_has_thumb(false); |
238 | 238 |
239 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 239 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
240 EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(), | 240 EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(), |
241 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 241 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
(...skipping 21 matching lines...) Expand all Loading... |
263 | 263 |
264 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 264 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); |
265 scrollbar_layer->SetBounds(gfx::Size(70, 10)); | 265 scrollbar_layer->SetBounds(gfx::Size(70, 10)); |
266 scrollbar_layer->SetScrollLayer(root_layer->id()); | 266 scrollbar_layer->SetScrollLayer(root_layer->id()); |
267 scrollbar_layer->SetClipLayer(root_clip_layer->id()); | 267 scrollbar_layer->SetClipLayer(root_clip_layer->id()); |
268 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); | 268 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); |
269 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); | 269 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); |
270 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); | 270 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); |
271 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); | 271 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); |
272 scrollbar_layer->UpdateThumbAndTrackGeometry(); | 272 scrollbar_layer->UpdateThumbAndTrackGeometry(); |
273 LayerImpl* root_clip_layer_impl = NULL; | 273 LayerImpl* root_clip_layer_impl = nullptr; |
274 LayerImpl* root_layer_impl = NULL; | 274 LayerImpl* root_layer_impl = nullptr; |
275 PaintedScrollbarLayerImpl* scrollbar_layer_impl = NULL; | 275 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; |
276 | 276 |
277 // Thumb is at the edge of the scrollbar (should be inset to | 277 // Thumb is at the edge of the scrollbar (should be inset to |
278 // the start of the track within the scrollbar layer's | 278 // the start of the track within the scrollbar layer's |
279 // position). | 279 // position). |
280 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 280 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
281 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), | 281 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), |
282 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 282 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
283 | 283 |
284 // Under-scroll (thumb position should clamp and be unchanged). | 284 // Under-scroll (thumb position should clamp and be unchanged). |
285 root_layer->SetScrollOffset(gfx::ScrollOffset(-5, 0)); | 285 root_layer->SetScrollOffset(gfx::ScrollOffset(-5, 0)); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 int max_size = 0; | 621 int max_size = 0; |
622 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); | 622 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); |
623 SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); | 623 SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); |
624 RunTest(true, true, true); | 624 RunTest(true, true, true); |
625 } | 625 } |
626 | 626 |
627 class FakeLayerTreeHost : public LayerTreeHost { | 627 class FakeLayerTreeHost : public LayerTreeHost { |
628 public: | 628 public: |
629 FakeLayerTreeHost(FakeLayerTreeHostClient* client, | 629 FakeLayerTreeHost(FakeLayerTreeHostClient* client, |
630 const LayerTreeSettings& settings) | 630 const LayerTreeSettings& settings) |
631 : LayerTreeHost(client, NULL, settings), | 631 : LayerTreeHost(client, 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 virtual 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( |
(...skipping 18 matching lines...) Expand all Loading... |
660 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); | 660 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); |
661 if (iter != ui_resource_bitmap_map_.end()) | 661 if (iter != ui_resource_bitmap_map_.end()) |
662 return iter->second.GetSize(); | 662 return iter->second.GetSize(); |
663 return gfx::Size(); | 663 return gfx::Size(); |
664 } | 664 } |
665 | 665 |
666 UIResourceBitmap* ui_resource_bitmap(UIResourceId id) { | 666 UIResourceBitmap* ui_resource_bitmap(UIResourceId id) { |
667 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); | 667 UIResourceBitmapMap::iterator iter = ui_resource_bitmap_map_.find(id); |
668 if (iter != ui_resource_bitmap_map_.end()) | 668 if (iter != ui_resource_bitmap_map_.end()) |
669 return &iter->second; | 669 return &iter->second; |
670 return NULL; | 670 return nullptr; |
671 } | 671 } |
672 | 672 |
673 private: | 673 private: |
674 typedef base::hash_map<UIResourceId, UIResourceBitmap> | 674 typedef base::hash_map<UIResourceId, UIResourceBitmap> |
675 UIResourceBitmapMap; | 675 UIResourceBitmapMap; |
676 UIResourceBitmapMap ui_resource_bitmap_map_; | 676 UIResourceBitmapMap ui_resource_bitmap_map_; |
677 | 677 |
678 int next_id_; | 678 int next_id_; |
679 int total_ui_resource_created_; | 679 int total_ui_resource_created_; |
680 int total_ui_resource_deleted_; | 680 int total_ui_resource_deleted_; |
(...skipping 412 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 |