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
,
21 is_left_side_vertical_scrollbar_
,
25 scoped_refptr
<SolidColorScrollbarLayer
> SolidColorScrollbarLayer::Create(
26 const LayerSettings
& settings
,
27 ScrollbarOrientation orientation
,
30 bool is_left_side_vertical_scrollbar
,
31 int scroll_layer_id
) {
32 return make_scoped_refptr(new SolidColorScrollbarLayer(
33 settings
, orientation
, thumb_thickness
, track_start
,
34 is_left_side_vertical_scrollbar
, scroll_layer_id
));
37 SolidColorScrollbarLayer::SolidColorScrollbarLayer(
38 const LayerSettings
& settings
,
39 ScrollbarOrientation orientation
,
42 bool is_left_side_vertical_scrollbar
,
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
) {
53 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {}
55 ScrollbarLayerInterface
* SolidColorScrollbarLayer::ToScrollbarLayer() {
59 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl
* layer
) {
60 Layer::PushPropertiesTo(layer
);
61 PushScrollClipPropertiesTo(layer
);
64 void SolidColorScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl
* layer
) {
65 SolidColorScrollbarLayerImpl
* scrollbar_layer
=
66 static_cast<SolidColorScrollbarLayerImpl
*>(layer
);
68 scrollbar_layer
->SetScrollLayerAndClipLayerByIds(scroll_layer_id_
,
72 void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect
& rect
) {
73 // Never needs repaint.
76 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
80 int SolidColorScrollbarLayer::ScrollLayerId() const {
81 return scroll_layer_id_
;
84 void SolidColorScrollbarLayer::SetScrollLayer(int layer_id
) {
85 if (layer_id
== scroll_layer_id_
)
88 scroll_layer_id_
= layer_id
;
89 SetNeedsFullTreeSync();
92 void SolidColorScrollbarLayer::SetClipLayer(int layer_id
) {
93 if (layer_id
== clip_layer_id_
)
96 clip_layer_id_
= layer_id
;
97 SetNeedsFullTreeSync();
100 ScrollbarOrientation
SolidColorScrollbarLayer::orientation() const {