├── .DS_Store ├── ImageFilterSwiftUI.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── alfianlosari.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── alfianlosari.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── ImageFilterSwiftUI.xcworkspace ├── contents.xcworkspacedata ├── xcshareddata │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── alfianlosari.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── ImageFilterSwiftUI ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── Bindings │ ├── AppState.swift │ └── ImageFilterObervable.swift ├── CPImage.swift ├── Helpers │ └── FilePanel+Extension.swift ├── ImageFilterSwiftUI.entitlements ├── Info.plist ├── Models │ └── ImageFilter.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── Views │ ├── ContentView.swift │ ├── ImageFilterView.swift │ └── ProgressView.swift ├── ImageFilterSwiftUIiOS ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── image.imageset │ │ ├── Contents.json │ │ └── d3efbcfa-9e9e-422e-ac34-e8916b8ecd07.jpg ├── Base.lproj │ └── LaunchScreen.storyboard ├── ContentView.swift ├── ImagePicker.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── SceneDelegate.swift ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── MetalPetal │ ├── Frameworks │ │ └── MetalPetal │ │ │ ├── Filters │ │ │ ├── MTIAlphaPremultiplicationFilter.h │ │ │ ├── MTIAlphaPremultiplicationFilter.m │ │ │ ├── MTIBlendFilter.h │ │ │ ├── MTIBlendFilter.m │ │ │ ├── MTIBlendWithMaskFilter.h │ │ │ ├── MTIBlendWithMaskFilter.m │ │ │ ├── MTIBulgeDistortionFilter.h │ │ │ ├── MTIBulgeDistortionFilter.m │ │ │ ├── MTICLAHEFilter.h │ │ │ ├── MTICLAHEFilter.m │ │ │ ├── MTIChromaKeyBlendFilter.h │ │ │ ├── MTIChromaKeyBlendFilter.m │ │ │ ├── MTIColorHalftoneFilter.h │ │ │ ├── MTIColorHalftoneFilter.m │ │ │ ├── MTIColorLookupFilter.h │ │ │ ├── MTIColorLookupFilter.m │ │ │ ├── MTIColorMatrixFilter.h │ │ │ ├── MTIColorMatrixFilter.m │ │ │ ├── MTICropFilter.h │ │ │ ├── MTICropFilter.m │ │ │ ├── MTIDotScreenFilter.h │ │ │ ├── MTIDotScreenFilter.m │ │ │ ├── MTIFilter.h │ │ │ ├── MTIFilter.m │ │ │ ├── MTIHexagonalBokehBlurFilter.h │ │ │ ├── MTIHexagonalBokehBlurFilter.m │ │ │ ├── MTIHighPassSkinSmoothingFilter.h │ │ │ ├── MTIHighPassSkinSmoothingFilter.m │ │ │ ├── MTIImage+Filters.h │ │ │ ├── MTIImage+Filters.m │ │ │ ├── MTIMPSBoxBlurFilter.h │ │ │ ├── MTIMPSBoxBlurFilter.m │ │ │ ├── MTIMPSConvolutionFilter.h │ │ │ ├── MTIMPSConvolutionFilter.m │ │ │ ├── MTIMPSDefinitionFilter.h │ │ │ ├── MTIMPSDefinitionFilter.m │ │ │ ├── MTIMPSGaussianBlurFilter.h │ │ │ ├── MTIMPSGaussianBlurFilter.m │ │ │ ├── MTIMPSHistogramFilter.h │ │ │ ├── MTIMPSHistogramFilter.m │ │ │ ├── MTIMPSSobelFilter.h │ │ │ ├── MTIMPSSobelFilter.m │ │ │ ├── MTIMPSUnsharpMaskFilter.h │ │ │ ├── MTIMPSUnsharpMaskFilter.m │ │ │ ├── MTIMultilayerCompositingFilter.h │ │ │ ├── MTIMultilayerCompositingFilter.m │ │ │ ├── MTIPixellateFilter.h │ │ │ ├── MTIPixellateFilter.m │ │ │ ├── MTIRGBColorSpaceConversionFilter.h │ │ │ ├── MTIRGBColorSpaceConversionFilter.m │ │ │ ├── MTIRGBToneCurveFilter.h │ │ │ ├── MTIRGBToneCurveFilter.m │ │ │ ├── MTIRoundCornerFilter.h │ │ │ ├── MTIRoundCornerFilter.m │ │ │ ├── MTITransformFilter.h │ │ │ ├── MTITransformFilter.m │ │ │ ├── MTIUnaryImageRenderingFilter.h │ │ │ ├── MTIUnaryImageRenderingFilter.m │ │ │ ├── MTIVibranceFilter.h │ │ │ └── MTIVibranceFilter.m │ │ │ ├── Kernels │ │ │ ├── MTIComputePipelineKernel.h │ │ │ ├── MTIComputePipelineKernel.m │ │ │ ├── MTIKernel.h │ │ │ ├── MTIKernel.m │ │ │ ├── MTIMPSKernel.h │ │ │ ├── MTIMPSKernel.m │ │ │ ├── MTIMultilayerCompositeKernel.h │ │ │ ├── MTIMultilayerCompositeKernel.m │ │ │ ├── MTIRenderCommand.h │ │ │ ├── MTIRenderCommand.m │ │ │ ├── MTIRenderPipelineKernel.h │ │ │ └── MTIRenderPipelineKernel.m │ │ │ ├── MTIAlphaType.h │ │ │ ├── MTIAlphaType.m │ │ │ ├── MTIBlendModes.h │ │ │ ├── MTIBlendModes.m │ │ │ ├── MTIBuffer.h │ │ │ ├── MTIBuffer.m │ │ │ ├── MTICVMetalIOSurfaceBridge.h │ │ │ ├── MTICVMetalIOSurfaceBridge.m │ │ │ ├── MTICVMetalTextureBridging.h │ │ │ ├── MTICVMetalTextureCache.h │ │ │ ├── MTICVMetalTextureCache.m │ │ │ ├── MTICVPixelBufferPool.h │ │ │ ├── MTICVPixelBufferPool.m │ │ │ ├── MTICVPixelBufferPromise.h │ │ │ ├── MTICVPixelBufferPromise.m │ │ │ ├── MTICVPixelBufferRendering.h │ │ │ ├── MTICVPixelBufferRendering.m │ │ │ ├── MTIColor.h │ │ │ ├── MTIColor.m │ │ │ ├── MTIColorMatrix.h │ │ │ ├── MTIColorMatrix.m │ │ │ ├── MTIComputePipeline.h │ │ │ ├── MTIComputePipeline.m │ │ │ ├── MTIContext+Internal.h │ │ │ ├── MTIContext+Rendering.h │ │ │ ├── MTIContext+Rendering.m │ │ │ ├── MTIContext.h │ │ │ ├── MTIContext.m │ │ │ ├── MTICoreImageRendering.h │ │ │ ├── MTICoreImageRendering.m │ │ │ ├── MTIDefer.h │ │ │ ├── MTIDefer.m │ │ │ ├── MTIDrawableRendering.h │ │ │ ├── MTIDrawableRendering.m │ │ │ ├── MTIError.h │ │ │ ├── MTIError.m │ │ │ ├── MTIFunctionDescriptor.h │ │ │ ├── MTIFunctionDescriptor.m │ │ │ ├── MTIGeometry.h │ │ │ ├── MTIGeometry.m │ │ │ ├── MTIGeometryUtilities.h │ │ │ ├── MTIGeometryUtilities.m │ │ │ ├── MTIHasher.h │ │ │ ├── MTIHasher.m │ │ │ ├── MTIImage+Promise.h │ │ │ ├── MTIImage.h │ │ │ ├── MTIImage.m │ │ │ ├── MTIImageOrientation.h │ │ │ ├── MTIImageOrientation.m │ │ │ ├── MTIImagePromise.h │ │ │ ├── MTIImagePromise.m │ │ │ ├── MTIImagePromiseDebug.h │ │ │ ├── MTIImagePromiseDebug.m │ │ │ ├── MTIImageProperties.h │ │ │ ├── MTIImageProperties.m │ │ │ ├── MTIImageRenderingContext+Internal.h │ │ │ ├── MTIImageRenderingContext.h │ │ │ ├── MTIImageRenderingContext.mm │ │ │ ├── MTILayer.h │ │ │ ├── MTILayer.m │ │ │ ├── MTILibrarySource.h │ │ │ ├── MTILibrarySource.m │ │ │ ├── MTILock.h │ │ │ ├── MTILock.m │ │ │ ├── MTIMask.h │ │ │ ├── MTIMask.m │ │ │ ├── MTIMemoryWarningObserver.h │ │ │ ├── MTIMemoryWarningObserver.m │ │ │ ├── MTIPixelFormat.h │ │ │ ├── MTIPixelFormat.m │ │ │ ├── MTIPrint.h │ │ │ ├── MTIPrint.m │ │ │ ├── MTIRenderGraphOptimization.h │ │ │ ├── MTIRenderGraphOptimization.m │ │ │ ├── MTIRenderPassOutputDescriptor.h │ │ │ ├── MTIRenderPassOutputDescriptor.m │ │ │ ├── MTIRenderPipeline.h │ │ │ ├── MTIRenderPipeline.m │ │ │ ├── MTIRenderTask.h │ │ │ ├── MTIRenderTask.m │ │ │ ├── MTISamplerDescriptor.h │ │ │ ├── MTISamplerDescriptor.m │ │ │ ├── MTITextureDescriptor.h │ │ │ ├── MTITextureDescriptor.m │ │ │ ├── MTITextureDimensions.h │ │ │ ├── MTITextureDimensions.m │ │ │ ├── MTITextureLoader.h │ │ │ ├── MTITextureLoader.m │ │ │ ├── MTITextureLoaderForiOS9.h │ │ │ ├── MTITextureLoaderForiOS9.m │ │ │ ├── MTITexturePool.h │ │ │ ├── MTITexturePool.mm │ │ │ ├── MTITransform.h │ │ │ ├── MTITransform.m │ │ │ ├── MTIVector+SIMD.h │ │ │ ├── MTIVector+SIMD.m │ │ │ ├── MTIVector.h │ │ │ ├── MTIVector.m │ │ │ ├── MTIVertex.h │ │ │ ├── MTIVertex.m │ │ │ ├── MTIWeakToStrongObjectsMapTable.h │ │ │ ├── MTIWeakToStrongObjectsMapTable.m │ │ │ ├── MetalPetal.h │ │ │ ├── MetalPetal.modulemap │ │ │ ├── SceneKit │ │ │ ├── MTISCNSceneRenderer.h │ │ │ └── MTISCNSceneRenderer.m │ │ │ ├── Shaders │ │ │ ├── BlendingShaders.metal │ │ │ ├── CLAHE.metal │ │ │ ├── ColorConversionShaders.metal │ │ │ ├── Halftone.metal │ │ │ ├── HighPassSkinSmoothing.metal │ │ │ ├── LensBlur.metal │ │ │ ├── MTIShaderLib.h │ │ │ ├── MultilayerCompositeShaders.metal │ │ │ └── Shaders.metal │ │ │ └── UI │ │ │ ├── MTIImageView.h │ │ │ ├── MTIImageView.m │ │ │ ├── MTIThreadSafeImageView.h │ │ │ └── MTIThreadSafeImageView.m │ ├── LICENSE │ └── README.md ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── alfianlosari.xcuserdatad │ │ └── xcschemes │ │ ├── MetalPetal-iOS.xcscheme │ │ ├── MetalPetal-macOS.xcscheme │ │ ├── Pods-ImageFilterSwiftUI.xcscheme │ │ ├── Pods-ImageFilterSwiftUIiOS.xcscheme │ │ └── xcschememanagement.plist └── Target Support Files │ ├── MetalPetal-iOS │ ├── MetalPetal-iOS-Info.plist │ ├── MetalPetal-iOS-dummy.m │ ├── MetalPetal-iOS.modulemap │ └── MetalPetal-iOS.xcconfig │ ├── MetalPetal-macOS │ ├── MetalPetal-macOS-Info.plist │ ├── MetalPetal-macOS-dummy.m │ ├── MetalPetal-macOS.modulemap │ └── MetalPetal-macOS.xcconfig │ ├── Pods-ImageFilterSwiftUI │ ├── Pods-ImageFilterSwiftUI-Info.plist │ ├── Pods-ImageFilterSwiftUI-acknowledgements.markdown │ ├── Pods-ImageFilterSwiftUI-acknowledgements.plist │ ├── Pods-ImageFilterSwiftUI-dummy.m │ ├── Pods-ImageFilterSwiftUI-frameworks-Debug-input-files.xcfilelist │ ├── Pods-ImageFilterSwiftUI-frameworks-Debug-output-files.xcfilelist │ ├── Pods-ImageFilterSwiftUI-frameworks-Release-input-files.xcfilelist │ ├── Pods-ImageFilterSwiftUI-frameworks-Release-output-files.xcfilelist │ ├── Pods-ImageFilterSwiftUI-frameworks.sh │ ├── Pods-ImageFilterSwiftUI-umbrella.h │ ├── Pods-ImageFilterSwiftUI.debug.xcconfig │ ├── Pods-ImageFilterSwiftUI.modulemap │ └── Pods-ImageFilterSwiftUI.release.xcconfig │ └── Pods-ImageFilterSwiftUIiOS │ ├── Pods-ImageFilterSwiftUIiOS-Info.plist │ ├── Pods-ImageFilterSwiftUIiOS-acknowledgements.markdown │ ├── Pods-ImageFilterSwiftUIiOS-acknowledgements.plist │ ├── Pods-ImageFilterSwiftUIiOS-dummy.m │ ├── Pods-ImageFilterSwiftUIiOS-frameworks-Debug-input-files.xcfilelist │ ├── Pods-ImageFilterSwiftUIiOS-frameworks-Debug-output-files.xcfilelist │ ├── Pods-ImageFilterSwiftUIiOS-frameworks-Release-input-files.xcfilelist │ ├── Pods-ImageFilterSwiftUIiOS-frameworks-Release-output-files.xcfilelist │ ├── Pods-ImageFilterSwiftUIiOS-frameworks.sh │ ├── Pods-ImageFilterSwiftUIiOS-umbrella.h │ ├── Pods-ImageFilterSwiftUIiOS.debug.xcconfig │ ├── Pods-ImageFilterSwiftUIiOS.modulemap │ └── Pods-ImageFilterSwiftUIiOS.release.xcconfig ├── README.md └── promo.jpg /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfianlosari/ImageFilterSwiftUICompleted/2d9f26a642e417484635c39b49bb84fc6c74747a/.DS_Store -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcodeproj/project.xcworkspace/xcuserdata/alfianlosari.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfianlosari/ImageFilterSwiftUICompleted/2d9f26a642e417484635c39b49bb84fc6c74747a/ImageFilterSwiftUI.xcodeproj/project.xcworkspace/xcuserdata/alfianlosari.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ImageFilterSwiftUI.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 4 11 | 12 | ImageFilterSwiftUIiOS.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 5 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcworkspace/xcuserdata/alfianlosari.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfianlosari/ImageFilterSwiftUICompleted/2d9f26a642e417484635c39b49bb84fc6c74747a/ImageFilterSwiftUI.xcworkspace/xcuserdata/alfianlosari.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ImageFilterSwiftUI.xcworkspace/xcuserdata/alfianlosari.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ImageFilterMac 4 | // 5 | // Created by Alfian Losari on 23/02/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import SwiftUI 11 | 12 | @NSApplicationMain 13 | class AppDelegate: NSObject, NSApplicationDelegate { 14 | 15 | var window: NSWindow! 16 | 17 | func applicationDidFinishLaunching(_ aNotification: Notification) { 18 | // Create the SwiftUI view that provides the window contents. 19 | let appState = AppState.shared 20 | let contentView = ContentView() 21 | .environmentObject(appState) 22 | 23 | // Create the window and set the content view. 24 | window = NSWindow( 25 | contentRect: .zero, 26 | styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], 27 | backing: .buffered, defer: false) 28 | 29 | window.title = "Image Filter" 30 | window.collectionBehavior = [.fullScreenAuxiliary, .fullScreenNone] 31 | window.center() 32 | window.setFrameAutosaveName("Main Window") 33 | window.contentView = NSHostingView(rootView: contentView) 34 | window.makeKeyAndOrderFront(nil) 35 | } 36 | 37 | func applicationWillTerminate(_ aNotification: Notification) { 38 | // Insert code here to tear down your application 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Bindings/AppState.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppState.swift 3 | // ImageFilterMac 4 | // 5 | // Created by Alfian Losari on 25/02/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import Combine 10 | 11 | class AppState: ObservableObject { 12 | 13 | static let shared = AppState() 14 | 15 | private init() {} 16 | 17 | @Published var filteredImage: CPImage? 18 | @Published var image: CPImage? { 19 | didSet { 20 | self.filteredImage = nil 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Bindings/ImageFilterObervable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFilterObervable.swift 3 | // ImageFilterMac 4 | // 5 | // Created by Alfian Losari on 25/02/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import Combine 10 | 11 | class ImageFilterObservable: ObservableObject { 12 | 13 | @Published var filteredImage: CPImage? = nil 14 | 15 | let image: CPImage 16 | let filter: ImageFilter 17 | 18 | init(image: CPImage, filter: ImageFilter) { 19 | self.image = image 20 | self.filter = filter 21 | } 22 | 23 | func filterImage() { 24 | self.filter.performFilter(with: self.image) { 25 | self.filteredImage = $0 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/CPImage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CPImage.swift 3 | // ImageFilterSwiftUI 4 | // 5 | // Created by Alfian Losari on 13/03/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | import SwiftUI 9 | 10 | #if os(iOS) 11 | import UIKit 12 | public typealias CPImage = UIImage 13 | #elseif os(OSX) 14 | import AppKit 15 | public typealias CPImage = NSImage 16 | #endif 17 | 18 | extension CPImage { 19 | 20 | var coreImage: CIImage? { 21 | #if os(iOS) 22 | guard let cgImage = self.cgImage else { 23 | return nil 24 | } 25 | return CIImage(cgImage: cgImage) 26 | #elseif os(OSX) 27 | guard 28 | let tiffData = tiffRepresentation, 29 | let ciImage = CIImage(data: tiffData) 30 | else { 31 | return nil 32 | } 33 | return ciImage 34 | #endif 35 | } 36 | } 37 | 38 | extension CGImage { 39 | 40 | var cpImage: CPImage { 41 | #if os(iOS) 42 | return UIImage(cgImage: self) 43 | #elseif os(OSX) 44 | return NSImage(cgImage: self, size: .init(width: width, height: height)) 45 | #endif 46 | } 47 | } 48 | 49 | extension Image { 50 | 51 | init(cpImage: CPImage) { 52 | #if os(iOS) 53 | self.init(uiImage: cpImage) 54 | #elseif os(OSX) 55 | self.init(nsImage: cpImage) 56 | #endif 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Helpers/FilePanel+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FilePanel+Extension.swift 3 | // ImageFilterMac 4 | // 5 | // Created by Alfian Losari on 25/02/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | extension NSOpenPanel { 12 | 13 | static func openImage(completion: @escaping (_ result: Result) -> ()) { 14 | let panel = NSOpenPanel() 15 | panel.allowsMultipleSelection = false 16 | panel.canChooseFiles = true 17 | panel.canChooseDirectories = false 18 | panel.allowedFileTypes = ["jpg", "jpeg", "png", "heic"] 19 | panel.canChooseFiles = true 20 | panel.begin { (result) in 21 | if result == .OK, 22 | let url = panel.urls.first, 23 | let image = NSImage(contentsOf: url) { 24 | completion(.success(image)) 25 | } else { 26 | completion(.failure( 27 | NSError(domain: "", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to get file location"]) 28 | )) 29 | } 30 | } 31 | } 32 | } 33 | 34 | extension NSSavePanel { 35 | 36 | static func saveImage(_ image: NSImage, completion: @escaping (_ result: Result) -> ()) { 37 | let savePanel = NSSavePanel() 38 | savePanel.canCreateDirectories = true 39 | savePanel.showsTagField = false 40 | savePanel.nameFieldStringValue = "image.jpg" 41 | savePanel.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.modalPanelWindow))) 42 | savePanel.begin { (result) in 43 | guard result == .OK, 44 | let url = savePanel.url else { 45 | completion(.failure( 46 | NSError(domain: "", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to get file location"]) 47 | )) 48 | return 49 | } 50 | 51 | DispatchQueue.global(qos: .userInitiated).async { 52 | guard 53 | let data = image.tiffRepresentation, 54 | let imageRep = NSBitmapImageRep(data: data) else { return } 55 | 56 | do { 57 | let imageData = imageRep.representation(using: .jpeg, properties: [.compressionFactor: 1.0]) 58 | try imageData?.write(to: url) 59 | } catch { 60 | completion(.failure(error)) 61 | } 62 | } 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/ImageFilterSwiftUI.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2020 Alfian Losari. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | NSSupportsAutomaticTermination 32 | 33 | NSSupportsSuddenTermination 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUI/Views/ProgressView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ProgressView.swift 3 | // ImageFilterMac 4 | // 5 | // Created by Alfian Losari on 25/02/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | #if os(iOS) 12 | import UIKit 13 | struct ProgressView: UIViewRepresentable { 14 | func makeUIView(context: UIViewRepresentableContext) -> UIActivityIndicatorView { 15 | UIActivityIndicatorView(style: .large) 16 | } 17 | 18 | func updateUIView(_ uiView: UIActivityIndicatorView, context: UIViewRepresentableContext) { 19 | uiView.startAnimating() 20 | } 21 | 22 | } 23 | 24 | #elseif os(OSX) 25 | import AppKit 26 | struct ProgressView: NSViewRepresentable { 27 | 28 | func updateNSView(_ nsView: NSProgressIndicator, context: NSViewRepresentableContext) { 29 | nsView.style = .spinning 30 | nsView.startAnimation(self) 31 | } 32 | 33 | func makeNSView(context: NSViewRepresentableContext) -> NSProgressIndicator { 34 | let progressIndicator = NSProgressIndicator() 35 | return progressIndicator 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ImageFilterSwiftUIiOS 4 | // 5 | // Created by Alfian Losari on 13/03/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Assets.xcassets/image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "d3efbcfa-9e9e-422e-ac34-e8916b8ecd07.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Assets.xcassets/image.imageset/d3efbcfa-9e9e-422e-ac34-e8916b8ecd07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfianlosari/ImageFilterSwiftUICompleted/2d9f26a642e417484635c39b49bb84fc6c74747a/ImageFilterSwiftUIiOS/Assets.xcassets/image.imageset/d3efbcfa-9e9e-422e-ac34-e8916b8ecd07.jpg -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/ImagePicker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImagePicker.swift 3 | // ImageFilterSwiftUIiOS 4 | // 5 | // Created by Alfian Losari on 16/03/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ImagePicker: UIViewControllerRepresentable { 12 | 13 | @Environment(\.presentationMode) var presentationMode 14 | @Binding var image: UIImage? 15 | 16 | var sourceType: UIImagePickerController.SourceType 17 | 18 | func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext) {} 19 | 20 | func makeCoordinator() -> Coordinator { 21 | Coordinator(self) 22 | } 23 | 24 | class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate { 25 | var parent: ImagePicker 26 | 27 | init(_ parent: ImagePicker) { 28 | self.parent = parent 29 | super.init() 30 | } 31 | 32 | func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { 33 | parent.presentationMode.wrappedValue.dismiss() 34 | } 35 | 36 | func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { 37 | if let uiImage = info[.originalImage] as? UIImage { 38 | parent.image = uiImage.fixOrientation 39 | } 40 | parent.presentationMode.wrappedValue.dismiss() 41 | } 42 | 43 | 44 | } 45 | 46 | func makeUIViewController(context: UIViewControllerRepresentableContext) -> UIImagePickerController { 47 | let imagePicker = UIImagePickerController() 48 | imagePicker.sourceType = sourceType 49 | imagePicker.delegate = context.coordinator 50 | return imagePicker 51 | } 52 | } 53 | 54 | extension UIImage { 55 | 56 | var fixOrientation: UIImage { 57 | if (imageOrientation == .up) { 58 | return self 59 | } 60 | 61 | UIGraphicsBeginImageContextWithOptions(size, false, scale) 62 | let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) 63 | draw(in: rect) 64 | 65 | let normalizedImage = UIGraphicsGetImageFromCurrentImageContext()! 66 | UIGraphicsEndImageContext() 67 | 68 | return normalizedImage 69 | } 70 | } 71 | 72 | extension UIImagePickerController.SourceType: Identifiable { 73 | public var id: Int { rawValue } 74 | } 75 | -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPhotoLibraryUsageDescription 6 | Access Photo library 7 | NSCameraUsageDescription 8 | Take picture with camera 9 | CFBundleDevelopmentRegion 10 | $(DEVELOPMENT_LANGUAGE) 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UIApplicationSceneManifest 28 | 29 | UIApplicationSupportsMultipleScenes 30 | 31 | UISceneConfigurations 32 | 33 | UIWindowSceneSessionRoleApplication 34 | 35 | 36 | UISceneConfigurationName 37 | Default Configuration 38 | UISceneDelegateClassName 39 | $(PRODUCT_MODULE_NAME).SceneDelegate 40 | 41 | 42 | 43 | 44 | UILaunchStoryboardName 45 | LaunchScreen 46 | UIRequiredDeviceCapabilities 47 | 48 | armv7 49 | 50 | UISupportedInterfaceOrientations 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageFilterSwiftUIiOS/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // ImageFilterSwiftUIiOS 4 | // 5 | // Created by Alfian Losari on 13/03/20. 6 | // Copyright © 2020 Alfian Losari. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | import MetalPetal 12 | 13 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 14 | 15 | var window: UIWindow? 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | 18 | let appState = AppState.shared 19 | let contentView = ContentView() 20 | .environmentObject(appState) 21 | 22 | if let windowScene = scene as? UIWindowScene { 23 | let window = UIWindow(windowScene: windowScene) 24 | window.rootViewController = UIHostingController(rootView: contentView) 25 | self.window = window 26 | window.makeKeyAndVisible() 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'ImageFilterSwiftUI' do 5 | # Comment the next line if you don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for ImageFilterSwiftUI 9 | pod 'MetalPetal' 10 | 11 | end 12 | 13 | 14 | 15 | target 'ImageFilterSwiftUIiOS' do 16 | # Comment the next line if you don't want to use dynamic frameworks 17 | use_frameworks! 18 | 19 | # Pods for ImageFilterSwiftUI 20 | pod 'MetalPetal' 21 | 22 | 23 | 24 | 25 | end 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MetalPetal (1.9.0): 3 | - MetalPetal/Core (= 1.9.0) 4 | - MetalPetal/Core (1.9.0) 5 | 6 | DEPENDENCIES: 7 | - MetalPetal 8 | 9 | SPEC REPOS: 10 | trunk: 11 | - MetalPetal 12 | 13 | SPEC CHECKSUMS: 14 | MetalPetal: 07d93f6b0e8bcdd4da238dbb2b769b5405f183c0 15 | 16 | PODFILE CHECKSUM: 42459ac846f220daae04214ef795b5db068c01c4 17 | 18 | COCOAPODS: 1.8.4 19 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MetalPetal (1.9.0): 3 | - MetalPetal/Core (= 1.9.0) 4 | - MetalPetal/Core (1.9.0) 5 | 6 | DEPENDENCIES: 7 | - MetalPetal 8 | 9 | SPEC REPOS: 10 | trunk: 11 | - MetalPetal 12 | 13 | SPEC CHECKSUMS: 14 | MetalPetal: 07d93f6b0e8bcdd4da238dbb2b769b5405f183c0 15 | 16 | PODFILE CHECKSUM: 42459ac846f220daae04214ef795b5db068c01c4 17 | 18 | COCOAPODS: 1.8.4 19 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIAlphaPremultiplicationFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUnpremultiplyAlphaFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIUnaryImageRenderingFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIUnpremultiplyAlphaFilter : MTIUnaryImageRenderingFilter 14 | 15 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 16 | 17 | @end 18 | 19 | @interface MTIPremultiplyAlphaFilter : MTIUnaryImageRenderingFilter 20 | 21 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 22 | 23 | @end 24 | 25 | /// Unpremultiply alpha and convert to linear RGB 26 | @interface MTIUnpremultiplyAlphaWithSRGBToLinearRGBFilter : MTIUnaryImageRenderingFilter 27 | 28 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBlendFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBlendFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 12/10/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIBlendModes.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIBlendFilter : NSObject 14 | 15 | - (instancetype)init NS_UNAVAILABLE; 16 | 17 | + (instancetype)new NS_UNAVAILABLE; 18 | 19 | @property (nonatomic,copy,readonly) MTIBlendMode blendMode; 20 | 21 | - (instancetype)initWithBlendMode:(MTIBlendMode)mode; 22 | 23 | @property (nonatomic,strong,nullable) MTIImage *inputBackgroundImage; 24 | 25 | @property (nonatomic,strong,nullable) MTIImage *inputImage; 26 | 27 | @property (nonatomic) float intensity; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBlendFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBlendFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 12/10/2017. 6 | // 7 | 8 | #import "MTIBlendFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIImage.h" 11 | #import "MTIRenderPipelineKernel.h" 12 | 13 | @interface MTIBlendFilter () 14 | 15 | @property (nonatomic,strong,readonly) MTIRenderPipelineKernel *kernel; 16 | 17 | @end 18 | 19 | @implementation MTIBlendFilter 20 | @synthesize outputPixelFormat = _outputPixelFormat; 21 | 22 | + (MTIRenderPipelineKernel *)kernelWithBlendMode:(MTIBlendMode)mode { 23 | static NSMutableDictionary *kernels; 24 | static NSLock *kernelsLock; 25 | static dispatch_once_t onceToken; 26 | dispatch_once(&onceToken, ^{ 27 | kernels = [NSMutableDictionary dictionary]; 28 | kernelsLock = [[NSLock alloc] init]; 29 | }); 30 | 31 | [kernelsLock lock]; 32 | MTIRenderPipelineKernel *kernel = kernels[mode]; 33 | if (!kernel) { 34 | kernel = [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName] 35 | fragmentFunctionDescriptor:[MTIBlendModes functionDescriptorsForBlendMode:mode].fragmentFunctionDescriptorForBlendFilter]; 36 | kernels[mode] = kernel; 37 | } 38 | [kernelsLock unlock]; 39 | 40 | return kernel; 41 | } 42 | 43 | - (instancetype)initWithBlendMode:(MTIBlendMode)mode { 44 | if (self = [super init]) { 45 | NSParameterAssert([MTIBlendModes.allModes containsObject:mode]); 46 | _blendMode = [mode copy]; 47 | _kernel = [MTIBlendFilter kernelWithBlendMode:mode]; 48 | _intensity = 1.0; 49 | } 50 | return self; 51 | } 52 | 53 | - (MTIImage *)outputImage { 54 | if (!_inputBackgroundImage || !_inputImage) { 55 | return nil; 56 | } 57 | return [self.kernel applyToInputImages:@[_inputBackgroundImage, _inputImage] 58 | parameters:@{@"intensity": @(_intensity)} 59 | outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(_inputBackgroundImage.size) 60 | outputPixelFormat:_outputPixelFormat]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBlendWithMaskFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMaskBlendFilter.h 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/10/26. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | #import "MTIColor.h" 11 | #import "MTIMask.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface MTIBlendWithMaskFilter: NSObject 16 | 17 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 18 | 19 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 20 | 21 | @property (nonatomic, strong, nullable) MTIMask *inputMask; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBlendWithMaskFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMaskBlendFilter.m 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/10/26. 6 | // 7 | 8 | #import "MTIBlendWithMaskFilter.h" 9 | #import "MTIRenderPipelineKernel.h" 10 | #import "MTIFunctionDescriptor.h" 11 | #import "MTIImage.h" 12 | 13 | @implementation MTIBlendWithMaskFilter 14 | @synthesize outputPixelFormat = _outputPixelFormat; 15 | 16 | + (MTIRenderPipelineKernel *)kernel { 17 | static MTIRenderPipelineKernel *kernel; 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | kernel = [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName] 21 | fragmentFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:@"blendWithMask"]]; 22 | }); 23 | return kernel; 24 | } 25 | 26 | - (MTIImage *)outputImage { 27 | if (!self.inputImage || !self.inputMask || !self.inputBackgroundImage) { 28 | return nil; 29 | } 30 | BOOL usesOneMinusMaskValue = self.inputMask.mode == MTIMaskModeOneMinusMaskValue; 31 | return [self.class.kernel applyToInputImages:@[self.inputImage, self.inputMask.content, self.inputBackgroundImage] 32 | parameters:@{@"maskComponent": @((int)self.inputMask.component), 33 | @"usesOneMinusMaskValue": @(usesOneMinusMaskValue)} 34 | outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(_inputBackgroundImage.size) 35 | outputPixelFormat:_outputPixelFormat]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBulgeDistortionFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBulgeDistortionFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/14. 6 | // 7 | 8 | #import "MTIUnaryImageRenderingFilter.h" 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIBulgeDistortionFilter : MTIUnaryImageRenderingFilter 14 | 15 | @property (nonatomic) simd_float2 center; //in pixels 16 | 17 | @property (nonatomic) float radius; //in pixels 18 | 19 | @property (nonatomic) float scale; 20 | 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBulgeDistortionFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBulgeDistortionFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/14. 6 | // 7 | 8 | #import "MTIBulgeDistortionFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector+SIMD.h" 11 | 12 | @implementation MTIBulgeDistortionFilter 13 | 14 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 15 | return [[MTIFunctionDescriptor alloc] initWithName:@"bulgeDistortion"]; 16 | } 17 | 18 | - (NSDictionary *)parameters { 19 | return @{@"center": [MTIVector vectorWithFloat2:_center], 20 | @"radius": @(_radius), 21 | @"scale": @(_scale)}; 22 | } 23 | 24 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 25 | return MTIAlphaTypeHandlingRule.passthroughAlphaTypeHandlingRule; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTICLAHEFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICLAHEFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 13/10/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | struct MTICLAHESize { 13 | NSUInteger width, height; 14 | }; 15 | typedef struct MTICLAHESize MTICLAHESize; 16 | 17 | FOUNDATION_EXPORT MTICLAHESize MTICLAHESizeMake(NSUInteger width, NSUInteger height) NS_SWIFT_UNAVAILABLE("Use MTICLAHESize.init instead."); 18 | 19 | @interface MTICLAHEFilter : NSObject 20 | 21 | @property (nonatomic) float clipLimit; 22 | 23 | @property (nonatomic) MTICLAHESize tileGridSize; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIChromaKeyBlendFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIChromaKeyBlendFilter.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 29/12/2017. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | #import "MTIColor.h" 11 | 12 | @interface MTIChromaKeyBlendFilter : NSObject 13 | 14 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 15 | 16 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 17 | 18 | @property (nonatomic) float thresholdSensitivity; 19 | 20 | @property (nonatomic) float smoothing; 21 | 22 | @property (nonatomic) MTIColor color; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIChromaKeyBlendFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIChromaKeyBlendFilter.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 29/12/2017. 6 | // 7 | 8 | #import "MTIChromaKeyBlendFilter.h" 9 | #import "MTIRenderPipelineKernel.h" 10 | #import "MTIVector+SIMD.h" 11 | #import "MTIFunctionDescriptor.h" 12 | #import "MTIImage.h" 13 | 14 | @implementation MTIChromaKeyBlendFilter 15 | @synthesize outputPixelFormat = _outputPixelFormat; 16 | 17 | + (MTIRenderPipelineKernel *)kernel { 18 | static MTIRenderPipelineKernel *kernel; 19 | static dispatch_once_t onceToken; 20 | dispatch_once(&onceToken, ^{ 21 | kernel = [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName] 22 | fragmentFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:@"chromaKeyBlend"]]; 23 | }); 24 | return kernel; 25 | } 26 | 27 | - (instancetype)init { 28 | if (self = [super init]) { 29 | _thresholdSensitivity = 0.4; 30 | _smoothing = 0.1; 31 | _color = MTIColorMake(0.0, 1.0, 0.0, 1.0); 32 | } 33 | return self; 34 | } 35 | 36 | - (MTIImage *)outputImage { 37 | if (!self.inputImage || !self.inputBackgroundImage) { 38 | return nil; 39 | } 40 | return [self.class.kernel applyToInputImages:@[self.inputImage, self.inputBackgroundImage] 41 | parameters:@{@"color": [MTIVector vectorWithFloat4:MTIColorToFloat4(self.color)], 42 | @"thresholdSensitivity": @(self.thresholdSensitivity), 43 | @"smoothing": @(self.smoothing)} 44 | outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(self.inputImage.size) 45 | outputPixelFormat:self.outputPixelFormat]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIColorHalftoneFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorHalftoneFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 17/01/2018. 6 | // 7 | 8 | #import "MTIUnaryImageRenderingFilter.h" 9 | #import 10 | 11 | @interface MTIColorHalftoneFilter : MTIUnaryImageRenderingFilter 12 | 13 | @property (nonatomic) float scale; 14 | 15 | @property (nonatomic) simd_float4 angles; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIColorHalftoneFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorHalftoneFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 17/01/2018. 6 | // 7 | 8 | #import "MTIColorHalftoneFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector+SIMD.h" 11 | 12 | @implementation MTIColorHalftoneFilter 13 | 14 | - (instancetype)init { 15 | if (self = [super init]) { 16 | _scale = 20; 17 | _angles = simd_make_float4(M_PI_4, M_PI_4, M_PI_4, 0); 18 | } 19 | return self; 20 | } 21 | 22 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 23 | return [[MTIFunctionDescriptor alloc] initWithName:@"colorHalftone"]; 24 | } 25 | 26 | - (NSDictionary *)parameters { 27 | BOOL allAnglesAreEqual = NO; 28 | if (self.angles.x == self.angles.y && self.angles.y == self.angles.z) { 29 | allAnglesAreEqual = YES; 30 | } 31 | return @{@"scale": @(MAX(self.scale, 1.0f)), 32 | @"angles": [MTIVector vectorWithFloat4:self.angles], 33 | @"singleAngleMode": @(allAnglesAreEqual)}; 34 | } 35 | 36 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 37 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIColorLookupFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTILookUpTableFilter.h 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/10/12. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, MTIColorLookupTableType) { 14 | MTIColorLookupTableTypeUnknown, 15 | 16 | /// The look up table contents must a 2D image representing `n` slices of a unit color cube texture, arranged in an square of `n` images. For instance, a color cube of dimension 64x64x64 should be provided as an image of size 512x512 - sqrt(64x64x64). 17 | MTIColorLookupTableType2DSquare, 18 | 19 | /// The look up table contents must a 2D image representing `n` slices of a unit color cube texture, arranged in an horizontal row of `n` images. For instance, a color cube of dimension 16x16x16 should be provided as an image of size 256x16. 20 | MTIColorLookupTableType2DHorizontalStrip, 21 | 22 | MTIColorLookupTableType2DVerticalStrip, 23 | 24 | MTIColorLookupTableType3D 25 | }; 26 | 27 | @interface MTIColorLookupTableInfo: NSObject 28 | 29 | @property (nonatomic,readonly) MTIColorLookupTableType type; 30 | 31 | @property (nonatomic,readonly) NSInteger dimension; 32 | 33 | - (instancetype)init NS_UNAVAILABLE; 34 | 35 | + (instancetype)new NS_UNAVAILABLE; 36 | 37 | - (instancetype)initWithType:(MTIColorLookupTableType)type dimension:(NSInteger)dimension NS_DESIGNATED_INITIALIZER; 38 | 39 | @end 40 | 41 | @interface MTIColorLookupFilter : NSObject 42 | 43 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 44 | 45 | @property (nonatomic, strong, nullable) MTIImage *inputColorLookupTable; 46 | 47 | @property (nonatomic, strong, nullable, readonly) MTIColorLookupTableInfo *inputColorLookupTableInfo; 48 | 49 | @property (nonatomic) float intensity; 50 | 51 | + (nullable MTIImage *)create3DColorLookupTableFrom2DColorLookupTable:(MTIImage *)image pixelFormat:(MTLPixelFormat)pixelFormat NS_SWIFT_NAME(make3DColorLookupTable(from:pixelFormat:)); 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIColorMatrixFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorMatrixFilter.h 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/27. 6 | // 7 | // 8 | 9 | #import "MTIFilter.h" 10 | #import "MTIUnaryImageRenderingFilter.h" 11 | #import "MTIColorMatrix.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | FOUNDATION_EXPORT NSString * const MTIColorMatrixFilterColorMatrixParameterKey; 16 | 17 | @interface MTIColorMatrixFilter : MTIUnaryImageRenderingFilter 18 | 19 | @property (nonatomic) MTIColorMatrix colorMatrix; 20 | 21 | @end 22 | 23 | @interface MTIExposureFilter : MTIColorMatrixFilter 24 | 25 | - (void)setColorMatrix:(MTIColorMatrix)colorMatrix NS_UNAVAILABLE; 26 | 27 | @property (nonatomic) float exposure; 28 | 29 | @end 30 | 31 | @interface MTISaturationFilter : MTIColorMatrixFilter 32 | 33 | - (void)setColorMatrix:(MTIColorMatrix)colorMatrix NS_UNAVAILABLE; 34 | 35 | @property (nonatomic) simd_float3 grayColorTransform; 36 | 37 | @property (nonatomic) float saturation; 38 | 39 | @end 40 | 41 | @interface MTIColorInvertFilter : MTIColorMatrixFilter 42 | 43 | - (void)setColorMatrix:(MTIColorMatrix)colorMatrix NS_UNAVAILABLE; 44 | 45 | @end 46 | 47 | @interface MTIOpacityFilter: MTIColorMatrixFilter 48 | 49 | - (void)setColorMatrix:(MTIColorMatrix)colorMatrix NS_UNAVAILABLE; 50 | 51 | @property (nonatomic) float opacity; 52 | 53 | @end 54 | 55 | @interface MTIBrightnessFilter: MTIColorMatrixFilter 56 | 57 | - (void)setColorMatrix:(MTIColorMatrix)colorMatrix NS_UNAVAILABLE; 58 | 59 | @property (nonatomic) float brightness; 60 | 61 | @end 62 | 63 | @interface MTIContrastFilter: MTIColorMatrixFilter 64 | 65 | - (void)setColorMatrix:(MTIColorMatrix)colorMatrix NS_UNAVAILABLE; 66 | 67 | @property (nonatomic) float contrast; 68 | 69 | @end 70 | 71 | NS_ASSUME_NONNULL_END 72 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTICropFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICropFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 28/10/2017. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSUInteger, MTICropRegionUnit) { 14 | MTICropRegionUnitPixel, 15 | MTICropRegionUnitPercentage 16 | }; 17 | 18 | // Rounding policies: 19 | // 20 | // Original Value 1.2 | 1.21 | 1.25 | 1.35 | 1.27 21 | // ----------------------------------------------- 22 | // Plain 1.2 | 1.2 | 1.3 | 1.4 | 1.3 23 | // Floor 1.2 | 1.2 | 1.2 | 1.3 | 1.2 24 | // Ceiling 1.2 | 1.3 | 1.3 | 1.4 | 1.3 25 | 26 | typedef NS_ENUM(NSUInteger, MTICropFilterRoundingMode) { 27 | MTICropFilterRoundingModePlain, 28 | MTICropFilterRoundingModeCeiling, 29 | MTICropFilterRoundingModeFloor 30 | }; 31 | 32 | struct MTICropRegion { 33 | CGRect bounds; 34 | MTICropRegionUnit unit; 35 | }; 36 | typedef struct MTICropRegion MTICropRegion; 37 | 38 | FOUNDATION_EXPORT MTICropRegion MTICropRegionMake(CGRect rect, MTICropRegionUnit unit) NS_SWIFT_UNAVAILABLE("Use MTICropRegion.init instead."); 39 | 40 | @interface MTICropFilter : NSObject 41 | 42 | @property (nonatomic) MTICropRegion cropRegion; 43 | 44 | @property (nonatomic) float scale; 45 | 46 | @property (nonatomic) MTICropFilterRoundingMode roundingMode; 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIDotScreenFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDotScreenFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | 8 | #import "MTIUnaryImageRenderingFilter.h" 9 | #import 10 | 11 | @interface MTIDotScreenFilter : MTIUnaryImageRenderingFilter 12 | 13 | @property (nonatomic) float angle; 14 | 15 | @property (nonatomic) float scale; 16 | 17 | @property (nonatomic) simd_float3 grayColorTransform; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIDotScreenFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDotScreenFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | 8 | #import "MTIDotScreenFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector+SIMD.h" 11 | #import "MTIColor.h" 12 | 13 | @implementation MTIDotScreenFilter 14 | 15 | - (instancetype)init { 16 | if (self = [super init]) { 17 | _angle = M_PI_4; 18 | _scale = 12.0; 19 | _grayColorTransform = MTIGrayColorTransformDefault; 20 | } 21 | return self; 22 | } 23 | 24 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 25 | return [[MTIFunctionDescriptor alloc] initWithName:@"dotScreen"]; 26 | } 27 | 28 | - (NSDictionary *)parameters { 29 | return @{@"angle": @(self.angle), 30 | @"scale": @(MAX(self.scale, 1.0f)), 31 | @"grayColorTransform": [MTIVector vectorWithFloat3:self.grayColorTransform]}; 32 | } 33 | 34 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 35 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MTIPixelFormat.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | FOUNDATION_EXPORT NSString * const MTIFilterPassthroughVertexFunctionName; 16 | FOUNDATION_EXPORT NSString * const MTIFilterPassthroughFragmentFunctionName; 17 | 18 | FOUNDATION_EXPORT NSString * const MTIFilterUnpremultiplyAlphaFragmentFunctionName; 19 | FOUNDATION_EXPORT NSString * const MTIFilterUnpremultiplyAlphaWithSRGBToLinearRGBFragmentFunctionName; 20 | FOUNDATION_EXPORT NSString * const MTIFilterPremultiplyAlphaFragmentFunctionName; 21 | 22 | FOUNDATION_EXPORT NSString * const MTIFilterColorMatrixFragmentFunctionName; 23 | 24 | @class MTIImage; 25 | 26 | @protocol MTIFilter 27 | 28 | @property (nonatomic) MTLPixelFormat outputPixelFormat; //Default: MTIPixelFormatUnspecified aka MTLPixelFormatInvalid 29 | 30 | @property (nonatomic, readonly, nullable) MTIImage *outputImage; 31 | 32 | @end 33 | 34 | @protocol MTIUnaryFilter 35 | 36 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilter.m 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import "MTIFilter.h" 10 | #import "MTIVertex.h" 11 | #import "MTIImage.h" 12 | #import "MTIFunctionDescriptor.h" 13 | 14 | NSString * const MTIFilterPassthroughVertexFunctionName = @"passthroughVertex"; 15 | NSString * const MTIFilterPassthroughFragmentFunctionName = @"passthrough"; 16 | 17 | NSString * const MTIFilterUnpremultiplyAlphaFragmentFunctionName = @"unpremultiplyAlpha"; 18 | NSString * const MTIFilterUnpremultiplyAlphaWithSRGBToLinearRGBFragmentFunctionName = @"unpremultiplyAlphaWithSRGBToLinearRGB"; 19 | NSString * const MTIFilterPremultiplyAlphaFragmentFunctionName = @"premultiplyAlpha"; 20 | 21 | NSString * const MTIFilterColorMatrixFragmentFunctionName = @"colorMatrixProjection"; 22 | 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIHexagonalBokehBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIHexagonalBokehBlurFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 13/10/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIMask.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// An implementation of lens blur (bokeh) based on `Siggraph 2011 - Advances in Real-Time Rendering` 14 | /// https://colinbarrebrisebois.com/2017/04/18/hexagonal-bokeh-blur-revisited/ 15 | 16 | @interface MTIHexagonalBokehBlurFilter : NSObject 17 | 18 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 19 | @property (nonatomic, strong, nullable) MTIMask *inputMask; 20 | 21 | @property (nonatomic) float radius; 22 | @property (nonatomic) float brightness; 23 | @property (nonatomic) float angle; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIHighPassSkinSmoothingFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIHighPassSkinSmoothingFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 15/01/2018. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIVector.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIHighPassSkinSmoothingFilter : NSObject 14 | 15 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 16 | 17 | @property (nonatomic) float amount; 18 | 19 | @property (nonatomic) float radius; 20 | 21 | @property (nonatomic, copy, null_resettable) NSArray *toneCurveControlPoints; 22 | 23 | + (BOOL)isSupportedOnDevice:(id)device; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIImage+Filters.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImage+Filters.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIImage.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIImage (Filters) 14 | 15 | - (MTIImage *)imageByUnpremultiplyingAlpha; 16 | 17 | - (MTIImage *)imageByPremultiplyingAlpha; 18 | 19 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation NS_SWIFT_NAME(oriented(_:)); 20 | 21 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation outputPixelFormat:(MTLPixelFormat)pixelFormat NS_SWIFT_NAME(oriented(_:outputPixelFormat:)); 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIImage+Filters.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImage+Filters.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #import "MTIImage+Filters.h" 9 | #import "MTIAlphaPremultiplicationFilter.h" 10 | #import "MTIUnaryImageRenderingFilter.h" 11 | 12 | @implementation MTIImage (Filters) 13 | 14 | - (MTIImage *)imageByUnpremultiplyingAlpha { 15 | return [[MTIUnpremultiplyAlphaFilter imageByProcessingImage:[self imageWithCachePolicy:MTIImageCachePolicyTransient]] imageWithCachePolicy:self.cachePolicy]; 16 | } 17 | 18 | - (MTIImage *)imageByPremultiplyingAlpha { 19 | return [[MTIPremultiplyAlphaFilter imageByProcessingImage:[self imageWithCachePolicy:MTIImageCachePolicyTransient]] imageWithCachePolicy:self.cachePolicy]; 20 | } 21 | 22 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation { 23 | return [self imageByApplyingCGOrientation:orientation outputPixelFormat:MTIPixelFormatUnspecified]; 24 | } 25 | 26 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation outputPixelFormat:(MTLPixelFormat)pixelFormat { 27 | if (orientation == kCGImagePropertyOrientationUp) { 28 | return self; 29 | } 30 | MTIImageOrientation imageOrientation; 31 | switch (orientation) { 32 | case kCGImagePropertyOrientationUp: 33 | imageOrientation = MTIImageOrientationUp; 34 | break; 35 | case kCGImagePropertyOrientationDown: 36 | imageOrientation = MTIImageOrientationDown; 37 | break; 38 | case kCGImagePropertyOrientationLeft: 39 | imageOrientation = MTIImageOrientationRight; 40 | break; 41 | case kCGImagePropertyOrientationRight: 42 | imageOrientation = MTIImageOrientationLeft; 43 | break; 44 | case kCGImagePropertyOrientationUpMirrored: 45 | imageOrientation = MTIImageOrientationUpMirrored; 46 | break; 47 | case kCGImagePropertyOrientationDownMirrored: 48 | imageOrientation = MTIImageOrientationDownMirrored; 49 | break; 50 | case kCGImagePropertyOrientationLeftMirrored: 51 | imageOrientation = MTIImageOrientationRightMirrored; 52 | break; 53 | case kCGImagePropertyOrientationRightMirrored: 54 | imageOrientation = MTIImageOrientationLeftMirrored; 55 | break; 56 | default: 57 | imageOrientation = MTIImageOrientationUnknown; 58 | break; 59 | } 60 | return [[MTIUnaryImageRenderingFilter imageByProcessingImage:[self imageWithCachePolicy:MTIImageCachePolicyTransient] orientation:imageOrientation parameters:@{} outputPixelFormat:pixelFormat] imageWithCachePolicy:self.cachePolicy]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSBoxBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSBoxBlurFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import 10 | 11 | @interface MTIMPSBoxBlurFilter : NSObject 12 | 13 | @property (nonatomic) simd_int2 size; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSBoxBlurFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSBoxBlurFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 18/01/2018. 6 | // 7 | 8 | #import "MTIMPSBoxBlurFilter.h" 9 | #import "MTIMPSKernel.h" 10 | #import "MTIImage.h" 11 | #import 12 | 13 | @implementation MTIMPSBoxBlurFilter 14 | @synthesize outputPixelFormat = _outputPixelFormat; 15 | @synthesize inputImage = _inputImage; 16 | 17 | + (MTIMPSKernel *)kernelWithSize:(simd_int2)size { 18 | static NSMutableDictionary *kernels; 19 | static NSLock *kernelsLock; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | kernels = [NSMutableDictionary dictionary]; 23 | kernelsLock = [[NSLock alloc] init]; 24 | }); 25 | 26 | [kernelsLock lock]; 27 | id key = @[@(size.x),@(size.y)]; 28 | MTIMPSKernel *kernel = kernels[key]; 29 | if (!kernel) { 30 | kernel = [[MTIMPSKernel alloc] initWithMPSKernelBuilder:^MPSKernel * _Nonnull(id _Nonnull device) { 31 | MPSImageBox *k = [[MPSImageBox alloc] initWithDevice:device kernelWidth:size.x kernelHeight:size.y]; 32 | k.edgeMode = MPSImageEdgeModeClamp; 33 | return k; 34 | }]; 35 | kernels[key] = kernel; 36 | } 37 | [kernelsLock unlock]; 38 | 39 | return kernel; 40 | } 41 | 42 | - (MTIImage *)outputImage { 43 | if (!self.inputImage) { 44 | return nil; 45 | } 46 | if (self.size.x <= 1 || self.size.y <= 1) { 47 | return self.inputImage; 48 | } 49 | simd_int2 size = self.size; 50 | size.x = size.x + (size.x + 1) % 2; 51 | size.y = size.y + (size.y + 1) % 2; 52 | return [[self.class kernelWithSize:size] applyToInputImages:@[self.inputImage] parameters:@{} outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(self.inputImage.size) outputPixelFormat:_outputPixelFormat]; 53 | } 54 | @end 55 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSConvolutionFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSImageConvolution.h 3 | // Pods 4 | // 5 | // Created by shuyj on 2017/8/14. 6 | // 7 | // 8 | 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIMPSConvolutionFilter : NSObject 14 | 15 | /*! @property bias 16 | * @discussion The bias is a value to be added to convolved pixel before it is converted back to the storage format. 17 | * It can be used to convert negative values into a representable range for a unsigned MTLPixelFormat. 18 | * For example, many edge detection filters produce results in the range [-k,k]. By scaling the filter 19 | * weights by 0.5/k and adding 0.5, the results will be in range [0,1] suitable for use with unorm formats. 20 | * It can be used in combination with renormalization of the filter weights to do video ranging as part 21 | * of the convolution effect. It can also just be used to increase the brightness of the image. 22 | * 23 | * Default value is 0.0f. 24 | */ 25 | @property (nonatomic) float bias; 26 | 27 | - (instancetype)init NS_UNAVAILABLE; 28 | 29 | + (instancetype)new NS_UNAVAILABLE; 30 | 31 | - (instancetype)initWithKernelWidth:(NSUInteger)kernelWidth kernelHeight:(NSUInteger)kernelHeight weights:(const float *)kernelWeights NS_DESIGNATED_INITIALIZER; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSDefinitionFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSDefinitionFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/8/21. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIMPSDefinitionFilter : NSObject 14 | 15 | @property (nonatomic) float intensity; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSDefinitionFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSDefinitionFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/8/21. 6 | // 7 | 8 | #import "MTIMPSDefinitionFilter.h" 9 | #import "MTIMPSGaussianBlurFilter.h" 10 | #import "MTIRenderPipelineKernel.h" 11 | #import "MTIFunctionDescriptor.h" 12 | #import "MTIImage.h" 13 | 14 | @interface MTIMPSDefinitionFilter () 15 | 16 | @property (nonatomic, strong) MTIMPSGaussianBlurFilter *blurFilter; 17 | 18 | @end 19 | 20 | @implementation MTIMPSDefinitionFilter 21 | @synthesize inputImage = _inputImage; 22 | @synthesize outputPixelFormat = _outputPixelFormat; 23 | 24 | + (MTIRenderPipelineKernel *)kernel { 25 | return [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName] 26 | fragmentFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:@"clarity"]]; 27 | } 28 | 29 | - (instancetype)init { 30 | if (self = [super init]) { 31 | _blurFilter = [[MTIMPSGaussianBlurFilter alloc] init]; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)setInputImage:(MTIImage *)inputImage { 37 | _inputImage = inputImage; 38 | _blurFilter.inputImage = inputImage; 39 | } 40 | 41 | - (MTIImage *)outputImage { 42 | if (!self.inputImage) { 43 | return nil; 44 | } 45 | 46 | if (self.intensity <= 0) { 47 | return self.inputImage; 48 | } 49 | 50 | self.blurFilter.radius = self.inputImage.size.width / 1024.0 * 32.0; 51 | MTIImage *blurredImage = self.blurFilter.outputImage; 52 | 53 | return [MTIMPSDefinitionFilter.kernel applyToInputImages:@[self.inputImage, blurredImage] 54 | parameters:@{@"intensity": @(self.intensity)} 55 | outputTextureDimensions:self.inputImage.dimensions 56 | outputPixelFormat:self.outputPixelFormat]; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSGaussianBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSGaussianBlurFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 03/08/2017. 6 | // 7 | // 8 | 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIMPSGaussianBlurFilter : NSObject 14 | 15 | @property (nonatomic) float radius; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSGaussianBlurFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSGaussianBlurFilter.m 3 | // Pods 4 | // 5 | // Created by YuAo on 03/08/2017. 6 | // 7 | // 8 | 9 | #import "MTIMPSGaussianBlurFilter.h" 10 | #import "MTIMPSKernel.h" 11 | #import "MTIImage.h" 12 | 13 | @interface MTIMPSGaussianBlurFilter () 14 | 15 | @end 16 | 17 | @implementation MTIMPSGaussianBlurFilter 18 | @synthesize outputPixelFormat = _outputPixelFormat; 19 | @synthesize inputImage = _inputImage; 20 | 21 | + (MTIMPSKernel *)kernelWithRadius:(NSInteger)radius { 22 | static NSMutableDictionary *kernels; 23 | static NSLock *kernelsLock; 24 | static dispatch_once_t onceToken; 25 | dispatch_once(&onceToken, ^{ 26 | kernels = [NSMutableDictionary dictionary]; 27 | kernelsLock = [[NSLock alloc] init]; 28 | }); 29 | 30 | [kernelsLock lock]; 31 | MTIMPSKernel *kernel = kernels[@(radius)]; 32 | if (!kernel) { 33 | //ceil(sqrt(-log(0.01)*2)*sigma) ~ ceil(3.7*sigma) 34 | float sigma = radius; 35 | kernel = [[MTIMPSKernel alloc] initWithMPSKernelBuilder:^MPSKernel * _Nonnull(id _Nonnull device) { 36 | MPSImageGaussianBlur *k = [[MPSImageGaussianBlur alloc] initWithDevice:device sigma:sigma]; 37 | k.edgeMode = MPSImageEdgeModeClamp; 38 | return k; 39 | }]; 40 | kernels[@(radius)] = kernel; 41 | } 42 | [kernelsLock unlock]; 43 | 44 | return kernel; 45 | } 46 | 47 | - (MTIImage *)outputImage { 48 | if (!self.inputImage) { 49 | return nil; 50 | } 51 | if (ceil(self.radius) <= 0) { 52 | return self.inputImage; 53 | } 54 | return [[self.class kernelWithRadius:ceil(self.radius)] applyToInputImages:@[self.inputImage] parameters:@{} outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(self.inputImage.size) outputPixelFormat:_outputPixelFormat]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSHistogramFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSHistogramFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/6/11. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import "MTIFilter.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | typedef NS_OPTIONS(NSUInteger, MTIHistogramType) { 16 | MTIHistogramTypeLuminance = 1 << 0, 17 | MTIHistogramTypeRGB = 1 << 1 18 | }; 19 | 20 | @interface MTIMPSHistogramFilter : NSObject 21 | 22 | - (void)setOutputPixelFormat:(MTLPixelFormat)outputPixelFormat NS_UNAVAILABLE; 23 | 24 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 25 | 26 | @property (nonatomic) float scaleFactor; //Unimplemented 27 | 28 | @property (nonatomic) MTIHistogramType type; //Unimplemented 29 | 30 | @end 31 | 32 | @interface MTIHistogramDisplayFilter: NSObject 33 | 34 | @property (nonatomic) CGSize outputSize; 35 | 36 | @end 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSSobelFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSSobelFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 11/12/2017. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | 11 | typedef NS_ENUM(NSUInteger, MTIMPSSobelColorMode) { 12 | MTIMPSSobelColorModeAuto, 13 | MTIMPSSobelColorModeGrayscale, 14 | MTIMPSSobelColorModeGrayscaleInverted 15 | }; 16 | 17 | @interface MTIMPSSobelFilter : NSObject 18 | 19 | @property (nonatomic, readonly) simd_float3 grayColorTransform; 20 | 21 | - (instancetype)initWithGrayColorTransform:(simd_float3)grayColorTransform NS_DESIGNATED_INITIALIZER; 22 | 23 | @property (nonatomic) MTIMPSSobelColorMode colorMode; 24 | 25 | @end 26 | 27 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSUnsharpMaskFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUSMSharpenFilter.h 3 | // MetalPetal 4 | // 5 | // Created by yi chen on 2018/2/7. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface MTIMPSUnsharpMaskFilter : NSObject 13 | 14 | @property (nonatomic) float scale; //(0, 1]. Default is 0.5. 15 | @property (nonatomic) float radius; 16 | @property (nonatomic) float threshold; //[0, 1). Default is 0. 17 | 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSUnsharpMaskFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUSMSharpenFilter.m 3 | // MetalPetal 4 | // 5 | // Created by yi chen on 2018/2/7. 6 | // 7 | 8 | #import "MTIMPSUnsharpMaskFilter.h" 9 | #import "MTIMPSGaussianBlurFilter.h" 10 | #import "MTIRenderPipelineKernel.h" 11 | #import "MTIFunctionDescriptor.h" 12 | #import "MTIImage.h" 13 | 14 | @interface MTIMPSUnsharpMaskFilter () 15 | 16 | @property (nonatomic,strong) MTIMPSGaussianBlurFilter *gaussianBlurFilter; 17 | 18 | @end 19 | 20 | @implementation MTIMPSUnsharpMaskFilter 21 | @synthesize outputPixelFormat = _outputPixelFormat; 22 | @synthesize inputImage = _inputImage; 23 | 24 | - (instancetype)init 25 | { 26 | self = [super init]; 27 | if (self) { 28 | _scale = 0.5; 29 | _threshold = 0; 30 | _radius = 2.0; 31 | _gaussianBlurFilter = [[MTIMPSGaussianBlurFilter alloc] init]; 32 | _gaussianBlurFilter.radius = _radius; 33 | } 34 | return self; 35 | } 36 | 37 | + (MTIRenderPipelineKernel *)kernel { 38 | static MTIRenderPipelineKernel *kernel; 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | kernel = [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName] 42 | fragmentFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:@"usmSecondPass"]]; 43 | }); 44 | return kernel; 45 | } 46 | 47 | - (void)setInputImage:(MTIImage *)inputImage { 48 | _inputImage = inputImage; 49 | _gaussianBlurFilter.inputImage = inputImage; 50 | } 51 | 52 | - (void)setRadius:(float)radius { 53 | _radius = radius; 54 | _gaussianBlurFilter.radius = radius; 55 | } 56 | 57 | - (MTIImage *)outputImage { 58 | if (!self.inputImage) { 59 | return nil; 60 | } 61 | 62 | MTIImage *blurImage = self.gaussianBlurFilter.outputImage; 63 | 64 | return [[[self class] kernel] applyToInputImages:@[self.inputImage, blurImage] 65 | parameters:@{@"scale": @(self.scale), @"threshold": @(self.threshold)} 66 | outputTextureDimensions: MTITextureDimensionsMake2DFromCGSize(self.inputImage.size) 67 | outputPixelFormat:_outputPixelFormat]; 68 | 69 | return nil; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMultilayerCompositingFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMultilayerCompositingFilter.h 3 | // Pods 4 | // 5 | // Created by YuAo on 27/09/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTILayer.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIMultilayerCompositingFilter : NSObject 14 | 15 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 16 | 17 | @property (nonatomic, copy) NSArray *layers; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMultilayerCompositingFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMultilayerCompositingFilter.m 3 | // Pods 4 | // 5 | // Created by YuAo on 27/09/2017. 6 | // 7 | 8 | #import "MTIMultilayerCompositingFilter.h" 9 | #import "MTIMultilayerCompositeKernel.h" 10 | #import "MTIImage.h" 11 | 12 | @implementation MTIMultilayerCompositingFilter 13 | 14 | @synthesize outputPixelFormat = _outputPixelFormat; 15 | 16 | + (MTIMultilayerCompositeKernel *)kernel { 17 | static MTIMultilayerCompositeKernel *kernel; 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | kernel = [[MTIMultilayerCompositeKernel alloc] init]; 21 | }); 22 | return kernel; 23 | } 24 | 25 | - (MTIImage *)outputImage { 26 | if (!_inputBackgroundImage) { 27 | return nil; 28 | } 29 | if (_layers.count == 0) { 30 | return _inputBackgroundImage; 31 | } 32 | return [self.class.kernel applyToBackgroundImage:_inputBackgroundImage 33 | layers:_layers 34 | outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(_inputBackgroundImage.size) 35 | outputPixelFormat:_outputPixelFormat]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIPixellateFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixellateFilter.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 08/01/2018. 6 | // 7 | 8 | #import "MTIUnaryImageRenderingFilter.h" 9 | 10 | @interface MTIPixellateFilter : MTIUnaryImageRenderingFilter 11 | 12 | @property (nonatomic) CGSize scale; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIPixellateFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixellateFilter.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 08/01/2018. 6 | // 7 | 8 | #import "MTIPixellateFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | #import "MTIVector.h" 11 | 12 | @implementation MTIPixellateFilter 13 | 14 | - (instancetype)init { 15 | if (self = [super init]) { 16 | _scale = CGSizeMake(16.0, 16.0); 17 | } 18 | return self; 19 | } 20 | 21 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 22 | return [[MTIFunctionDescriptor alloc] initWithName:@"pixellate"]; 23 | } 24 | 25 | - (NSDictionary *)parameters { 26 | return @{@"scale": [MTIVector vectorWithCGSize:CGSizeMake(MAX(self.scale.width,1), MAX(self.scale.height,1))]}; 27 | } 28 | 29 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 30 | return MTIAlphaTypeHandlingRule.passthroughAlphaTypeHandlingRule; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBColorSpaceConversionFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRGBColorSpaceConversionFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/11. 6 | // 7 | 8 | #import "MTIUnaryImageRenderingFilter.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface MTILinearToSRGBToneCurveFilter : MTIUnaryImageRenderingFilter 13 | 14 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 15 | 16 | @end 17 | 18 | @interface MTISRGBToneCurveToLinearFilter: MTIUnaryImageRenderingFilter 19 | 20 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 21 | 22 | @end 23 | 24 | @interface MTIITUR709RGBToLinearRGBFilter: MTIUnaryImageRenderingFilter 25 | 26 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 27 | 28 | @end 29 | 30 | @interface MTIITUR709RGBToSRGBFilter: MTIUnaryImageRenderingFilter 31 | 32 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBColorSpaceConversionFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRGBColorSpaceConversionFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/11. 6 | // 7 | 8 | #import "MTIRGBColorSpaceConversionFilter.h" 9 | #import "MTIFunctionDescriptor.h" 10 | 11 | @implementation MTILinearToSRGBToneCurveFilter 12 | 13 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 14 | return [[MTIFunctionDescriptor alloc] initWithName:@"convertLinearRGBToSRGB"]; 15 | } 16 | 17 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image { 18 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified]; 19 | } 20 | 21 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 22 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 23 | } 24 | 25 | @end 26 | 27 | @implementation MTISRGBToneCurveToLinearFilter 28 | 29 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 30 | return [[MTIFunctionDescriptor alloc] initWithName:@"convertSRGBToLinearRGB"]; 31 | } 32 | 33 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image { 34 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified]; 35 | } 36 | 37 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 38 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 39 | } 40 | 41 | @end 42 | 43 | @implementation MTIITUR709RGBToLinearRGBFilter 44 | 45 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 46 | return [[MTIFunctionDescriptor alloc] initWithName:@"convertITUR709RGBToLinearRGB"]; 47 | } 48 | 49 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image { 50 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified]; 51 | } 52 | 53 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 54 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 55 | } 56 | 57 | @end 58 | 59 | @implementation MTIITUR709RGBToSRGBFilter 60 | 61 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 62 | return [[MTIFunctionDescriptor alloc] initWithName:@"convertITUR709RGBToSRGB"]; 63 | } 64 | 65 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image { 66 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified]; 67 | } 68 | 69 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 70 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBToneCurveFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRGBToneCurveFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 12/01/2018. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIVector.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIRGBToneCurveFilter : NSObject 14 | 15 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 16 | 17 | @property (nonatomic, copy) NSArray *redControlPoints; 18 | @property (nonatomic, copy) NSArray *greenControlPoints; 19 | @property (nonatomic, copy) NSArray *blueControlPoints; 20 | @property (nonatomic, copy) NSArray *RGBCompositeControlPoints; 21 | 22 | @property (nonatomic) float intensity; //default 1.0 23 | 24 | @property (nonatomic, strong, readonly) MTIImage *toneCurveColorLookupImage; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRoundCornerFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRoundCornerFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/12/20. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIRoundCornerFilter : NSObject 14 | 15 | @property (nonatomic) simd_float4 radius; //lt rt rb lb 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTITransformFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITransformFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 28/10/2017. 6 | // 7 | 8 | #import 9 | #import "MTIFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /* 14 | ^ y+ 15 | | 16 | | 17 | +--+--+--+--+ 18 | |/////|/////| 19 | ----|-----|-----|---> x+ 20 | |/////|/////| 21 | +--+--+--+--+ 22 | | 23 | | 24 | */ 25 | 26 | typedef CGRect MTITransformFilterViewport NS_SWIFT_NAME(MTITransformFilter.Viewport); 27 | 28 | @interface MTITransformFilter : NSObject 29 | 30 | @property (nonatomic) CATransform3D transform; 31 | 32 | /*! 33 | @property fov 34 | @abstract Determines the receiver's field of view on the X And Y axis (in radian). 35 | @discussion When fov is zero the orthographic matrix will be applied . Otherwise, use the perspective matrix. Value in [0, M_PI) is valid. Defaults to 0. 36 | */ 37 | @property (nonatomic) float fieldOfView; 38 | 39 | @property (nonatomic) MTITransformFilterViewport viewport; 40 | 41 | @property (nonatomic, readonly) MTITransformFilterViewport minimumEnclosingViewport; 42 | 43 | @property (nonatomic, readonly) MTITransformFilterViewport defaultViewport; 44 | 45 | @end 46 | 47 | NS_ASSUME_NONNULL_END 48 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIUnaryImageRenderingFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUnaryImageFilter.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 10/10/2017. 6 | // 7 | 8 | #import "MTIFilter.h" 9 | #import "MTIImageOrientation.h" 10 | #import "MTIAlphaType.h" 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @class MTIRenderPipelineKernel, MTIFunctionDescriptor; 16 | 17 | @interface MTIUnaryImageRenderingFilter : NSObject 18 | 19 | + (MTIRenderPipelineKernel *)kernel; 20 | 21 | @property (nonatomic) MTIImageOrientation orientation; //Rotate the canvas to that orientation. 22 | 23 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image withInputParameters:(NSDictionary *)parameters outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 24 | 25 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image orientation:(MTIImageOrientation)orientation parameters:(NSDictionary *)parameters outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 26 | 27 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image orientation:(MTIImageOrientation)orientation parameters:(NSDictionary *)parameters outputPixelFormat:(MTLPixelFormat)outputPixelFormat outputImageSize:(CGSize)outputImageSize; 28 | 29 | @end 30 | 31 | @interface MTIUnaryImageRenderingFilter (SubclassingHooks) 32 | 33 | @property (nonatomic,copy,readonly) NSDictionary *parameters; 34 | 35 | - (CGSize)outputImageSizeForInputImage:(MTIImage *)inputImage; 36 | 37 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor; 38 | 39 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIVibranceFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVibranceFilter.h 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/11/6. 6 | // 7 | 8 | #import 9 | #import "MTIUnaryImageRenderingFilter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIVibranceFilter : MTIUnaryImageRenderingFilter 14 | 15 | @property (nonatomic) float amount; 16 | 17 | @property (nonatomic) BOOL avoidsSaturatingSkinTones; 18 | 19 | @property (nonatomic) simd_float3 grayColorTransform; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIVibranceFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVibranceFilter.m 3 | // MetalPetal 4 | // 5 | // Created by 杨乃川 on 2017/11/6. 6 | // 7 | 8 | #import "MTIVibranceFilter.h" 9 | #import "MTIVector+SIMD.h" 10 | #import "MTIFunctionDescriptor.h" 11 | #import "MTIColor.h" 12 | 13 | @implementation MTIVibranceFilter 14 | 15 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 16 | return [[MTIFunctionDescriptor alloc] initWithName:@"vibranceAdjust"]; 17 | } 18 | 19 | - (instancetype)init { 20 | if (self = [super init]) { 21 | _grayColorTransform = MTIGrayColorTransformDefault; 22 | } 23 | return self; 24 | } 25 | 26 | - (NSDictionary *)parameters { 27 | simd_float4 vector = (simd_float4){ 28 | 3 * _amount, 29 | -9.0/2.0 * _amount * _amount - 3.0/2.0 * _amount, 30 | 9.0/2.0 * _amount * _amount * _amount - _amount/2.0, 31 | -9.0/2.0 * _amount * _amount * _amount + 9.0/2.0 * _amount * _amount - _amount 32 | }; 33 | return @{ 34 | @"amount": @(_amount), 35 | @"vibranceVector": [MTIVector vectorWithFloat4:vector], 36 | @"avoidsSaturatingSkinTones": @(_avoidsSaturatingSkinTones), 37 | @"grayColorTransform": [MTIVector vectorWithFloat3:_grayColorTransform] 38 | }; 39 | } 40 | 41 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 42 | return MTIAlphaTypeHandlingRule.generalAlphaTypeHandlingRule; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIComputePipelineKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIComputePipelineKernel.h 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/27. 6 | // 7 | // 8 | #import 9 | #import "MTIKernel.h" 10 | #import "MTITextureDimensions.h" 11 | #import "MTIPixelFormat.h" 12 | #import "MTIAlphaType.h" 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @class MTIComputePipeline, MTIFunctionDescriptor, MTIImage; 17 | 18 | @interface MTIComputeFunctionDispatchOptions : NSObject 19 | 20 | + (instancetype)new NS_UNAVAILABLE; 21 | 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | - (instancetype)initWithThreads:(MTLSize)threads threadgroups:(MTLSize)threadgroups threadsPerThreadgroup:(MTLSize)threadsPerThreadgroup; 25 | 26 | - (instancetype)initWithGenerator:(void (^)(id pipelineState, MTLSize *threads, MTLSize *threadgroups, MTLSize *threadsPerThreadgroup))block NS_REFINED_FOR_SWIFT; 27 | 28 | @end 29 | 30 | @interface MTIComputePipelineKernel : NSObject 31 | 32 | - (instancetype)init NS_UNAVAILABLE; 33 | 34 | + (instancetype)new NS_UNAVAILABLE; 35 | 36 | @property (nonatomic,copy,readonly) MTIAlphaTypeHandlingRule *alphaTypeHandlingRule; 37 | 38 | @property (nonatomic, copy, readonly) MTIFunctionDescriptor *computeFunctionDescriptor; 39 | 40 | - (instancetype)initWithComputeFunctionDescriptor:(MTIFunctionDescriptor *)computeFunctionDescriptor; 41 | 42 | - (instancetype)initWithComputeFunctionDescriptor:(MTIFunctionDescriptor *)computeFunctionDescriptor alphaTypeHandlingRule:(MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule NS_DESIGNATED_INITIALIZER; 43 | 44 | - (MTIImage *)applyToInputImages:(NSArray *)images 45 | parameters:(NSDictionary *)parameters 46 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 47 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 48 | 49 | - (MTIImage *)applyToInputImages:(NSArray *)images 50 | parameters:(NSDictionary *)parameters 51 | dispatchOptions:(nullable MTIComputeFunctionDispatchOptions *)dispatchOptions 52 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 53 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 54 | 55 | @end 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIKernel.h 3 | // Pods 4 | // 5 | // Created by YuAo on 02/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @class MTIContext; 15 | 16 | @protocol MTIKernelConfiguration 17 | 18 | @property (nonatomic, copy, readonly) id identifier; 19 | 20 | @end 21 | 22 | /// A kernel must be stateless. 23 | 24 | @protocol MTIKernel 25 | 26 | - (nullable id)newKernelStateWithContext:(MTIContext *)context configuration:(nullable id)configuration error:(NSError **)error NS_SWIFT_NAME(makeKernelState(context:configuration:)); 27 | 28 | @end 29 | 30 | @interface MTIArgumentsEncoder : NSObject 31 | 32 | + (BOOL)encodeArguments:(NSArray*)arguments 33 | values:(NSDictionary *)parameters 34 | functionType:(MTLFunctionType)functionType 35 | encoder:(id)encoder 36 | error:(NSError **)error; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIMPSKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSKernel.h 3 | // Pods 4 | // 5 | // Created by YuAo on 03/08/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MTIKernel.h" 12 | #import "MTITextureDimensions.h" 13 | #import "MTIPixelFormat.h" 14 | #import "MTIAlphaType.h" 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @class MTIContext, MTIImage; 19 | 20 | typedef MPSKernel * _Nonnull (^MTIMPSKernelBuilder)(id device); 21 | 22 | @interface MTIMPSKernel : NSObject 23 | 24 | - (instancetype)init NS_UNAVAILABLE; 25 | 26 | + (instancetype)new NS_UNAVAILABLE; 27 | 28 | @property (nonatomic,copy,readonly) MTIAlphaTypeHandlingRule *alphaTypeHandlingRule; 29 | 30 | - (instancetype)initWithMPSKernelBuilder:(MTIMPSKernelBuilder)builder NS_SWIFT_NAME(init(builder:)); 31 | 32 | - (instancetype)initWithMPSKernelBuilder:(MTIMPSKernelBuilder)builder alphaTypeHandlingRule:(MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(builder:alphaTypeHandlingRule:)); 33 | 34 | - (MTIImage *)applyToInputImages:(NSArray *)images 35 | parameters:(NSDictionary *)parameters 36 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 37 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 38 | 39 | @end 40 | 41 | NS_ASSUME_NONNULL_END 42 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIMultilayerCompositeKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMultilayerRenderPipelineKernel.h 3 | // MetalPetal 4 | // 5 | // Created by YuAo on 27/09/2017. 6 | // 7 | 8 | #import 9 | #import 10 | #import "MTIKernel.h" 11 | #import "MTIBlendModes.h" 12 | #import "MTITextureDimensions.h" 13 | #import "MTIPixelFormat.h" 14 | #import "MTIImagePromise.h" 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @class MTIRenderPipeline, MTIFunctionDescriptor, MTIContext, MTIImage, MTILayer; 19 | 20 | @interface MTIMultilayerCompositeKernel : NSObject 21 | 22 | - (MTIImage *)applyToBackgroundImage:(MTIImage *)image 23 | layers:(NSArray *)layers 24 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 25 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 26 | 27 | @end 28 | 29 | @class MTIRenderGraphNode; 30 | 31 | FOUNDATION_EXPORT void MTIMultilayerCompositingRenderGraphNodeOptimize(MTIRenderGraphNode *node); 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIRenderCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderCommand.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 26/11/2017. 6 | // 7 | 8 | #import 9 | #import "MTIVertex.h" 10 | 11 | @class MTIRenderPipelineKernel, MTIImage, MTIRenderPassOutputDescriptor; 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface MTIRenderCommand : NSObject 16 | 17 | @property (nonatomic, strong, readonly) MTIRenderPipelineKernel *kernel; 18 | 19 | @property (nonatomic, copy, readonly) id geometry; 20 | 21 | @property (nonatomic, copy, readonly) NSArray *images; 22 | 23 | @property (nonatomic, copy, readonly) NSDictionary *parameters; 24 | 25 | - (instancetype)init NS_UNAVAILABLE; 26 | 27 | + (instancetype)new NS_UNAVAILABLE; 28 | 29 | - (instancetype)initWithKernel:(MTIRenderPipelineKernel *)kernel 30 | geometry:(id)geometry 31 | images:(NSArray *)images 32 | parameters:(NSDictionary *)parameters NS_DESIGNATED_INITIALIZER; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIRenderCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderCommand.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 26/11/2017. 6 | // 7 | 8 | #import "MTIRenderCommand.h" 9 | #import "MTIRenderPipelineKernel.h" 10 | #import "MTIImage.h" 11 | 12 | @implementation MTIRenderCommand 13 | 14 | - (instancetype)initWithKernel:(MTIRenderPipelineKernel *)kernel geometry:(id)geometry images:(NSArray *)images parameters:(NSDictionary *)parameters { 15 | if (self = [super init]) { 16 | NSParameterAssert(kernel); 17 | NSParameterAssert(images); 18 | NSParameterAssert(parameters); 19 | NSParameterAssert(geometry); 20 | NSParameterAssert({ 21 | /* Alpha Type Assert */ 22 | BOOL canAcceptAlphaType = YES; 23 | for (MTIImage *image in images) { 24 | if (![kernel.alphaTypeHandlingRule canAcceptAlphaType:image.alphaType]) { 25 | canAcceptAlphaType = NO; 26 | break; 27 | } 28 | } 29 | canAcceptAlphaType; 30 | }); 31 | _kernel = kernel; 32 | _geometry = [geometry copyWithZone:nil]; 33 | _images = [images copy]; 34 | _parameters = [parameters copy]; 35 | } 36 | return self; 37 | } 38 | 39 | - (id)copyWithZone:(NSZone *)zone { 40 | return self; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIAlphaType.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIAlphaType.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 23/10/2017. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /// Describe different ways to represent the opacity of a color value. See also: https://microsoft.github.io/Win2D/html/PremultipliedAlpha.htm 13 | typedef NS_CLOSED_ENUM(NSInteger, MTIAlphaType) { 14 | /// MTIAlphaTypeUnknown The alpha type is unknown. 15 | MTIAlphaTypeUnknown = 0, 16 | 17 | /// RGB values specify the color of the thing being drawn. The alpha value specifies how solid it is. 18 | MTIAlphaTypeNonPremultiplied = 1, 19 | 20 | /// RGB specifies how much color the thing being drawn contributes to the output. The alpha value specifies how much it obscures whatever is behind it. 21 | MTIAlphaTypePremultiplied = 2, 22 | 23 | /// There is no alpha channel or the alpha value is one. 24 | MTIAlphaTypeAlphaIsOne = 3 25 | }; 26 | 27 | FOUNDATION_EXPORT NSString * MTIAlphaTypeGetDescription(MTIAlphaType alphaType); 28 | 29 | @class MTIImage; 30 | 31 | typedef MTIAlphaType (^MTIAlphaTypeHandlingOutputAlphaTypeRule)(NSArray *inputAlphaTypes); 32 | 33 | /// Describes how a image processing unit handles alpha type. 34 | @interface MTIAlphaTypeHandlingRule: NSObject 35 | 36 | /// Acceptable alpha types. 37 | @property (nonatomic, copy, readonly) NSArray *acceptableAlphaTypes NS_REFINED_FOR_SWIFT; 38 | 39 | - (instancetype)init NS_UNAVAILABLE; 40 | 41 | + (instancetype)new NS_UNAVAILABLE; 42 | 43 | - (BOOL)canAcceptAlphaType:(MTIAlphaType)alphaType; 44 | 45 | - (MTIAlphaType)outputAlphaTypeForInputAlphaTypes:(NSArray *)inputAlphaTypes NS_REFINED_FOR_SWIFT; 46 | 47 | - (MTIAlphaType)outputAlphaTypeForInputImages:(NSArray *)inputImages; 48 | 49 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaTypeHandler:(MTIAlphaTypeHandlingOutputAlphaTypeRule)outputAlphaTypeHandler NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT; 50 | 51 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaType:(MTIAlphaType)outputAlphaType NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT; 52 | 53 | /// Accepts MTIAlphaTypeNonPremultiplied, MTIAlphaTypeAlphaIsOne. Outputs MTIAlphaTypeNonPremultiplied. 54 | @property (nonatomic, copy, class, readonly) MTIAlphaTypeHandlingRule *generalAlphaTypeHandlingRule; 55 | 56 | /// Accepts all alpha types. The output alpha type is the same as input alpha type. 57 | @property (nonatomic, copy, class, readonly) MTIAlphaTypeHandlingRule *passthroughAlphaTypeHandlingRule; 58 | 59 | 60 | @end 61 | 62 | NS_ASSUME_NONNULL_END 63 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBuffer.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/1/22. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /// A GPU mutable data buffer. You can pass a `MTIDataBuffer` instance to multiple processing units, they can all read and write the buffer's content. However, accessing a `MTIDataBuffer`'s contents using CPU is not safe. You must ensure all the GPU reads/writes to this buffer is completed. e.g. call a render task's waitUntilCompleted. For one `MTIDataBuffer` instance, one and only one underlaying `MTLBuffer` will be created for one GPU device. 13 | @interface MTIDataBuffer : NSObject 14 | 15 | + (instancetype)new NS_UNAVAILABLE; 16 | 17 | - (instancetype)init NS_UNAVAILABLE; 18 | 19 | - (nullable instancetype)initWithBytes:(const void *)bytes 20 | length:(NSUInteger)length 21 | options:(MTLResourceOptions)options; 22 | 23 | - (nullable instancetype)initWithData:(NSData *)data options:(MTLResourceOptions)options; 24 | 25 | - (nullable instancetype)initWithLength:(NSUInteger)length options:(MTLResourceOptions)options NS_DESIGNATED_INITIALIZER; 26 | 27 | @property (nonatomic, readonly) NSUInteger length; 28 | 29 | @property (nonatomic, readonly) MTLResourceOptions options; 30 | 31 | - (nullable id)bufferForDevice:(id)device NS_SWIFT_NAME(buffer(for:)); 32 | 33 | /// Accessing contents from CPU is unsafe. 34 | - (void)unsafeAccess:(void (NS_NOESCAPE ^)(void *contents, NSUInteger length))block; 35 | 36 | @end 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalIOSurfaceBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalIOSurfaceBridge.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/10/10. 6 | // 7 | 8 | #import 9 | #import "MTICVMetalTextureBridging.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT NSString * const MTICVMetalIOSurfaceBridgeErrorDomain; 14 | 15 | typedef NS_ERROR_ENUM(MTICVMetalIOSurfaceBridgeErrorDomain, MTICVMetalIOSurfaceBridgeError) { 16 | MTICVMetalIOSurfaceBridgeErrorImageBufferIsNotBackedByIOSurface = 10001, 17 | MTICVMetalIOSurfaceBridgeErrorFailedToCreateTexture = 10002, 18 | MTICVMetalIOSurfaceBridgeErrorCoreVideoDoesNotSupportIOSurface = 10003 19 | }; 20 | 21 | NS_CLASS_AVAILABLE(10_11, 11_0) 22 | @interface MTICVMetalIOSurfaceBridge : NSObject 23 | 24 | - (instancetype)initWithDevice:(id)device; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalIOSurfaceBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalIOSurfaceBridge.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/10/10. 6 | // 7 | 8 | #import "MTICVMetalIOSurfaceBridge.h" 9 | 10 | NSString * const MTICVMetalIOSurfaceBridgeErrorDomain = @"MTICVMetalIOSurfaceBridgeErrorDomain"; 11 | 12 | @interface MTICVMetalIOSurfaceBridgeTexture : NSObject 13 | 14 | @end 15 | 16 | @implementation MTICVMetalIOSurfaceBridgeTexture 17 | @synthesize texture = _texture; 18 | 19 | - (instancetype)initWithTexture:(id)texture { 20 | if (self = [super init]) { 21 | _texture = texture; 22 | } 23 | return self; 24 | } 25 | 26 | @end 27 | 28 | @interface MTICVMetalIOSurfaceBridge () 29 | 30 | @property (nonatomic, readonly, strong) id device; 31 | 32 | @end 33 | 34 | @implementation MTICVMetalIOSurfaceBridge 35 | 36 | + (instancetype)newCoreVideoMetalTextureBridgeWithDevice:(id)device error:(NSError * __autoreleasing *)error { 37 | return [[self alloc] initWithDevice:device]; 38 | } 39 | 40 | - (instancetype)initWithDevice:(id)device { 41 | if (self = [super init]) { 42 | NSParameterAssert(device); 43 | _device = device; 44 | } 45 | return self; 46 | } 47 | 48 | - (id)newTextureWithCVImageBuffer:(CVImageBufferRef)imageBuffer textureDescriptor:(MTLTextureDescriptor *)textureDescriptor planeIndex:(size_t)planeIndex error:(NSError * __autoreleasing *)error { 49 | NSParameterAssert(imageBuffer); 50 | #if COREVIDEO_SUPPORTS_IOSURFACE 51 | IOSurfaceRef ioSurface = CVPixelBufferGetIOSurface(imageBuffer); 52 | if (ioSurface) { 53 | id texture = [self.device newTextureWithDescriptor:textureDescriptor iosurface:ioSurface plane:planeIndex]; 54 | if (texture) { 55 | return [[MTICVMetalIOSurfaceBridgeTexture alloc] initWithTexture:texture]; 56 | } else { 57 | if (error) { 58 | *error = [NSError errorWithDomain:MTICVMetalIOSurfaceBridgeErrorDomain code:MTICVMetalIOSurfaceBridgeErrorFailedToCreateTexture userInfo:@{}]; 59 | } 60 | return nil; 61 | } 62 | } else { 63 | if (error) { 64 | *error = [NSError errorWithDomain:MTICVMetalIOSurfaceBridgeErrorDomain code:MTICVMetalIOSurfaceBridgeErrorImageBufferIsNotBackedByIOSurface userInfo:@{}]; 65 | } 66 | return nil; 67 | } 68 | #else 69 | if (error) { 70 | *error = [NSError errorWithDomain:MTICVMetalIOSurfaceBridgeErrorDomain code:MTICVMetalIOSurfaceBridgeErrorCoreVideoDoesNotSupportIOSurface userInfo:@{}]; 71 | } 72 | return nil; 73 | #endif 74 | } 75 | 76 | - (void)flushCache { 77 | 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalTextureBridging.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalTextureBridging.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 2018/10/10. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol MTICVMetalTexture 14 | 15 | @property (nonatomic, readonly) id texture; 16 | 17 | @end 18 | 19 | @protocol MTICVMetalTextureBridging 20 | 21 | + (nullable instancetype)newCoreVideoMetalTextureBridgeWithDevice:(id)device error:(NSError **)error NS_SWIFT_NAME(makeCoreVideoMetalTextureBridge(with:)); 22 | 23 | - (nullable id)newTextureWithCVImageBuffer:(CVImageBufferRef)imageBuffer 24 | textureDescriptor:(MTLTextureDescriptor *)textureDescriptor 25 | planeIndex:(size_t)planeIndex 26 | error:(NSError **)error NS_SWIFT_NAME(makeTexture(with:textureDescriptor:planeIndex:)); 27 | 28 | - (void)flushCache; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalTextureCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalTextureCache.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 07/01/2018. 6 | // 7 | 8 | #import 9 | #import "MTICVMetalTextureBridging.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT NSString * const MTICVMetalTextureCacheErrorDomain; 14 | 15 | typedef NS_ERROR_ENUM(MTICVMetalTextureCacheErrorDomain, MTICVMetalTextureCacheError) { 16 | MTICVMetalTextureCacheErrorMetalIsNotSupported = 10001, 17 | MTICVMetalTextureCacheErrorFailedToInitialize = 10002, 18 | MTICVMetalTextureCacheErrorFailedToCreateTexture = 10003 19 | }; 20 | 21 | /// Thread-safe object-orientated CVMetalTextureCache. 22 | 23 | @interface MTICVMetalTextureCache : NSObject 24 | 25 | - (nullable instancetype)initWithDevice:(id)device 26 | cacheAttributes:(nullable NSDictionary *)cacheAttributes 27 | textureAttributes:(nullable NSDictionary *)textureAttributes 28 | error:(NSError **)error; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferPool.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVPixelBufferPool.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/12/7. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT NSString * const MTICVPixelBufferPoolErrorDomain; 14 | 15 | typedef NS_ERROR_ENUM(MTICVPixelBufferPoolErrorDomain, MTICVPixelBufferPoolError) { 16 | MTICVPixelBufferPoolErrorNone = kCVReturnSuccess, 17 | MTICVPixelBufferPoolErrorWouldExceedAllocationThreshold = kCVReturnWouldExceedAllocationThreshold, 18 | MTICVPixelBufferPoolErrorPoolAllocationFailed = kCVReturnPoolAllocationFailed, 19 | MTICVPixelBufferPoolErrorInvalidPoolAttributes = kCVReturnInvalidPoolAttributes, 20 | MTICVPixelBufferPoolErrorRetry = kCVReturnRetry 21 | }; 22 | 23 | @interface MTICVPixelBufferPool : NSObject 24 | 25 | @property (nonatomic, readonly) size_t pixelBufferWidth; 26 | @property (nonatomic, readonly) size_t pixelBufferHeight; 27 | 28 | @property (nonatomic, readonly) NSUInteger minimumBufferCount; 29 | 30 | @property (nonatomic, readonly) OSType pixelFormatType; 31 | 32 | @property (nonatomic, copy, readonly) NSString *pixelFormatDescription; 33 | 34 | @property (nonatomic, copy, readonly) NSDictionary *poolAttributes; 35 | @property (nonatomic, copy, readonly) NSDictionary *pixelBufferAttributes; 36 | 37 | @property (nonatomic, readonly) CVPixelBufferPoolRef internalPool NS_RETURNS_INNER_POINTER; 38 | 39 | - (instancetype)init NS_UNAVAILABLE; 40 | 41 | - (nullable instancetype)initWithPixelBufferWidth:(size_t)width pixelBufferHeight:(size_t)height pixelFormatType:(OSType)pixelFormatType minimumBufferCount:(NSUInteger)minimumBufferCount error:(NSError **)error; 42 | 43 | - (nullable instancetype)initWithPoolAttributes:(NSDictionary *)poolAttributes pixelBufferAttributes:(NSDictionary *)pixelBufferAttributes error:(NSError **)error; 44 | 45 | - (instancetype)initWithCVPixelBufferPool:(CVPixelBufferPoolRef)pixelBufferPool NS_DESIGNATED_INITIALIZER; 46 | 47 | - (nullable CVPixelBufferRef)newPixelBufferWithAllocationThreshold:(NSUInteger)allocationThreshold error:(NSError **)error CF_RETURNS_RETAINED NS_SWIFT_NAME(makePixelBuffer(allocationThreshold:)); 48 | 49 | - (void)flush:(CVPixelBufferPoolFlushFlags)flags; 50 | 51 | @end 52 | 53 | NS_ASSUME_NONNULL_END 54 | 55 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferPromise.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVPixelBufferPromise.h 3 | // Pods 4 | // 5 | // Created by YuAo on 21/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import "MTIImagePromise.h" 11 | #import "MTICVPixelBufferRendering.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface MTICVPixelBufferPromise : NSObject 16 | 17 | @property (nonatomic, readonly) MTICVPixelBufferRenderingAPI renderingAPI; 18 | 19 | @property (nonatomic, readonly) BOOL sRGB; 20 | 21 | - (instancetype)init NS_UNAVAILABLE; 22 | 23 | + (instancetype)new NS_UNAVAILABLE; 24 | 25 | - (instancetype)initWithCVPixelBuffer:(CVPixelBufferRef)pixelBuffer options:(MTICVPixelBufferRenderingOptions *)options alphaType:(MTIAlphaType)alphaType; 26 | 27 | @end 28 | 29 | @interface MTICVPixelBufferDirectBridgePromise : NSObject 30 | 31 | - (instancetype)init NS_UNAVAILABLE; 32 | 33 | + (instancetype)new NS_UNAVAILABLE; 34 | 35 | - (instancetype)initWithCVPixelBuffer:(CVPixelBufferRef)pixelBuffer planeIndex:(NSUInteger)planeIndex textureDescriptor:(MTLTextureDescriptor *)textureDescriptor alphaType:(MTIAlphaType)alphaType NS_DESIGNATED_INITIALIZER; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferRendering.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVPixelBufferRendering.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 08/04/2018. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | typedef NS_ENUM(NSInteger, MTICVPixelBufferRenderingAPI) { 13 | MTICVPixelBufferRenderingAPIDefault = 1, 14 | MTICVPixelBufferRenderingAPIMetalPetal = 1, 15 | MTICVPixelBufferRenderingAPICoreImage = 2 16 | }; 17 | 18 | @interface MTICVPixelBufferRenderingOptions: NSObject 19 | 20 | @property (nonatomic, readonly) MTICVPixelBufferRenderingAPI renderingAPI; 21 | 22 | @property (nonatomic, readonly) BOOL sRGB; //An option for treating the pixel buffer data as sRGB image data. Specifying whether to create the texture with an sRGB (gamma corrected) pixel format. 23 | 24 | + (instancetype)new NS_UNAVAILABLE; 25 | 26 | - (instancetype)init NS_UNAVAILABLE; 27 | 28 | - (instancetype)initWithRenderingAPI:(MTICVPixelBufferRenderingAPI)renderingAPI sRGB:(BOOL)sRGB NS_DESIGNATED_INITIALIZER; 29 | 30 | @property (nonatomic, strong, class, readonly) MTICVPixelBufferRenderingOptions *defaultOptions; 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferRendering.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVPixelBufferRendering.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 08/04/2018. 6 | // 7 | 8 | #import "MTICVPixelBufferRendering.h" 9 | 10 | @implementation MTICVPixelBufferRenderingOptions 11 | 12 | - (instancetype)initWithRenderingAPI:(MTICVPixelBufferRenderingAPI)renderingAPI sRGB:(BOOL)sRGB { 13 | if (self = [super init]) { 14 | _renderingAPI = renderingAPI; 15 | _sRGB = sRGB; 16 | } 17 | return self; 18 | } 19 | 20 | - (id)copyWithZone:(NSZone *)zone { 21 | return self; 22 | } 23 | 24 | + (MTICVPixelBufferRenderingOptions *)defaultOptions { 25 | static MTICVPixelBufferRenderingOptions *options; 26 | static dispatch_once_t onceToken; 27 | dispatch_once(&onceToken, ^{ 28 | options = [[MTICVPixelBufferRenderingOptions alloc] initWithRenderingAPI:MTICVPixelBufferRenderingAPIDefault sRGB:NO]; 29 | }); 30 | return options; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColor.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 10/10/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, MTIColorComponent) { 12 | MTIColorComponentRed, 13 | MTIColorComponentGreen, 14 | MTIColorComponentBlue, 15 | MTIColorComponentAlpha 16 | }; 17 | 18 | struct MTIColor { 19 | float red; 20 | float green; 21 | float blue; 22 | float alpha; 23 | }; 24 | typedef struct MTIColor MTIColor; 25 | 26 | FOUNDATION_EXPORT MTIColor MTIColorMake(float red, float green, float blue, float alpha) NS_SWIFT_UNAVAILABLE("Use MTIColor.init instead."); 27 | 28 | FOUNDATION_EXPORT simd_float4 MTIColorToFloat4(MTIColor color) NS_SWIFT_NAME(MTIColor.toFloat4(self:)); 29 | 30 | FOUNDATION_EXPORT MTIColor const MTIColorWhite NS_SWIFT_NAME(MTIColor.white); 31 | FOUNDATION_EXPORT MTIColor const MTIColorBlack NS_SWIFT_NAME(MTIColor.black); 32 | FOUNDATION_EXPORT MTIColor const MTIColorClear NS_SWIFT_NAME(MTIColor.clear); 33 | 34 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransformDefault; //MTIGrayColorTransform_ITU_R_601 35 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransform_ITU_R_601; //0.299, 0.587, 0.114 36 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransform_ITU_R_709; //0.2126, 0.7152, 0.0722 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColor.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 10/10/2017. 6 | // 7 | 8 | #import "MTIColor.h" 9 | 10 | MTIColor MTIColorMake(float red, float green, float blue, float alpha) { 11 | return (MTIColor){red,green,blue,alpha}; 12 | } 13 | 14 | simd_float4 MTIColorToFloat4(MTIColor color) { 15 | return simd_make_float4(color.red, color.green, color.blue, color.alpha); 16 | } 17 | 18 | MTIColor const MTIColorWhite = (MTIColor){.red = 1, .green = 1, .blue = 1, .alpha = 1}; 19 | MTIColor const MTIColorBlack = (MTIColor){.red = 0, .green = 0, .blue = 0, .alpha = 1}; 20 | MTIColor const MTIColorClear = (MTIColor){.red = 0, .green = 0, .blue = 0, .alpha = 0}; 21 | 22 | simd_float3 const MTIGrayColorTransform_ITU_R_601 = (simd_float3){0.299f, 0.587f, 0.114f}; 23 | simd_float3 const MTIGrayColorTransform_ITU_R_709 = (simd_float3){0.2126f, 0.7152f, 0.0722f}; 24 | 25 | simd_float3 const MTIGrayColorTransformDefault = MTIGrayColorTransform_ITU_R_601; 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIColorMatrix.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorMatrix.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 25/10/2017. 6 | // 7 | 8 | #import 9 | #import "MTIShaderLib.h" 10 | 11 | FOUNDATION_EXPORT const MTIColorMatrix MTIColorMatrixIdentity NS_SWIFT_NAME(MTIColorMatrix.identity); 12 | FOUNDATION_EXPORT const MTIColorMatrix MTIColorMatrixRGBColorInvert NS_SWIFT_NAME(MTIColorMatrix.rgbColorInvert); 13 | 14 | FOUNDATION_EXPORT BOOL MTIColorMatrixEqualToColorMatrix(MTIColorMatrix a, MTIColorMatrix b) NS_SWIFT_NAME(MTIColorMatrix.isEqual(self:to:)); 15 | FOUNDATION_EXPORT BOOL MTIColorMatrixIsIdentity(MTIColorMatrix matrix) NS_SWIFT_NAME(getter:MTIColorMatrix.isIdentity(self:)); 16 | 17 | FOUNDATION_EXPORT MTIColorMatrix MTIColorMatrixConcat(MTIColorMatrix a, MTIColorMatrix b) NS_SWIFT_NAME(MTIColorMatrix.concat(self:with:)); 18 | 19 | FOUNDATION_EXPORT MTIColorMatrix MTIColorMatrixMakeWithExposure(float exposure) NS_SWIFT_NAME(MTIColorMatrix.init(exposure:)); 20 | FOUNDATION_EXPORT MTIColorMatrix MTIColorMatrixMakeWithSaturation(float saturation, simd_float3 grayColorTransform) NS_SWIFT_NAME(MTIColorMatrix.init(saturation:grayColorTransform:)); 21 | FOUNDATION_EXPORT MTIColorMatrix MTIColorMatrixMakeWithBrightness(float brightness) NS_SWIFT_NAME(MTIColorMatrix.init(brightness:)); 22 | FOUNDATION_EXPORT MTIColorMatrix MTIColorMatrixMakeWithContrast(float contrast) NS_SWIFT_NAME(MTIColorMatrix.init(contrast:)); 23 | FOUNDATION_EXPORT MTIColorMatrix MTIColorMatrixMakeWithOpacity(float opacity) NS_SWIFT_NAME(MTIColorMatrix.init(opacity:)); 24 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIComputePipeline.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIComputePipeline.h 3 | // Pods 4 | // 5 | // Created by YuAo on 27/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIComputePipeline : NSObject 14 | 15 | @property (nonatomic,strong,readonly) id state; 16 | 17 | @property (nonatomic,strong,readonly) MTLComputePipelineReflection *reflection; 18 | 19 | - (instancetype)init NS_UNAVAILABLE; 20 | 21 | + (instancetype)new NS_UNAVAILABLE; 22 | 23 | - (instancetype)initWithState:(id)state reflection:(MTLComputePipelineReflection *)reflection NS_DESIGNATED_INITIALIZER; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIComputePipeline.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIComputePipeline.m 3 | // Pods 4 | // 5 | // Created by YuAo on 27/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIComputePipeline.h" 10 | 11 | @implementation MTIComputePipeline 12 | 13 | - (instancetype)initWithState:(id)state reflection:(MTLComputePipelineReflection *)reflection { 14 | if (self = [super init]) { 15 | _state = state; 16 | _reflection = reflection; 17 | } 18 | return self; 19 | } 20 | 21 | - (id)copyWithZone:(NSZone *)zone { 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICoreImageRendering.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICoreImageRendering.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 04/04/2018. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface MTICIImageRenderingOptions : NSObject 16 | 17 | @property (nullable, nonatomic, readonly) CGColorSpaceRef colorSpace; 18 | 19 | @property (getter=isFlipped, readonly, nonatomic) BOOL flipped; 20 | 21 | @property (nonatomic, readonly) MTLPixelFormat destinationPixelFormat; 22 | 23 | @property (nonatomic, readonly) CIRenderDestinationAlphaMode alphaMode NS_AVAILABLE(10_13, 11_0); 24 | 25 | - (instancetype)init NS_UNAVAILABLE; 26 | 27 | + (instancetype)new NS_UNAVAILABLE; 28 | 29 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat colorSpace:(nullable CGColorSpaceRef)colorSpace flipped:(BOOL)flipped NS_DESIGNATED_INITIALIZER; 30 | 31 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat alphaMode:(CIRenderDestinationAlphaMode)alphaMode colorSpace:(nullable CGColorSpaceRef)colorSpace flipped:(BOOL)flipped NS_DESIGNATED_INITIALIZER NS_AVAILABLE(10_13, 11_0); 32 | 33 | @property (nonatomic, strong, class, readonly) MTICIImageRenderingOptions *defaultOptions; 34 | 35 | @end 36 | 37 | @interface MTICIImageCreationOptions: NSObject 38 | 39 | @property (nonatomic, nullable, readonly) CGColorSpaceRef colorSpace; 40 | 41 | @property (getter=isFlipped, readonly, nonatomic) BOOL flipped; 42 | 43 | - (instancetype)init NS_UNAVAILABLE; 44 | 45 | + (instancetype)new NS_UNAVAILABLE; 46 | 47 | - (instancetype)initWithColorSpace:(nullable CGColorSpaceRef)colorSpace flipped:(BOOL)flipped NS_DESIGNATED_INITIALIZER; 48 | 49 | @property (nonatomic, strong, class, readonly) MTICIImageCreationOptions *defaultOptions; 50 | 51 | @end 52 | 53 | NS_ASSUME_NONNULL_END 54 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICoreImageRendering.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTICoreImageRendering.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 04/04/2018. 6 | // 7 | 8 | #import "MTICoreImageRendering.h" 9 | 10 | @implementation MTICIImageRenderingOptions 11 | 12 | - (void)dealloc { 13 | CGColorSpaceRelease(_colorSpace); 14 | } 15 | 16 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat colorSpace:(CGColorSpaceRef)colorSpace flipped:(BOOL)flipped { 17 | if (self = [super init]) { 18 | _destinationPixelFormat = pixelFormat; 19 | _alphaMode = CIRenderDestinationAlphaPremultiplied; 20 | _colorSpace = CGColorSpaceRetain(colorSpace); 21 | _flipped = flipped; 22 | } 23 | return self; 24 | } 25 | 26 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat alphaMode:(CIRenderDestinationAlphaMode)alphaMode colorSpace:(CGColorSpaceRef)colorSpace flipped:(BOOL)flipped { 27 | if (self = [super init]) { 28 | _destinationPixelFormat = pixelFormat; 29 | _alphaMode = alphaMode; 30 | _colorSpace = CGColorSpaceRetain(colorSpace); 31 | _flipped = flipped; 32 | } 33 | return self; 34 | } 35 | 36 | - (id)copyWithZone:(NSZone *)zone { 37 | return self; 38 | } 39 | 40 | + (MTICIImageRenderingOptions *)defaultOptions { 41 | static MTICIImageRenderingOptions *defaultOptions; 42 | static dispatch_once_t onceToken; 43 | dispatch_once(&onceToken, ^{ 44 | CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); 45 | defaultOptions = [[MTICIImageRenderingOptions alloc] initWithDestinationPixelFormat:MTLPixelFormatBGRA8Unorm colorSpace:colorspace flipped:YES]; 46 | CGColorSpaceRelease(colorspace); 47 | }); 48 | return defaultOptions; 49 | } 50 | 51 | @end 52 | 53 | @implementation MTICIImageCreationOptions 54 | 55 | - (void)dealloc { 56 | CGColorSpaceRelease(_colorSpace); 57 | } 58 | 59 | - (instancetype)initWithColorSpace:(CGColorSpaceRef)colorSpace flipped:(BOOL)flipped { 60 | if (self = [super init]) { 61 | _colorSpace = CGColorSpaceRetain(colorSpace); 62 | _flipped = flipped; 63 | } 64 | return self; 65 | } 66 | 67 | - (id)copyWithZone:(NSZone *)zone { 68 | return self; 69 | } 70 | 71 | + (MTICIImageCreationOptions *)defaultOptions { 72 | static MTICIImageCreationOptions *defaultOptions; 73 | static dispatch_once_t onceToken; 74 | dispatch_once(&onceToken, ^{ 75 | CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); 76 | defaultOptions = [[MTICIImageCreationOptions alloc] initWithColorSpace:colorspace flipped:YES]; 77 | CGColorSpaceRelease(colorspace); 78 | }); 79 | return defaultOptions; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDefer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUtilities.h 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/26. 6 | // 7 | // 8 | 9 | #import 10 | 11 | #define MTI_METAMACRO_CONCAT(A, B) \ 12 | MTI_METAMACRO_CONCAT_(A, B) 13 | 14 | #define MTI_METAMACRO_CONCAT_(A, B) A ## B 15 | 16 | #define MTI_DEFER \ 17 | try {} @finally {} \ 18 | __strong MTIDeferBlock MTI_METAMACRO_CONCAT(MTIExitBlock_, __LINE__) __attribute__((cleanup(MTIExecuteCleanupBlock), unused)) = ^ 19 | 20 | typedef void (^MTIDeferBlock)(void); 21 | 22 | void MTIExecuteCleanupBlock (__strong MTIDeferBlock *block); 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDefer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUtilities.m 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/26. 6 | // 7 | // 8 | 9 | #import "MTIDefer.h" 10 | 11 | void MTIExecuteCleanupBlock (__strong MTIDeferBlock *block) { 12 | (*block)(); 13 | } 14 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDrawableRendering.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDrawableRendering.h 3 | // Pods 4 | // 5 | // Created by YuAo on 01/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @class MTIDrawableRenderingRequest; 15 | 16 | @protocol MTIDrawableProvider 17 | 18 | - (nullable id)drawableForRequest:(MTIDrawableRenderingRequest *)request; 19 | 20 | - (nullable MTLRenderPassDescriptor *)renderPassDescriptorForRequest:(MTIDrawableRenderingRequest *)request; 21 | 22 | @end 23 | 24 | typedef NS_ENUM(NSUInteger, MTIDrawableRenderingResizingMode) { 25 | MTIDrawableRenderingResizingModeScale, 26 | MTIDrawableRenderingResizingModeAspect, 27 | MTIDrawableRenderingResizingModeAspectFill 28 | }; 29 | 30 | @interface MTIDrawableRenderingRequest : NSObject 31 | 32 | @property (nonatomic, weak, readonly) id drawableProvider; 33 | 34 | @property (nonatomic, readonly) MTIDrawableRenderingResizingMode resizingMode; 35 | 36 | - (instancetype)initWithDrawableProvider:(id)drawableProvider resizingMode:(MTIDrawableRenderingResizingMode)resizingMode; 37 | 38 | - (instancetype)init NS_UNAVAILABLE; 39 | 40 | + (instancetype)new NS_UNAVAILABLE; 41 | 42 | @end 43 | 44 | NS_ASSUME_NONNULL_END 45 | 46 | #import 47 | 48 | NS_ASSUME_NONNULL_BEGIN 49 | 50 | @interface MTKView (MTIDrawableProvider) 51 | 52 | @end 53 | 54 | NS_ASSUME_NONNULL_END 55 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIDrawableRendering.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIDrawableRendering.m 3 | // Pods 4 | // 5 | // Created by YuAo on 01/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIDrawableRendering.h" 10 | 11 | @implementation MTIDrawableRenderingRequest 12 | 13 | - (instancetype)initWithDrawableProvider:(id)drawableProvider resizingMode:(MTIDrawableRenderingResizingMode)resizingMode { 14 | if (self = [super init]) { 15 | _drawableProvider = drawableProvider; 16 | _resizingMode = resizingMode; 17 | } 18 | return self; 19 | } 20 | 21 | @end 22 | 23 | @implementation MTKView (MTIDrawableProvider) 24 | 25 | - (id)drawableForRequest:(MTIDrawableRenderingRequest *)request { 26 | return self.currentDrawable; 27 | } 28 | 29 | - (MTLRenderPassDescriptor *)renderPassDescriptorForRequest:(MTIDrawableRenderingRequest *)request { 30 | return self.currentRenderPassDescriptor; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIError.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIError.h 3 | // Pods 4 | // 5 | // Created by YuAo on 10/08/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT NSString * const MTIErrorDomain; 14 | 15 | typedef NS_ERROR_ENUM(MTIErrorDomain, MTIError) { 16 | //Core errors 17 | MTIErrorDeviceNotFound = 1001, 18 | MTIErrorFunctionNotFound = 1002, 19 | MTIErrorFailedToCreateSamplerState = 1003, 20 | MTIErrorFailedToCreateTexture = 1004, 21 | MTIErrorFailedToCreateCommandEncoder = 1005, 22 | MTIErrorFailedToCreateHeap = 1006, 23 | 24 | //Texture loading errors 25 | MTIErrorUnsupportedCVPixelBufferFormat = 2001, 26 | MTIErrorTextureDimensionsMismatch = 2002, 27 | 28 | //Image errors 29 | MTIErrorUnsupportedImageCachePolicy = 3001, 30 | 31 | //Kernel errors 32 | MTIErrorDataBufferSizeMismatch = 4001, 33 | MTIErrorParameterDataTypeNotSupported = 4002, 34 | MTIErrorMPSKernelInputCountMismatch = 4003, 35 | MTIErrorMPSKernelNotSupported = 4004, 36 | 37 | //Render errors 38 | MTIErrorEmptyDrawable = 5001, 39 | MTIErrorEmptyDrawableTexture = 5101, 40 | MTIErrorFailedToCreateCGImageFromCVPixelBuffer = 5002, 41 | MTIErrorFailedToCreateCVPixelBuffer = 5003, 42 | MTIErrorInvalidCVPixelBufferRenderingAPI = 5004, 43 | MTIErrorFailedToGetRenderedBuffer = 5005, 44 | 45 | //For operations do not support cross device or cross context rendering, we report these errors. 46 | MTIErrorCrossDeviceRendering = 5006, 47 | MTIErrorCrossContextRendering = 5007, 48 | 49 | //For features not available on iOS simulator. 50 | MTIErrorFeatureNotAvailableOnSimulator = 6001 51 | }; 52 | 53 | /// Create a NSError with MTIErrorDomain and the specified error code and user info. Creating a symbolic breakpoint for `_MTIErrorCreate` can help you locate the source of the error. 54 | FOUNDATION_EXPORT NSError * _MTIErrorCreate(MTIError code, NSString *defaultDescription, NSDictionary * _Nullable userInfo); 55 | 56 | #define MTIErrorCreate(code, userInfo) _MTIErrorCreate(code, @#code, userInfo) 57 | 58 | NS_ASSUME_NONNULL_END 59 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIError.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIError.m 3 | // Pods 4 | // 5 | // Created by YuAo on 10/08/2017. 6 | // 7 | // 8 | 9 | #import "MTIError.h" 10 | 11 | NSString * const MTIErrorDomain = @"MTIErrorDomain"; 12 | 13 | NSError * _MTIErrorCreate(MTIError code, NSString *defaultDescription, NSDictionary *userInfo) { 14 | if (userInfo[NSLocalizedDescriptionKey] == nil) { 15 | NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:userInfo]; 16 | info[NSLocalizedDescriptionKey] = defaultDescription; 17 | return [NSError errorWithDomain:MTIErrorDomain code:code userInfo:info]; 18 | } else { 19 | return [NSError errorWithDomain:MTIErrorDomain code:code userInfo:userInfo]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIFunctionDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilterFunctionDescriptor.h 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface MTIFunctionDescriptor : NSObject 15 | 16 | @property (nonatomic, copy, readonly, nullable) NSURL *libraryURL; 17 | 18 | @property (nonatomic, copy, readonly) NSString *name; 19 | 20 | @property (nonatomic, copy, readonly, nullable) MTLFunctionConstantValues *constantValues NS_AVAILABLE(10_12, 10_0); 21 | 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | + (instancetype)new NS_UNAVAILABLE; 25 | 26 | - (instancetype)initWithName:(NSString *)name; 27 | 28 | - (instancetype)initWithName:(NSString *)name libraryURL:(nullable NSURL *)URL NS_DESIGNATED_INITIALIZER; 29 | 30 | - (instancetype)initWithName:(NSString *)name constantValues:(nullable MTLFunctionConstantValues *)constantValues libraryURL:(nullable NSURL *)URL NS_AVAILABLE(10_12, 10_0) NS_DESIGNATED_INITIALIZER; 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometry.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometry.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 2018/5/6. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @class MTIRenderPipeline; 13 | 14 | @protocol MTIGeometryRenderingContext 15 | 16 | @property (nonatomic, readonly, strong) MTIRenderPipeline *renderPipeline; 17 | 18 | @property (nonatomic, readonly, strong) id device; 19 | 20 | @end 21 | 22 | @protocol MTIGeometry 23 | 24 | - (void)encodeDrawCallWithCommandEncoder:(id)commandEncoder 25 | context:(id)context; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | 31 | 32 | #import "MTIRenderPipeline.h" 33 | 34 | NS_ASSUME_NONNULL_BEGIN 35 | 36 | @interface MTIRenderPipeline (MTIGeometryRenderingContext) 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometry.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometry.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/2/2. 6 | // 7 | 8 | #import "MTIGeometry.h" 9 | 10 | @implementation MTIRenderPipeline (MTIGeometryRenderingContext) 11 | 12 | - (MTIRenderPipeline *)renderPipeline { 13 | return self; 14 | } 15 | 16 | - (id)device { 17 | return self.state.device; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometryUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometryUtilities.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/11/8. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT CGRect MTIMakeRectWithAspectRatioFillRect(CGSize aspectRatio, CGRect boundingRect) NS_SWIFT_NAME(MTIMakeRect(aspectRatio:fillRect:)); 14 | 15 | FOUNDATION_EXPORT CGRect MTIMakeRectWithAspectRatioInsideRect(CGSize aspectRatio, CGRect boundingRect) NS_SWIFT_NAME(MTIMakeRect(aspectRatio:insideRect:)); 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometryUtilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIGeometryUtilities.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/11/8. 6 | // 7 | 8 | #import "MTIGeometryUtilities.h" 9 | #import 10 | 11 | CGRect MTIMakeRectWithAspectRatioFillRect(CGSize aspectRatio, CGRect boundingRect) { 12 | CGFloat horizontalRatio = boundingRect.size.width / aspectRatio.width; 13 | CGFloat verticalRatio = boundingRect.size.height / aspectRatio.height; 14 | CGFloat ratio = MAX(horizontalRatio, verticalRatio); 15 | CGSize newSize = CGSizeMake(aspectRatio.width * ratio, aspectRatio.height * ratio); 16 | CGRect rect = CGRectMake(boundingRect.origin.x + (boundingRect.size.width - newSize.width)/2, boundingRect.origin.y + (boundingRect.size.height - newSize.height)/2, newSize.width, newSize.height); 17 | return rect; 18 | } 19 | 20 | CGRect MTIMakeRectWithAspectRatioInsideRect(CGSize aspectRatio, CGRect boundingRect) { 21 | return AVMakeRectWithAspectRatioInsideRect(aspectRatio, boundingRect); 22 | } 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIHasher.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIHasher.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/1/7. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | struct MTIHasher { 13 | uint64_t _seed; 14 | BOOL _finalized; 15 | }; 16 | typedef struct MTIHasher MTIHasher; 17 | 18 | static inline MTIHasher MTIHasherMake(NSUInteger seed) { 19 | //MTIHasher is designed to work on 64-bit systems. 20 | assert(sizeof(NSUInteger) == 8); 21 | return (MTIHasher){._seed = seed, ._finalized = NO}; 22 | } 23 | 24 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, uint64_t value) { 25 | //Ref boost::hash_combine 26 | //Ref https://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine 27 | hasher -> _seed ^= value + 0x9e3779b97f4a7c15 + (hasher -> _seed << 6) + (hasher -> _seed >> 2); 28 | } 29 | 30 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, unsigned int intValue) { 31 | uint64_t value = intValue; 32 | MTIHasherCombine(hasher, value); 33 | } 34 | 35 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, unsigned long intValue) { 36 | uint64_t value = intValue; 37 | MTIHasherCombine(hasher, value); 38 | } 39 | 40 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, double doubleValue) { 41 | //in .m file: static_assert(sizeof(uint64_t) == sizeof(double), "") 42 | uint64_t value = *(uint64_t *)&doubleValue; 43 | MTIHasherCombine(hasher, value); 44 | } 45 | 46 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, float floatValue) { 47 | double doubleValue = floatValue; 48 | MTIHasherCombine(hasher, doubleValue); 49 | } 50 | 51 | static inline __attribute__((__overloadable__)) NSUInteger MTIHasherFinalize(MTIHasher *hasher) { 52 | NSCParameterAssert(hasher -> _finalized == NO); 53 | hasher -> _finalized = YES; 54 | return (NSUInteger)hasher -> _seed; 55 | } 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIHasher.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIHasher.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/1/7. 6 | // 7 | 8 | #import "MTIHasher.h" 9 | 10 | static_assert(sizeof(uint64_t) == sizeof(double), ""); 11 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImage+Promise.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImage-Private.h 3 | // Pods 4 | // 5 | // Created by YuAo on 14/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIImage.h" 10 | #import "MTIImagePromise.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface MTIImage (Promise) 15 | 16 | @property (nonatomic,copy,readonly) id promise; 17 | 18 | - (instancetype)initWithPromise:(id)promise; 19 | 20 | - (instancetype)initWithPromise:(id)promise samplerDescriptor:(MTISamplerDescriptor *)samplerDescriptor; 21 | 22 | - (instancetype)initWithPromise:(id)promise samplerDescriptor:(MTISamplerDescriptor *)samplerDescriptor cachePolicy:(MTIImageCachePolicy)cachePolicy; 23 | 24 | @end 25 | 26 | NS_ASSUME_NONNULL_END 27 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageOrientation.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageOrientation.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 16/10/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | // https://developer.apple.com/documentation/uikit/uiimageorientation?language=objc 12 | 13 | typedef NS_ENUM(NSInteger, MTIImageOrientation) { 14 | MTIImageOrientationUnknown = 0, 15 | MTIImageOrientationUp = 1, 16 | MTIImageOrientationUpMirrored = 2, 17 | MTIImageOrientationDown = 3, 18 | MTIImageOrientationDownMirrored = 4, 19 | MTIImageOrientationLeftMirrored = 5, 20 | MTIImageOrientationRight = 6, 21 | MTIImageOrientationRightMirrored = 7, 22 | MTIImageOrientationLeft = 8 23 | }; 24 | 25 | FOUNDATION_EXPORT MTIImageOrientation MTIImageOrientationFromCGImagePropertyOrientation(CGImagePropertyOrientation orientation) NS_SWIFT_NAME(MTIImageOrientation.init(cgImagePropertyOrientation:)); 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageOrientation.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageOrientation.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 16/10/2017. 6 | // 7 | 8 | #import "MTIImageOrientation.h" 9 | 10 | MTIImageOrientation MTIImageOrientationFromCGImagePropertyOrientation(CGImagePropertyOrientation orientation) { 11 | MTIImageOrientation imageOrientation; 12 | switch (orientation) { 13 | case kCGImagePropertyOrientationUp: 14 | imageOrientation = MTIImageOrientationUp; 15 | break; 16 | case kCGImagePropertyOrientationDown: 17 | imageOrientation = MTIImageOrientationDown; 18 | break; 19 | case kCGImagePropertyOrientationLeft: 20 | imageOrientation = MTIImageOrientationLeft; 21 | break; 22 | case kCGImagePropertyOrientationRight: 23 | imageOrientation = MTIImageOrientationRight; 24 | break; 25 | case kCGImagePropertyOrientationUpMirrored: 26 | imageOrientation = MTIImageOrientationUpMirrored; 27 | break; 28 | case kCGImagePropertyOrientationDownMirrored: 29 | imageOrientation = MTIImageOrientationDownMirrored; 30 | break; 31 | case kCGImagePropertyOrientationLeftMirrored: 32 | imageOrientation = MTIImageOrientationLeftMirrored; 33 | break; 34 | case kCGImagePropertyOrientationRightMirrored: 35 | imageOrientation = MTIImageOrientationRightMirrored; 36 | break; 37 | default: 38 | imageOrientation = MTIImageOrientationUnknown; 39 | break; 40 | } 41 | return imageOrientation; 42 | } 43 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImagePromiseDebug.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImagePromiseDebug.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 23/11/2017. 6 | // 7 | 8 | #import 9 | #import "MTIImagePromise.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, MTIImagePromiseType) { 14 | MTIImagePromiseTypeSource, 15 | MTIImagePromiseTypeProcessor 16 | }; 17 | 18 | FOUNDATION_EXPORT NSString * MTIImagePromiseDebugIdentifierForObject(id object); 19 | 20 | @interface MTIImagePromiseDebugInfo : NSObject 21 | 22 | @property (nonatomic,copy,readonly) NSString *identifier; 23 | 24 | @property (nonatomic,readonly) MTIImagePromiseType type; 25 | 26 | @property (nonatomic,copy,readonly) NSString *title; 27 | 28 | @property (nonatomic,strong,readonly,nullable) id content; 29 | 30 | - (instancetype)init NS_UNAVAILABLE; 31 | 32 | + (instancetype)new NS_UNAVAILABLE; 33 | 34 | - (instancetype)initWithPromise:(id)promise 35 | type:(MTIImagePromiseType)type 36 | content:(id)content; 37 | 38 | @end 39 | 40 | @interface MTIImagePromiseDebugInfo (RenderGraph) 41 | 42 | + (CALayer *)layerRepresentationOfRenderGraphForPromise:(id)promise; 43 | 44 | @end 45 | 46 | NS_ASSUME_NONNULL_END 47 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageProperties.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageProperties.h 3 | // Pods 4 | // 5 | // Created by YuAo on 2018/6/22. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface MTIImageProperties : NSObject 15 | 16 | + (instancetype)new NS_UNAVAILABLE; 17 | 18 | - (instancetype)init NS_UNAVAILABLE; 19 | 20 | - (nullable instancetype)initWithImageSource:(CGImageSourceRef)imageSource index:(NSUInteger)index NS_DESIGNATED_INITIALIZER; 21 | 22 | - (instancetype)initWithCGImage:(CGImageRef)image NS_DESIGNATED_INITIALIZER; 23 | 24 | - (nullable instancetype)initWithImageAtURL:(NSURL *)URL; 25 | 26 | @property (nonatomic, readonly) CGImageAlphaInfo alphaInfo; 27 | @property (nonatomic, readonly) CGImageByteOrderInfo byteOrderInfo; 28 | @property (nonatomic, readonly) BOOL floatComponents; 29 | @property (nonatomic, readonly, nullable) CGColorSpaceRef colorSpace; 30 | 31 | @property (nonatomic, readonly) NSUInteger pixelWidth; 32 | @property (nonatomic, readonly) NSUInteger pixelHeight; 33 | 34 | @property (nonatomic, readonly) CGImagePropertyOrientation orientation; 35 | 36 | // Width and height with orientation applied. 37 | @property (nonatomic, readonly) NSUInteger displayWidth; 38 | @property (nonatomic, readonly) NSUInteger displayHeight; 39 | 40 | @property (nonatomic, copy, readonly) NSDictionary *properties; 41 | 42 | @end 43 | 44 | NS_ASSUME_NONNULL_END 45 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageRenderingContext+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageRenderingContext+Internal.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2020/1/20. 6 | // 7 | 8 | #import 9 | #import "MTIImageRenderingContext.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol MTIImagePromiseResolution 14 | 15 | @property (nonatomic,readonly) id texture; 16 | 17 | - (void)markAsConsumedBy:(id)consumer; 18 | 19 | @end 20 | 21 | @interface MTIImageRenderingContext (Internal) 22 | 23 | - (instancetype)initWithContext:(MTIContext *)context; 24 | 25 | - (nullable id)resolutionForImage:(MTIImage *)image error:(NSError **)error; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIImageRenderingContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageRenderingContext.h 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MTIImagePromise.h" 12 | 13 | @class MTIImage, MTIContext; 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | /*! @brief Rendering context related constant for MTIContextImageAssociatedValueTableName. */ 18 | FOUNDATION_EXPORT NSString * const MTIContextImagePersistentResolutionHolderTableName; 19 | 20 | @interface MTIImageRenderingContext : NSObject 21 | 22 | @property (nonatomic, strong, readonly) MTIContext *context; 23 | 24 | @property (nonatomic, strong, readonly) id commandBuffer; 25 | 26 | - (instancetype)init NS_UNAVAILABLE; 27 | 28 | + (instancetype)new NS_UNAVAILABLE; 29 | 30 | /// Use this method in -[MTIImagePromise resolveWithContext:error:] to get the resolved dependencies of the promise. The `image` parameter must be one of the resolving promise's dependencies. An exception is thrown when calling this method outside the -[MTIImagePromise resolveWithContext:error:] method or passing an invalid image. 31 | - (id)resolvedTextureForImage:(MTIImage *)image; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | 37 | 38 | #import "MTIContext.h" 39 | 40 | NS_ASSUME_NONNULL_BEGIN 41 | 42 | @interface MTIContext (RenderedImageBuffer) 43 | 44 | - (nullable MTIImage *)renderedBufferForImage:(MTIImage *)targetImage; 45 | 46 | @end 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILibrarySource.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTILibrarySource.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/5/7. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | FOUNDATION_EXPORT NSString * const MTIURLSchemeForLibraryWithSource; 13 | 14 | FOUNDATION_EXPORT NSString * const MTILibrarySourceErrorDomain; 15 | 16 | typedef NS_ERROR_ENUM(MTILibrarySourceErrorDomain, MTILibrarySourceError) { 17 | MTILibrarySourceErrorLibraryNotFound = 10001 18 | }; 19 | 20 | /// MTILibrarySourceRegistration can be used under the situation where it is impossible to use a offline metal compiler. You should avoid using this class as possbile as you can. 21 | @interface MTILibrarySourceRegistration : NSObject 22 | 23 | + (instancetype)new NS_UNAVAILABLE; 24 | 25 | - (instancetype)init NS_UNAVAILABLE; 26 | 27 | @property (nonatomic, strong, readonly, class) MTILibrarySourceRegistration *sharedRegistration; 28 | 29 | /// Returns a URL representing the metal library compiled with the `source` code. This URL can be used in `MTIFunctionDescriptor(name:libraryURL:)`. 30 | - (NSURL *)registerLibraryWithSource:(NSString *)source 31 | compileOptions:(nullable MTLCompileOptions *)compileOptions NS_SWIFT_NAME(registerLibrary(source:compileOptions:)); 32 | 33 | - (void)unregisterLibraryWithURL:(NSURL *)url; 34 | 35 | @end 36 | 37 | @interface MTILibrarySourceRegistration (Internal) 38 | 39 | - (nullable id)newLibraryWithURL:(NSURL *)libraryURL device:(id)device error:(NSError **)error; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILock.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTILock.h 3 | // Pods 4 | // 5 | // Created by YuAo on 05/08/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol MTILocking 14 | 15 | - (BOOL)tryLock; 16 | 17 | @end 18 | 19 | ///Create a non-recursive lock. Unlocking a lock from a different thread other than the locking thread can result in undefined behavior. 20 | FOUNDATION_EXPORT id MTILockCreate(void) NS_RETURNS_RETAINED; 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILock.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTILock.m 3 | // Pods 4 | // 5 | // Created by YuAo on 05/08/2017. 6 | // 7 | // 8 | 9 | #import "MTILock.h" 10 | #import 11 | 12 | //https://gist.github.com/steipete/36350a8a60693d440954b95ea6cbbafc 13 | 14 | OS_UNFAIR_LOCK_AVAILABILITY 15 | @interface MTILock : NSObject { 16 | os_unfair_lock _unfairlock; 17 | } 18 | 19 | @end 20 | 21 | @implementation MTILock 22 | 23 | - (instancetype)init { 24 | if (self = [super init]) { 25 | _unfairlock = OS_UNFAIR_LOCK_INIT; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)lock { 31 | os_unfair_lock_lock(&_unfairlock); 32 | } 33 | 34 | - (void)unlock { 35 | os_unfair_lock_unlock(&_unfairlock); 36 | } 37 | 38 | - (BOOL)tryLock { 39 | return os_unfair_lock_trylock(&_unfairlock); 40 | } 41 | 42 | @end 43 | 44 | @interface NSLock (MTILocking) 45 | 46 | @end 47 | 48 | @implementation NSLock (MTILocking) 49 | 50 | @end 51 | 52 | id MTILockCreate(void) { 53 | if (@available(iOS 10.0, *)) { 54 | return [[MTILock alloc] init]; 55 | } else { 56 | return [[NSLock alloc] init]; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMask.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMask.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 14/11/2017. 6 | // 7 | 8 | #import 9 | #import "MTIColor.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class MTIImage; 14 | 15 | typedef NS_ENUM(NSInteger, MTIMaskMode) { 16 | MTIMaskModeNormal = 0, 17 | MTIMaskModeOneMinusMaskValue 18 | }; 19 | 20 | @interface MTIMask : NSObject 21 | 22 | @property (nonatomic, strong, readonly) MTIImage *content; 23 | 24 | @property (nonatomic, readonly) MTIColorComponent component; 25 | 26 | @property (nonatomic, readonly) MTIMaskMode mode; 27 | 28 | - (instancetype)init NS_UNAVAILABLE; 29 | 30 | + (instancetype)new NS_UNAVAILABLE; 31 | 32 | - (instancetype)initWithContent:(MTIImage *)content component:(MTIColorComponent)component mode:(MTIMaskMode)mode NS_DESIGNATED_INITIALIZER; 33 | 34 | - (instancetype)initWithContent:(MTIImage *)content; 35 | 36 | @end 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMask.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMask.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 14/11/2017. 6 | // 7 | 8 | #import "MTIMask.h" 9 | 10 | @implementation MTIMask 11 | 12 | - (instancetype)initWithContent:(MTIImage *)content component:(MTIColorComponent)component mode:(MTIMaskMode)mode { 13 | if (self = [super init]) { 14 | _content = content; 15 | _component = component; 16 | _mode = mode; 17 | } 18 | return self; 19 | } 20 | 21 | - (instancetype)initWithContent:(MTIImage *)content { 22 | return [self initWithContent:content component:MTIColorComponentRed mode:MTIMaskModeNormal]; 23 | } 24 | 25 | - (id)copyWithZone:(NSZone *)zone { 26 | return self; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMemoryWarningObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMemoryWarningObserver.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/8/27. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @protocol MTIMemoryWarningHandling 13 | 14 | - (void)handleMemoryWarning; 15 | 16 | @end 17 | 18 | @interface MTIMemoryWarningObserver : NSObject 19 | 20 | - (instancetype)init NS_UNAVAILABLE; 21 | 22 | + (void)addMemoryWarningHandler:(id)memoryWarningHandler; 23 | 24 | + (void)removeMemoryWarningHandler:(id)memoryWarningHandler; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIMemoryWarningObserver.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMemoryWarningObserver.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/8/27. 6 | // 7 | 8 | #import "MTIMemoryWarningObserver.h" 9 | #import "MTILock.h" 10 | 11 | #if __has_include() 12 | #import 13 | #endif 14 | 15 | @interface MTIMemoryWarningObserver () 16 | 17 | @property (nonatomic, strong, readonly) NSHashTable *handlers; 18 | @property (nonatomic, strong, readonly) id lock; 19 | 20 | @end 21 | 22 | @implementation MTIMemoryWarningObserver 23 | 24 | + (instancetype)sharedObserver { 25 | static MTIMemoryWarningObserver *observer; 26 | static dispatch_once_t onceToken; 27 | dispatch_once(&onceToken, ^{ 28 | observer = [[MTIMemoryWarningObserver alloc] initForSharedObserver]; 29 | }); 30 | return observer; 31 | } 32 | 33 | - (instancetype)initForSharedObserver { 34 | if (self = [super init]) { 35 | _handlers = [NSHashTable weakObjectsHashTable]; 36 | _lock = MTILockCreate(); 37 | #if __has_include() 38 | [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidReceiveMemoryWarningNotification 39 | object:nil 40 | queue:nil 41 | usingBlock:^(NSNotification * _Nonnull note) { 42 | [self handleMemoryWarning]; 43 | }]; 44 | #endif 45 | } 46 | return self; 47 | } 48 | 49 | - (void)handleMemoryWarning { 50 | [_lock lock]; 51 | for (id handler in _handlers) { 52 | [handler handleMemoryWarning]; 53 | } 54 | [_lock unlock]; 55 | } 56 | 57 | - (void)addMemoryWarningHandler:(id)memoryWarningHandler { 58 | [_lock lock]; 59 | [_handlers addObject:memoryWarningHandler]; 60 | [_lock unlock]; 61 | } 62 | 63 | - (void)removeMemoryWarningHandler:(id)memoryWarningHandler { 64 | [_lock lock]; 65 | [_handlers removeObject:memoryWarningHandler]; 66 | [_lock unlock]; 67 | } 68 | 69 | + (void)addMemoryWarningHandler:(id)memoryWarningHandler { 70 | [self.sharedObserver addMemoryWarningHandler:memoryWarningHandler]; 71 | } 72 | 73 | + (void)removeMemoryWarningHandler:(id)memoryWarningHandler { 74 | [self.sharedObserver removeMemoryWarningHandler:memoryWarningHandler]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPixelFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixelFormat.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatUnspecified NS_REFINED_FOR_SWIFT; //aliased to MTLPixelFormatInvalid 14 | 15 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P NS_REFINED_FOR_SWIFT; 16 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P_sRGB NS_REFINED_FOR_SWIFT; 17 | 18 | FOUNDATION_EXPORT BOOL MTIDeviceSupportsYCBCRPixelFormat(id device); 19 | 20 | NS_ASSUME_NONNULL_END 21 | 22 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPixelFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPixelFormat.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | #import "MTIPixelFormat.h" 9 | #import 10 | 11 | MTLPixelFormat const MTIPixelFormatUnspecified = MTLPixelFormatInvalid; 12 | 13 | MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P = 500; 14 | MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P_sRGB = 520; 15 | 16 | BOOL MTIDeviceSupportsYCBCRPixelFormat(id device) { 17 | #if TARGET_OS_SIMULATOR 18 | return NO; 19 | #elif TARGET_OS_IPHONE 20 | return [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]; 21 | #else 22 | return NO; 23 | #endif 24 | } 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPrint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPrint.h 3 | // Pods 4 | // 5 | // Created by YuAo on 26/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | #if !defined(MTIPrint) 12 | 13 | #if DEBUG 14 | 15 | #define MTIPrint(format, ...) do { \ 16 | if (getenv("MTI_PRINT_ENABLED") != NULL) {\ 17 | NSLog(format, ##__VA_ARGS__); \ 18 | }\ 19 | } while(0) 20 | 21 | #else 22 | 23 | #define MTIPrint(format, ...) do { } while(0) 24 | 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIPrint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIPrint.m 3 | // Pods 4 | // 5 | // Created by YuAo on 26/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIPrint.h" 10 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderGraphOptimization.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderGraphMerge.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 20/11/2017. 6 | // 7 | 8 | #import 9 | #import "MTIImagePromise.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class MTIImage; 14 | 15 | @interface MTIRenderGraphNode: NSObject 16 | 17 | @property (nonatomic, strong, nullable) NSMutableArray *inputs; 18 | 19 | @property (nonatomic, strong, nullable) MTIImage *image; 20 | 21 | @property (nonatomic, readonly) NSInteger uniqueDependentCount; 22 | 23 | @end 24 | 25 | @interface MTIRenderGraphOptimizer : NSObject 26 | 27 | + (id)promiseByOptimizingRenderGraphOfPromise:(id)promise; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPassOutputDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineOutputDescriptor.h 3 | // Pods 4 | // 5 | // Created by YuAo on 18/11/2017. 6 | // 7 | 8 | #import 9 | #import 10 | #import "MTITextureDimensions.h" 11 | #import "MTIPixelFormat.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface MTIRenderPassOutputDescriptor: NSObject 16 | 17 | @property (nonatomic,readonly) MTITextureDimensions dimensions; 18 | 19 | @property (nonatomic,readonly) MTLPixelFormat pixelFormat; 20 | 21 | @property (nonatomic,readonly) MTLLoadAction loadAction; 22 | 23 | @property (nonatomic,readonly) MTLStoreAction storeAction; 24 | 25 | @property (nonatomic,readonly) MTLClearColor clearColor; 26 | 27 | - (instancetype)init NS_UNAVAILABLE; 28 | 29 | + (instancetype)new NS_UNAVAILABLE; 30 | 31 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat; 32 | 33 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction; 34 | 35 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction storeAction:(MTLStoreAction)storeAction; 36 | 37 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat clearColor:(MTLClearColor)clearColor loadAction:(MTLLoadAction)loadAction storeAction:(MTLStoreAction)storeAction NS_DESIGNATED_INITIALIZER; 38 | 39 | - (BOOL)isEqualToOutputDescriptor:(MTIRenderPassOutputDescriptor *)object; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPipeline.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineInfo.h 3 | // Pods 4 | // 5 | // Created by YuAo on 30/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MTIRenderPipeline : NSObject 14 | 15 | @property (nonatomic,strong,readonly) id state; 16 | 17 | @property (nonatomic,strong,readonly) MTLRenderPipelineReflection *reflection; 18 | 19 | - (instancetype)init NS_UNAVAILABLE; 20 | 21 | + (instancetype)new NS_UNAVAILABLE; 22 | 23 | - (instancetype)initWithState:(id)state reflection:(MTLRenderPipelineReflection *)reflection NS_DESIGNATED_INITIALIZER; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPipeline.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineInfo.m 3 | // Pods 4 | // 5 | // Created by YuAo on 30/06/2017. 6 | // 7 | // 8 | 9 | #import "MTIRenderPipeline.h" 10 | 11 | @implementation MTIRenderPipeline 12 | 13 | - (instancetype)initWithState:(id)state reflection:(MTLRenderPipelineReflection *)reflection { 14 | if (self = [super init]) { 15 | _state = state; 16 | _reflection = reflection; 17 | } 18 | return self; 19 | } 20 | 21 | - (id)copyWithZone:(NSZone *)zone { 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderTask.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/5/22. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class MTIImageRenderingContext; 14 | 15 | /// Represents a GPU render task - i.e., commands in a command buffer. 16 | @interface MTIRenderTask : NSObject 17 | 18 | /// Status of the underlaying command buffer. 19 | @property (readonly) MTLCommandBufferStatus commandBufferStatus; 20 | 21 | - (instancetype)initWithCommandBuffer:(id)commandBuffer NS_DESIGNATED_INITIALIZER; 22 | 23 | - (instancetype)init NS_UNAVAILABLE; 24 | 25 | + (instancetype)new NS_UNAVAILABLE; 26 | 27 | /// Synchronously blocks execution until the task either completes or fails (with error). 28 | - (void)waitUntilCompleted; 29 | 30 | /// If an error occurred during execution, the NSError may contain more details about the problem. 31 | @property (nullable, readonly) NSError *error; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderTask.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderTask.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/5/22. 6 | // 7 | 8 | #import "MTIRenderTask.h" 9 | #import "MTIImageRenderingContext.h" 10 | 11 | @interface MTIRenderTask () 12 | 13 | @property (nonatomic, readonly, strong) id commandBuffer; 14 | 15 | @end 16 | 17 | @implementation MTIRenderTask 18 | 19 | - (instancetype)initWithCommandBuffer:(id)commandBuffer { 20 | if (self = [super init]) { 21 | _commandBuffer = commandBuffer; 22 | } 23 | return self; 24 | } 25 | 26 | - (NSError *)error { 27 | return _commandBuffer.error; 28 | } 29 | 30 | - (void)waitUntilCompleted { 31 | [_commandBuffer waitUntilCompleted]; 32 | } 33 | 34 | - (MTLCommandBufferStatus)commandBufferStatus { 35 | return _commandBuffer.status; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTISamplerDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTISamplerDescriptor.h 3 | // Pods 4 | // 5 | // Created by YuAo on 29/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// An immutable wrapper for MTLSamplerDescriptor. 14 | @interface MTISamplerDescriptor : NSObject 15 | 16 | - (instancetype)init NS_UNAVAILABLE; 17 | 18 | + (instancetype)new NS_UNAVAILABLE; 19 | 20 | - (instancetype)initWithMTLSamplerDescriptor:(MTLSamplerDescriptor *)samplerDescriptor NS_DESIGNATED_INITIALIZER; 21 | 22 | - (MTLSamplerDescriptor *)newMTLSamplerDescriptor NS_SWIFT_NAME(makeMTLSamplerDescriptor()); 23 | 24 | @property (nonatomic, readonly, class) MTISamplerDescriptor *defaultSamplerDescriptor; 25 | 26 | + (instancetype)defaultSamplerDescriptorWithAddressMode:(MTLSamplerAddressMode)addressMode; 27 | 28 | @end 29 | 30 | @interface MTLSamplerDescriptor (MTISamplerDescriptor) 31 | 32 | - (MTISamplerDescriptor *)newMTISamplerDescriptor NS_SWIFT_NAME(makeMTISamplerDescriptor()); 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureDimensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDimensions.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | struct MTITextureDimensions { 14 | NSUInteger width; 15 | NSUInteger height; 16 | NSUInteger depth; 17 | }; 18 | typedef struct MTITextureDimensions MTITextureDimensions; 19 | 20 | FOUNDATION_EXPORT MTITextureDimensions MTITextureDimensionsMake2DFromCGSize(CGSize size) NS_SWIFT_NAME(MTITextureDimensions.init(cgSize:)); 21 | 22 | FOUNDATION_EXPORT BOOL MTITextureDimensionsEqualToTextureDimensions(MTITextureDimensions a, MTITextureDimensions b) NS_SWIFT_NAME(MTITextureDimensions.isEqual(self:to:)); 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureDimensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDimensions.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | #import "MTITextureDimensions.h" 9 | 10 | MTITextureDimensions MTITextureDimensionsMake2DFromCGSize(CGSize size) { 11 | return (MTITextureDimensions){.width = size.width, .height = size.height, .depth = 1}; 12 | } 13 | 14 | BOOL MTITextureDimensionsEqualToTextureDimensions(MTITextureDimensions a, MTITextureDimensions b) { 15 | return a.width == b.width && a.height == b.height && a.depth == b.depth; 16 | } 17 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureLoader.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/1/10. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /// Abstract interface for texture loader. 13 | @protocol MTITextureLoader 14 | 15 | + (instancetype)newTextureLoaderWithDevice:(id )device; 16 | 17 | - (nullable id )newTextureWithCGImage:(nonnull CGImageRef)cgImage 18 | options:(nullable NSDictionary *)options 19 | error:(NSError *__nullable *__nullable)error; 20 | 21 | - (nullable id )newTextureWithContentsOfURL:(nonnull NSURL *)URL 22 | options:(nullable NSDictionary *)options 23 | error:(NSError *__nullable *__nullable)error; 24 | 25 | - (nullable id )newTextureWithName:(nonnull NSString *)name 26 | scaleFactor:(CGFloat)scaleFactor 27 | bundle:(nullable NSBundle *)bundle 28 | options:(nullable NSDictionary *)options 29 | error:(NSError *__nullable *__nullable)error; 30 | 31 | - (nullable id )newTextureWithMDLTexture:(nonnull MDLTexture *)texture 32 | options:(nullable NSDictionary *)options 33 | error:(NSError *__nullable *__nullable)error; 34 | 35 | @end 36 | 37 | @interface MTKTextureLoader (MTITextureLoader) 38 | 39 | @end 40 | 41 | NS_ASSUME_NONNULL_END 42 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureLoader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureLoader.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/1/10. 6 | // 7 | 8 | #import "MTITextureLoader.h" 9 | 10 | @implementation MTKTextureLoader (MTITextureLoader) 11 | 12 | + (instancetype)newTextureLoaderWithDevice:(id)device { 13 | return [[MTKTextureLoader alloc] initWithDevice:device]; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureLoaderForiOS9.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTKTextureLoaderExtension.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 06/12/2017. 6 | // 7 | 8 | #import 9 | #import 10 | #import "MTITextureLoader.h" 11 | 12 | #if TARGET_OS_IPHONE 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | /*! 17 | @brief A custom implemented texture loader for iOS 9, which loads images without filpping them vertically. This matches the behavior of `MTKTextureLoader` on iOS 10 and above. 18 | 19 | @discussion To use this texture loader, assgin MTITextureLoaderForiOS9WithImageOrientationFix.class to MTIContextOptions.defaultTextureLoaderClass on iOS 9 only. 20 | 21 | @code 22 | if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_9_x_Max) { 23 | MTIContextOptions.defaultTextureLoaderClass = MTITextureLoaderForiOS9WithImageOrientationFix.class; 24 | } 25 | */ 26 | 27 | NS_CLASS_DEPRECATED_IOS(9_0, 10_0, "Use MTKTextureLoader instead.") __TVOS_PROHIBITED 28 | @interface MTITextureLoaderForiOS9WithImageOrientationFix : NSObject 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITransform.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITransform.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 28/10/2017. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | FOUNDATION_EXPORT simd_float4x4 MTIMakeOrthographicMatrix(float left, float right, float top, float bottom, float near, float far); 13 | 14 | FOUNDATION_EXPORT simd_float4x4 MTIMakePerspectiveMatrix(float left, float right, float top, float bottom, float near, float far); 15 | 16 | FOUNDATION_EXPORT simd_float4x4 MTIMakeTransformMatrixFromCATransform3D(CATransform3D transform); 17 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIVector.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVector.h 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/25. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | typedef NS_ENUM(NSInteger, MTIVectorScalarType) { 15 | MTIVectorScalarTypeFloat, 16 | MTIVectorScalarTypeInt, 17 | MTIVectorScalarTypeUInt NS_SWIFT_NAME(uint) 18 | } NS_SWIFT_NAME(MTIVector.ScalarType); 19 | 20 | @interface MTIVector : NSObject 21 | 22 | - (instancetype)init NS_UNAVAILABLE; 23 | + (instancetype)new NS_UNAVAILABLE; 24 | 25 | - (instancetype)initWithFloatValues:(const float *)values count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 26 | - (instancetype)initWithIntValues:(const int *)values count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 27 | - (instancetype)initWithUIntValues:(const uint *)values count:(NSUInteger)count NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(uintValues:count:)); 28 | 29 | + (instancetype)vectorWithFloatValues:(const float *)values count:(NSUInteger)count; 30 | + (instancetype)vectorWithIntValues:(const int *)values count:(NSUInteger)count; 31 | + (instancetype)vectorWithUIntValues:(const uint *)values count:(NSUInteger)count NS_SWIFT_NAME(init(uintValues:count:)); 32 | 33 | @property (readonly, nonatomic) MTIVectorScalarType scalarType; 34 | 35 | @property (readonly, nonatomic) NSUInteger count; 36 | 37 | + (instancetype)vectorWithX:(float)X Y:(float)Y; 38 | + (instancetype)vectorWithCGPoint:(CGPoint)point NS_SWIFT_NAME(init(value:)); 39 | + (instancetype)vectorWithCGSize:(CGSize)size NS_SWIFT_NAME(init(value:)); 40 | + (instancetype)vectorWithCGRect:(CGRect)rect NS_SWIFT_NAME(init(value:)); 41 | 42 | @property (readonly) CGPoint CGPointValue; 43 | @property (readonly) CGSize CGSizeValue; 44 | @property (readonly) CGRect CGRectValue; 45 | 46 | @end 47 | 48 | @interface MTIVector (Contents) 49 | 50 | @property (readonly) NSUInteger byteLength; 51 | 52 | - (const void *)bytes NS_RETURNS_INNER_POINTER; 53 | 54 | @end 55 | 56 | NS_ASSUME_NONNULL_END 57 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIVertex.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIStructs.h 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MTIShaderLib.h" 14 | #import "MTIGeometry.h" 15 | #import "MTIBuffer.h" 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | FOUNDATION_EXPORT MTIVertex MTIVertexMake(float x, float y, float z, float w, float u, float v) NS_SWIFT_NAME(MTIVertex.init(x:y:z:w:u:v:)); 20 | FOUNDATION_EXPORT BOOL MTIVertexEqualToVertex(MTIVertex v1, MTIVertex v2) NS_SWIFT_NAME(MTIVertex.isEqual(self:to:)); 21 | 22 | 23 | /// A MTIGeometry implementation. A MTIVertices contains MTIVertex data structures. It is designed to handle small amount of vertices. A MTIVertices bounds its contents to the vertex buffer with index of 0. The shader receives a MTIVertices' contents as `MTIVertex *`. e.g. `const device MTIVertex * vertices [[ buffer(0) ]]`. 24 | @interface MTIVertices : NSObject 25 | 26 | @property (nonatomic, readonly) NSUInteger vertexCount; 27 | 28 | @property (nonatomic, readonly) NSUInteger indexCount; 29 | 30 | @property (nonatomic, readonly) MTLPrimitiveType primitiveType; 31 | 32 | - (instancetype)init NS_UNAVAILABLE; 33 | 34 | + (instancetype)new NS_UNAVAILABLE; 35 | 36 | - (instancetype)initWithVertices:(const MTIVertex * _Nonnull)vertices 37 | count:(NSUInteger)count 38 | primitiveType:(MTLPrimitiveType)primitiveType NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT; 39 | 40 | /// Create a `MTIVertices` instance with `MTIDataBuffer` objects. The contents of the vertexBuffer must be `MTIVertex *`. Only `MTLIndexTypeUInt32` is supported, so the contents of the indexBuffer must be `uint32_t *`. 41 | - (instancetype)initWithVertexBuffer:(MTIDataBuffer *)vertexBuffer 42 | vertexCount:(NSUInteger)vertexCount 43 | indexBuffer:(nullable MTIDataBuffer *)indexBuffer 44 | indexCount:(NSUInteger)indexCount 45 | primitiveType:(MTLPrimitiveType)primitiveType NS_DESIGNATED_INITIALIZER; 46 | 47 | + (instancetype)squareVerticesForRect:(CGRect)rect; 48 | 49 | + (instancetype)verticallyFlippedSquareVerticesForRect:(CGRect)rect; 50 | 51 | @property (nonatomic, class, readonly, strong) MTIVertices *fullViewportSquareVertices; 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | 57 | 58 | @interface MTIDataBuffer (MTIVertices) 59 | 60 | + (nullable instancetype)dataBufferWithMTIVertices:(const MTIVertex * _Nonnull)vertices count:(NSUInteger)count NS_REFINED_FOR_SWIFT; 61 | 62 | + (nullable instancetype)dataBufferWithUInt32Indexes:(const uint32_t * _Nonnull)indexes count:(NSUInteger)count NS_REFINED_FOR_SWIFT; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIWeakToStrongObjectsMapTable.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIWeakToStrongMapTable.h 3 | // Pods 4 | // 5 | // Created by YuAo on 16/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// Behaves like NSMapTable with key options: NSMapTableObjectPointerPersonality|NSMapTableWeakMemory, value options: NSMapTableStrongMemory. Entries are purged right away when the weak key is reclaimed. 14 | 15 | @interface MTIWeakToStrongObjectsMapTable : NSObject 16 | 17 | - (nullable ObjectType)objectForKey:(KeyType)aKey; 18 | 19 | - (void)removeObjectForKey:(KeyType)aKey; 20 | 21 | - (void)setObject:(nullable ObjectType)anObject forKey:(KeyType)aKey; 22 | 23 | - (void)removeAllObjects; 24 | 25 | - (void)compact; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIWeakToStrongObjectsMapTable.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIWeakToStrongMapTable.m 3 | // Pods 4 | // 5 | // Created by YuAo on 16/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIWeakToStrongObjectsMapTable.h" 10 | #import 11 | 12 | NSUInteger const MTIWeakToStrongObjectsMapTableCompactThreshold = 1024 * 64; //1024 x 64 x 8 (byte size of a pointer) = 512K 13 | 14 | @interface MTIWeakToStrongObjectsMapTable () 15 | 16 | @property (nonatomic,strong,readonly) NSPointerArray *items; 17 | 18 | @property (nonatomic) NSUInteger compactableItemCount; 19 | 20 | @end 21 | 22 | @implementation MTIWeakToStrongObjectsMapTable 23 | 24 | - (void)dealloc { 25 | [self removeAllObjects]; 26 | } 27 | 28 | - (instancetype)init { 29 | if (self = [super init]) { 30 | _items = [[NSPointerArray alloc] initWithOptions:NSPointerFunctionsWeakMemory|NSPointerFunctionsObjectPointerPersonality]; 31 | } 32 | return self; 33 | } 34 | 35 | - (id)objectForKey:(id)aKey { 36 | NSParameterAssert(aKey); 37 | return objc_getAssociatedObject(aKey, (__bridge const void *)(self)); 38 | } 39 | 40 | - (void)setObject:(id)anObject forKey:(id)aKey { 41 | NSParameterAssert(aKey); 42 | 43 | //Safe to use `(__bridge const void *)(self)` here, since we'll remove all the associations on deallocation. 44 | objc_setAssociatedObject(aKey, (__bridge const void *)(self), anObject, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | if (anObject) { 46 | [_items addPointer:(__bridge void *)(aKey)]; 47 | _compactableItemCount += 1; 48 | if (_compactableItemCount >= MTIWeakToStrongObjectsMapTableCompactThreshold) { 49 | [self compact]; 50 | } 51 | } else { 52 | [self compact]; 53 | NSUInteger index = NSNotFound; 54 | NSUInteger i = 0; 55 | for (id object in _items) { 56 | if (object == aKey) { 57 | index = i; 58 | break; 59 | } 60 | i += 1; 61 | } 62 | if (index != NSNotFound) { 63 | [_items removePointerAtIndex:index]; 64 | } 65 | } 66 | } 67 | 68 | - (void)removeObjectForKey:(id)aKey { 69 | [self setObject:nil forKey:aKey]; 70 | } 71 | 72 | - (void)removeAllObjects { 73 | [self compact]; 74 | for (id key in _items) { 75 | objc_setAssociatedObject(key, (__bridge const void *)(self), nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 76 | } 77 | _items.count = 0; 78 | } 79 | 80 | - (void)compact { 81 | // http://www.openradar.me/15396578 82 | // https://stackoverflow.com/questions/31322290/nspointerarray-weird-compaction 83 | [_items addPointer:nil]; 84 | [_items compact]; 85 | _compactableItemCount = 0; 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MetalPetal.modulemap: -------------------------------------------------------------------------------- 1 | framework module MetalPetal { 2 | umbrella header "MetalPetal.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Extension { 8 | header "MTIContext+Internal.h" 9 | header "MTIImage+Promise.h" 10 | export * 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/SceneKit/MTISCNSceneRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MLARSCNCamera.h 3 | // MLARSCNCameraDemo 4 | // 5 | // 6 | 7 | #if __has_include() 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @class MTIImage; 16 | 17 | FOUNDATION_EXPORT NSString * const MTISCNSceneRendererErrorDomain; 18 | 19 | typedef NS_ERROR_ENUM(MTISCNSceneRendererErrorDomain, MTISCNSceneRendererError) { 20 | MTISCNSceneRendererErrorSceneKitDoesNotSupportMetal = 1001 21 | }; 22 | 23 | @interface MTISCNSceneRenderer : NSObject 24 | 25 | @property (nonatomic, strong, nullable) SCNScene *scene; 26 | 27 | @property (nonatomic, strong, readonly) SCNRenderer *scnRenderer; 28 | 29 | @property(nonatomic, readonly) CFTimeInterval nextFrameTime; 30 | 31 | + (instancetype)new NS_UNAVAILABLE; 32 | 33 | - (instancetype)init NS_UNAVAILABLE; 34 | 35 | - (instancetype)initWithDevice:(id)device NS_DESIGNATED_INITIALIZER; 36 | 37 | @end 38 | 39 | @interface MTISCNSceneRenderer (MTIImage) 40 | 41 | /// Create a MTImage for the scene at the specified time. The image can only be render with the MTIContext that shares the same metal device with this renderer. 42 | - (MTIImage *)snapshotAtTime:(CFTimeInterval)time 43 | viewport:(CGRect)viewport 44 | pixelFormat:(MTLPixelFormat)pixelFormat 45 | isOpaque:(BOOL)isOpaque; 46 | 47 | @end 48 | 49 | @interface MTISCNSceneRenderer (CVPixelBuffer) 50 | 51 | /// Render the scene at the specified time to a pixel buffer. The completion block will be called on an internal queue. 52 | - (BOOL)renderAtTime:(CFTimeInterval)time 53 | viewport:(CGRect)viewport 54 | completion:(void(^)(CVPixelBufferRef pixelBuffer))completion 55 | error:(NSError **)error; 56 | 57 | @end 58 | 59 | NS_ASSUME_NONNULL_END 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/UI/MTIImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImageView.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 09/10/2017. 6 | // 7 | 8 | #if __has_include() 9 | 10 | #import 11 | #import 12 | #import "MTIDrawableRendering.h" 13 | 14 | @class MTIImage,MTIContext; 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @interface MTIImageView : UIView 19 | 20 | @property (nonatomic) MTLPixelFormat colorPixelFormat; 21 | 22 | @property (nonatomic) MTLClearColor clearColor; 23 | 24 | @property (nonatomic) MTIDrawableRenderingResizingMode resizingMode; 25 | 26 | @property (nonatomic, strong) MTIContext *context; 27 | 28 | @property (nonatomic, strong, nullable) MTIImage *image; 29 | 30 | @property (nonatomic) BOOL drawsImmediately __attribute__((deprecated("Set `drawsImmediately` to `YES` is not recommended anymore. Please file an issue describing how you'd like to use this feature. https://github.com/MetalPetal/MetalPetal"))); //Default `NO`. 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/UI/MTIThreadSafeImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIAsyncImageView.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2019/6/12. 6 | // 7 | 8 | #if __has_include() 9 | 10 | #import 11 | #import "MTIDrawableRendering.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | FOUNDATION_EXPORT NSString * const MTIImageViewErrorDomain; 16 | 17 | typedef NS_ERROR_ENUM(MTIImageViewErrorDomain, MTIImageViewError) { 18 | MTIImageViewErrorContextNotFound = 1001, 19 | MTIImageViewErrorSameImage = 1002 20 | }; 21 | 22 | @class MTIImage,MTIContext; 23 | 24 | /// An image view that immediately draws its `image` on the calling thread. Most of the custom properties can be accessed from any thread safely. It's recommanded to use the `MTIImageView` which draws it's content on the main thread instead of this view. 25 | 26 | @interface MTIThreadSafeImageView : UIView 27 | 28 | @property (atomic) MTLPixelFormat colorPixelFormat; 29 | 30 | @property (atomic) MTLClearColor clearColor; 31 | 32 | @property (atomic) MTIDrawableRenderingResizingMode resizingMode; 33 | 34 | @property (atomic, strong) MTIContext *context; 35 | 36 | @property (atomic, nullable, strong) MTIImage *image; 37 | 38 | /// Update the image. `renderCompletion` will be called when the rendering is finished or failed. The callback will be called on current thread or a metal internal thread. 39 | - (void)setImage:(MTIImage * __nullable)image renderCompletion:(void (^ __nullable)(NSError * __nullable error))renderCompletion; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Pods/MetalPetal/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yu Ao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/MetalPetal-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/MetalPetal-macOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/Pods-ImageFilterSwiftUI.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/Pods-ImageFilterSwiftUIiOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MetalPetal-iOS.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | MetalPetal-macOS.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | Pods-ImageFilterSwiftUI.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | Pods-ImageFilterSwiftUIiOS.xcscheme 29 | 30 | isShown 31 | 32 | orderHint 33 | 3 34 | 35 | 36 | SuppressBuildableAutocreation 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-iOS/MetalPetal-iOS-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.9.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-iOS/MetalPetal-iOS-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MetalPetal_iOS : NSObject 3 | @end 4 | @implementation PodsDummy_MetalPetal_iOS 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-iOS/MetalPetal-iOS.modulemap: -------------------------------------------------------------------------------- 1 | framework module MetalPetal { 2 | umbrella header "MetalPetal.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Extension { 8 | header "MTIContext+Internal.h" 9 | header "MTIImage+Promise.h" 10 | export * 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-iOS/MetalPetal-iOS.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-iOS 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = $(inherited) -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MetalPetal 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-macOS/MetalPetal-macOS-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.9.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-macOS/MetalPetal-macOS-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MetalPetal_macOS : NSObject 3 | @end 4 | @implementation PodsDummy_MetalPetal_macOS 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-macOS/MetalPetal-macOS.modulemap: -------------------------------------------------------------------------------- 1 | framework module MetalPetal { 2 | umbrella header "MetalPetal.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Extension { 8 | header "MTIContext+Internal.h" 9 | header "MTIImage+Promise.h" 10 | export * 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal-macOS/MetalPetal-macOS.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-macOS 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MetalPetal 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MetalPetal 5 | 6 | MIT License 7 | 8 | Copyright (c) 2017 Yu Ao 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | Generated by CocoaPods - https://cocoapods.org 29 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | MIT License 18 | 19 | Copyright (c) 2017 Yu Ao 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | License 40 | MIT 41 | Title 42 | MetalPetal 43 | Type 44 | PSGroupSpecifier 45 | 46 | 47 | FooterText 48 | Generated by CocoaPods - https://cocoapods.org 49 | Title 50 | 51 | Type 52 | PSGroupSpecifier 53 | 54 | 55 | StringsTable 56 | Acknowledgements 57 | Title 58 | Acknowledgements 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ImageFilterSwiftUI : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ImageFilterSwiftUI 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/MetalPetal-macOS/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/MetalPetal-macOS/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ImageFilterSwiftUIVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ImageFilterSwiftUIVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-macOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-macOS/MetalPetal.framework/Headers" 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ImageFilterSwiftUI { 2 | umbrella header "Pods-ImageFilterSwiftUI-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUI/Pods-ImageFilterSwiftUI.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-macOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-macOS/MetalPetal.framework/Headers" 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MetalPetal 5 | 6 | MIT License 7 | 8 | Copyright (c) 2017 Yu Ao 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | Generated by CocoaPods - https://cocoapods.org 29 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | MIT License 18 | 19 | Copyright (c) 2017 Yu Ao 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | License 40 | MIT 41 | Title 42 | MetalPetal 43 | Type 44 | PSGroupSpecifier 45 | 46 | 47 | FooterText 48 | Generated by CocoaPods - https://cocoapods.org 49 | Title 50 | 51 | Type 52 | PSGroupSpecifier 53 | 54 | 55 | StringsTable 56 | Acknowledgements 57 | Title 58 | Acknowledgements 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ImageFilterSwiftUIiOS : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ImageFilterSwiftUIiOS 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/MetalPetal-iOS/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/MetalPetal-iOS/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MetalPetal.framework -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ImageFilterSwiftUIiOSVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ImageFilterSwiftUIiOSVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-iOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-iOS/MetalPetal.framework/Headers" 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ImageFilterSwiftUIiOS { 2 | umbrella header "Pods-ImageFilterSwiftUIiOS-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ImageFilterSwiftUIiOS/Pods-ImageFilterSwiftUIiOS.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-iOS" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal-iOS/MetalPetal.framework/Headers" 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" -weak_framework "MetalKit" -weak_framework "MetalPerformanceShaders" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Completed Project for Cross Platform Image Filter SwiftUI macOS & iOS App 2 | 3 | ![Alt text](./promo.jpg?raw=true "Cross Platform Image Filter SwiftUI macOS & iOS App") 4 | 5 | Follow the tutorial at [alfianlosari.com](https://alfianlosari.com "Alfian Losari") 6 | 7 | ## Features 8 | - Filter image using predefined filters from the MetalPetal Swift library. 9 | - Select input image using macOS file panel and iOS UIImagePickerController. 10 | - Drag & Drop input image using SwiftUI View modifier in macOS 11 | - Save the filtered image using macOS file panel and iOS UIActivityViewController 12 | - Shared models and service code between targets 13 | 14 | ## Requirements 15 | - Xcode 11.3 16 | - macOS 10.15 Catalina 17 | 18 | ## Getting Started 19 | - Clone or download 20 | - Run pod install 21 | - Build and Run 22 | -------------------------------------------------------------------------------- /promo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfianlosari/ImageFilterSwiftUICompleted/2d9f26a642e417484635c39b49bb84fc6c74747a/promo.jpg --------------------------------------------------------------------------------