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