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

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

Issue 1991523002: cc : Track ids for which active opacity always wins on property trees (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
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.cc ('k') | cc/layers/solid_color_scrollbar_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 AppendQuadsData data; 490 AppendQuadsData data;
491 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data); 491 scrollbar_layer_impl->AppendQuads(render_pass.get(), &data);
492 492
493 const QuadList& quads = render_pass->quad_list; 493 const QuadList& quads = render_pass->quad_list;
494 ASSERT_EQ(1u, quads.size()); 494 ASSERT_EQ(1u, quads.size());
495 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material); 495 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads.front()->material);
496 EXPECT_EQ(gfx::Rect(3, 0, 3, 3), quads.front()->rect); 496 EXPECT_EQ(gfx::Rect(3, 0, 3, 3), quads.front()->rect);
497 } 497 }
498 } 498 }
499 499
500 TEST_F(ScrollbarLayerTest, ScrollbarLayerOpacity) {
501 const int kThumbThickness = 3;
502 const int kTrackStart = 0;
503
504 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
505
506 scoped_refptr<Layer> layer_tree_root = Layer::Create();
507 scoped_refptr<Layer> scroll_layer = Layer::Create();
508 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
509 scoped_refptr<Layer> child1 = Layer::Create();
510 scoped_refptr<Layer> scrollbar_layer;
511 const bool kIsLeftSideVerticalScrollbar = false;
512 scrollbar_layer = SolidColorScrollbarLayer::Create(
513 scrollbar->Orientation(), kThumbThickness, kTrackStart,
514 kIsLeftSideVerticalScrollbar, child1->id());
515 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
516 scroll_layer->AddChild(child1);
517 scroll_layer->InsertChild(scrollbar_layer, 1);
518 layer_tree_root->AddChild(scroll_layer);
519 layer_tree_host_->SetRootLayer(layer_tree_root);
520
521 // Choose layer bounds to give max_scroll_offset = (8, 8).
522 layer_tree_root->SetBounds(gfx::Size(2, 2));
523 scroll_layer->SetBounds(gfx::Size(10, 10));
524
525 layer_tree_host_->UpdateLayers();
526
527 LayerImpl* layer_impl_tree_root =
528 layer_tree_host_->CommitAndCreateLayerImplTree();
529
530 scrollbar_layer->SetOpacity(0.5f);
531 layer_tree_host_->UpdateLayers();
532 EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node(
533 scrollbar_layer->effect_tree_index());
534 EXPECT_EQ(node->data.opacity, 0.5f);
535
536 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
537 host_impl->CreatePendingTree();
538 layer_impl_tree_root = layer_tree_host_->CommitAndCreatePendingTree();
539 LayerTreeImpl* layer_tree_impl = layer_impl_tree_root->layer_tree_impl();
540 EXPECT_TRUE(layer_tree_impl->IsPendingTree());
541 layer_tree_impl->property_trees()->effect_tree.Node(
542 scrollbar_layer->effect_tree_index());
543 EXPECT_EQ(node->data.opacity, 0.5f);
544 // The active tree opacity should not change with activation for scrollbar
545 // layer.
546 host_impl->ActivateSyncTree();
547 layer_tree_impl = host_impl->active_tree();
548 node = layer_tree_impl->property_trees()->effect_tree.Node(
549 scrollbar_layer->effect_tree_index());
550 EXPECT_EQ(node->data.opacity, 1.f);
551 }
552
500 class ScrollbarLayerSolidColorThumbTest : public testing::Test { 553 class ScrollbarLayerSolidColorThumbTest : public testing::Test {
501 public: 554 public:
502 ScrollbarLayerSolidColorThumbTest() { 555 ScrollbarLayerSolidColorThumbTest() {
503 LayerTreeSettings layer_tree_settings; 556 LayerTreeSettings layer_tree_settings;
504 host_impl_.reset(new FakeLayerTreeHostImpl( 557 host_impl_.reset(new FakeLayerTreeHostImpl(
505 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_, 558 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_,
506 &task_graph_runner_)); 559 &task_graph_runner_));
507 560
508 const int kThumbThickness = 3; 561 const int kThumbThickness = 3;
509 const int kTrackStart = 0; 562 const int kTrackStart = 0;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 1072 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1020 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1073 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1021 1074
1022 // Horizontal Scrollbars. 1075 // Horizontal Scrollbars.
1023 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1076 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1024 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1077 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1025 } 1078 }
1026 1079
1027 } // namespace 1080 } // namespace
1028 } // namespace cc 1081 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.cc ('k') | cc/layers/solid_color_scrollbar_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698