Permalink
Browse files

Removed motion blur for better compatibility. Closes #2.

  • Loading branch information...
1 parent 75ffa2b commit a81789da1e3f4941932799e1de9f941981bbdfc6 @tomaz committed Jan 7, 2014
Showing with 1 addition and 37 deletions.
  1. +1 −37 ScrollingAboutWindow/AboutWindowController.m
@@ -10,7 +10,6 @@
#import "AboutWindowController.h"
static CGFloat kAboutWindowCreditsAnimationSpeed = 2.0; // Points per second
-static CGFloat kAboutWindowCreditsAssumedFPS = 60.0; // Assumed frames per second
static CGFloat kAboutWindowCreditsFadeHeight = 6.0;
static CGColorRef kAboutWindowCreditsFadeColor1 = NULL;
static CGColorRef kAboutWindowCreditsFadeColor2 = NULL;
@@ -38,7 +37,6 @@ - (CGSize)sizeForAttributedString:(NSAttributedString *)string inWidth:(CGFloat)
@property (nonatomic, readonly) CAGradientLayer *creditsTopFadeLayer;
@property (nonatomic, readonly) CAGradientLayer *creditsBottomFadeLayer;
@property (nonatomic, readonly) CATextLayer *creditsTextLayer;
-@property (nonatomic, readonly) CIFilter *motionBlurFilter;
@end
#pragma mark -
@@ -48,7 +46,6 @@ @implementation AboutWindowController {
CAGradientLayer *_creditsTopFadeLayer;
CAGradientLayer *_creditsBottomFadeLayer;
CATextLayer *_creditsTextLayer;
- CIFilter *_motionBlurFilter;
CGFloat _scaleFactor;
}
@@ -169,30 +166,6 @@ - (CGFloat)creditsFadeHeightCompensation {
return self.creditsTopFadeLayer.frame.size.height;
}
-#pragma mark - Filters
-
-- (CGFloat)calculateBlurDistanceForScale:(CGFloat)scale {
- CGFloat blurDistance;
-
- blurDistance = ((kAboutWindowCreditsAnimationSpeed / kAboutWindowCreditsAssumedFPS) * scale);
- blurDistance = MAX(0.5, blurDistance); // We need least half a real pixel of blur or we might get flicker
-
- return blurDistance;
-}
-
-- (CIFilter *)motionBlurFilter {
- if (_motionBlurFilter) return _motionBlurFilter;
- // The blurDistance is based on the distance traveled per frame
- CGFloat blurDistance = [self calculateBlurDistanceForScale:_creditsTextLayer.contentsScale];
- _motionBlurFilter = [CIFilter filterWithName:@"CIMotionBlur"];
- [_motionBlurFilter setDefaults];
- [_motionBlurFilter setValue:[NSNumber numberWithFloat:blurDistance] forKey:@"inputRadius"];
- [_motionBlurFilter setValue:[NSNumber numberWithFloat:(M_PI/2)] forKey:@"inputAngle"]; // 90°
- _motionBlurFilter.name = @"motionBlur";
-
- return _motionBlurFilter;
-}
-
#pragma mark - Core Animation layers
- (CATextLayer *)creditsTextLayer {
@@ -209,9 +182,6 @@ - (CATextLayer *)creditsTextLayer {
_creditsTextLayer.contentsScale = self.scaleFactor;
_creditsTextLayer.delegate = self;
- // Adding motion blur filter to reduce pixel crawl/flicker
- _creditsTextLayer.filters = [NSArray arrayWithObject:self.motionBlurFilter];
-
return _creditsTextLayer;
}
@@ -275,16 +245,10 @@ - (CGSize)sizeForAttributedString:(NSAttributedString *)string inWidth:(CGFloat)
return CGSizeMake(width, ceil(height));
}
-- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window
-{
+- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window {
if (layer == _creditsRootLayer) {
_scaleFactor = newScale; // Just to keep the value consistent
}
- else if (layer == _creditsTextLayer) {
- CGFloat blurDistance = [self calculateBlurDistanceForScale:newScale];
- [_motionBlurFilter setValue:[NSNumber numberWithFloat:blurDistance] forKey:@"inputRadius"];
- }
-
return YES;
}

0 comments on commit a81789d

Please sign in to comment.