Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions LiveFrost/LFDisplayBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
+ (instancetype) sharedInstance;

@property (nonatomic, readonly, assign) CFMutableSetRef subscribedViews;
- (void) addSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object;
- (void) removeSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object;
- (void) addSubscribedLayer:(CALayer<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.

Actually this is a bit off, please reference Mutable Unordered Accessors, Key-Value Coding Programming Guide (). The methods were added to facilitate faster Key-Value Coding because methods must conform to;

  • -add<Key>Object: or -add<Key>:
  • -remove<Key>Object: or -remove<Key>:
  • -intersect<Key>:

I suppose the original design exposing the underlying mutable set was not the best call. Also, now we announce subscribedViews but privately work on subscribedLayers which is incongruent.

Copy link
Author

Choose a reason for hiding this comment

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

Fair reasoning, I missed subscribedViews when I was renaming every bit to describe layers.

I don't think we need to expose subscribedViews publicly to begin with. We should take out that public facing API.

Copy link
Owner

Choose a reason for hiding this comment

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

✂️ 👍

- (void) removeSubscribedLayer:(CALayer<LFDisplayBridgeTriggering> *)object;

@end
34 changes: 17 additions & 17 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_refreshAllSubscribedLayersApplierFunction(const void *value, void *context);

@interface LFDisplayBridge ()

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

@end

void LF_refreshAllSubscribedViewsApplierFunction(const void *value, void *context) {
void LF_refreshAllSubscribedLayersApplierFunction(const void *value, void *context) {
[(__bridge UIView<LFDisplayBridgeTriggering> *)value refresh];
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe id<LFDisplayBridgeTriggering> is good enough.

}

#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);
_subscribedLayers = 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(_subscribedLayers);
}

- (void) removeSubscribedViewsObject:(UIView<LFDisplayBridgeTriggering> *)object {
CFSetRemoveValue(_subscribedViews, (__bridge const void*)object);
- (void) addSubscribedLayer:(CALayer<LFDisplayBridgeTriggering> *)object {
CFSetAddValue(_subscribedLayers, (__bridge const void*)object);
}

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

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

- (void) refresh {
CFSetApplyFunction(_subscribedViews, LF_refreshAllSubscribedViewsApplierFunction, NULL);
CFSetApplyFunction(_subscribedLayers, LF_refreshAllSubscribedLayersApplierFunction, NULL);
}

@end
47 changes: 47 additions & 0 deletions LiveFrost/LFGlassLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
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.
//
// Contains contributions from Nam Kennic
//

#import <Accelerate/Accelerate.h>
#import <QuartzCore/QuartzCore.h>
#import "LFDisplayBridge.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