| OLD | NEW |
| 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 Loading... |
| 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 ElementId PaintedOverlayScrollbarLayer::scroll_element_id() const { |
| 53 return scroll_layer_id_; | 56 return scroll_element_id_; |
| 54 } | 57 } |
| 55 | 58 |
| 56 void PaintedOverlayScrollbarLayer::SetScrollLayer(int layer_id) { | 59 void PaintedOverlayScrollbarLayer::SetScrollInfo(int layer_id, |
| 57 if (layer_id == scroll_layer_id_) | 60 ElementId element_id) { |
| 61 if (layer_id == scroll_layer_id_ && element_id == scroll_element_id_) |
| 58 return; | 62 return; |
| 59 | 63 |
| 60 scroll_layer_id_ = layer_id; | 64 scroll_layer_id_ = layer_id; |
| 65 scroll_element_id_ = element_id; |
| 61 SetNeedsFullTreeSync(); | 66 SetNeedsFullTreeSync(); |
| 62 } | 67 } |
| 63 | 68 |
| 64 bool PaintedOverlayScrollbarLayer::OpacityCanAnimateOnImplThread() const { | 69 bool PaintedOverlayScrollbarLayer::OpacityCanAnimateOnImplThread() const { |
| 65 return scrollbar_->IsOverlay(); | 70 return scrollbar_->IsOverlay(); |
| 66 } | 71 } |
| 67 | 72 |
| 68 bool PaintedOverlayScrollbarLayer::AlwaysUseActiveTreeOpacity() const { | 73 bool PaintedOverlayScrollbarLayer::AlwaysUseActiveTreeOpacity() const { |
| 69 return true; | 74 return true; |
| 70 } | 75 } |
| 71 | 76 |
| 72 ScrollbarOrientation PaintedOverlayScrollbarLayer::orientation() const { | 77 ScrollbarOrientation PaintedOverlayScrollbarLayer::orientation() const { |
| 73 return scrollbar_->Orientation(); | 78 return scrollbar_->Orientation(); |
| 74 } | 79 } |
| 75 | 80 |
| 76 void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { | 81 void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
| 77 Layer::PushPropertiesTo(layer); | 82 Layer::PushPropertiesTo(layer); |
| 78 | 83 |
| 79 PaintedOverlayScrollbarLayerImpl* scrollbar_layer = | 84 PaintedOverlayScrollbarLayerImpl* scrollbar_layer = |
| 80 static_cast<PaintedOverlayScrollbarLayerImpl*>(layer); | 85 static_cast<PaintedOverlayScrollbarLayerImpl*>(layer); |
| 81 | 86 |
| 82 scrollbar_layer->SetScrollLayerId(scroll_layer_id_); | 87 scrollbar_layer->SetScrollInfo(scroll_layer_id_, scroll_element_id_); |
| 83 | 88 |
| 84 scrollbar_layer->SetThumbThickness(thumb_thickness_); | 89 scrollbar_layer->SetThumbThickness(thumb_thickness_); |
| 85 scrollbar_layer->SetThumbLength(thumb_length_); | 90 scrollbar_layer->SetThumbLength(thumb_length_); |
| 86 if (orientation() == HORIZONTAL) { | 91 if (orientation() == HORIZONTAL) { |
| 87 scrollbar_layer->SetTrackStart(track_rect_.x() - location_.x()); | 92 scrollbar_layer->SetTrackStart(track_rect_.x() - location_.x()); |
| 88 scrollbar_layer->SetTrackLength(track_rect_.width()); | 93 scrollbar_layer->SetTrackLength(track_rect_.width()); |
| 89 } else { | 94 } else { |
| 90 scrollbar_layer->SetTrackStart(track_rect_.y() - location_.y()); | 95 scrollbar_layer->SetTrackStart(track_rect_.y() - location_.y()); |
| 91 scrollbar_layer->SetTrackLength(track_rect_.height()); | 96 scrollbar_layer->SetTrackLength(track_rect_.height()); |
| 92 } | 97 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 170 |
| 166 thumb_resource_ = ScopedUIResource::Create( | 171 thumb_resource_ = ScopedUIResource::Create( |
| 167 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); | 172 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); |
| 168 | 173 |
| 169 SetNeedsPushProperties(); | 174 SetNeedsPushProperties(); |
| 170 | 175 |
| 171 return true; | 176 return true; |
| 172 } | 177 } |
| 173 | 178 |
| 174 } // namespace cc | 179 } // namespace cc |
| OLD | NEW |