solid_color_scrollbar_layer.cc revision 58537e28ecd584eab876aee8be7156509866d23a
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
11namespace cc {
12
13scoped_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl(
14    LayerTreeImpl* tree_impl) {
15  return SolidColorScrollbarLayerImpl::Create(
16      tree_impl, id(), orientation(), thumb_thickness_,
17      is_left_side_vertical_scrollbar_).PassAs<LayerImpl>();
18}
19
20scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create(
21    ScrollbarOrientation orientation,
22    int thumb_thickness,
23    bool is_left_side_vertical_scrollbar,
24    int scroll_layer_id) {
25  return make_scoped_refptr(new SolidColorScrollbarLayer(
26      orientation,
27      thumb_thickness,
28      is_left_side_vertical_scrollbar,
29      scroll_layer_id));
30}
31
32SolidColorScrollbarLayer::SolidColorScrollbarLayer(
33    ScrollbarOrientation orientation,
34    int thumb_thickness,
35    bool is_left_side_vertical_scrollbar,
36    int scroll_layer_id)
37    : scroll_layer_id_(scroll_layer_id),
38      orientation_(orientation),
39      thumb_thickness_(thumb_thickness),
40      is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {}
41
42SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {}
43
44ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() {
45  return this;
46}
47
48bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
49  return true;
50}
51
52int SolidColorScrollbarLayer::ScrollLayerId() const {
53  return scroll_layer_id_;
54}
55
56void SolidColorScrollbarLayer::SetScrollLayerId(int id) {
57  if (id == scroll_layer_id_)
58    return;
59
60  scroll_layer_id_ = id;
61  SetNeedsFullTreeSync();
62}
63
64ScrollbarOrientation SolidColorScrollbarLayer::orientation() const {
65  return orientation_;
66}
67
68}  // namespace cc
69