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

Side by Side Diff: cc/test/fake_scrollbar.cc

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Rebase and resolve Created 5 years 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 unified diff | Download patch
« no previous file with comments | « cc/test/fake_scrollbar.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/skia_util.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 FakeScrollbar::FakeScrollbar() 12 FakeScrollbar::FakeScrollbar()
13 : paint_(false), 13 : paint_(false),
14 has_thumb_(false), 14 has_thumb_(false),
15 is_overlay_(false), 15 is_overlay_(false),
16 thumb_thickness_(10), 16 thumb_thickness_(10),
17 thumb_length_(5), 17 thumb_length_(5),
18 thumb_opacity_(1),
19 needs_paint_thumb_(true),
20 needs_paint_track_(true),
18 track_rect_(0, 0, 100, 10), 21 track_rect_(0, 0, 100, 10),
19 fill_color_(SK_ColorGREEN) {} 22 fill_color_(SK_ColorGREEN) {}
20 23
21 FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay) 24 FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay)
22 : paint_(paint), 25 : paint_(paint),
23 has_thumb_(has_thumb), 26 has_thumb_(has_thumb),
24 is_overlay_(is_overlay), 27 is_overlay_(is_overlay),
25 thumb_thickness_(10), 28 thumb_thickness_(10),
26 thumb_length_(5), 29 thumb_length_(5),
30 thumb_opacity_(1),
31 needs_paint_thumb_(true),
32 needs_paint_track_(true),
27 track_rect_(0, 0, 100, 10), 33 track_rect_(0, 0, 100, 10),
28 fill_color_(SK_ColorGREEN) {} 34 fill_color_(SK_ColorGREEN) {}
29 35
30 FakeScrollbar::~FakeScrollbar() {} 36 FakeScrollbar::~FakeScrollbar() {}
31 37
32 ScrollbarOrientation FakeScrollbar::Orientation() const { 38 ScrollbarOrientation FakeScrollbar::Orientation() const {
33 return HORIZONTAL; 39 return HORIZONTAL;
34 } 40 }
35 41
36 bool FakeScrollbar::IsLeftSideVerticalScrollbar() const { 42 bool FakeScrollbar::IsLeftSideVerticalScrollbar() const {
(...skipping 11 matching lines...) Expand all
48 } 54 }
49 55
50 int FakeScrollbar::ThumbLength() const { 56 int FakeScrollbar::ThumbLength() const {
51 return thumb_length_; 57 return thumb_length_;
52 } 58 }
53 59
54 gfx::Rect FakeScrollbar::TrackRect() const { 60 gfx::Rect FakeScrollbar::TrackRect() const {
55 return track_rect_; 61 return track_rect_;
56 } 62 }
57 63
64 float FakeScrollbar::ThumbOpacity() const {
65 return thumb_opacity_;
66 }
67
68 bool FakeScrollbar::NeedsPaintPart(ScrollbarPart part) const {
69 if (part == THUMB)
70 return needs_paint_thumb_;
71 return needs_paint_track_;
72 }
73
58 void FakeScrollbar::PaintPart(SkCanvas* canvas, 74 void FakeScrollbar::PaintPart(SkCanvas* canvas,
59 ScrollbarPart part, 75 ScrollbarPart part,
60 const gfx::Rect& content_rect) { 76 const gfx::Rect& content_rect) {
61 if (!paint_) 77 if (!paint_)
62 return; 78 return;
63 79
64 // Fill the scrollbar with a different color each time. 80 // Fill the scrollbar with a different color each time.
65 fill_color_++; 81 fill_color_++;
66 SkPaint paint; 82 SkPaint paint;
67 paint.setAntiAlias(false); 83 paint.setAntiAlias(false);
68 paint.setColor(paint_fill_color()); 84 paint.setColor(paint_fill_color());
69 paint.setStyle(SkPaint::kFill_Style); 85 paint.setStyle(SkPaint::kFill_Style);
70 86
71 // Emulate the how the real scrollbar works by using scrollbar's rect for 87 // Emulate the how the real scrollbar works by using scrollbar's rect for
72 // TRACK and the given content_rect for the THUMB 88 // TRACK and the given content_rect for the THUMB
73 SkRect rect = part == TRACK ? RectToSkRect(TrackRect()) 89 SkRect rect = part == TRACK ? RectToSkRect(TrackRect())
74 : RectToSkRect(content_rect); 90 : RectToSkRect(content_rect);
75 canvas->drawRect(rect, paint); 91 canvas->drawRect(rect, paint);
76 } 92 }
77 93
78 } // namespace cc 94 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_scrollbar.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698