Skip to content

Commit

Permalink
Fixed warning in SCFilterSelectorView.
Browse files Browse the repository at this point in the history
  • Loading branch information
rFlex committed Sep 10, 2015
1 parent 29bcb62 commit d889e05
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
33 changes: 17 additions & 16 deletions Library/Sources/SCFilterSelectorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ - (id)initWithCoder:(NSCoder *)aDecoder {

- (void)commonInit {
_preferredCIImageTransform = CGAffineTransformIdentity;
_glkView = [[GLKView alloc] initWithFrame:self.bounds context:nil];
_glkView.backgroundColor = [UIColor clearColor];

_glkView.delegate = self;


_sampleBufferHolder = [SCSampleBufferHolder new];

[self addSubview:_glkView];
}

- (void)_loadContext {
- (void)_loadContextIfNeeded {
if (_CIContext == nil) {
SCContext *context = [SCContext context];
_CIContext = context.CIContext;
_glkView.context = context.EAGLContext;

_glkView = [[GLKView alloc] initWithFrame:self.bounds context:context.EAGLContext];
_glkView.backgroundColor = [UIColor clearColor];

_glkView.delegate = self;
[self insertSubview:_glkView atIndex:0];

[self setNeedsLayout];
}
}

Expand Down Expand Up @@ -81,22 +82,22 @@ - (void)render:(CIImage *)image toContext:(CIContext *)context inRect:(CGRect)re

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
CIImage *newImage = [CIImageRendererUtils generateImageFromSampleBufferHolder:_sampleBufferHolder];

if (newImage != nil) {
_CIImage = newImage;
}

CIImage *outputImage = _CIImage;

if (outputImage != nil) {
outputImage = [outputImage imageByApplyingTransform:self.preferredCIImageTransform];

if (self.preprocessingFilter != nil) {
outputImage = [self.preprocessingFilter imageByProcessingImage:outputImage atTime:self.CIImageTime];
}

rect = [CIImageRendererUtils processRect:rect withImageSize:outputImage.extent.size contentScale:_glkView.contentScaleFactor contentMode:self.contentMode];

[self render:outputImage toContext:_CIContext inRect:rect];
}
}
Expand Down Expand Up @@ -149,7 +150,7 @@ - (void)setCIImage:(CIImage *)CIImage {
_CIImage = CIImage;

if (CIImage != nil) {
[self _loadContext];
[self _loadContextIfNeeded];
}
[_glkView setNeedsDisplay];
}
Expand Down
22 changes: 13 additions & 9 deletions Library/Sources/SCSwipeableFilterView.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,21 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat contentOffsetX = scrollView.contentOffset.x;
CGFloat contentSizeWidth = scrollView.contentSize.width;
CGFloat normalWidth = self.filters.count * width;

if (contentOffsetX <= 0) {
scrollView.contentOffset = CGPointMake(contentOffsetX + normalWidth, scrollView.contentOffset.y);
} else if (contentOffsetX + width >= contentSizeWidth) {
scrollView.contentOffset = CGPointMake(contentOffsetX - normalWidth, scrollView.contentOffset.y);

if (width > 0 && contentSizeWidth > 0) {
if (contentOffsetX <= 0) {
scrollView.contentOffset = CGPointMake(contentOffsetX + normalWidth, scrollView.contentOffset.y);
} else if (contentOffsetX + width >= contentSizeWidth) {
scrollView.contentOffset = CGPointMake(contentOffsetX - normalWidth, scrollView.contentOffset.y);
}

CGFloat ratio = scrollView.contentOffset.x / width;

_filterGroupIndexRatio = ratio;
} else {
_filterGroupIndexRatio = 0;
}

CGFloat ratio = scrollView.contentOffset.x / width;

_filterGroupIndexRatio = ratio;

if (_refreshAutomaticallyWhenScrolling) {
[self refresh];
}
Expand Down

0 comments on commit d889e05

Please sign in to comment.