| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/spinner_view.h" | 5 #import "chrome/browser/ui/cocoa/spinner_view.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | |
| 10 #include "base/mac/sdk_forward_declarations.h" | 9 #include "base/mac/sdk_forward_declarations.h" |
| 11 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "skia/ext/skia_utils_mac.h" | 11 #include "skia/ext/skia_utils_mac.h" |
| 13 #include "ui/base/theme_provider.h" | 12 #include "ui/base/theme_provider.h" |
| 14 #include "ui/native_theme/native_theme.h" | 13 #include "ui/native_theme/native_theme.h" |
| 15 #include "ui/native_theme/native_theme_mac.h" | 14 #include "ui/native_theme/native_theme_mac.h" |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 18 const CGFloat kDegrees90 = (M_PI / 2); | 17 const CGFloat kDegrees90 = (M_PI / 2); |
| 19 const CGFloat kDegrees180 = (M_PI); | 18 const CGFloat kDegrees180 = (M_PI); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // shrinks over the course of each cycle, which the spinner achieves by drawing | 170 // shrinks over the course of each cycle, which the spinner achieves by drawing |
| 172 // the arc using a (solid) dashed line pattern and animating the "lineDashPhase" | 171 // the arc using a (solid) dashed line pattern and animating the "lineDashPhase" |
| 173 // property. | 172 // property. |
| 174 - (void)initializeAnimation { | 173 - (void)initializeAnimation { |
| 175 CGRect bounds = [self bounds]; | 174 CGRect bounds = [self bounds]; |
| 176 CGFloat scaleFactor = bounds.size.width / kDesignWidth; | 175 CGFloat scaleFactor = bounds.size.width / kDesignWidth; |
| 177 | 176 |
| 178 // Make sure |shapeLayer_|'s content scale factor matches the window's | 177 // Make sure |shapeLayer_|'s content scale factor matches the window's |
| 179 // backing depth (e.g. it's 2.0 on Retina Macs). Don't worry about adjusting | 178 // backing depth (e.g. it's 2.0 on Retina Macs). Don't worry about adjusting |
| 180 // any other layers because |shapeLayer_| is the only one displaying content. | 179 // any other layers because |shapeLayer_| is the only one displaying content. |
| 181 if (base::mac::IsOSLionOrLater()) { | 180 CGFloat backingScaleFactor = [[self window] backingScaleFactor]; |
| 182 CGFloat backingScaleFactor = [[self window] backingScaleFactor]; | 181 [shapeLayer_ setContentsScale:backingScaleFactor]; |
| 183 [shapeLayer_ setContentsScale:backingScaleFactor]; | |
| 184 } | |
| 185 | 182 |
| 186 // Create the first half of the arc animation, where it grows from a short | 183 // Create the first half of the arc animation, where it grows from a short |
| 187 // block to its full length. | 184 // block to its full length. |
| 188 base::scoped_nsobject<CAMediaTimingFunction> timingFunction( | 185 base::scoped_nsobject<CAMediaTimingFunction> timingFunction( |
| 189 [[CAMediaTimingFunction alloc] initWithControlPoints:0.4 :0.0 :0.2 :1]); | 186 [[CAMediaTimingFunction alloc] initWithControlPoints:0.4 :0.0 :0.2 :1]); |
| 190 base::scoped_nsobject<CAKeyframeAnimation> firstHalfAnimation( | 187 base::scoped_nsobject<CAKeyframeAnimation> firstHalfAnimation( |
| 191 [[CAKeyframeAnimation alloc] init]); | 188 [[CAKeyframeAnimation alloc] init]); |
| 192 [firstHalfAnimation setTimingFunction:timingFunction]; | 189 [firstHalfAnimation setTimingFunction:timingFunction]; |
| 193 [firstHalfAnimation setKeyPath:@"lineDashPhase"]; | 190 [firstHalfAnimation setKeyPath:@"lineDashPhase"]; |
| 194 // Begin the lineDashPhase animation just short of the full arc length, | 191 // Begin the lineDashPhase animation just short of the full arc length, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 [rotationLayer_ addAnimation:rotationAnimation_.get() | 293 [rotationLayer_ addAnimation:rotationAnimation_.get() |
| 297 forKey:kRotationAnimationName]; | 294 forKey:kRotationAnimationName]; |
| 298 } | 295 } |
| 299 } else { | 296 } else { |
| 300 [shapeLayer_ removeAllAnimations]; | 297 [shapeLayer_ removeAllAnimations]; |
| 301 [rotationLayer_ removeAllAnimations]; | 298 [rotationLayer_ removeAllAnimations]; |
| 302 } | 299 } |
| 303 } | 300 } |
| 304 | 301 |
| 305 @end | 302 @end |
| OLD | NEW |