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

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

Issue 2827163005: Remove scroll layer ids from scrollbar layers (Closed)
Patch Set: 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,
36 ElementId scroll_element_id) { 35 ElementId scroll_element_id) {
37 return make_scoped_refptr(new PaintedOverlayScrollbarLayer( 36 return make_scoped_refptr(new PaintedOverlayScrollbarLayer(
38 std::move(scrollbar), scroll_layer_id, scroll_element_id)); 37 std::move(scrollbar), scroll_element_id));
39 } 38 }
40 39
41 PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer( 40 PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer(
42 std::unique_ptr<Scrollbar> scrollbar, 41 std::unique_ptr<Scrollbar> scrollbar,
43 int scroll_layer_id,
44 ElementId scroll_element_id) 42 ElementId scroll_element_id)
45 : scrollbar_(std::move(scrollbar)), 43 : scrollbar_(std::move(scrollbar)),
46 scroll_layer_id_(scroll_layer_id),
47 scroll_element_id_(scroll_element_id), 44 scroll_element_id_(scroll_element_id),
48 thumb_thickness_(scrollbar_->ThumbThickness()), 45 thumb_thickness_(scrollbar_->ThumbThickness()),
49 thumb_length_(scrollbar_->ThumbLength()) { 46 thumb_length_(scrollbar_->ThumbLength()) {
50 DCHECK(scrollbar_->UsesNinePatchThumbResource()); 47 DCHECK(scrollbar_->UsesNinePatchThumbResource());
51 } 48 }
52 49
53 PaintedOverlayScrollbarLayer::~PaintedOverlayScrollbarLayer() {} 50 PaintedOverlayScrollbarLayer::~PaintedOverlayScrollbarLayer() {}
54 51
55 ElementId PaintedOverlayScrollbarLayer::scroll_element_id() const { 52 ElementId PaintedOverlayScrollbarLayer::scroll_element_id() const {
56 return scroll_element_id_; 53 return scroll_element_id_;
57 } 54 }
58 55
59 void PaintedOverlayScrollbarLayer::SetScrollInfo(int layer_id, 56 void PaintedOverlayScrollbarLayer::SetScrollElementId(ElementId element_id) {
60 ElementId element_id) { 57 if (element_id == scroll_element_id_)
61 if (layer_id == scroll_layer_id_ && element_id == scroll_element_id_)
62 return; 58 return;
63 59
64 scroll_layer_id_ = layer_id;
65 scroll_element_id_ = element_id; 60 scroll_element_id_ = element_id;
66 SetNeedsFullTreeSync(); 61 SetNeedsFullTreeSync();
67 } 62 }
68 63
69 bool PaintedOverlayScrollbarLayer::OpacityCanAnimateOnImplThread() const { 64 bool PaintedOverlayScrollbarLayer::OpacityCanAnimateOnImplThread() const {
70 return scrollbar_->IsOverlay(); 65 return scrollbar_->IsOverlay();
71 } 66 }
72 67
73 bool PaintedOverlayScrollbarLayer::AlwaysUseActiveTreeOpacity() const { 68 bool PaintedOverlayScrollbarLayer::AlwaysUseActiveTreeOpacity() const {
74 return true; 69 return true;
75 } 70 }
76 71
77 ScrollbarOrientation PaintedOverlayScrollbarLayer::orientation() const { 72 ScrollbarOrientation PaintedOverlayScrollbarLayer::orientation() const {
78 return scrollbar_->Orientation(); 73 return scrollbar_->Orientation();
79 } 74 }
80 75
81 void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 76 void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
82 Layer::PushPropertiesTo(layer); 77 Layer::PushPropertiesTo(layer);
83 78
84 PaintedOverlayScrollbarLayerImpl* scrollbar_layer = 79 PaintedOverlayScrollbarLayerImpl* scrollbar_layer =
85 static_cast<PaintedOverlayScrollbarLayerImpl*>(layer); 80 static_cast<PaintedOverlayScrollbarLayerImpl*>(layer);
86 81
87 scrollbar_layer->SetScrollInfo(scroll_layer_id_, scroll_element_id_); 82 scrollbar_layer->SetScrollElementId(scroll_element_id_);
88 83
89 scrollbar_layer->SetThumbThickness(thumb_thickness_); 84 scrollbar_layer->SetThumbThickness(thumb_thickness_);
90 scrollbar_layer->SetThumbLength(thumb_length_); 85 scrollbar_layer->SetThumbLength(thumb_length_);
91 if (orientation() == HORIZONTAL) { 86 if (orientation() == HORIZONTAL) {
92 scrollbar_layer->SetTrackStart(track_rect_.x() - location_.x()); 87 scrollbar_layer->SetTrackStart(track_rect_.x() - location_.x());
93 scrollbar_layer->SetTrackLength(track_rect_.width()); 88 scrollbar_layer->SetTrackLength(track_rect_.width());
94 } else { 89 } else {
95 scrollbar_layer->SetTrackStart(track_rect_.y() - location_.y()); 90 scrollbar_layer->SetTrackStart(track_rect_.y() - location_.y());
96 scrollbar_layer->SetTrackLength(track_rect_.height()); 91 scrollbar_layer->SetTrackLength(track_rect_.height());
97 } 92 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 165
171 thumb_resource_ = ScopedUIResource::Create( 166 thumb_resource_ = ScopedUIResource::Create(
172 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); 167 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap));
173 168
174 SetNeedsPushProperties(); 169 SetNeedsPushProperties();
175 170
176 return true; 171 return true;
177 } 172 }
178 173
179 } // namespace cc 174 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698