Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: cc/layers/solid_color_scrollbar_layer_impl.cc

Issue 18341009: Refactor cc scrollbar layers to separate solid-color vs desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased patch as it's sat for a while. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9ec6534831d48f706666e9b4666ff4ba0bf437b7
--- /dev/null
+++ b/cc/layers/solid_color_scrollbar_layer_impl.cc
@@ -0,0 +1,87 @@
+// Copyright 2013 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);
+}
+
+int SolidColorScrollbarLayerImpl::ThumbThickness() const {
+ if (thumb_thickness_ != -1)
+ return thumb_thickness_;
+
+ if (orientation() == HORIZONTAL)
+ return bounds().height();
+ else
+ return bounds().width();
+}
+
+int SolidColorScrollbarLayerImpl::ThumbLength() const {
+ return std::max(
+ static_cast<int>(visible_to_total_length_ratio() * TrackLength()),
+ ThumbThickness());
+}
+
+float SolidColorScrollbarLayerImpl::TrackLength() const {
+ if (orientation() == HORIZONTAL)
+ return bounds().width();
+ else
+ return bounds().height() + vertical_adjust();
+}
+
+int SolidColorScrollbarLayerImpl::TrackStart() const {
+ return 0;
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698