Skip to content

Commit

Permalink
fix rendering: Use Metal for rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenhador committed Mar 5, 2020
1 parent 7b36c5e commit 2a7dee5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
34 changes: 27 additions & 7 deletions Library/SCRecorder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
objects = {

/* Begin PBXBuildFile section */
9079317B1BD2A06700D7D181 /* SCFilter+VideoComposition.h in Headers */ = {isa = PBXBuildFile; fileRef = 907931791BD2A06700D7D181 /* SCFilter+VideoComposition.h */; };
45C61A4524108A7300C7E848 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 45C61A4424108A7300C7E848 /* Metal.framework */; };
45C61A47241093A500C7E848 /* SCFilter+VideoComposition.m in Sources */ = {isa = PBXBuildFile; fileRef = 9079317A1BD2A06700D7D181 /* SCFilter+VideoComposition.m */; };
45C61A482410940700C7E848 /* SCFilter+UIImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9079317E1BD451C200D7D181 /* SCFilter+UIImage.m */; };
45C61A49241096EF00C7E848 /* SCFilterImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 90D4FBDE1BC6C1840017748D /* SCFilterImageView.m */; };
45C61A4C2410993300C7E848 /* SCWeakSelectorTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DC10CF261ACFD458009880C4 /* SCWeakSelectorTarget.h */; };
45C61A4D2410993800C7E848 /* SCWeakSelectorTarget.m in Sources */ = {isa = PBXBuildFile; fileRef = DC10CF271ACFD458009880C4 /* SCWeakSelectorTarget.m */; };
45C61A4E241099AD00C7E848 /* NSURL+SCSaveToCameraRoll.h in Headers */ = {isa = PBXBuildFile; fileRef = 90B02E331BC995CD00559011 /* NSURL+SCSaveToCameraRoll.h */; };
45C61A4F241099B000C7E848 /* NSURL+SCSaveToCameraRoll.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B02E341BC995CD00559011 /* NSURL+SCSaveToCameraRoll.m */; };
45C61A50241099B400C7E848 /* SCSaveToCameraRollOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 90B02E391BCBFE7F00559011 /* SCSaveToCameraRollOperation.h */; };
45C61A51241099B600C7E848 /* SCSaveToCameraRollOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B02E3A1BCBFE7F00559011 /* SCSaveToCameraRollOperation.m */; };
45C61A52241099BA00C7E848 /* UIImage+SCSaveToCameraRoll.h in Headers */ = {isa = PBXBuildFile; fileRef = 90B02E3D1BCC003D00559011 /* UIImage+SCSaveToCameraRoll.h */; };
45C61A53241099BD00C7E848 /* UIImage+SCSaveToCameraRoll.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B02E3E1BCC003D00559011 /* UIImage+SCSaveToCameraRoll.m */; };
9079317B1BD2A06700D7D181 /* SCFilter+VideoComposition.h in Headers */ = {isa = PBXBuildFile; fileRef = 907931791BD2A06700D7D181 /* SCFilter+VideoComposition.h */; settings = {ATTRIBUTES = (Public, ); }; };
9079317C1BD2A06700D7D181 /* SCFilter+VideoComposition.m in Sources */ = {isa = PBXBuildFile; fileRef = 9079317A1BD2A06700D7D181 /* SCFilter+VideoComposition.m */; };
9079317F1BD451C200D7D181 /* SCFilter+UIImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 9079317D1BD451C200D7D181 /* SCFilter+UIImage.h */; };
907931801BD451C200D7D181 /* SCFilter+UIImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9079317E1BD451C200D7D181 /* SCFilter+UIImage.m */; };
Expand Down Expand Up @@ -118,7 +130,6 @@
DCEE378A1B17E6480019C7B5 /* SCContext.h in Headers */ = {isa = PBXBuildFile; fileRef = DCEE37881B17E6480019C7B5 /* SCContext.h */; };
DCEE378B1B17E6480019C7B5 /* SCContext.m in Sources */ = {isa = PBXBuildFile; fileRef = DCEE37891B17E6480019C7B5 /* SCContext.m */; };
DCEE378D1B17F3CA0019C7B5 /* SCContext.m in Sources */ = {isa = PBXBuildFile; fileRef = DCEE37891B17E6480019C7B5 /* SCContext.m */; };
DCEE378E1B17F3D50019C7B5 /* SCWeakSelectorTarget.m in Sources */ = {isa = PBXBuildFile; fileRef = DC10CF271ACFD458009880C4 /* SCWeakSelectorTarget.m */; };
DCEE378F1B17F3D50019C7B5 /* SCFilterAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = DC7A62BE1AFA47EC00EAB60C /* SCFilterAnimation.m */; };
DCF3A68F1AB9F4760034CF5C /* SCRecorderDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = DCF3A68E1AB9F4760034CF5C /* SCRecorderDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A5C23FE9A5F00689167 /* SCIOPixelBuffers.h in Headers */ = {isa = PBXBuildFile; fileRef = DCD12AA21B45AA540064674D /* SCIOPixelBuffers.h */; };
Expand All @@ -129,13 +140,12 @@
FD783A6123FE9C1800689167 /* SCFilterAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = DC7A62BD1AFA47EC00EAB60C /* SCFilterAnimation.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A6223FE9CEC00689167 /* SCRecorderHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 90B02E411BCC00AC00559011 /* SCRecorderHeader.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A6323FE9D0600689167 /* SCFilterImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D4FBDD1BC6C1840017748D /* SCFilterImageView.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A6423FE9D4000689167 /* NSURL+SCSaveToCameraRoll.h in Headers */ = {isa = PBXBuildFile; fileRef = 90B02E331BC995CD00559011 /* NSURL+SCSaveToCameraRoll.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A6523FE9D6400689167 /* UIImage+SCSaveToCameraRoll.h in Headers */ = {isa = PBXBuildFile; fileRef = 90B02E3D1BCC003D00559011 /* UIImage+SCSaveToCameraRoll.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A6623FE9D6B00689167 /* SCFilter+VideoComposition.h in Headers */ = {isa = PBXBuildFile; fileRef = 907931791BD2A06700D7D181 /* SCFilter+VideoComposition.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD783A6723FE9D7200689167 /* SCFilter+UIImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 9079317D1BD451C200D7D181 /* SCFilter+UIImage.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
45C61A4424108A7300C7E848 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; };
907931791BD2A06700D7D181 /* SCFilter+VideoComposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SCFilter+VideoComposition.h"; sourceTree = "<group>"; };
9079317A1BD2A06700D7D181 /* SCFilter+VideoComposition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SCFilter+VideoComposition.m"; sourceTree = "<group>"; };
9079317D1BD451C200D7D181 /* SCFilter+UIImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SCFilter+UIImage.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -262,6 +272,7 @@
files = (
DCDC1E2D1AC7980A001DC3D9 /* AudioToolbox.framework in Frameworks */,
DCDC1E2C1AC79806001DC3D9 /* AVFoundation.framework in Frameworks */,
45C61A4524108A7300C7E848 /* Metal.framework in Frameworks */,
DCDC1E2B1AC79803001DC3D9 /* CoreGraphics.framework in Frameworks */,
DCDC1E2A1AC797FF001DC3D9 /* UIKit.framework in Frameworks */,
);
Expand Down Expand Up @@ -308,6 +319,7 @@
isa = PBXGroup;
children = (
90D4FBE31BC6DDBF0017748D /* Metal.framework */,
45C61A4424108A7300C7E848 /* Metal.framework */,
90D4FBE11BC6DDB80017748D /* MetalKit.framework */,
DCA8EF89192BD55900839BE2 /* AVFoundation.framework */,
DCA8EF87192BD55100839BE2 /* QuartzCore.framework */,
Expand Down Expand Up @@ -564,11 +576,11 @@
DCDC1DF81AC79592001DC3D9 /* SCRecorderFramework.h in Headers */,
DCDC1E2E1AC799CF001DC3D9 /* SCVideoConfiguration.h in Headers */,
DCDC1E2F1AC799CF001DC3D9 /* SCAudioConfiguration.h in Headers */,
FD783A6423FE9D4000689167 /* NSURL+SCSaveToCameraRoll.h in Headers */,
FD783A5E23FE9A7200689167 /* SCProcessingQueue.h in Headers */,
DCDC1E301AC799CF001DC3D9 /* SCMediaTypeConfiguration.h in Headers */,
DCDC1E311AC799CF001DC3D9 /* SCPhotoConfiguration.h in Headers */,
DCDC1E321AC799CF001DC3D9 /* SCRecordSession.h in Headers */,
45C61A52241099BA00C7E848 /* UIImage+SCSaveToCameraRoll.h in Headers */,
DCDC1E331AC799CF001DC3D9 /* SCRecorder.h in Headers */,
DCDC1E341AC799CF001DC3D9 /* SCRecordSessionSegment.h in Headers */,
FD783A6623FE9D6B00689167 /* SCFilter+VideoComposition.h in Headers */,
Expand All @@ -578,16 +590,18 @@
FD783A5C23FE9A5F00689167 /* SCIOPixelBuffers.h in Headers */,
DCDC1E371AC799CF001DC3D9 /* SCRecorderToolsView.h in Headers */,
FD783A6123FE9C1800689167 /* SCFilterAnimation.h in Headers */,
FD783A6523FE9D6400689167 /* UIImage+SCSaveToCameraRoll.h in Headers */,
DCDC1E391AC799CF001DC3D9 /* SCSwipeableFilterView.h in Headers */,
45C61A50241099B400C7E848 /* SCSaveToCameraRollOperation.h in Headers */,
DCDC1E3C1AC799CF001DC3D9 /* SCImageView.h in Headers */,
FD783A6323FE9D0600689167 /* SCFilterImageView.h in Headers */,
DCDC1E3D1AC799CF001DC3D9 /* SCPlayer.h in Headers */,
DCDC1E3E1AC799CF001DC3D9 /* SCVideoPlayerView.h in Headers */,
FD783A6023FE9BF300689167 /* SCContext.h in Headers */,
DCDC1E401AC799CF001DC3D9 /* SCSampleBufferHolder.h in Headers */,
45C61A4C2410993300C7E848 /* SCWeakSelectorTarget.h in Headers */,
DCDC1E411AC799CF001DC3D9 /* SCAssetExportSession.h in Headers */,
DCDC1E421AC799CF001DC3D9 /* SCAudioTools.h in Headers */,
45C61A4E241099AD00C7E848 /* NSURL+SCSaveToCameraRoll.h in Headers */,
DCDC1E431AC799CF001DC3D9 /* SCRecorderTools.h in Headers */,
DCDC1E441AC799CF001DC3D9 /* SCFilter.h in Headers */,
);
Expand Down Expand Up @@ -751,22 +765,28 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DCEE378E1B17F3D50019C7B5 /* SCWeakSelectorTarget.m in Sources */,
45C61A47241093A500C7E848 /* SCFilter+VideoComposition.m in Sources */,
DCEE378F1B17F3D50019C7B5 /* SCFilterAnimation.m in Sources */,
DCEE378D1B17F3CA0019C7B5 /* SCContext.m in Sources */,
DCDC1E161AC797EF001DC3D9 /* SCVideoConfiguration.m in Sources */,
DCDC1E171AC797EF001DC3D9 /* SCAudioConfiguration.m in Sources */,
45C61A4D2410993800C7E848 /* SCWeakSelectorTarget.m in Sources */,
DCDC1E181AC797EF001DC3D9 /* SCMediaTypeConfiguration.m in Sources */,
DCDC1E191AC797EF001DC3D9 /* SCPhotoConfiguration.m in Sources */,
DCDC1E1A1AC797EF001DC3D9 /* SCRecordSession.m in Sources */,
DCDC1E1B1AC797EF001DC3D9 /* SCRecorder.m in Sources */,
45C61A482410940700C7E848 /* SCFilter+UIImage.m in Sources */,
DCDC1E1C1AC797EF001DC3D9 /* SCRecordSessionSegment.m in Sources */,
45C61A49241096EF00C7E848 /* SCFilterImageView.m in Sources */,
DCDC1E1D1AC797EF001DC3D9 /* SCRecorderFocusTargetView.m in Sources */,
45C61A53241099BD00C7E848 /* UIImage+SCSaveToCameraRoll.m in Sources */,
DCDC1E1E1AC797EF001DC3D9 /* SCRecorderToolsView.m in Sources */,
DCDC1E1F1AC797EF001DC3D9 /* SCSwipeableFilterView.m in Sources */,
DCDC1E211AC797EF001DC3D9 /* SCImageView.m in Sources */,
FD783A5D23FE9A6700689167 /* SCIOPixelBuffers.m in Sources */,
DCDC1E221AC797EF001DC3D9 /* SCPlayer.m in Sources */,
45C61A51241099B600C7E848 /* SCSaveToCameraRollOperation.m in Sources */,
45C61A4F241099B000C7E848 /* NSURL+SCSaveToCameraRoll.m in Sources */,
DCDC1E231AC797EF001DC3D9 /* SCVideoPlayerView.m in Sources */,
DCDC1E251AC797EF001DC3D9 /* SCSampleBufferHolder.m in Sources */,
DCDC1E261AC797EF001DC3D9 /* SCAssetExportSession.m in Sources */,
Expand Down
7 changes: 3 additions & 4 deletions Library/Sources/SCContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ + (BOOL)supportsType:(SCContextType)contextType {

+ (SCContextType)suggestedContextType {
// On iOS 9.0, Metal does not behave nicely with gaussian blur filters
// if ([SCContext supportsType:SCContextTypeMetal]) {
// return SCContextTypeMetal;
// } else
if ([SCContext supportsType:SCContextTypeCoreGraphics]) {
if ([SCContext supportsType:SCContextTypeMetal]) {
return SCContextTypeMetal;
} else if ([SCContext supportsType:SCContextTypeCoreGraphics]) {
return SCContextTypeCoreGraphics;
} else {
return SCContextTypeDefault;
Expand Down
11 changes: 10 additions & 1 deletion Library/Sources/SCImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,16 @@ - (CIImage *)renderedCIImageInRect:(CGRect)rect {
if (image != nil) {
image = [image imageByApplyingTransform:self.preferredCIImageTransform];

image = [image imageByApplyingOrientation:4];
switch (self.context.type) {
case SCContextTypeMetal:
// Framebuffer coordinate in Metal: +Y is down
break;
case SCContextTypeCPU:
case SCContextTypeDefault:
case SCContextTypeCoreGraphics:
case SCContextTypeAuto:
image = [image imageByApplyingOrientation:4];
}

if (self.scaleAndResizeCIImageAutomatically) {
image = [self scaleAndResizeCIImage:image forRect:rect];
Expand Down
2 changes: 0 additions & 2 deletions Library/Sources/SCRecorderHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#import "SCRecorderTools.h"
#import "SCRecorderDelegate.h"
#import "SCContext.h"
#import "NSURL+SCSaveToCameraRoll.h"
#import "UIImage+SCSaveToCameraRoll.h"
#import "SCFilter+VideoComposition.h"
#import "SCFilter+UIImage.h"
#import "SCAudioTools.h"
Expand Down

0 comments on commit 2a7dee5

Please sign in to comment.