Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 1999783003: cc : Initialize solid color scrollbar layer on main thread to 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 8
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "cc/input/scrollbar_animation_controller.h" 10 #include "cc/input/scrollbar_animation_controller.h"
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); 515 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
516 scroll_layer->AddChild(child1); 516 scroll_layer->AddChild(child1);
517 scroll_layer->InsertChild(scrollbar_layer, 1); 517 scroll_layer->InsertChild(scrollbar_layer, 1);
518 layer_tree_root->AddChild(scroll_layer); 518 layer_tree_root->AddChild(scroll_layer);
519 layer_tree_host_->SetRootLayer(layer_tree_root); 519 layer_tree_host_->SetRootLayer(layer_tree_root);
520 520
521 // Choose layer bounds to give max_scroll_offset = (8, 8). 521 // Choose layer bounds to give max_scroll_offset = (8, 8).
522 layer_tree_root->SetBounds(gfx::Size(2, 2)); 522 layer_tree_root->SetBounds(gfx::Size(2, 2));
523 scroll_layer->SetBounds(gfx::Size(10, 10)); 523 scroll_layer->SetBounds(gfx::Size(10, 10));
524 524
525 layer_tree_host_->UpdateLayers(); 525 // A solid color scrollbar layer's opacity is initialized to 0 on main thread
526
527 LayerImpl* layer_impl_tree_root =
528 layer_tree_host_->CommitAndCreateLayerImplTree();
529
530 scrollbar_layer->SetOpacity(0.5f);
531 layer_tree_host_->UpdateLayers(); 526 layer_tree_host_->UpdateLayers();
532 EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node( 527 EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node(
533 scrollbar_layer->effect_tree_index()); 528 scrollbar_layer->effect_tree_index());
534 EXPECT_EQ(node->data.opacity, 0.5f); 529 EXPECT_EQ(node->data.opacity, 0.f);
535 530
531 // This tests that the initial opacity(0) of the scrollbar gets pushed onto
532 // the pending tree and then onto the active tree.
536 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); 533 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
537 host_impl->CreatePendingTree(); 534 host_impl->CreatePendingTree();
538 layer_impl_tree_root = layer_tree_host_->CommitAndCreatePendingTree(); 535 LayerImpl* layer_impl_tree_root =
536 layer_tree_host_->CommitAndCreatePendingTree();
539 LayerTreeImpl* layer_tree_impl = layer_impl_tree_root->layer_tree_impl(); 537 LayerTreeImpl* layer_tree_impl = layer_impl_tree_root->layer_tree_impl();
540 EXPECT_TRUE(layer_tree_impl->IsPendingTree()); 538 EXPECT_TRUE(layer_tree_impl->IsPendingTree());
541 layer_tree_impl->property_trees()->effect_tree.Node( 539 node = layer_tree_impl->property_trees()->effect_tree.Node(
542 scrollbar_layer->effect_tree_index()); 540 scrollbar_layer->effect_tree_index());
543 EXPECT_EQ(node->data.opacity, 0.5f); 541 EXPECT_EQ(node->data.opacity, 0.f);
544 // The active tree opacity should not change with activation for scrollbar
545 // layer.
546 host_impl->ActivateSyncTree(); 542 host_impl->ActivateSyncTree();
547 layer_tree_impl = host_impl->active_tree(); 543 layer_tree_impl = host_impl->active_tree();
548 node = layer_tree_impl->property_trees()->effect_tree.Node( 544 node = layer_tree_impl->property_trees()->effect_tree.Node(
549 scrollbar_layer->effect_tree_index()); 545 scrollbar_layer->effect_tree_index());
550 EXPECT_EQ(node->data.opacity, 1.f); 546 EXPECT_EQ(node->data.opacity, 0.f);
547
548 // This tests that activation does not change the opacity of scrollbar layer.
549 LayerImpl* scrollbar_layer_impl =
550 layer_tree_impl->LayerById(scrollbar_layer->id());
551 scrollbar_layer_impl->OnOpacityAnimated(0.25f);
552 host_impl->CreatePendingTree();
553 layer_impl_tree_root = layer_tree_host_->CommitAndCreatePendingTree();
554 layer_tree_impl = layer_impl_tree_root->layer_tree_impl();
555 EXPECT_TRUE(layer_tree_impl->IsPendingTree());
556 node = layer_tree_impl->property_trees()->effect_tree.Node(
557 scrollbar_layer->effect_tree_index());
558 EXPECT_EQ(node->data.opacity, 0.f);
559 host_impl->ActivateSyncTree();
560 layer_tree_impl = host_impl->active_tree();
561 node = layer_tree_impl->property_trees()->effect_tree.Node(
562 scrollbar_layer->effect_tree_index());
563 EXPECT_EQ(node->data.opacity, 0.25f);
551 } 564 }
552 565
553 class ScrollbarLayerSolidColorThumbTest : public testing::Test { 566 class ScrollbarLayerSolidColorThumbTest : public testing::Test {
554 public: 567 public:
555 ScrollbarLayerSolidColorThumbTest() { 568 ScrollbarLayerSolidColorThumbTest() {
556 LayerTreeSettings layer_tree_settings; 569 LayerTreeSettings layer_tree_settings;
557 host_impl_.reset(new FakeLayerTreeHostImpl( 570 host_impl_.reset(new FakeLayerTreeHostImpl(
558 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_, 571 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_,
559 &task_graph_runner_)); 572 &task_graph_runner_));
560 573
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 1085 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1073 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1086 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1074 1087
1075 // Horizontal Scrollbars. 1088 // Horizontal Scrollbars.
1076 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1089 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1077 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1090 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1078 } 1091 }
1079 1092
1080 } // namespace 1093 } // namespace
1081 } // namespace cc 1094 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698