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