Skip to content

Commit

Permalink
Fixed compilation on simulator.
Browse files Browse the repository at this point in the history
  • Loading branch information
rFlex committed Oct 19, 2015
1 parent a2a50f5 commit 689f085
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 30 deletions.
6 changes: 4 additions & 2 deletions Examples/ObjC/SCRecorderExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
90A0D7DE1BC7367A008F1BB0 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90A0D7DD1BC7367A008F1BB0 /* Launch Screen.storyboard */; settings = {ASSET_TAGS = (); }; };
90D4FBE81BC6DDE40017748D /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90D4FBE71BC6DDE40017748D /* MetalKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
90D4FBED1BC6DDEC0017748D /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90D4FBEC1BC6DDEC0017748D /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
DC10CF251ACFD082009880C4 /* libSCRecorder.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DC10CF1E1ACFCF6E009880C4 /* libSCRecorder.a */; };
DC1485DD1AFB78F2004896E9 /* a_filter.cisf in Resources */ = {isa = PBXBuildFile; fileRef = DC1485DC1AFB78F2004896E9 /* a_filter.cisf */; };
Expand Down Expand Up @@ -129,7 +128,6 @@
buildActionMask = 2147483647;
files = (
90D4FBED1BC6DDEC0017748D /* Metal.framework in Frameworks */,
90D4FBE81BC6DDE40017748D /* MetalKit.framework in Frameworks */,
DC10CF251ACFD082009880C4 /* libSCRecorder.a in Frameworks */,
DCB0416D19253FB800D945D2 /* GLKit.framework in Frameworks */,
DC7F370E18FC2A0D00D54901 /* CoreGraphics.framework in Frameworks */,
Expand Down Expand Up @@ -516,6 +514,8 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = NO;
ENABLE_BITCODE = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Sources/SCRecorderExamples-Prefix.pch";
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -543,6 +543,8 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = NO;
ENABLE_BITCODE = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Sources/SCRecorderExamples-Prefix.pch";
HEADER_SEARCH_PATHS = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
Expand Down
8 changes: 6 additions & 2 deletions Library/SCRecorder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
90B02E401BCC003D00559011 /* UIImage+SCSaveToCameraRoll.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B02E3E1BCC003D00559011 /* UIImage+SCSaveToCameraRoll.m */; settings = {ASSET_TAGS = (); }; };
90D4FBDF1BC6C1840017748D /* SCFilterImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D4FBDD1BC6C1840017748D /* SCFilterImageView.h */; settings = {ASSET_TAGS = (); }; };
90D4FBE01BC6C1840017748D /* SCFilterImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 90D4FBDE1BC6C1840017748D /* SCFilterImageView.m */; settings = {ASSET_TAGS = (); }; };
90D4FBE21BC6DDB80017748D /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90D4FBE11BC6DDB80017748D /* MetalKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
90D4FBE41BC6DDBF0017748D /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90D4FBE31BC6DDBF0017748D /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
90D4FBE61BC6DDDC0017748D /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90D4FBE51BC6DDDC0017748D /* GLKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
DC10CF281ACFD458009880C4 /* SCWeakSelectorTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DC10CF261ACFD458009880C4 /* SCWeakSelectorTarget.h */; };
Expand Down Expand Up @@ -232,7 +231,6 @@
files = (
90D4FBE61BC6DDDC0017748D /* GLKit.framework in Frameworks */,
90D4FBE41BC6DDBF0017748D /* Metal.framework in Frameworks */,
90D4FBE21BC6DDB80017748D /* MetalKit.framework in Frameworks */,
DC23FE2317B451A100389EDA /* UIKit.framework in Frameworks */,
DC23FE2217B4519A00389EDA /* CoreGraphics.framework in Frameworks */,
DC23FE2117B4519100389EDA /* AVFoundation.framework in Frameworks */,
Expand Down Expand Up @@ -775,7 +773,10 @@
DC23FE1B17B4200900389EDA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = NO;
DSTROOT = /tmp/SCAudioVideoRecorder.dst;
ENABLE_BITCODE = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
OTHER_LDFLAGS = "-ObjC";
Expand All @@ -787,7 +788,10 @@
DC23FE1C17B4200900389EDA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = NO;
DSTROOT = /tmp/SCAudioVideoRecorder.dst;
ENABLE_BITCODE = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
OTHER_LDFLAGS = "-ObjC";
Expand Down
3 changes: 2 additions & 1 deletion Library/Sources/SCFilter+UIImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright © 2015 rFlex. All rights reserved.
//

#import <SCRecorder/SCRecorder.h>
#import <UIKit/UIKit.h>
#import "SCFilter.h"

@interface SCFilter (UIImage)

Expand Down
61 changes: 39 additions & 22 deletions Library/Sources/SCImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
// Copyright (c) 2014 rFlex. All rights reserved.
//

#import <MetalKit/MetalKit.h>
#import "SCImageView.h"
#import "SCSampleBufferHolder.h"
#import "SCContext.h"

@interface SCImageView()<GLKViewDelegate, MTKViewDelegate> {
SCSampleBufferHolder *_sampleBufferHolder;
}
#if TARGET_IPHONE_SIMULATOR
@interface SCImageView()<GLKViewDelegate>

#else
@import MetalKit;

@interface SCImageView()<GLKViewDelegate, MTKViewDelegate>

@property (nonatomic, strong) GLKView *GLKView;
@property (nonatomic, strong) MTKView *MTKView;
#endif

@property (nonatomic, strong) GLKView *GLKView;
@property (nonatomic, strong) id<MTLCommandQueue> MTLCommandQueue;
@property (nonatomic, strong) SCSampleBufferHolder *sampleBufferHolder;

@end

Expand Down Expand Up @@ -85,20 +91,25 @@ - (void)layoutSubviews {
[super layoutSubviews];

_GLKView.frame = self.bounds;

#if !(TARGET_IPHONE_SIMULATOR)
_MTKView.frame = self.bounds;
#endif
}

- (void)unloadContext {
if (_GLKView != nil) {
[_GLKView removeFromSuperview];
_GLKView = nil;
}
#if !(TARGET_IPHONE_SIMULATOR)
if (_MTKView != nil) {
_MTLCommandQueue = nil;
[_MTKView removeFromSuperview];
[_MTKView releaseDrawables];
_MTKView = nil;
}
#endif
_context = nil;
}

Expand All @@ -115,6 +126,7 @@ - (void)setContext:(SCContext * _Nullable)context {
_GLKView.delegate = self;
[self insertSubview:_GLKView atIndex:0];
break;
#if !(TARGET_IPHONE_SIMULATOR)
case SCContextTypeMetal:
_MTLCommandQueue = [context.MTLDevice newCommandQueue];
_MTKView = [[MTKView alloc] initWithFrame:self.bounds device:context.MTLDevice];
Expand All @@ -125,6 +137,7 @@ - (void)setContext:(SCContext * _Nullable)context {
_MTKView.framebufferOnly = NO;
[self insertSubview:_MTKView atIndex:0];
break;
#endif
default:
[NSException raise:@"InvalidContext" format:@"Unsupported context type: %d. SCImageView only supports CoreGraphics, EAGL and Metal", (int)context.type];
break;
Expand All @@ -138,7 +151,9 @@ - (void)setNeedsDisplay {
[super setNeedsDisplay];

[_GLKView setNeedsDisplay];
#if !(TARGET_IPHONE_SIMULATOR)
[_MTKView setNeedsDisplay];
#endif
}

- (UIImage *)renderedUIImageInRect:(CGRect)rect {
Expand Down Expand Up @@ -322,6 +337,23 @@ static CGRect CGRectMultiply(CGRect rect, CGFloat contentScale) {
return rect;
}

#pragma mark -- GLKViewDelegate

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
@autoreleasepool {
rect = CGRectMultiply(rect, self.contentScaleFactor);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);

CIImage *image = [self renderedCIImageInRect:rect];

if (image != nil) {
[_context.CIContext drawImage:image inRect:rect fromRect:image.extent];
}
}
}

#if !(TARGET_IPHONE_SIMULATOR)
#pragma mark -- MTKViewDelegate

- (void)drawInMTKView:(nonnull MTKView *)view {
Expand All @@ -344,23 +376,8 @@ - (void)drawInMTKView:(nonnull MTKView *)view {
}

- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size {

}

#pragma mark -- GLKViewDelegate

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
@autoreleasepool {
rect = CGRectMultiply(rect, self.contentScaleFactor);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);

CIImage *image = [self renderedCIImageInRect:rect];

if (image != nil) {
[_context.CIContext drawImage:image inRect:rect fromRect:image.extent];
}
}

}
#endif

@end
5 changes: 2 additions & 3 deletions SCRecorder.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ Pod::Spec.new do |s|
s.homepage = "https://github.com/rFlex/SCRecorder"
s.license = 'Apache License, Version 2.0'
s.author = { "Simon CORSIN" => "[email protected]" }
s.platform = :ios, '9.0'
s.ios.deployment_target = '7.0'
s.platform = :ios, '7.0'
s.source = { :git => "https://github.com/rFlex/SCRecorder.git", :tag => "v2.6.0" }
s.source_files = 'Library/Sources/*.{h,m}'
s.public_header_files = 'Library/Sources/*.h'
s.requires_arc = true
s.weak_frameworks = 'Metal', 'GLKit', 'MetalKit'
s.weak_frameworks = 'Metal', 'GLKit'
s.frameworks = 'AVFoundation'

end

0 comments on commit 689f085

Please sign in to comment.