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.
5 #include "cc/layers/solid_color_scrollbar_layer.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "cc/layers/layer_impl.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
13 scoped_ptr
<LayerImpl
> SolidColorScrollbarLayer::CreateLayerImpl(
14 LayerTreeImpl
* tree_impl
) {
15 const bool kIsOverlayScrollbar
= true;
16 return SolidColorScrollbarLayerImpl::Create(tree_impl
,
20 is_left_side_vertical_scrollbar_
,
25 scoped_refptr
<SolidColorScrollbarLayer
> SolidColorScrollbarLayer::Create(
26 ScrollbarOrientation orientation
,
28 bool is_left_side_vertical_scrollbar
,
29 int scroll_layer_id
) {
30 return make_scoped_refptr(new SolidColorScrollbarLayer(
33 is_left_side_vertical_scrollbar
,
37 SolidColorScrollbarLayer::SolidColorScrollbarLayer(
38 ScrollbarOrientation orientation
,
40 bool is_left_side_vertical_scrollbar
,
42 : scroll_layer_id_(Layer::INVALID_ID
),
43 clip_layer_id_(scroll_layer_id
),
44 orientation_(orientation
),
45 thumb_thickness_(thumb_thickness
),
46 is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar
) {}
48 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {}
50 ScrollbarLayerInterface
* SolidColorScrollbarLayer::ToScrollbarLayer() {
54 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl
* layer
) {
55 Layer::PushPropertiesTo(layer
);
56 PushScrollClipPropertiesTo(layer
);
59 void SolidColorScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl
* layer
) {
60 SolidColorScrollbarLayerImpl
* scrollbar_layer
=
61 static_cast<SolidColorScrollbarLayerImpl
*>(layer
);
63 scrollbar_layer
->SetScrollLayerById(scroll_layer_id_
);
64 scrollbar_layer
->SetClipLayerById(clip_layer_id_
);
67 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
71 int SolidColorScrollbarLayer::ScrollLayerId() const {
72 return scroll_layer_id_
;
75 void SolidColorScrollbarLayer::SetScrollLayer(int layer_id
) {
76 if (layer_id
== scroll_layer_id_
)
79 scroll_layer_id_
= layer_id
;
80 SetNeedsFullTreeSync();
83 void SolidColorScrollbarLayer::SetClipLayer(int layer_id
) {
84 if (layer_id
== clip_layer_id_
)
87 clip_layer_id_
= layer_id
;
88 SetNeedsFullTreeSync();
91 ScrollbarOrientation
SolidColorScrollbarLayer::orientation() const {