| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // Thickness should be overridden to 3. | 339 // Thickness should be overridden to 3. |
| 340 { | 340 { |
| 341 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 341 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 342 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 342 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 343 AppendQuadsData data; | 343 AppendQuadsData data; |
| 344 scrollbar_layer_impl->AppendQuads( | 344 scrollbar_layer_impl->AppendQuads( |
| 345 render_pass.get(), occlusion_tracker, &data); | 345 render_pass.get(), occlusion_tracker, &data); |
| 346 | 346 |
| 347 const QuadList& quads = render_pass->quad_list; | 347 const QuadList& quads = render_pass->quad_list; |
| 348 ASSERT_EQ(1u, quads.size()); | 348 ASSERT_EQ(1u, quads.size()); |
| 349 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); | 349 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
| 350 EXPECT_RECT_EQ(gfx::Rect(6, 0, 39, 3), quads[0]->rect); | 350 EXPECT_RECT_EQ(gfx::Rect(6, 0, 39, 3), quads.front()->rect); |
| 351 } | 351 } |
| 352 | 352 |
| 353 // Contents scale should scale the draw quad. | 353 // Contents scale should scale the draw quad. |
| 354 scrollbar_layer_impl->draw_properties().contents_scale_x = 2.f; | 354 scrollbar_layer_impl->draw_properties().contents_scale_x = 2.f; |
| 355 scrollbar_layer_impl->draw_properties().contents_scale_y = 2.f; | 355 scrollbar_layer_impl->draw_properties().contents_scale_y = 2.f; |
| 356 { | 356 { |
| 357 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 357 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 358 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 358 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 359 AppendQuadsData data; | 359 AppendQuadsData data; |
| 360 scrollbar_layer_impl->AppendQuads( | 360 scrollbar_layer_impl->AppendQuads( |
| 361 render_pass.get(), occlusion_tracker, &data); | 361 render_pass.get(), occlusion_tracker, &data); |
| 362 | 362 |
| 363 const QuadList& quads = render_pass->quad_list; | 363 const QuadList& quads = render_pass->quad_list; |
| 364 ASSERT_EQ(1u, quads.size()); | 364 ASSERT_EQ(1u, quads.size()); |
| 365 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); | 365 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
| 366 EXPECT_RECT_EQ(gfx::Rect(12, 0, 78, 6), quads[0]->rect); | 366 EXPECT_RECT_EQ(gfx::Rect(12, 0, 78, 6), quads.front()->rect); |
| 367 } | 367 } |
| 368 scrollbar_layer_impl->draw_properties().contents_scale_x = 1.f; | 368 scrollbar_layer_impl->draw_properties().contents_scale_x = 1.f; |
| 369 scrollbar_layer_impl->draw_properties().contents_scale_y = 1.f; | 369 scrollbar_layer_impl->draw_properties().contents_scale_y = 1.f; |
| 370 | 370 |
| 371 // For solid color scrollbars, position and size should reflect the | 371 // For solid color scrollbars, position and size should reflect the |
| 372 // current viewport state. | 372 // current viewport state. |
| 373 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.2f); | 373 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.2f); |
| 374 { | 374 { |
| 375 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 375 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 376 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 376 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 377 AppendQuadsData data; | 377 AppendQuadsData data; |
| 378 scrollbar_layer_impl->AppendQuads( | 378 scrollbar_layer_impl->AppendQuads( |
| 379 render_pass.get(), occlusion_tracker, &data); | 379 render_pass.get(), occlusion_tracker, &data); |
| 380 | 380 |
| 381 const QuadList& quads = render_pass->quad_list; | 381 const QuadList& quads = render_pass->quad_list; |
| 382 ASSERT_EQ(1u, quads.size()); | 382 ASSERT_EQ(1u, quads.size()); |
| 383 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); | 383 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
| 384 EXPECT_RECT_EQ(gfx::Rect(8, 0, 19, 3), quads[0]->rect); | 384 EXPECT_RECT_EQ(gfx::Rect(8, 0, 19, 3), quads.front()->rect); |
| 385 } | 385 } |
| 386 | 386 |
| 387 // We shouldn't attempt div-by-zero when the maximum is zero. | 387 // We shouldn't attempt div-by-zero when the maximum is zero. |
| 388 scrollbar_layer_impl->SetCurrentPos(0.f); | 388 scrollbar_layer_impl->SetCurrentPos(0.f); |
| 389 scrollbar_layer_impl->SetMaximum(0); | 389 scrollbar_layer_impl->SetMaximum(0); |
| 390 { | 390 { |
| 391 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 391 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 392 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 392 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 393 AppendQuadsData data; | 393 AppendQuadsData data; |
| 394 scrollbar_layer_impl->AppendQuads( | 394 scrollbar_layer_impl->AppendQuads( |
| 395 render_pass.get(), occlusion_tracker, &data); | 395 render_pass.get(), occlusion_tracker, &data); |
| 396 | 396 |
| 397 const QuadList& quads = render_pass->quad_list; | 397 const QuadList& quads = render_pass->quad_list; |
| 398 ASSERT_EQ(1u, quads.size()); | 398 ASSERT_EQ(1u, quads.size()); |
| 399 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); | 399 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
| 400 EXPECT_RECT_EQ(gfx::Rect(1, 0, 19, 3), quads[0]->rect); | 400 EXPECT_RECT_EQ(gfx::Rect(1, 0, 19, 3), quads.front()->rect); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { | 404 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { |
| 405 const int kThumbThickness = 3; | 405 const int kThumbThickness = 3; |
| 406 const int kTrackStart = 0; | 406 const int kTrackStart = 0; |
| 407 const int kTrackLength = 10; | 407 const int kTrackLength = 10; |
| 408 | 408 |
| 409 LayerTreeSettings layer_tree_settings; | 409 LayerTreeSettings layer_tree_settings; |
| 410 scoped_ptr<FakeLayerTreeHost> host = | 410 scoped_ptr<FakeLayerTreeHost> host = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 { | 449 { |
| 450 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 450 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 451 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 451 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 452 | 452 |
| 453 AppendQuadsData data; | 453 AppendQuadsData data; |
| 454 scrollbar_layer_impl->AppendQuads( | 454 scrollbar_layer_impl->AppendQuads( |
| 455 render_pass.get(), occlusion_tracker, &data); | 455 render_pass.get(), occlusion_tracker, &data); |
| 456 | 456 |
| 457 const QuadList& quads = render_pass->quad_list; | 457 const QuadList& quads = render_pass->quad_list; |
| 458 ASSERT_EQ(1u, quads.size()); | 458 ASSERT_EQ(1u, quads.size()); |
| 459 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); | 459 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); |
| 460 EXPECT_RECT_EQ(gfx::Rect(3, 0, 3, 3), quads[0]->rect); | 460 EXPECT_RECT_EQ(gfx::Rect(3, 0, 3, 3), quads.front()->rect); |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 | 463 |
| 464 class ScrollbarLayerSolidColorThumbTest : public testing::Test { | 464 class ScrollbarLayerSolidColorThumbTest : public testing::Test { |
| 465 public: | 465 public: |
| 466 ScrollbarLayerSolidColorThumbTest() { | 466 ScrollbarLayerSolidColorThumbTest() { |
| 467 LayerTreeSettings layer_tree_settings; | 467 LayerTreeSettings layer_tree_settings; |
| 468 host_impl_.reset(new FakeLayerTreeHostImpl( | 468 host_impl_.reset(new FakeLayerTreeHostImpl( |
| 469 layer_tree_settings, &proxy_, &shared_bitmap_manager_)); | 469 layer_tree_settings, &proxy_, &shared_bitmap_manager_)); |
| 470 | 470 |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1095 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1096 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1096 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1097 | 1097 |
| 1098 // Horizontal Scrollbars. | 1098 // Horizontal Scrollbars. |
| 1099 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1099 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1100 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1100 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 } // namespace | 1103 } // namespace |
| 1104 } // namespace cc | 1104 } // namespace cc |
| OLD | NEW |