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

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

Issue 2816063003: Replace layer id with Element id for tracking scrollbar animation controllers (Closed)
Patch Set: Fix flaky LayerTreeHostImplTestScrollbarOpacity.Android Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/layers/painted_overlay_scrollbar_layer.h" 5 #include "cc/layers/painted_overlay_scrollbar_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 14 matching lines...) Expand all
25 25
26 std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl( 26 std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl(
27 LayerTreeImpl* tree_impl) { 27 LayerTreeImpl* tree_impl) {
28 return PaintedOverlayScrollbarLayerImpl::Create( 28 return PaintedOverlayScrollbarLayerImpl::Create(
29 tree_impl, id(), scrollbar_->Orientation(), 29 tree_impl, id(), scrollbar_->Orientation(),
30 scrollbar_->IsLeftSideVerticalScrollbar()); 30 scrollbar_->IsLeftSideVerticalScrollbar());
31 } 31 }
32 32
33 scoped_refptr<PaintedOverlayScrollbarLayer> 33 scoped_refptr<PaintedOverlayScrollbarLayer>
34 PaintedOverlayScrollbarLayer::Create(std::unique_ptr<Scrollbar> scrollbar, 34 PaintedOverlayScrollbarLayer::Create(std::unique_ptr<Scrollbar> scrollbar,
35 int scroll_layer_id) { 35 int scroll_layer_id,
36 return make_scoped_refptr( 36 ElementId scroll_element_id) {
37 new PaintedOverlayScrollbarLayer(std::move(scrollbar), scroll_layer_id)); 37 return make_scoped_refptr(new PaintedOverlayScrollbarLayer(
38 std::move(scrollbar), scroll_layer_id, scroll_element_id));
38 } 39 }
39 40
40 PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer( 41 PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer(
41 std::unique_ptr<Scrollbar> scrollbar, 42 std::unique_ptr<Scrollbar> scrollbar,
42 int scroll_layer_id) 43 int scroll_layer_id,
44 ElementId scroll_element_id)
43 : scrollbar_(std::move(scrollbar)), 45 : scrollbar_(std::move(scrollbar)),
44 scroll_layer_id_(scroll_layer_id), 46 scroll_layer_id_(scroll_layer_id),
47 scroll_element_id_(scroll_element_id),
45 thumb_thickness_(scrollbar_->ThumbThickness()), 48 thumb_thickness_(scrollbar_->ThumbThickness()),
46 thumb_length_(scrollbar_->ThumbLength()) { 49 thumb_length_(scrollbar_->ThumbLength()) {
47 DCHECK(scrollbar_->UsesNinePatchThumbResource()); 50 DCHECK(scrollbar_->UsesNinePatchThumbResource());
48 } 51 }
49 52
50 PaintedOverlayScrollbarLayer::~PaintedOverlayScrollbarLayer() {} 53 PaintedOverlayScrollbarLayer::~PaintedOverlayScrollbarLayer() {}
51 54
52 int PaintedOverlayScrollbarLayer::ScrollLayerId() const { 55 int PaintedOverlayScrollbarLayer::ScrollLayerId() const {
53 return scroll_layer_id_; 56 return scroll_layer_id_;
54 } 57 }
55 58
56 void PaintedOverlayScrollbarLayer::SetScrollLayer(int layer_id) { 59 ElementId PaintedOverlayScrollbarLayer::ScrollElementId() const {
57 if (layer_id == scroll_layer_id_) 60 return scroll_element_id_;
61 }
62
63 void PaintedOverlayScrollbarLayer::SetScrollInfo(int layer_id,
64 ElementId element_id) {
65 if (layer_id == scroll_layer_id_ && element_id == scroll_element_id_)
58 return; 66 return;
59 67
60 scroll_layer_id_ = layer_id; 68 scroll_layer_id_ = layer_id;
69 scroll_element_id_ = element_id;
61 SetNeedsFullTreeSync(); 70 SetNeedsFullTreeSync();
62 } 71 }
63 72
64 bool PaintedOverlayScrollbarLayer::OpacityCanAnimateOnImplThread() const { 73 bool PaintedOverlayScrollbarLayer::OpacityCanAnimateOnImplThread() const {
65 return scrollbar_->IsOverlay(); 74 return scrollbar_->IsOverlay();
66 } 75 }
67 76
68 bool PaintedOverlayScrollbarLayer::AlwaysUseActiveTreeOpacity() const { 77 bool PaintedOverlayScrollbarLayer::AlwaysUseActiveTreeOpacity() const {
69 return true; 78 return true;
70 } 79 }
71 80
72 ScrollbarOrientation PaintedOverlayScrollbarLayer::orientation() const { 81 ScrollbarOrientation PaintedOverlayScrollbarLayer::orientation() const {
73 return scrollbar_->Orientation(); 82 return scrollbar_->Orientation();
74 } 83 }
75 84
76 void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 85 void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
77 Layer::PushPropertiesTo(layer); 86 Layer::PushPropertiesTo(layer);
78 87
79 PaintedOverlayScrollbarLayerImpl* scrollbar_layer = 88 PaintedOverlayScrollbarLayerImpl* scrollbar_layer =
80 static_cast<PaintedOverlayScrollbarLayerImpl*>(layer); 89 static_cast<PaintedOverlayScrollbarLayerImpl*>(layer);
81 90
82 scrollbar_layer->SetScrollLayerId(scroll_layer_id_); 91 scrollbar_layer->SetScrollInfo(scroll_layer_id_, scroll_element_id_);
83 92
84 scrollbar_layer->SetThumbThickness(thumb_thickness_); 93 scrollbar_layer->SetThumbThickness(thumb_thickness_);
85 scrollbar_layer->SetThumbLength(thumb_length_); 94 scrollbar_layer->SetThumbLength(thumb_length_);
86 if (orientation() == HORIZONTAL) { 95 if (orientation() == HORIZONTAL) {
87 scrollbar_layer->SetTrackStart(track_rect_.x() - location_.x()); 96 scrollbar_layer->SetTrackStart(track_rect_.x() - location_.x());
88 scrollbar_layer->SetTrackLength(track_rect_.width()); 97 scrollbar_layer->SetTrackLength(track_rect_.width());
89 } else { 98 } else {
90 scrollbar_layer->SetTrackStart(track_rect_.y() - location_.y()); 99 scrollbar_layer->SetTrackStart(track_rect_.y() - location_.y());
91 scrollbar_layer->SetTrackLength(track_rect_.height()); 100 scrollbar_layer->SetTrackLength(track_rect_.height());
92 } 101 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 174
166 thumb_resource_ = ScopedUIResource::Create( 175 thumb_resource_ = ScopedUIResource::Create(
167 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); 176 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap));
168 177
169 SetNeedsPushProperties(); 178 SetNeedsPushProperties();
170 179
171 return true; 180 return true;
172 } 181 }
173 182
174 } // namespace cc 183 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698