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

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

Issue 2816063003: Replace layer id with Element id for tracking scrollbar animation controllers (Closed)
Patch Set: Address reviewer comments, pull element_id.h change to another patch 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_scrollbar_layer.h" 5 #include "cc/layers/painted_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 16 matching lines...) Expand all
27 27
28 std::unique_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl( 28 std::unique_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl(
29 LayerTreeImpl* tree_impl) { 29 LayerTreeImpl* tree_impl) {
30 return PaintedScrollbarLayerImpl::Create( 30 return PaintedScrollbarLayerImpl::Create(
31 tree_impl, id(), scrollbar_->Orientation(), 31 tree_impl, id(), scrollbar_->Orientation(),
32 scrollbar_->IsLeftSideVerticalScrollbar(), scrollbar_->IsOverlay()); 32 scrollbar_->IsLeftSideVerticalScrollbar(), scrollbar_->IsOverlay());
33 } 33 }
34 34
35 scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create( 35 scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create(
36 std::unique_ptr<Scrollbar> scrollbar, 36 std::unique_ptr<Scrollbar> scrollbar,
37 int scroll_layer_id) { 37 int scroll_layer_id,
38 return make_scoped_refptr( 38 ElementId scroll_element_id) {
39 new PaintedScrollbarLayer(std::move(scrollbar), scroll_layer_id)); 39 return make_scoped_refptr(new PaintedScrollbarLayer(
40 std::move(scrollbar), scroll_layer_id, scroll_element_id));
40 } 41 }
41 42
42 PaintedScrollbarLayer::PaintedScrollbarLayer( 43 PaintedScrollbarLayer::PaintedScrollbarLayer(
43 std::unique_ptr<Scrollbar> scrollbar, 44 std::unique_ptr<Scrollbar> scrollbar,
44 int scroll_layer_id) 45 int scroll_layer_id,
46 ElementId scroll_element_id)
45 : scrollbar_(std::move(scrollbar)), 47 : scrollbar_(std::move(scrollbar)),
46 scroll_layer_id_(scroll_layer_id), 48 scroll_layer_id_(scroll_layer_id),
49 scroll_element_id_(scroll_element_id),
47 internal_contents_scale_(1.f), 50 internal_contents_scale_(1.f),
48 thumb_thickness_(scrollbar_->ThumbThickness()), 51 thumb_thickness_(scrollbar_->ThumbThickness()),
49 thumb_length_(scrollbar_->ThumbLength()), 52 thumb_length_(scrollbar_->ThumbLength()),
50 is_overlay_(scrollbar_->IsOverlay()), 53 is_overlay_(scrollbar_->IsOverlay()),
51 has_thumb_(scrollbar_->HasThumb()), 54 has_thumb_(scrollbar_->HasThumb()),
52 thumb_opacity_(scrollbar_->ThumbOpacity()) { 55 thumb_opacity_(scrollbar_->ThumbOpacity()) {
53 if (!scrollbar_->IsOverlay()) 56 if (!scrollbar_->IsOverlay())
54 AddMainThreadScrollingReasons( 57 AddMainThreadScrollingReasons(
55 MainThreadScrollingReason::kScrollbarScrolling); 58 MainThreadScrollingReason::kScrollbarScrolling);
56 } 59 }
57 60
58 PaintedScrollbarLayer::~PaintedScrollbarLayer() {} 61 PaintedScrollbarLayer::~PaintedScrollbarLayer() {}
59 62
60 int PaintedScrollbarLayer::ScrollLayerId() const { 63 ElementId PaintedScrollbarLayer::scroll_element_id() const {
61 return scroll_layer_id_; 64 return scroll_element_id_;
62 } 65 }
63 66
64 void PaintedScrollbarLayer::SetScrollLayer(int layer_id) { 67 void PaintedScrollbarLayer::SetScrollInfo(int layer_id, ElementId element_id) {
65 if (layer_id == scroll_layer_id_) 68 if (layer_id == scroll_layer_id_ && element_id == scroll_element_id_)
66 return; 69 return;
67 70
68 scroll_layer_id_ = layer_id; 71 scroll_layer_id_ = layer_id;
72 scroll_element_id_ = element_id;
69 SetNeedsFullTreeSync(); 73 SetNeedsFullTreeSync();
70 } 74 }
71 75
72 bool PaintedScrollbarLayer::OpacityCanAnimateOnImplThread() const { 76 bool PaintedScrollbarLayer::OpacityCanAnimateOnImplThread() const {
73 return scrollbar_->IsOverlay(); 77 return scrollbar_->IsOverlay();
74 } 78 }
75 79
76 bool PaintedScrollbarLayer::AlwaysUseActiveTreeOpacity() const { 80 bool PaintedScrollbarLayer::AlwaysUseActiveTreeOpacity() const {
77 return true; 81 return true;
78 } 82 }
79 83
80 ScrollbarOrientation PaintedScrollbarLayer::orientation() const { 84 ScrollbarOrientation PaintedScrollbarLayer::orientation() const {
81 return scrollbar_->Orientation(); 85 return scrollbar_->Orientation();
82 } 86 }
83 87
84 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 88 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
85 Layer::PushPropertiesTo(layer); 89 Layer::PushPropertiesTo(layer);
86 90
87 PaintedScrollbarLayerImpl* scrollbar_layer = 91 PaintedScrollbarLayerImpl* scrollbar_layer =
88 static_cast<PaintedScrollbarLayerImpl*>(layer); 92 static_cast<PaintedScrollbarLayerImpl*>(layer);
89 93
90 scrollbar_layer->SetScrollLayerId(scroll_layer_id_); 94 scrollbar_layer->SetScrollInfo(scroll_layer_id_, scroll_element_id_);
91 scrollbar_layer->set_internal_contents_scale_and_bounds( 95 scrollbar_layer->set_internal_contents_scale_and_bounds(
92 internal_contents_scale_, internal_content_bounds_); 96 internal_contents_scale_, internal_content_bounds_);
93 97
94 scrollbar_layer->SetThumbThickness(thumb_thickness_); 98 scrollbar_layer->SetThumbThickness(thumb_thickness_);
95 scrollbar_layer->SetThumbLength(thumb_length_); 99 scrollbar_layer->SetThumbLength(thumb_length_);
96 if (orientation() == HORIZONTAL) { 100 if (orientation() == HORIZONTAL) {
97 scrollbar_layer->SetTrackStart( 101 scrollbar_layer->SetTrackStart(
98 track_rect_.x() - location_.x()); 102 track_rect_.x() - location_.x());
99 scrollbar_layer->SetTrackLength(track_rect_.width()); 103 scrollbar_layer->SetTrackLength(track_rect_.width());
100 } else { 104 } else {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 289
286 scrollbar_->PaintPart(&canvas, part, layer_rect); 290 scrollbar_->PaintPart(&canvas, part, layer_rect);
287 // Make sure that the pixels are no longer mutable to unavoid unnecessary 291 // Make sure that the pixels are no longer mutable to unavoid unnecessary
288 // allocation and copying. 292 // allocation and copying.
289 skbitmap.setImmutable(); 293 skbitmap.setImmutable();
290 294
291 return UIResourceBitmap(skbitmap); 295 return UIResourceBitmap(skbitmap);
292 } 296 }
293 297
294 } // namespace cc 298 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698