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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 scoped_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( | 13 scoped_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( |
14 LayerTreeImpl* tree_impl) { | 14 LayerTreeImpl* tree_impl) { |
15 return SolidColorScrollbarLayerImpl::Create( | 15 const bool kIsOverlayScrollbar = true; |
16 tree_impl, id(), orientation(), thumb_thickness_, | 16 return SolidColorScrollbarLayerImpl::Create(tree_impl, |
17 is_left_side_vertical_scrollbar_).PassAs<LayerImpl>(); | 17 id(), |
| 18 orientation(), |
| 19 thumb_thickness_, |
| 20 is_left_side_vertical_scrollbar_, |
| 21 kIsOverlayScrollbar) |
| 22 .PassAs<LayerImpl>(); |
18 } | 23 } |
19 | 24 |
20 scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create( | 25 scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create( |
21 ScrollbarOrientation orientation, | 26 ScrollbarOrientation orientation, |
22 int thumb_thickness, | 27 int thumb_thickness, |
23 bool is_left_side_vertical_scrollbar, | 28 bool is_left_side_vertical_scrollbar, |
24 int scroll_layer_id) { | 29 int scroll_layer_id) { |
25 return make_scoped_refptr(new SolidColorScrollbarLayer( | 30 return make_scoped_refptr(new SolidColorScrollbarLayer( |
26 orientation, | 31 orientation, |
27 thumb_thickness, | 32 thumb_thickness, |
28 is_left_side_vertical_scrollbar, | 33 is_left_side_vertical_scrollbar, |
29 scroll_layer_id)); | 34 scroll_layer_id)); |
30 } | 35 } |
31 | 36 |
32 SolidColorScrollbarLayer::SolidColorScrollbarLayer( | 37 SolidColorScrollbarLayer::SolidColorScrollbarLayer( |
33 ScrollbarOrientation orientation, | 38 ScrollbarOrientation orientation, |
34 int thumb_thickness, | 39 int thumb_thickness, |
35 bool is_left_side_vertical_scrollbar, | 40 bool is_left_side_vertical_scrollbar, |
36 int scroll_layer_id) | 41 int scroll_layer_id) |
37 : scroll_layer_id_(scroll_layer_id), | 42 : scroll_layer_id_(Layer::INVALID_ID), |
| 43 clip_layer_id_(scroll_layer_id), |
38 orientation_(orientation), | 44 orientation_(orientation), |
39 thumb_thickness_(thumb_thickness), | 45 thumb_thickness_(thumb_thickness), |
40 is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {} | 46 is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {} |
41 | 47 |
42 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {} | 48 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {} |
43 | 49 |
44 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() { | 50 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() { |
45 return this; | 51 return this; |
46 } | 52 } |
47 | 53 |
| 54 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
| 55 Layer::PushPropertiesTo(layer); |
| 56 PushScrollClipPropertiesTo(layer); |
| 57 } |
| 58 |
| 59 void SolidColorScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl* layer) { |
| 60 SolidColorScrollbarLayerImpl* scrollbar_layer = |
| 61 static_cast<SolidColorScrollbarLayerImpl*>(layer); |
| 62 |
| 63 scrollbar_layer->SetScrollLayerById(scroll_layer_id_); |
| 64 scrollbar_layer->SetClipLayerById(clip_layer_id_); |
| 65 } |
| 66 |
48 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { | 67 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { |
49 return true; | 68 return true; |
50 } | 69 } |
51 | 70 |
52 int SolidColorScrollbarLayer::ScrollLayerId() const { | 71 int SolidColorScrollbarLayer::ScrollLayerId() const { |
53 return scroll_layer_id_; | 72 return scroll_layer_id_; |
54 } | 73 } |
55 | 74 |
56 void SolidColorScrollbarLayer::SetScrollLayerId(int id) { | 75 void SolidColorScrollbarLayer::SetScrollLayer(int layer_id) { |
57 if (id == scroll_layer_id_) | 76 if (layer_id == scroll_layer_id_) |
58 return; | 77 return; |
59 | 78 |
60 scroll_layer_id_ = id; | 79 scroll_layer_id_ = layer_id; |
61 SetNeedsFullTreeSync(); | 80 SetNeedsFullTreeSync(); |
62 } | 81 } |
63 | 82 |
| 83 void SolidColorScrollbarLayer::SetClipLayer(int layer_id) { |
| 84 if (layer_id == clip_layer_id_) |
| 85 return; |
| 86 |
| 87 clip_layer_id_ = layer_id; |
| 88 SetNeedsFullTreeSync(); |
| 89 } |
| 90 |
64 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { | 91 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { |
65 return orientation_; | 92 return orientation_; |
66 } | 93 } |
67 | 94 |
68 } // namespace cc | 95 } // namespace cc |
OLD | NEW |