OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/test/fake_scrollbar.h" | 5 #include "cc/test/fake_scrollbar.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
| 8 #include "ui/gfx/skia_util.h" |
8 | 9 |
9 namespace cc { | 10 namespace cc { |
10 | 11 |
11 FakeScrollbar::FakeScrollbar() | 12 FakeScrollbar::FakeScrollbar() |
12 : paint_(false), | 13 : paint_(false), |
13 has_thumb_(false), | 14 has_thumb_(false), |
14 is_overlay_(false), | 15 is_overlay_(false), |
15 thumb_thickness_(10), | 16 thumb_thickness_(10), |
16 thumb_length_(5), | 17 thumb_length_(5), |
17 track_rect_(0, 0, 100, 10), | 18 track_rect_(0, 0, 100, 10), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 56 } |
56 | 57 |
57 void FakeScrollbar::PaintPart(SkCanvas* canvas, | 58 void FakeScrollbar::PaintPart(SkCanvas* canvas, |
58 ScrollbarPart part, | 59 ScrollbarPart part, |
59 const gfx::Rect& content_rect) { | 60 const gfx::Rect& content_rect) { |
60 if (!paint_) | 61 if (!paint_) |
61 return; | 62 return; |
62 | 63 |
63 // Fill the scrollbar with a different color each time. | 64 // Fill the scrollbar with a different color each time. |
64 fill_color_++; | 65 fill_color_++; |
65 canvas->clear(SK_ColorBLACK | fill_color_); | 66 SkPaint paint; |
| 67 paint.setAntiAlias(false); |
| 68 paint.setColor(paint_fill_color()); |
| 69 paint.setStyle(SkPaint::kFill_Style); |
| 70 |
| 71 // Emulate the how the real scrollbar works by using scrollbar's rect for |
| 72 // TRACK and the given content_rect for the THUMB |
| 73 SkRect rect = part == TRACK ? RectToSkRect(TrackRect()) |
| 74 : RectToSkRect(content_rect); |
| 75 canvas->drawRect(rect, paint); |
66 } | 76 } |
67 | 77 |
68 } // namespace cc | 78 } // namespace cc |
OLD | NEW |