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, |