Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Nam Kennic wrote the initial implementation for -setBackgroundColor:, on what was then the LFGlassView.
6 changes: 3 additions & 3 deletions LiveFrost.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Pod::Spec.new do |s|
s.name = "LiveFrost"
s.version = "1.1.2"
s.version = "2.0"
s.summary = "Real time blurring."
s.homepage = "https://github.com/radi/LiveFrost"
s.license = 'MIT'
s.author = {
"Evadne Wu" => "ev@radi.ws",
"Nicholas Gabriel Levin" => "nl@radi.ws"
}
s.source = { :git => "https://github.com/radi/LiveFrost.git", :tag => "1.1.2" }
s.source = { :git => "https://github.com/radi/LiveFrost.git", :tag => "2.0" }
s.platform = :ios, '6.0'
s.source_files = 'LiveFrost', 'LiveFrost/**/*.{h,m}'
s.source_files = 'LiveFrost', 'LiveFrost/**/*.{h,m,c}'
s.exclude_files = 'LiveFrost/Exclude'
s.frameworks = 'Accelerate', 'QuartzCore', 'UIKit'
s.requires_arc = true
Expand Down
26 changes: 26 additions & 0 deletions LiveFrost/LFDefines.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (c) 2014 Evadne Wu and Nicholas Levin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#include "LFDefines.h"
#include <math.h>

const CGPoint LFPointNull = (CGPoint){INFINITY, INFINITY};
30 changes: 30 additions & 0 deletions LiveFrost/LFDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) 2014 Evadne Wu and Nicholas Levin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#ifndef LiveFrost_LFDefines_h
#define LiveFrost_LFDefines_h

#include <CoreGraphics/CGGeometry.h>

extern const CGPoint LFPointNull;

#endif
12 changes: 4 additions & 8 deletions LiveFrost/LFDisplayBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@
// THE SOFTWARE.
//

#import <QuartzCore/QuartzCore.h>

@protocol LFDisplayBridgeTriggering <NSObject>
- (void) refresh;
@end
@import QuartzCore.CADisplayLink;
#import "LFDisplayBridgeTriggering.h"

@interface LFDisplayBridge : NSObject <LFDisplayBridgeTriggering>

+ (instancetype) sharedInstance;

@property (nonatomic, readonly, assign) CFMutableSetRef subscribedViews;
- (void) addSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object;
- (void) removeSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object;
- (void) addSubscribedObject:(id<LFDisplayBridgeTriggering>)object;
- (void) removeSubscribedObject:(id<LFDisplayBridgeTriggering>)object;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question, KVO methods. 👍 ? 👎 ?


@end
36 changes: 18 additions & 18 deletions LiveFrost/LFDisplayBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@

#import "LFDisplayBridge.h"

void LF_refreshAllSubscribedViewsApplierFunction(const void *value, void *context);
void LF_refreshAllSubscribedObjectsApplierFunction(const void *value, void *context);

@interface LFDisplayBridge ()

@property (nonatomic, readwrite, assign) CFMutableSetRef subscribedViews;
@property (nonatomic, readwrite, assign) CFMutableSetRef subscribedObjects;
@property (nonatomic, readonly, strong) CADisplayLink *displayLink;

@end

void LF_refreshAllSubscribedViewsApplierFunction(const void *value, void *context) {
[(__bridge UIView<LFDisplayBridgeTriggering> *)value refresh];
void LF_refreshAllSubscribedObjectsApplierFunction(const void *value, void *context) {
[(__bridge id<LFDisplayBridgeTriggering>)value refresh];
}

#if !__has_feature(objc_arc)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure with keeping ARC detection intact. We distribute thru CocoaPods which will ensure that the library has ARC enabled during compilation. We might want to move this into some kind of shared header if it appears more than once, or we might choose to simply omit this if that is fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was written for users that aren't using CocoaPods. (Which do exist.) (Cough, cough.)

Git submodules, for instance.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 🔥 🔥 🔥

I think this belongs to a shared header.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it can't be a header, as the ARC check needs to happen in the implementation files.

When adding exceptions to an ARC or not ARC aware codebase, the files that you need to pick out are specifically the implementation files. ARC doesn't care much for headers, as that's just an API.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess then the only solution is to ensure that this check is applied to each file.

#error This implementation file must be compiled with Objective-C ARC.
#error This implementation file must be compiled with Objective-C ARC.

#error Compile this file with the -fobjc-arc flag under your target's Build Phases,
#error or convert your project to Objective-C ARC.
#error Compile this file with the -fobjc-arc flag under your target's Build Phases,
#error or convert your project to Objective-C ARC.
#endif

@implementation LFDisplayBridge
Expand All @@ -55,32 +55,32 @@ + (instancetype) sharedInstance {

- (id) init {
if (self = [super init]) {
_subscribedViews = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL);
_subscribedObjects = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL);
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}
return self;
}

- (void) addSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object {
CFSetAddValue(_subscribedViews, (__bridge const void*)object);
- (void) dealloc {
[_displayLink invalidate];
CFRelease(_subscribedObjects);
}

- (void) removeSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object {
CFSetRemoveValue(_subscribedViews, (__bridge const void*)object);
- (void) addSubscribedObject:(id<LFDisplayBridgeTriggering>)object {
CFSetAddValue(_subscribedObjects, (__bridge const void*)object);
}

- (void) handleDisplayLink:(CADisplayLink *)displayLink {
[self refresh];
- (void) removeSubscribedObject:(id<LFDisplayBridgeTriggering>)object {
CFSetRemoveValue(_subscribedObjects, (__bridge const void*)object);
}

- (void) dealloc {
[_displayLink invalidate];
CFRelease(_subscribedViews);
- (void) handleDisplayLink:(CADisplayLink *)displayLink {
[self refresh];
}

- (void) refresh {
CFSetApplyFunction(_subscribedViews, LF_refreshAllSubscribedViewsApplierFunction, NULL);
CFSetApplyFunction(_subscribedObjects, LF_refreshAllSubscribedObjectsApplierFunction, NULL);
}

@end
25 changes: 25 additions & 0 deletions LiveFrost/LFDisplayBridgeTriggering.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright (c) 2013-2014 Evadne Wu and Nicholas Levin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@protocol LFDisplayBridgeTriggering <NSObject>
- (void) refresh;
@end
45 changes: 45 additions & 0 deletions LiveFrost/LFGlassLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headers are not included in this project by default, so we need to either add this to all files or remove ones introduced.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure what you mean. LFGlassView.h inherits from LFGlassLayer.h, though that could be moved to the implementation file and the header could see only a class definition for the LFGlassLayer instance.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the “Copyright” declaration block.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that's already been covered, as far as applying that copyright header to every interface and implementation file. Unless there are some additional files that I've missed.

// Copyright (c) 2013-2014 Evadne Wu and Nicholas Levin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@import Accelerate.vImage;
@import QuartzCore.CALayer;
#import "LFDisplayBridgeTriggering.h"

@interface LFGlassLayer : CALayer <LFDisplayBridgeTriggering>

@property (nonatomic, assign) CGFloat blurRadius;
@property (nonatomic, assign) CGFloat scaleFactor;

@property (nonatomic, assign) NSUInteger frameInterval;

- (BOOL) blurOnceIfPossible;

// optional properties for greater customization
@property (nonatomic, weak) CALayer *customBlurTargetLayer;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this part.

  • @property (nonatomic, readwrite, weak) LFBlurTarget blurTarget;
  • +[LFBlurTarget targetWithLayer:]
  • +[LFBlurTarget targetWithLayer:bounds:position:anchorPoint:frame:]
  • +[LFMutableBlurTarget targetWithLayer:bounds:position:anchorPoint:frame:]
    … 👍 ? 👎 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the extra layer of abstraction help? This doesn't seem like a place where an extra object helps out.

A better question may be, does this really clarify any logic, or add a greater degree of flexibility than what we have right now?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No but the API gets cleaner.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay, took me a little extra time to realize that you were thinking of moving out the bounds/position/anchorPoint/frame bits from the layer.

I don't know, it still seems a bit more limiting than what we have now. I did consider that custom parameters + just the bog standard superview would be a possible, even likely scenario, judging from issue #15.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do this then

@property (nonatomic, assign) CGRect customBlurBounds;
@property (nonatomic, assign) CGPoint customBlurPosition;
@property (nonatomic, assign) CGPoint customBlurAnchorPoint;
@property (nonatomic, assign) CGRect customBlurFrame;

- (void) resetCustomPositioning;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- (void) reset;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree here, it's not a universal reset, it's strictly for custom bounds/position/anchorPoint/frame.


@end
Loading