| OLD | NEW |
| 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/solid_color_scrollbar_layer.h" | 5 #include "cc/layers/solid_color_scrollbar_layer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 10 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 11 #include "cc/proto/cc_conversions.h" | |
| 12 #include "cc/proto/layer.pb.h" | |
| 13 | 11 |
| 14 namespace cc { | 12 namespace cc { |
| 15 | 13 |
| 16 std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( | 14 std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( |
| 17 LayerTreeImpl* tree_impl) { | 15 LayerTreeImpl* tree_impl) { |
| 18 const bool kIsOverlayScrollbar = true; | 16 const bool kIsOverlayScrollbar = true; |
| 19 return SolidColorScrollbarLayerImpl::Create( | 17 return SolidColorScrollbarLayerImpl::Create( |
| 20 tree_impl, id(), orientation(), | 18 tree_impl, id(), orientation(), |
| 21 solid_color_scrollbar_layer_inputs_.thumb_thickness, | 19 solid_color_scrollbar_layer_inputs_.thumb_thickness, |
| 22 solid_color_scrollbar_layer_inputs_.track_start, | 20 solid_color_scrollbar_layer_inputs_.track_start, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 scroll_layer_id) { | 61 scroll_layer_id) { |
| 64 Layer::SetOpacity(0.f); | 62 Layer::SetOpacity(0.f); |
| 65 } | 63 } |
| 66 | 64 |
| 67 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {} | 65 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {} |
| 68 | 66 |
| 69 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() { | 67 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() { |
| 70 return this; | 68 return this; |
| 71 } | 69 } |
| 72 | 70 |
| 73 void SolidColorScrollbarLayer::ToLayerNodeProto(proto::LayerNode* proto) const { | |
| 74 Layer::ToLayerNodeProto(proto); | |
| 75 | |
| 76 proto::SolidColorScrollbarLayerProperties* scrollbar = | |
| 77 proto->mutable_solid_scrollbar(); | |
| 78 scrollbar->set_scroll_layer_id( | |
| 79 solid_color_scrollbar_layer_inputs_.scroll_layer_id); | |
| 80 scrollbar->set_thumb_thickness( | |
| 81 solid_color_scrollbar_layer_inputs_.thumb_thickness); | |
| 82 scrollbar->set_track_start(solid_color_scrollbar_layer_inputs_.track_start); | |
| 83 scrollbar->set_is_left_side_vertical_scrollbar( | |
| 84 solid_color_scrollbar_layer_inputs_.is_left_side_vertical_scrollbar); | |
| 85 scrollbar->set_orientation(ScrollbarOrientationToProto( | |
| 86 solid_color_scrollbar_layer_inputs_.orientation)); | |
| 87 } | |
| 88 | |
| 89 void SolidColorScrollbarLayer::SetOpacity(float opacity) { | 71 void SolidColorScrollbarLayer::SetOpacity(float opacity) { |
| 90 // The opacity of a solid color scrollbar layer is always 0 on main thread. | 72 // The opacity of a solid color scrollbar layer is always 0 on main thread. |
| 91 DCHECK_EQ(opacity, 0.f); | 73 DCHECK_EQ(opacity, 0.f); |
| 92 Layer::SetOpacity(opacity); | 74 Layer::SetOpacity(opacity); |
| 93 } | 75 } |
| 94 | 76 |
| 95 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { | 77 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
| 96 Layer::PushPropertiesTo(layer); | 78 Layer::PushPropertiesTo(layer); |
| 97 SolidColorScrollbarLayerImpl* scrollbar_layer = | 79 SolidColorScrollbarLayerImpl* scrollbar_layer = |
| 98 static_cast<SolidColorScrollbarLayerImpl*>(layer); | 80 static_cast<SolidColorScrollbarLayerImpl*>(layer); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 122 return; | 104 return; |
| 123 | 105 |
| 124 solid_color_scrollbar_layer_inputs_.scroll_layer_id = layer_id; | 106 solid_color_scrollbar_layer_inputs_.scroll_layer_id = layer_id; |
| 125 SetNeedsFullTreeSync(); | 107 SetNeedsFullTreeSync(); |
| 126 } | 108 } |
| 127 | 109 |
| 128 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { | 110 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { |
| 129 return solid_color_scrollbar_layer_inputs_.orientation; | 111 return solid_color_scrollbar_layer_inputs_.orientation; |
| 130 } | 112 } |
| 131 | 113 |
| 132 void SolidColorScrollbarLayer::SetTypeForProtoSerialization( | |
| 133 proto::LayerNode* proto) const { | |
| 134 proto->set_type(proto::LayerNode::SOLID_COLOR_SCROLLBAR_LAYER); | |
| 135 } | |
| 136 | |
| 137 } // namespace cc | 114 } // namespace cc |
| OLD | NEW |