| 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 "skia/ext/cdl_canvas.h" |
| 8 #include "skia/ext/cdl_paint.h" |
| 7 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 8 #include "ui/gfx/skia_util.h" | 10 #include "ui/gfx/skia_util.h" |
| 9 | 11 |
| 10 namespace cc { | 12 namespace cc { |
| 11 | 13 |
| 12 FakeScrollbar::FakeScrollbar() | 14 FakeScrollbar::FakeScrollbar() |
| 13 : FakeScrollbar(false, false, HORIZONTAL, false, false) {} | 15 : FakeScrollbar(false, false, HORIZONTAL, false, false) {} |
| 14 | 16 |
| 15 FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay) | 17 FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay) |
| 16 : FakeScrollbar(paint, has_thumb, HORIZONTAL, false, is_overlay) {} | 18 : FakeScrollbar(paint, has_thumb, HORIZONTAL, false, is_overlay) {} |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 float FakeScrollbar::ThumbOpacity() const { | 66 float FakeScrollbar::ThumbOpacity() const { |
| 65 return thumb_opacity_; | 67 return thumb_opacity_; |
| 66 } | 68 } |
| 67 | 69 |
| 68 bool FakeScrollbar::NeedsPaintPart(ScrollbarPart part) const { | 70 bool FakeScrollbar::NeedsPaintPart(ScrollbarPart part) const { |
| 69 if (part == THUMB) | 71 if (part == THUMB) |
| 70 return needs_paint_thumb_; | 72 return needs_paint_thumb_; |
| 71 return needs_paint_track_; | 73 return needs_paint_track_; |
| 72 } | 74 } |
| 73 | 75 |
| 74 void FakeScrollbar::PaintPart(SkCanvas* canvas, | 76 void FakeScrollbar::PaintPart(CdlCanvas* canvas, |
| 75 ScrollbarPart part, | 77 ScrollbarPart part, |
| 76 const gfx::Rect& content_rect) { | 78 const gfx::Rect& content_rect) { |
| 77 if (!paint_) | 79 if (!paint_) |
| 78 return; | 80 return; |
| 79 | 81 |
| 80 // Fill the scrollbar with a different color each time. | 82 // Fill the scrollbar with a different color each time. |
| 81 fill_color_++; | 83 fill_color_++; |
| 82 SkPaint paint; | 84 CdlPaint paint; |
| 83 paint.setAntiAlias(false); | 85 paint.setAntiAlias(false); |
| 84 paint.setColor(paint_fill_color()); | 86 paint.setColor(paint_fill_color()); |
| 85 paint.setStyle(SkPaint::kFill_Style); | 87 paint.setStyle(CdlPaint::kFill_Style); |
| 86 | 88 |
| 87 // Emulate the how the real scrollbar works by using scrollbar's rect for | 89 // Emulate the how the real scrollbar works by using scrollbar's rect for |
| 88 // TRACK and the given content_rect for the THUMB | 90 // TRACK and the given content_rect for the THUMB |
| 89 SkRect rect = part == TRACK ? RectToSkRect(TrackRect()) | 91 SkRect rect = part == TRACK ? RectToSkRect(TrackRect()) |
| 90 : RectToSkRect(content_rect); | 92 : RectToSkRect(content_rect); |
| 91 canvas->drawRect(rect, paint); | 93 canvas->drawRect(rect, paint); |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace cc | 96 } // namespace cc |
| OLD | NEW |