Index: cc/layers/solid_color_scrollbar_layer_impl.cc |
diff --git a/cc/layers/solid_color_scrollbar_layer_impl.cc b/cc/layers/solid_color_scrollbar_layer_impl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..85ba2fcaaf4679db47e9c75beb22bdd168bb4b3e |
--- /dev/null |
+++ b/cc/layers/solid_color_scrollbar_layer_impl.cc |
@@ -0,0 +1,81 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "cc/layers/quad_sink.h" |
+#include "cc/layers/solid_color_scrollbar_layer_impl.h" |
+#include "cc/quads/solid_color_draw_quad.h" |
+#include "cc/trees/layer_tree_impl.h" |
+#include "cc/trees/layer_tree_settings.h" |
+ |
+namespace cc { |
+ |
+scoped_ptr<SolidColorScrollbarLayerImpl> SolidColorScrollbarLayerImpl::Create( |
+ LayerTreeImpl* tree_impl, |
+ int id, |
+ ScrollbarOrientation orientation, |
+ int thumb_thickness, |
+ SkColor color) { |
+ return make_scoped_ptr(new SolidColorScrollbarLayerImpl( |
+ tree_impl, id, orientation, thumb_thickness, color)); |
+} |
+ |
+SolidColorScrollbarLayerImpl::~SolidColorScrollbarLayerImpl() {} |
+ |
+scoped_ptr<LayerImpl> SolidColorScrollbarLayerImpl::CreateLayerImpl( |
+ LayerTreeImpl* tree_impl) { |
+ return SolidColorScrollbarLayerImpl::Create(tree_impl, |
+ id(), |
+ orientation_, |
+ thumb_thickness_, |
+ color_).PassAs<LayerImpl>(); |
+} |
+ |
+SolidColorScrollbarLayerImpl::SolidColorScrollbarLayerImpl( |
+ LayerTreeImpl* tree_impl, |
+ int id, |
+ ScrollbarOrientation orientation, |
+ int thumb_thickness, |
+ SkColor color) |
+ : ScrollbarLayerImplBase(tree_impl, id, orientation), |
+ thumb_thickness_(thumb_thickness), |
+ color_(color) {} |
+void SolidColorScrollbarLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
+ ScrollbarLayerImplBase::PushPropertiesTo(layer); |
+} |
+ |
+gfx::Rect SolidColorScrollbarLayerImpl::ComputeThumbQuadRect() const { |
+ int thumb_thickness = thumb_thickness_; |
+ float track_length; |
+ if (orientation_ == HORIZONTAL) { |
+ track_length = bounds().width(); |
+ if (thumb_thickness == -1) |
+ thumb_thickness = bounds().height(); |
+ } else { |
+ track_length = bounds().height() + vertical_adjust_; |
+ if (thumb_thickness == -1) |
+ thumb_thickness = bounds().width(); |
+ } |
+ |
+ int thumb_length = std::max( |
+ static_cast<int>(visible_to_total_length_ratio_ * track_length), |
+ thumb_thickness); |
+ |
+ return ComputeThumbQuadRectInternal( |
+ thumb_length, track_length, 0, thumb_thickness_); |
+} |
+ |
+void SolidColorScrollbarLayerImpl::AppendQuads(QuadSink* quad_sink, |
+ AppendQuadsData* append_quads_data) { |
+ gfx::Rect thumb_quad_rect = ComputeThumbQuadRect(); |
+ |
+ SharedQuadState* shared_quad_state = |
+ quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
+ AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
+ |
+ scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
+ quad->SetNew(shared_quad_state, thumb_quad_rect, color_, false); |
+ quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
+} |
+ |
+} // namespace cc |