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

Unified Diff: ui/gfx/paint_throbber.cc

Issue 1400783002: Use a layer transform for the waiting throbber Base URL: https://chromium.googlesource.com/chromium/src.git@20151006-MacViewsBrowser-Power
Patch Set: Fix color Created 5 years, 2 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
« no previous file with comments | « ui/gfx/paint_throbber.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/paint_throbber.cc
diff --git a/ui/gfx/paint_throbber.cc b/ui/gfx/paint_throbber.cc
index 0c4505af6e48352bbe3fd1b880ce0d9a3e9b4e5c..b75d52d32ec86112cec066f951bb6a824e464824 100644
--- a/ui/gfx/paint_throbber.cc
+++ b/ui/gfx/paint_throbber.cc
@@ -26,35 +26,6 @@ const int64_t kArcTimeMs = 666;
// rotation.
const int64_t kRotationTimeMs = 1568;
-void PaintArc(Canvas* canvas,
- const Rect& bounds,
- SkColor color,
- SkScalar start_angle,
- SkScalar sweep) {
- // Stroke width depends on size.
- // . For size < 28: 3 - (28 - size) / 16
- // . For 28 <= size: (8 + size) / 12
- SkScalar stroke_width = bounds.width() < 28
- ? 3.0 - SkIntToScalar(28 - bounds.width()) / 16.0
- : SkIntToScalar(bounds.width() + 8) / 12.0;
- Rect oval = bounds;
- // Inset by half the stroke width to make sure the whole arc is inside
- // the visible rect.
- int inset = SkScalarCeilToInt(stroke_width / 2.0);
- oval.Inset(inset, inset);
-
- SkPath path;
- path.arcTo(RectToSkRect(oval), start_angle, sweep, true);
-
- SkPaint paint;
- paint.setColor(color);
- paint.setStrokeCap(SkPaint::kRound_Cap);
- paint.setStrokeWidth(stroke_width);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setAntiAlias(true);
- canvas->DrawPath(path, paint);
-}
-
void CalculateWaitingAngles(const base::TimeDelta& elapsed_time,
int64_t* start_angle,
int64_t* sweep) {
@@ -110,12 +81,41 @@ void PaintThrobberSpinningWithStartAngle(Canvas* canvas,
// To keep the sweep smooth, we have an additional rotation after each
// |arc_time| period has elapsed. See SVG's 'rot' animation.
int64_t rot_keyframe = (elapsed_time / (arc_time * 2)) % 4;
- PaintArc(canvas, bounds, color, start_angle + rot_keyframe * kMaxArcSize,
- sweep);
+ PaintThrobberArc(canvas, bounds, color,
+ start_angle + rot_keyframe * kMaxArcSize, sweep);
}
} // namespace
+void PaintThrobberArc(Canvas* canvas,
+ const Rect& bounds,
+ SkColor color,
+ SkScalar start_angle,
+ SkScalar sweep) {
+ // Stroke width depends on size.
+ // . For size < 28: 3 - (28 - size) / 16
+ // . For 28 <= size: (8 + size) / 12
+ SkScalar stroke_width = bounds.width() < 28
+ ? 3.0 - SkIntToScalar(28 - bounds.width()) / 16.0
+ : SkIntToScalar(bounds.width() + 8) / 12.0;
+ Rect oval = bounds;
+ // Inset by half the stroke width to make sure the whole arc is inside
+ // the visible rect.
+ int inset = SkScalarCeilToInt(stroke_width / 2.0);
+ oval.Inset(inset, inset);
+
+ SkPath path;
+ path.arcTo(RectToSkRect(oval), start_angle, sweep, true);
+
+ SkPaint paint;
+ paint.setColor(color);
+ paint.setStrokeCap(SkPaint::kRound_Cap);
+ paint.setStrokeWidth(stroke_width);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setAntiAlias(true);
+ canvas->DrawPath(path, paint);
+}
+
void PaintThrobberSpinning(Canvas* canvas,
const Rect& bounds,
SkColor color,
@@ -131,7 +131,7 @@ void PaintThrobberWaiting(Canvas* canvas,
const Rect& bounds, SkColor color, const base::TimeDelta& elapsed_time) {
int64_t start_angle = 0, sweep = 0;
CalculateWaitingAngles(elapsed_time, &start_angle, &sweep);
- PaintArc(canvas, bounds, color, start_angle, sweep);
+ PaintThrobberArc(canvas, bounds, color, start_angle, sweep);
}
void PaintThrobberSpinningAfterWaiting(Canvas* canvas,
« no previous file with comments | « ui/gfx/paint_throbber.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698