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 const bool kIsOverlayScrollbar = true; |
15 return SolidColorScrollbarLayerImpl::Create( | 16 return SolidColorScrollbarLayerImpl::Create( |
16 tree_impl, id(), orientation(), thumb_thickness_, | 17 tree_impl, |
17 is_left_side_vertical_scrollbar_).PassAs<LayerImpl>(); | 18 id(), |
| 19 orientation(), |
| 20 thumb_thickness_, |
| 21 is_left_side_vertical_scrollbar_, |
| 22 kIsOverlayScrollbar).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 Layer* scroll_layer) { |
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)); |
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 Layer* scroll_layer) |
37 : scroll_layer_id_(scroll_layer_id), | 42 : scroll_layer_(scroll_layer), |
| 43 clip_layer_(NULL), |
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_ ? scroll_layer_->id() |
| 64 : Layer::INVALID_ID); |
| 65 scrollbar_layer->SetClipLayerById(clip_layer_ ? clip_layer_->id() |
| 66 : Layer::INVALID_ID); |
| 67 } |
| 68 |
48 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { | 69 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { |
49 return true; | 70 return true; |
50 } | 71 } |
51 | 72 |
52 int SolidColorScrollbarLayer::ScrollLayerId() const { | 73 int SolidColorScrollbarLayer::ScrollLayerId() const { |
53 return scroll_layer_id_; | 74 return scroll_layer_->id(); |
54 } | 75 } |
55 | 76 |
56 void SolidColorScrollbarLayer::SetScrollLayerId(int id) { | 77 void SolidColorScrollbarLayer::SetScrollLayer(scoped_refptr<Layer> layer) { |
57 if (id == scroll_layer_id_) | 78 if (layer == scroll_layer_) |
58 return; | 79 return; |
59 | 80 |
60 scroll_layer_id_ = id; | 81 scroll_layer_ = layer; |
61 SetNeedsFullTreeSync(); | 82 SetNeedsFullTreeSync(); |
62 } | 83 } |
63 | 84 |
| 85 void SolidColorScrollbarLayer::SetClipLayer(scoped_refptr<Layer> layer) { |
| 86 if (layer == clip_layer_) |
| 87 return; |
| 88 |
| 89 clip_layer_ = layer; |
| 90 SetNeedsFullTreeSync(); |
| 91 } |
| 92 |
64 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { | 93 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { |
65 return orientation_; | 94 return orientation_; |
66 } | 95 } |
67 | 96 |
68 } // namespace cc | 97 } // namespace cc |
OLD | NEW |