├── .gitignore ├── LICENSE ├── LUTConverter.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── LUTConverter.xcworkspace └── contents.xcworkspacedata ├── LUTConverter ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── AppIcon 2 2.png │ │ ├── AppIcon 2-1.png │ │ ├── AppIcon 2-2.png │ │ ├── AppIcon 2-3.png │ │ ├── AppIcon 2-4.png │ │ ├── AppIcon 2-5.png │ │ ├── AppIcon 2-6.png │ │ ├── AppIcon 2-7.png │ │ ├── AppIcon 2.png │ │ ├── AppIcon.png │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── DropDestinationView.swift ├── Info.plist ├── LUTConverter.entitlements └── MainViewController.swift ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── MetalPetal │ ├── Frameworks │ │ └── MetalPetal │ │ │ ├── Filters │ │ │ ├── MTIAlphaPremultiplicationFilter.h │ │ │ ├── MTIAlphaPremultiplicationFilter.m │ │ │ ├── MTIBlendFilter.h │ │ │ ├── MTIBlendFilter.m │ │ │ ├── MTIBlendWithMaskFilter.h │ │ │ ├── MTIBlendWithMaskFilter.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 │ │ │ ├── MTIFilter.swift │ │ │ ├── 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 │ │ │ ├── MTIRGBToneCurveFilter.h │ │ │ ├── MTIRGBToneCurveFilter.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 │ │ │ ├── MTIAlphaType.swift │ │ │ ├── MTIBlendModes.h │ │ │ ├── MTIBlendModes.m │ │ │ ├── MTICVMetalTextureBridge.h │ │ │ ├── MTICVMetalTextureBridge.m │ │ │ ├── MTICVMetalTextureBridging.h │ │ │ ├── MTICVMetalTextureCache.h │ │ │ ├── MTICVMetalTextureCache.m │ │ │ ├── MTICVPixelBufferPromise.h │ │ │ ├── MTICVPixelBufferPromise.m │ │ │ ├── MTICVPixelBufferRendering.h │ │ │ ├── MTICVPixelBufferRendering.m │ │ │ ├── MTIColor.h │ │ │ ├── MTIColor.m │ │ │ ├── MTIColorMatrix.h │ │ │ ├── MTIColorMatrix.m │ │ │ ├── MTIColorMatrix.swift │ │ │ ├── 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 │ │ │ ├── MTIImage+Promise.h │ │ │ ├── MTIImage.h │ │ │ ├── MTIImage.m │ │ │ ├── MTIImageOrientation.h │ │ │ ├── MTIImageOrientation.m │ │ │ ├── MTIImagePromise.h │ │ │ ├── MTIImagePromise.m │ │ │ ├── MTIImagePromiseDebug.h │ │ │ ├── MTIImagePromiseDebug.m │ │ │ ├── MTIImageProperties.h │ │ │ ├── MTIImageProperties.m │ │ │ ├── MTIImageRenderingContext.h │ │ │ ├── MTIImageRenderingContext.m │ │ │ ├── MTILayer.h │ │ │ ├── MTILayer.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 │ │ │ ├── MTITextureDimensions.swift │ │ │ ├── MTITexturePool.h │ │ │ ├── MTITexturePool.m │ │ │ ├── MTITransform.h │ │ │ ├── MTITransform.m │ │ │ ├── MTIVector+SIMD.h │ │ │ ├── MTIVector+SIMD.m │ │ │ ├── MTIVector.h │ │ │ ├── MTIVector.m │ │ │ ├── MTIVector.swift │ │ │ ├── MTIVertex.h │ │ │ ├── MTIVertex.m │ │ │ ├── MTIVertex.swift │ │ │ ├── MTIWeakToStrongObjectsMapTable.h │ │ │ ├── MTIWeakToStrongObjectsMapTable.m │ │ │ ├── MTKTextureLoaderExtensions.h │ │ │ ├── MTKTextureLoaderExtensions.m │ │ │ ├── MetalPetal.h │ │ │ ├── MetalPetal.modulemap │ │ │ ├── Shaders │ │ │ ├── BlendingShaders.metal │ │ │ ├── CLAHE.metal │ │ │ ├── ColorConversionShaders.metal │ │ │ ├── Halftone.metal │ │ │ ├── HighPassSkinSmoothing.metal │ │ │ ├── LensBlur.metal │ │ │ ├── MTIShaderLib.h │ │ │ ├── MultilayerCompositeShaders.metal │ │ │ └── Shaders.metal │ │ │ └── UI │ │ │ ├── MTIImageView.h │ │ │ └── MTIImageView.m │ ├── LICENSE │ └── README.md ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── MetalPetal │ ├── MetalPetal-Info.plist │ ├── MetalPetal-dummy.m │ ├── MetalPetal-prefix.pch │ ├── MetalPetal.modulemap │ └── MetalPetal.xcconfig │ └── Pods-LUTConverter │ ├── Pods-LUTConverter-Info.plist │ ├── Pods-LUTConverter-acknowledgements.markdown │ ├── Pods-LUTConverter-acknowledgements.plist │ ├── Pods-LUTConverter-dummy.m │ ├── Pods-LUTConverter-frameworks.sh │ ├── Pods-LUTConverter-umbrella.h │ ├── Pods-LUTConverter.debug.xcconfig │ ├── Pods-LUTConverter.modulemap │ └── Pods-LUTConverter.release.xcconfig └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Xcode 4 | # 5 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 6 | 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | xcshareddata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xccheckout 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | # CocoaPods 35 | # 36 | # We recommend against adding the Pods directory to your .gitignore. However 37 | # you should judge for yourself, the pros and cons are mentioned at: 38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 39 | # 40 | # Pods/ 41 | 42 | # Carthage 43 | # 44 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 45 | # Carthage/Checkouts 46 | 47 | Carthage/Build 48 | 49 | # fastlane 50 | # 51 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 52 | # screenshots whenever they are needed. 53 | # For more information about the recommended setup visit: 54 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 55 | 56 | fastlane/report.xml 57 | fastlane/Preview.html 58 | fastlane/screenshots 59 | fastlane/test_output 60 | 61 | # Code Injection 62 | # 63 | # After new code Injection tools there's a generated folder /iOSInjectionProject 64 | # https://github.com/johnno1962/injectionforxcode 65 | 66 | iOSInjectionProject/ 67 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 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 | -------------------------------------------------------------------------------- /LUTConverter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LUTConverter.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LUTConverter/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LUTConverter 4 | // 5 | // Created by Yu Ao on 2018/10/12. 6 | // Copyright © 2018 Meteor. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 25 | return true 26 | } 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2 2.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-1.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-2.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-3.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-4.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-5.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-6.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2-7.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon 2.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/ColorLookupTable2Cube/81ecdc0110c0bf179be3a09aa4b040b97f2f087c/LUTConverter/Assets.xcassets/AppIcon.appiconset/AppIcon.png -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "AppIcon 2-7.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "AppIcon 2-6.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "AppIcon 2-5.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "AppIcon 2-4.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "AppIcon 2-3.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "AppIcon 2-2.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "AppIcon 2-1.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "AppIcon 2 2.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "AppIcon 2.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "AppIcon.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /LUTConverter/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /LUTConverter/DropDestinationView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DropDestinationView'.swift 3 | // CameraX-macOS 4 | // 5 | // Created by Yu Ao on 2018/4/28. 6 | // Copyright © 2018 Meteor. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AppKit 11 | 12 | class DropDestinationView: NSView { 13 | 14 | var draggingAcceptedHandler: (([URL]) -> Void)? 15 | 16 | var draggingAcceptanceStateChangedHandler: ((_ accept: Bool) -> Void)? 17 | 18 | var allowsDrop: Bool = false 19 | 20 | override init(frame frameRect: NSRect) { 21 | super.init(frame: frameRect) 22 | self.setupDropDestinationView() 23 | } 24 | 25 | required init?(coder: NSCoder) { 26 | super.init(coder: coder) 27 | self.setupDropDestinationView() 28 | } 29 | 30 | private func setupDropDestinationView() { 31 | self.registerForDraggedTypes([.fileURL]) 32 | } 33 | 34 | private static func readableFileURLsFromPasteboard(_ pasteboard: NSPasteboard) -> [URL] { 35 | var readableFileURLs = [URL]() 36 | for item in pasteboard.pasteboardItems ?? [] { 37 | if item.types.contains(.fileURL) { 38 | if let filePath = pasteboard.propertyList(forType: .fileURL) as? String { 39 | if let url = URL(string: filePath) { 40 | readableFileURLs.append(url) 41 | } 42 | } 43 | } 44 | } 45 | return readableFileURLs 46 | } 47 | 48 | override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation { 49 | if !self.allowsDrop { 50 | return [] 51 | } 52 | if let types = sender.draggingPasteboard.types { 53 | if types.contains(.fileURL) { 54 | let validItemCount = DropDestinationView.readableFileURLsFromPasteboard(sender.draggingPasteboard).count 55 | if validItemCount > 0 { 56 | sender.numberOfValidItemsForDrop = validItemCount 57 | self.draggingAcceptanceStateChangedHandler?(true) 58 | return .copy 59 | } 60 | } 61 | } 62 | return [] 63 | } 64 | 65 | override func updateDraggingItemsForDrag(_ sender: NSDraggingInfo?) { 66 | if let sender = sender, let types = sender.draggingPasteboard.types { 67 | if types.contains(.fileURL) { 68 | sender.enumerateDraggingItems(options: [.concurrent, .clearNonenumeratedImages], for: self, classes: [NSURL.self], searchOptions: [:], using: { (item, index, stop) in 69 | 70 | }) 71 | } 72 | } 73 | } 74 | 75 | override func draggingExited(_ sender: NSDraggingInfo?) { 76 | self.draggingAcceptanceStateChangedHandler?(false) 77 | } 78 | 79 | override func performDragOperation(_ sender: NSDraggingInfo) -> Bool { 80 | if let types = sender.draggingPasteboard.types { 81 | if types.contains(.fileURL) { 82 | let URLs = DropDestinationView.readableFileURLsFromPasteboard(sender.draggingPasteboard) 83 | if URLs.count > 0 { 84 | self.draggingAcceptedHandler?(URLs) 85 | return true 86 | } 87 | } 88 | } 89 | return false 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /LUTConverter/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 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2018 Meteor. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /LUTConverter/LUTConverter.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 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'LUTConverter' do 5 | 6 | use_frameworks! 7 | 8 | pod 'MetalPetal/Swift' 9 | 10 | end 11 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MetalPetal/Core (0.9.4) 3 | - MetalPetal/Swift (0.9.4): 4 | - MetalPetal/Core 5 | 6 | DEPENDENCIES: 7 | - MetalPetal/Swift 8 | 9 | SPEC REPOS: 10 | https://github.com/cocoapods/specs.git: 11 | - MetalPetal 12 | 13 | SPEC CHECKSUMS: 14 | MetalPetal: 048321fecc223f87291fb08ffe03f6b07b735a0f 15 | 16 | PODFILE CHECKSUM: a7f8fc8dbc06b9b7fa1d961b0aa4f8dc326b634a 17 | 18 | COCOAPODS: 1.6.0.beta.1 19 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MetalPetal/Core (0.9.4) 3 | - MetalPetal/Swift (0.9.4): 4 | - MetalPetal/Core 5 | 6 | DEPENDENCIES: 7 | - MetalPetal/Swift 8 | 9 | SPEC REPOS: 10 | https://github.com/cocoapods/specs.git: 11 | - MetalPetal 12 | 13 | SPEC CHECKSUMS: 14 | MetalPetal: 048321fecc223f87291fb08ffe03f6b07b735a0f 15 | 16 | PODFILE CHECKSUM: a7f8fc8dbc06b9b7fa1d961b0aa4f8dc326b634a 17 | 18 | COCOAPODS: 1.6.0.beta.1 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 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIAlphaPremultiplicationFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIUnpremultiplyAlphaFilter.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #import "MTIAlphaPremultiplicationFilter.h" 9 | #import "MTIRenderPipelineKernel.h" 10 | #import "MTIFunctionDescriptor.h" 11 | #import "MTIImage.h" 12 | 13 | @implementation MTIPremultiplyAlphaFilter 14 | 15 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 16 | return [[MTIFunctionDescriptor alloc] initWithName:MTIFilterPremultiplyAlphaFragmentFunctionName]; 17 | } 18 | 19 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image { 20 | if (image.alphaType == MTIAlphaTypeAlphaIsOne || image.alphaType == MTIAlphaTypePremultiplied) { 21 | return image; 22 | } 23 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified]; 24 | } 25 | 26 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 27 | return [[MTIAlphaTypeHandlingRule alloc] initWithAcceptableAlphaTypes:@[@(MTIAlphaTypeNonPremultiplied)] outputAlphaType:MTIAlphaTypePremultiplied]; 28 | } 29 | 30 | - (MTIImage *)outputImage { 31 | if (self.inputImage.alphaType == MTIAlphaTypeAlphaIsOne || self.inputImage.alphaType == MTIAlphaTypePremultiplied) { 32 | return self.inputImage; 33 | } 34 | return [super outputImage]; 35 | } 36 | 37 | @end 38 | 39 | @implementation MTIUnpremultiplyAlphaFilter 40 | 41 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 42 | return [[MTIFunctionDescriptor alloc] initWithName:MTIFilterUnpremultiplyAlphaFragmentFunctionName]; 43 | } 44 | 45 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image { 46 | if (image.alphaType == MTIAlphaTypeAlphaIsOne || image.alphaType == MTIAlphaTypeNonPremultiplied) { 47 | return image; 48 | } 49 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified]; 50 | } 51 | 52 | + (MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule { 53 | return [[MTIAlphaTypeHandlingRule alloc] initWithAcceptableAlphaTypes:@[@(MTIAlphaTypePremultiplied)] outputAlphaType:MTIAlphaTypeNonPremultiplied]; 54 | } 55 | 56 | - (MTIImage *)outputImage { 57 | if (self.inputImage.alphaType == MTIAlphaTypeAlphaIsOne || self.inputImage.alphaType == MTIAlphaTypeNonPremultiplied) { 58 | return self.inputImage; 59 | } 60 | return [super outputImage]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /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/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": @(self.scale), 32 | @"angles": [MTIVector vectorWithFloat4:self.angles], 33 | @"singleAngleMode": @(allAnglesAreEqual)}; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /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/MTIColorMatrixFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorMatrixFilter.m 3 | // Pods 4 | // 5 | // Created by yi chen on 2017/7/27. 6 | // 7 | // 8 | 9 | #import "MTIColorMatrixFilter.h" 10 | #import "MTIFunctionDescriptor.h" 11 | #import "MTIImage.h" 12 | #import "MTIKernel.h" 13 | #import "MTIRenderPipelineKernel.h" 14 | 15 | NSString * const MTIColorMatrixFilterColorMatrixParameterKey = @"colorMatrix"; 16 | 17 | @implementation MTIColorMatrixFilter 18 | 19 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor { 20 | return [[MTIFunctionDescriptor alloc] initWithName:MTIFilterColorMatrixFragmentFunctionName]; 21 | } 22 | 23 | - (instancetype)init { 24 | if (self = [super init]) { 25 | self.colorMatrix = MTIColorMatrixIdentity; 26 | } 27 | return self; 28 | } 29 | 30 | - (NSDictionary *)parameters { 31 | return @{MTIColorMatrixFilterColorMatrixParameterKey: [NSData dataWithBytes:&_colorMatrix length:sizeof(MTIColorMatrix)]}; 32 | } 33 | 34 | @end 35 | 36 | @implementation MTIExposureFilter 37 | 38 | - (void)setExposure:(float)exposure { 39 | _exposure = exposure; 40 | [super setColorMatrix:MTIColorMatrixMakeWithExposure(exposure)]; 41 | } 42 | 43 | @end 44 | 45 | @implementation MTISaturationFilter 46 | 47 | - (instancetype)init { 48 | if (self = [super init]) { 49 | self.grayColorTransform = MTIGrayColorTransformDefault; 50 | self.saturation = 1; 51 | } 52 | return self; 53 | } 54 | 55 | - (void)setSaturation:(float)saturation { 56 | _saturation = saturation; 57 | [super setColorMatrix:MTIColorMatrixMakeWithSaturation(self.saturation,self.grayColorTransform)]; 58 | } 59 | 60 | - (void)setGrayColorTransform:(simd_float3)grayColorTransform { 61 | _grayColorTransform = grayColorTransform; 62 | [super setColorMatrix:MTIColorMatrixMakeWithSaturation(self.saturation,self.grayColorTransform)]; 63 | } 64 | 65 | @end 66 | 67 | @implementation MTIColorInvertFilter 68 | 69 | - (instancetype)init { 70 | if (self = [super init]) { 71 | [super setColorMatrix:MTIColorMatrixRGBColorInvert]; 72 | } 73 | return self; 74 | } 75 | 76 | @end 77 | 78 | @implementation MTIOpacityFilter 79 | 80 | - (instancetype)init { 81 | if (self = [super init]) { 82 | self.opacity = 1; 83 | } 84 | return self; 85 | } 86 | 87 | - (void)setOpacity:(float)opacity { 88 | _opacity = opacity; 89 | [super setColorMatrix:MTIColorMatrixMakeWithOpacity(opacity)]; 90 | } 91 | 92 | @end 93 | 94 | @implementation MTIBrightnessFilter 95 | 96 | - (void)setBrightness:(float)brightness { 97 | _brightness = brightness; 98 | [super setColorMatrix:MTIColorMatrixMakeWithBrightness(brightness)]; 99 | } 100 | 101 | @end 102 | 103 | @implementation MTIContrastFilter 104 | 105 | - (instancetype)init { 106 | if (self = [super init]) { 107 | self.contrast = 1; 108 | } 109 | return self; 110 | } 111 | 112 | - (void)setContrast:(float)contrast { 113 | _contrast = contrast; 114 | [super setColorMatrix:MTIColorMatrixMakeWithContrast(contrast)]; 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /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": @(self.scale), 31 | @"grayColorTransform": [MTIVector vectorWithFloat3:self.grayColorTransform]}; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /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 MTIFilterPremultiplyAlphaFragmentFunctionName; 20 | 21 | FOUNDATION_EXPORT NSString * const MTIFilterColorMatrixFragmentFunctionName; 22 | 23 | @class MTIImage; 24 | 25 | @protocol MTIFilter 26 | 27 | @property (nonatomic) MTLPixelFormat outputPixelFormat; //Default: MTIPixelFormatUnspecified aka MTLPixelFormatInvalid 28 | 29 | @property (nonatomic, readonly, nullable) MTIImage *outputImage; 30 | 31 | @end 32 | 33 | @protocol MTIUnaryFilter 34 | 35 | @property (nonatomic, strong, nullable) MTIImage *inputImage; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /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 MTIFilterPremultiplyAlphaFragmentFunctionName = @"premultiplyAlpha"; 19 | 20 | NSString * const MTIFilterColorMatrixFragmentFunctionName = @"colorMatrixProjection"; 21 | 22 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilter.swift 3 | // Pods 4 | // 5 | // Created by YuAo on 22/09/2017. 6 | // 7 | 8 | import Foundation 9 | 10 | extension MTIFilter { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /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 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /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:self.cachePolicy]; 16 | } 17 | 18 | - (MTIImage *)imageByPremultiplyingAlpha { 19 | return [[MTIPremultiplyAlphaFilter imageByProcessingImage:self] imageWithCachePolicy:self.cachePolicy]; 20 | } 21 | 22 | - (MTIImage *)imageByApplyingCGOrientation:(CGImagePropertyOrientation)orientation { 23 | MTIImageOrientation imageOrientation; 24 | switch (orientation) { 25 | case kCGImagePropertyOrientationUp: 26 | imageOrientation = MTIImageOrientationUp; 27 | break; 28 | case kCGImagePropertyOrientationDown: 29 | imageOrientation = MTIImageOrientationDown; 30 | break; 31 | case kCGImagePropertyOrientationLeft: 32 | imageOrientation = MTIImageOrientationRight; 33 | break; 34 | case kCGImagePropertyOrientationRight: 35 | imageOrientation = MTIImageOrientationLeft; 36 | break; 37 | case kCGImagePropertyOrientationUpMirrored: 38 | imageOrientation = MTIImageOrientationUpMirrored; 39 | break; 40 | case kCGImagePropertyOrientationDownMirrored: 41 | imageOrientation = MTIImageOrientationDownMirrored; 42 | break; 43 | case kCGImagePropertyOrientationLeftMirrored: 44 | imageOrientation = MTIImageOrientationRightMirrored; 45 | break; 46 | case kCGImagePropertyOrientationRightMirrored: 47 | imageOrientation = MTIImageOrientationLeftMirrored; 48 | break; 49 | default: 50 | imageOrientation = MTIImageOrientationUnknown; 51 | break; 52 | } 53 | return [[MTIUnaryImageRenderingFilter imageByProcessingImage:self orientation:imageOrientation parameters:@{} outputPixelFormat:MTIPixelFormatUnspecified] imageWithCachePolicy:self.cachePolicy]; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /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/MTIMPSConvolutionFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIMPSImageConvolution.m 3 | // Pods 4 | // 5 | // Created by shuyj on 2017/8/14. 6 | // 7 | // 8 | 9 | #import "MTIMPSConvolutionFilter.h" 10 | #import "MTIMPSKernel.h" 11 | #import "MTIImage.h" 12 | 13 | @interface MTIMPSImageConvolutionSettings : NSObject 14 | 15 | @property (nonatomic,readonly) NSUInteger kernelWidth; 16 | @property (nonatomic,readonly) NSUInteger kernelHeight; 17 | 18 | @property (nonatomic,copy,readonly) NSData *weights; 19 | 20 | @end 21 | 22 | @implementation MTIMPSImageConvolutionSettings 23 | 24 | - (instancetype)initWithKernelWidth:(NSUInteger)kernelWidth kernelHeight:(NSUInteger)kernelHeight weights:(const float *)kernelWeights { 25 | if (self = [super init]) { 26 | NSParameterAssert(kernelWidth); 27 | NSParameterAssert(kernelHeight); 28 | NSParameterAssert(kernelWeights); 29 | _kernelWidth = kernelWidth; 30 | _kernelHeight = kernelHeight; 31 | _weights = [NSData dataWithBytes:kernelWeights length:kernelWidth * kernelHeight * sizeof(float)]; 32 | } 33 | return self; 34 | } 35 | 36 | - (id)copyWithZone:(NSZone *)zone { 37 | return self; 38 | } 39 | 40 | - (BOOL)isEqual:(id)object { 41 | if (self == object) { 42 | return YES; 43 | } 44 | if ([object isKindOfClass:[MTIMPSImageConvolutionSettings class]]) { 45 | MTIMPSImageConvolutionSettings *settings = object; 46 | return [self.weights isEqualToData:settings.weights] && self.kernelWidth == settings.kernelWidth && self.kernelHeight == settings.kernelHeight; 47 | } 48 | return NO; 49 | } 50 | 51 | - (NSUInteger)hash { 52 | return self.weights.hash ^ self.kernelWidth ^ self.kernelHeight; 53 | } 54 | 55 | @end 56 | 57 | @interface MTIMPSConvolutionFilter () 58 | 59 | @property (nonatomic, copy, readonly) MTIMPSImageConvolutionSettings *settings; 60 | 61 | @property (nonatomic, strong, readonly) MTIMPSKernel *kernel; 62 | 63 | @end 64 | 65 | @implementation MTIMPSConvolutionFilter 66 | @synthesize outputPixelFormat = _outputPixelFormat; 67 | @synthesize inputImage = _inputImage; 68 | 69 | - (instancetype)initWithKernelWidth:(NSUInteger)kernelWidth kernelHeight:(NSUInteger)kernelHeight weights:(const float *)kernelWeights { 70 | if (self = [super init]) { 71 | _settings = [[MTIMPSImageConvolutionSettings alloc] initWithKernelWidth:kernelWidth kernelHeight:kernelHeight weights:kernelWeights]; 72 | _kernel = [MTIMPSConvolutionFilter kernelWithSettings:_settings]; 73 | _bias = 0; 74 | } 75 | return self; 76 | } 77 | 78 | + (MTIMPSKernel *)kernelWithSettings:(MTIMPSImageConvolutionSettings *)settings { 79 | static NSMutableDictionary *kernels; 80 | static NSLock *kernelsLock; 81 | static dispatch_once_t onceToken; 82 | dispatch_once(&onceToken, ^{ 83 | kernels = [NSMutableDictionary dictionary]; 84 | kernelsLock = [[NSLock alloc] init]; 85 | }); 86 | [kernelsLock lock]; 87 | MTIMPSKernel *kernel = kernels[settings]; 88 | if (!kernel) { 89 | kernel = [[MTIMPSKernel alloc] initWithMPSKernelBuilder:^MPSKernel * _Nonnull(id _Nonnull device) { 90 | return [[MPSImageConvolution alloc] initWithDevice:device kernelWidth:settings.kernelWidth kernelHeight:settings.kernelHeight weights:settings.weights.bytes]; 91 | }]; 92 | kernels[settings] = kernel; 93 | } 94 | [kernelsLock unlock]; 95 | return kernel; 96 | } 97 | 98 | - (MTIImage *)outputImage { 99 | if (!self.inputImage) { 100 | return nil; 101 | } 102 | return [self.kernel applyToInputImages:@[self.inputImage] 103 | parameters:@{NSStringFromSelector(@selector(bias)): @(self.bias)} 104 | outputTextureDimensions:MTITextureDimensionsMake2DFromCGSize(self.inputImage.size) 105 | outputPixelFormat:_outputPixelFormat]; 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /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 | - (MTIImage *)outputImage { 37 | if (!self.inputImage) { 38 | return nil; 39 | } 40 | 41 | if (self.intensity <= 0) { 42 | return self.inputImage; 43 | } 44 | 45 | self.blurFilter.radius = self.inputImage.size.width / 1024.0 * 32.0; 46 | self.blurFilter.inputImage = self.inputImage; 47 | MTIImage *blurredImage = self.blurFilter.outputImage; 48 | 49 | return [MTIMPSDefinitionFilter.kernel applyToInputImages:@[self.inputImage, blurredImage] 50 | parameters:@{@"intensity": @(self.intensity)} 51 | outputTextureDimensions:self.inputImage.dimensions 52 | outputPixelFormat:self.outputPixelFormat]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /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 | - (MTIImage *)outputImage { 48 | if (!self.inputImage) { 49 | return nil; 50 | } 51 | self.gaussianBlurFilter.outputPixelFormat = self.outputPixelFormat; 52 | self.gaussianBlurFilter.inputImage = self.inputImage; 53 | self.gaussianBlurFilter.radius = self.radius; 54 | MTIImage *blurImage = self.gaussianBlurFilter.outputImage; 55 | if (!blurImage) { 56 | return nil; 57 | } 58 | return [[[self class] kernel] applyToInputImages:@[self.inputImage, blurImage] 59 | parameters:@{@"scale": @(self.scale), @"threshold": @(self.threshold)} 60 | outputTextureDimensions: MTITextureDimensionsMake2DFromCGSize(self.inputImage.size) 61 | outputPixelFormat:_outputPixelFormat]; 62 | 63 | return nil; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /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 | API_UNAVAILABLE(macos) 14 | @interface MTIMultilayerCompositingFilter : NSObject 15 | 16 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage; 17 | 18 | @property (nonatomic, copy) NSArray *layers; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /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:self.scale]}; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /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/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 | @end 42 | -------------------------------------------------------------------------------- /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 MTIComputePipelineKernel : NSObject 19 | 20 | - (instancetype)init NS_UNAVAILABLE; 21 | 22 | + (instancetype)new NS_UNAVAILABLE; 23 | 24 | @property (nonatomic,copy,readonly) MTIAlphaTypeHandlingRule *alphaTypeHandlingRule; 25 | 26 | @property (nonatomic, copy, readonly) MTIFunctionDescriptor *computeFunctionDescriptor; 27 | 28 | - (instancetype)initWithComputeFunctionDescriptor:(MTIFunctionDescriptor *)computeFunctionDescriptor; 29 | 30 | - (instancetype)initWithComputeFunctionDescriptor:(MTIFunctionDescriptor *)computeFunctionDescriptor alphaTypeHandlingRule:(MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule NS_DESIGNATED_INITIALIZER; 31 | 32 | - (MTIImage *)applyToInputImages:(NSArray *)images 33 | parameters:(NSDictionary *)parameters 34 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 35 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /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/MTIKernel.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIKernel.m 3 | // Pods 4 | // 5 | // Created by YuAo on 02/07/2017. 6 | // 7 | // 8 | 9 | #import "MTIKernel.h" 10 | #import "MTIDefer.h" 11 | #import "MTIVector.h" 12 | #import "MTIError.h" 13 | 14 | @implementation MTIArgumentsEncoder 15 | 16 | + (BOOL)encodeArguments:(NSArray *)arguments values:(NSDictionary *)parameters functionType:(MTLFunctionType)functionType encoder:(id)encoder error:(NSError * _Nullable __autoreleasing *)inOutError { 17 | 18 | void (^encodeBytes)(const void * bytes, NSUInteger length, NSUInteger index) = ^(const void * bytes, NSUInteger length, NSUInteger index) { 19 | switch (functionType) { 20 | case MTLFunctionTypeFragment: 21 | if ([encoder conformsToProtocol:@protocol(MTLRenderCommandEncoder)]) { 22 | [(id)encoder setFragmentBytes:bytes length:length atIndex:index]; 23 | } 24 | break; 25 | case MTLFunctionTypeVertex: 26 | if ([encoder conformsToProtocol:@protocol(MTLRenderCommandEncoder)]) { 27 | [(id)encoder setVertexBytes:bytes length:length atIndex:index]; 28 | } 29 | break; 30 | case MTLFunctionTypeKernel: 31 | if ([encoder conformsToProtocol:@protocol(MTLComputeCommandEncoder)]) { 32 | [(id)encoder setBytes:bytes length:length atIndex:index]; 33 | } else if ([encoder conformsToProtocol:@protocol(MTLRenderCommandEncoder)]) { 34 | #if TARGET_OS_IPHONE 35 | if (@available(iOS 11.0, *)) { 36 | [(id)encoder setTileBytes:bytes length:length atIndex:index]; 37 | } 38 | #endif 39 | } 40 | break; 41 | default: 42 | break; 43 | } 44 | }; 45 | 46 | for (MTLArgument *argument in arguments) { 47 | if (argument.type != MTLArgumentTypeBuffer) { 48 | continue; 49 | } 50 | id value = parameters[argument.name]; 51 | if (value) { 52 | if ([value isKindOfClass:[NSValue class]]) { 53 | NSValue *nsValue = (NSValue *)value; 54 | NSUInteger size; 55 | NSGetSizeAndAlignment(nsValue.objCType, &size, NULL); 56 | void *valuePtr = malloc(size); 57 | [nsValue getValue:valuePtr]; 58 | @MTI_DEFER { 59 | free(valuePtr); 60 | }; 61 | if (argument.bufferDataSize != size) { 62 | if (inOutError != nil) { 63 | *inOutError = MTIErrorCreate(MTIErrorDataBufferSizeMismatch, (@{@"Argument": argument, @"Value": value})); 64 | } 65 | return NO; 66 | } 67 | encodeBytes(valuePtr, size, argument.index); 68 | }else if ([value isKindOfClass:[NSData class]]) { 69 | NSData *data = (NSData *)value; 70 | encodeBytes(data.bytes, data.length, argument.index); 71 | }else if ([value isKindOfClass:[MTIVector class]]) { 72 | MTIVector *vector = (MTIVector *)value; 73 | encodeBytes(vector.bytes, vector.byteLength, argument.index); 74 | }else { 75 | if (inOutError != nil) { 76 | *inOutError = MTIErrorCreate(MTIErrorParameterDataTypeNotSupported, (@{@"Argument": argument, @"Value": value})); 77 | } 78 | return NO; 79 | } 80 | } 81 | } 82 | 83 | return YES; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /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 | 10 | @implementation MTIRenderCommand 11 | 12 | - (instancetype)initWithKernel:(MTIRenderPipelineKernel *)kernel geometry:(id)geometry images:(NSArray *)images parameters:(NSDictionary *)parameters { 13 | if (self = [super init]) { 14 | NSParameterAssert(kernel); 15 | NSParameterAssert(images); 16 | NSParameterAssert(parameters); 17 | NSParameterAssert(geometry); 18 | _kernel = kernel; 19 | _geometry = [geometry copyWithZone:nil]; 20 | _images = [images copy]; 21 | _parameters = [parameters copy]; 22 | } 23 | return self; 24 | } 25 | 26 | - (id)copyWithZone:(NSZone *)zone { 27 | return self; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIRenderPipelineKernel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineKernel.h 3 | // Pods 4 | // 5 | // Created by YuAo on 02/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MTIKernel.h" 12 | #import "MTIVertex.h" 13 | #import "MTIAlphaType.h" 14 | #import "MTIImagePromise.h" 15 | #import "MTIRenderCommand.h" 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | @class MTIRenderPipeline, MTIFunctionDescriptor, MTIContext, MTIImage, MTIRenderPassOutputDescriptor; 20 | 21 | FOUNDATION_EXPORT NSUInteger const MTIRenderPipelineMaximumColorAttachmentCount; 22 | 23 | @interface MTIRenderPipelineKernelConfiguration: NSObject 24 | 25 | @property (nonatomic, readonly) const MTLPixelFormat *colorAttachmentPixelFormats; 26 | 27 | @property (nonatomic, readonly) NSUInteger colorAttachmentCount; 28 | 29 | - (instancetype)initWithColorAttachmentPixelFormats:(MTLPixelFormat[_Nonnull])colorAttachmentPixelFormats count:(NSUInteger)count; 30 | 31 | - (instancetype)initWithColorAttachmentPixelFormat:(MTLPixelFormat)colorAttachmentPixelFormat; 32 | 33 | @end 34 | 35 | @interface MTIRenderPipelineKernel : NSObject 36 | 37 | @property (nonatomic,copy,readonly) MTIFunctionDescriptor *vertexFunctionDescriptor; 38 | 39 | @property (nonatomic,copy,readonly) MTIFunctionDescriptor *fragmentFunctionDescriptor; 40 | 41 | @property (nonatomic,copy,readonly,nullable) MTLVertexDescriptor *vertexDescriptor; 42 | 43 | - (instancetype)init NS_UNAVAILABLE; 44 | 45 | + (instancetype)new NS_UNAVAILABLE; 46 | 47 | @property (nonatomic,readonly) NSUInteger colorAttachmentCount; 48 | 49 | @property (nonatomic,copy,readonly) MTIAlphaTypeHandlingRule *alphaTypeHandlingRule; 50 | 51 | - (instancetype)initWithVertexFunctionDescriptor:(MTIFunctionDescriptor *)vertexFunctionDescriptor 52 | fragmentFunctionDescriptor:(MTIFunctionDescriptor *)fragmentFunctionDescriptor 53 | vertexDescriptor:(nullable MTLVertexDescriptor *)vertexDescriptor 54 | colorAttachmentCount:(NSUInteger)colorAttachmentCount 55 | alphaTypeHandlingRule:(MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule NS_DESIGNATED_INITIALIZER; 56 | 57 | - (instancetype)initWithVertexFunctionDescriptor:(MTIFunctionDescriptor *)vertexFunctionDescriptor 58 | fragmentFunctionDescriptor:(MTIFunctionDescriptor *)fragmentFunctionDescriptor; 59 | 60 | @end 61 | 62 | @interface MTIRenderPipelineKernel (ImageCreation) 63 | 64 | - (MTIImage *)applyToInputImages:(NSArray *)images 65 | parameters:(NSDictionary *)parameters 66 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions 67 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat; 68 | 69 | - (NSArray *)applyToInputImages:(NSArray *)images 70 | parameters:(NSDictionary *)parameters 71 | outputDescriptors:(NSArray *)outputDescriptors; 72 | 73 | @end 74 | 75 | @interface MTIRenderPipelineKernel (PassthroughKernel) 76 | 77 | @property (nonatomic, class, strong, readonly) MTIRenderPipelineKernel *passthroughRenderPipelineKernel; 78 | 79 | @end 80 | 81 | @interface MTIRenderCommand (ImageCreation) 82 | 83 | + (NSArray *)imagesByPerformingRenderCommands:(NSArray *)renderCommands 84 | outputDescriptors:(NSArray *)outputDescriptors; 85 | 86 | @end 87 | 88 | @class MTIImageRenderingDependencyGraph, MTIRenderGraphNode; 89 | 90 | FOUNDATION_EXPORT void MTIColorMatrixRenderGraphNodeOptimize(MTIRenderGraphNode *node); 91 | 92 | NS_ASSUME_NONNULL_END 93 | -------------------------------------------------------------------------------- /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 | typedef NS_ENUM(NSInteger, MTIAlphaType) { 13 | MTIAlphaTypeUnknown = 0, 14 | MTIAlphaTypeNonPremultiplied = 1, 15 | MTIAlphaTypePremultiplied = 2, 16 | MTIAlphaTypeAlphaIsOne = 3 17 | }; 18 | 19 | FOUNDATION_EXPORT NSString * MTIAlphaTypeGetDescription(MTIAlphaType alphaType); 20 | 21 | @class MTIImage; 22 | 23 | typedef MTIAlphaType (^MTIAlphaTypeHandlingOutputAlphaTypeRule)(NSArray *inputAlphaTypes); 24 | 25 | @interface MTIAlphaTypeHandlingRule: NSObject 26 | 27 | @property (nonatomic, copy, readonly) NSArray *acceptableAlphaTypes NS_REFINED_FOR_SWIFT; 28 | 29 | - (instancetype)init NS_UNAVAILABLE; 30 | 31 | + (instancetype)new NS_UNAVAILABLE; 32 | 33 | - (BOOL)canAcceptAlphaType:(MTIAlphaType)alphaType; 34 | 35 | - (MTIAlphaType)outputAlphaTypeForInputAlphaTypes:(NSArray *)inputAlphaTypes NS_REFINED_FOR_SWIFT; 36 | 37 | - (MTIAlphaType)outputAlphaTypeForInputImages:(NSArray *)inputImages; 38 | 39 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaTypeHandler:(MTIAlphaTypeHandlingOutputAlphaTypeRule)outputAlphaTypeHandler NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT; 40 | 41 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaType:(MTIAlphaType)outputAlphaType NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT; 42 | 43 | @property (nonatomic, copy, class, readonly) MTIAlphaTypeHandlingRule *generalAlphaTypeHandlingRule; //accepts MTIAlphaTypeNonPremultiplied, MTIAlphaTypeAlphaIsOne; outputs MTIAlphaTypeNonPremultiplied 44 | 45 | @property (nonatomic, copy, class, readonly) MTIAlphaTypeHandlingRule *passthroughAlphaTypeHandlingRule; //accepts all; output is same as input. 46 | 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIAlphaType.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIAlphaType.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 23/10/2017. 6 | // 7 | 8 | #import "MTIAlphaType.h" 9 | #import "MTIImage.h" 10 | 11 | NSString * MTIAlphaTypeGetDescription(MTIAlphaType alphaType) { 12 | switch (alphaType) { 13 | case MTIAlphaTypePremultiplied: 14 | return @"Premultiplied"; 15 | case MTIAlphaTypeNonPremultiplied: 16 | return @"NonPremultiplied"; 17 | case MTIAlphaTypeAlphaIsOne: 18 | return @"AlphaIsOne"; 19 | default: 20 | return @"UnknownAlphaType"; 21 | } 22 | } 23 | 24 | @interface MTIAlphaTypeHandlingRule () 25 | 26 | @property (nonatomic,copy,readonly) MTIAlphaTypeHandlingOutputAlphaTypeRule outputAlphaTypeHandler; 27 | @property (nonatomic,readonly) MTIAlphaType outputAlphaType; 28 | 29 | @end 30 | 31 | @implementation MTIAlphaTypeHandlingRule 32 | 33 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaTypeHandler:(MTIAlphaTypeHandlingOutputAlphaTypeRule)outputAlphaTypeHandler { 34 | if (self = [super init]) { 35 | _acceptableAlphaTypes = acceptableAlphaTypes; 36 | _outputAlphaTypeHandler = [outputAlphaTypeHandler copy]; 37 | } 38 | return self; 39 | } 40 | 41 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaType:(MTIAlphaType)outputAlphaType { 42 | if (self = [super init]) { 43 | _acceptableAlphaTypes = acceptableAlphaTypes; 44 | _outputAlphaType = outputAlphaType; 45 | } 46 | return self; 47 | } 48 | 49 | - (id)copyWithZone:(NSZone *)zone { 50 | return self; 51 | } 52 | 53 | - (BOOL)canAcceptAlphaType:(MTIAlphaType)alphaType { 54 | return [self.acceptableAlphaTypes containsObject:@(alphaType)]; 55 | } 56 | 57 | - (MTIAlphaType)outputAlphaTypeForInputAlphaTypes:(NSArray *)inputAlphaTypes { 58 | if (_outputAlphaTypeHandler) { 59 | return _outputAlphaTypeHandler(inputAlphaTypes); 60 | } else { 61 | return _outputAlphaType; 62 | } 63 | } 64 | 65 | - (MTIAlphaType)outputAlphaTypeForInputImages:(NSArray *)inputImages { 66 | if (_outputAlphaTypeHandler) { 67 | NSMutableArray *alphaTypes = [NSMutableArray arrayWithCapacity:inputImages.count]; 68 | for (MTIImage *image in inputImages) { 69 | [alphaTypes addObject:@(image.alphaType)]; 70 | } 71 | NSParameterAssert([[NSSet setWithArray:alphaTypes] isSubsetOfSet:[NSSet setWithArray:_acceptableAlphaTypes]]); 72 | return [self outputAlphaTypeForInputAlphaTypes:alphaTypes]; 73 | } else { 74 | return _outputAlphaType; 75 | } 76 | } 77 | 78 | + (MTIAlphaTypeHandlingRule *)generalAlphaTypeHandlingRule { 79 | static MTIAlphaTypeHandlingRule * generalAlphaTypeHandlingRule; 80 | static dispatch_once_t onceToken; 81 | dispatch_once(&onceToken, ^{ 82 | generalAlphaTypeHandlingRule = [[MTIAlphaTypeHandlingRule alloc] initWithAcceptableAlphaTypes:@[@(MTIAlphaTypeNonPremultiplied),@(MTIAlphaTypeAlphaIsOne)] outputAlphaType:MTIAlphaTypeNonPremultiplied]; 83 | }); 84 | return generalAlphaTypeHandlingRule; 85 | } 86 | 87 | + (MTIAlphaTypeHandlingRule *)passthroughAlphaTypeHandlingRule { 88 | static MTIAlphaTypeHandlingRule * passthroughAlphaTypeHandlingRule; 89 | static dispatch_once_t onceToken; 90 | dispatch_once(&onceToken, ^{ 91 | passthroughAlphaTypeHandlingRule = [[MTIAlphaTypeHandlingRule alloc] initWithAcceptableAlphaTypes:@[@(MTIAlphaTypeNonPremultiplied),@(MTIAlphaTypeAlphaIsOne),@(MTIAlphaTypePremultiplied)] outputAlphaTypeHandler:^MTIAlphaType(NSArray * _Nonnull inputAlphaTypes) { 92 | NSAssert(inputAlphaTypes.count == 1, @""); 93 | return [inputAlphaTypes.firstObject integerValue]; 94 | }]; 95 | }); 96 | return passthroughAlphaTypeHandlingRule; 97 | } 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIAlphaType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIAlphaType.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 23/10/2017. 6 | // 7 | 8 | import Foundation 9 | 10 | extension MTIAlphaTypeHandlingRule { 11 | 12 | public var acceptableAlphaTypes: [MTIAlphaType] { 13 | return self.__acceptableAlphaTypes.compactMap({ value in 14 | return MTIAlphaType(rawValue: value.intValue) 15 | }) 16 | } 17 | 18 | public convenience init(acceptableAlphaTypes: [MTIAlphaType], outputAlphaType: MTIAlphaType) { 19 | self.init(__acceptableAlphaTypes: acceptableAlphaTypes.map({ NSNumber(value: $0.rawValue) }), outputAlphaType: outputAlphaType) 20 | } 21 | 22 | public func outputAlphaType(forInputAlphaTypes inputAlphaTypes: [MTIAlphaType]) -> MTIAlphaType { 23 | return self.__outputAlphaType(forInputAlphaTypes: inputAlphaTypes.map({ NSNumber(value: $0.rawValue) })) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIBlendModes.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIBlendModes.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 30/09/2017. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | typedef NSString * MTIBlendMode NS_EXTENSIBLE_STRING_ENUM; 13 | 14 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeNormal; 15 | // FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeDissolve; 16 | 17 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeDarken; 18 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeMultiply; 19 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeColorBurn; 20 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeLinearBurn; 21 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeDarkerColor; 22 | 23 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeLighten; 24 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeScreen; 25 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeColorDodge; 26 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeAdd; // also LinearDodge 27 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeLighterColor; 28 | 29 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeOverlay; 30 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeSoftLight; 31 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeHardLight; 32 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeVividLight; 33 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeLinearLight; 34 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModePinLight; 35 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeHardMix; 36 | 37 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeDifference; 38 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeExclusion; 39 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeSubtract; 40 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeDivide; 41 | 42 | // non-separable 43 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeHue; 44 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeSaturation; 45 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeColor; 46 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeLuminosity; 47 | 48 | 49 | //custom 50 | FOUNDATION_EXPORT MTIBlendMode const MTIBlendModeColorLookup512x512; 51 | 52 | @class MTIFunctionDescriptor; 53 | 54 | @interface MTIBlendFunctionDescriptors: NSObject 55 | 56 | @property (nonatomic,copy,readonly) MTIFunctionDescriptor *fragmentFunctionDescriptorForBlendFilter; 57 | 58 | @property (nonatomic,copy,readonly) MTIFunctionDescriptor *fragmentFunctionDescriptorForMultilayerCompositingFilter; 59 | 60 | - (instancetype)initWithFragmentFunctionDescriptorForBlendFilter:(MTIFunctionDescriptor *)fragmentFunctionDescriptorForBlendFilter 61 | fragmentFunctionDescriptorForMultilayerCompositingFilter:(MTIFunctionDescriptor *)fragmentFunctionDescriptorForMultilayerCompositingFilter; 62 | 63 | @end 64 | 65 | @interface MTIBlendModes: NSObject 66 | 67 | @property (nonatomic,copy,readonly,class) NSArray *allModes NS_SWIFT_NAME(all); 68 | 69 | + (void)registerBlendMode:(MTIBlendMode)blendMode withFunctionDescriptors:(MTIBlendFunctionDescriptors *)functionDescriptors; 70 | 71 | + (nullable MTIBlendFunctionDescriptors *)functionDescriptorsForBlendMode:(MTIBlendMode)blendMode NS_SWIFT_NAME(functionDescriptors(for:)); 72 | 73 | @end 74 | 75 | NS_ASSUME_NONNULL_END 76 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalTextureBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalTextureBridge.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 MTICVMetalTextureBridgeErrorDomain; 14 | 15 | typedef NS_ERROR_ENUM(MTICVMetalTextureBridgeErrorDomain, MTICVMetalTextureBridgeError) { 16 | MTICVMetalTextureBridgeErrorImageBufferIsNotBackedByIOSurface = 10001, 17 | MTICVMetalTextureBridgeErrorFailedToCreateTexture = 10002, 18 | MTICVMetalTextureBridgeErrorCoreVideoDoesNotSupportIOSurface = 10003 19 | }; 20 | 21 | NS_CLASS_AVAILABLE(10_11, 11_0) 22 | @interface MTICVMetalTextureBridge : NSObject 23 | 24 | - (instancetype)initWithDevice:(id)device; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTICVMetalTextureBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTICVMetalTextureBridge.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/10/10. 6 | // 7 | 8 | #import "MTICVMetalTextureBridge.h" 9 | 10 | NSString * const MTICVMetalTextureBridgeErrorDomain = @"MTICVMetalTextureBridgeErrorDomain"; 11 | 12 | @interface MTICVMetalTextureBridgeTexture : NSObject 13 | 14 | @end 15 | 16 | @implementation MTICVMetalTextureBridgeTexture 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 MTICVMetalTextureBridge () 29 | 30 | @property (nonatomic, readonly, strong) id device; 31 | 32 | @end 33 | 34 | @implementation MTICVMetalTextureBridge 35 | 36 | - (instancetype)initWithDevice:(id)device { 37 | if (self = [super init]) { 38 | NSParameterAssert(device); 39 | _device = device; 40 | } 41 | return self; 42 | } 43 | 44 | - (id)newTextureWithCVImageBuffer:(CVImageBufferRef)imageBuffer textureDescriptor:(MTLTextureDescriptor *)textureDescriptor planeIndex:(size_t)planeIndex error:(NSError * _Nullable __autoreleasing *)error { 45 | NSParameterAssert(imageBuffer); 46 | #if COREVIDEO_SUPPORTS_IOSURFACE 47 | IOSurfaceRef ioSurface = CVPixelBufferGetIOSurface(imageBuffer); 48 | if (ioSurface) { 49 | id texture = [self.device newTextureWithDescriptor:textureDescriptor iosurface:ioSurface plane:planeIndex]; 50 | if (texture) { 51 | return [[MTICVMetalTextureBridgeTexture alloc] initWithTexture:texture]; 52 | } else { 53 | if (error) { 54 | *error = [NSError errorWithDomain:MTICVMetalTextureBridgeErrorDomain code:MTICVMetalTextureBridgeErrorFailedToCreateTexture userInfo:@{}]; 55 | } 56 | return nil; 57 | } 58 | } else { 59 | if (error) { 60 | *error = [NSError errorWithDomain:MTICVMetalTextureBridgeErrorDomain code:MTICVMetalTextureBridgeErrorImageBufferIsNotBackedByIOSurface userInfo:@{}]; 61 | } 62 | return nil; 63 | } 64 | #else 65 | if (error) { 66 | *error = [NSError errorWithDomain:MTICVMetalTextureBridgeErrorDomain code:MTICVMetalTextureBridgeErrorCoreVideoDoesNotSupportIOSurface userInfo:@{}]; 67 | } 68 | return nil; 69 | #endif 70 | } 71 | 72 | - (void)flushCache { 73 | 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /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 id)newTextureWithCVImageBuffer:(CVImageBufferRef)imageBuffer 22 | textureDescriptor:(MTLTextureDescriptor *)textureDescriptor 23 | planeIndex:(size_t)planeIndex 24 | error:(NSError **)error 25 | NS_SWIFT_NAME(makeTexture(with:textureDescriptor:planeIndex:)); 26 | 27 | - (void)flushCache; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /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/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 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /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 simd_float3 const MTIGrayColorTransformDefault; //MTIGrayColorTransform_ITU_R_601 31 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransform_ITU_R_601; //0.299, 0.587, 0.114 32 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransform_ITU_R_709; //0.2126, 0.7152, 0.0722 33 | -------------------------------------------------------------------------------- /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 | simd_float3 const MTIGrayColorTransform_ITU_R_601 = (simd_float3){0.299f, 0.587f, 0.114f}; 19 | simd_float3 const MTIGrayColorTransform_ITU_R_709 = (simd_float3){0.2126f, 0.7152f, 0.0722f}; 20 | 21 | simd_float3 const MTIGrayColorTransformDefault = MTIGrayColorTransform_ITU_R_601; 22 | -------------------------------------------------------------------------------- /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/MTIColorMatrix.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIColorMatrix.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 25/10/2017. 6 | // 7 | 8 | import Foundation 9 | 10 | extension MTIColorMatrix : Equatable { 11 | public static func == (lhs: MTIColorMatrix, rhs: MTIColorMatrix) -> Bool { 12 | return lhs.isEqual(to: rhs) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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/MTIContext+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIContext+Internal.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 07/01/2018. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import "MTIContext.h" 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @interface MTIImagePromiseRenderTarget : NSObject 17 | 18 | @property (nonatomic,strong,readonly,nullable) id texture; 19 | 20 | - (BOOL)retainTexture; 21 | 22 | - (void)releaseTexture; 23 | 24 | @end 25 | 26 | typedef NSString * MTIContextPromiseAssociatedValueTableName NS_EXTENSIBLE_STRING_ENUM; 27 | typedef NSString * MTIContextImageAssociatedValueTableName NS_EXTENSIBLE_STRING_ENUM; 28 | 29 | @class MTIFunctionDescriptor, MTISamplerDescriptor, MTIRenderPipeline, MTIComputePipeline, MTITextureDescriptor; 30 | 31 | @interface MTIContext (Internal) 32 | 33 | #pragma mark - Render Target 34 | 35 | - (nullable MTIImagePromiseRenderTarget *)newRenderTargetWithResuableTextureDescriptor:(MTITextureDescriptor *)textureDescriptor error:(NSError **)error NS_SWIFT_NAME(makeRenderTarget(resuableTextureDescriptor:)); 36 | 37 | - (MTIImagePromiseRenderTarget *)newRenderTargetWithTexture:(id)texture NS_SWIFT_NAME(makeRenderTarget(texture:)); 38 | 39 | #pragma mark - Lock 40 | 41 | - (void)lockForRendering; 42 | 43 | - (void)unlockForRendering; 44 | 45 | #pragma mark - Cache 46 | 47 | - (nullable id)libraryWithURL:(NSURL *)URL error:(NSError **)error; 48 | 49 | - (nullable id)functionWithDescriptor:(MTIFunctionDescriptor *)descriptor error:(NSError **)error; 50 | 51 | - (nullable id)samplerStateWithDescriptor:(MTISamplerDescriptor *)descriptor error:(NSError **)error; 52 | 53 | - (nullable MTIRenderPipeline *)renderPipelineWithDescriptor:(MTLRenderPipelineDescriptor *)descriptor error:(NSError **)error; 54 | 55 | - (nullable MTIComputePipeline *)computePipelineWithDescriptor:(MTLComputePipelineDescriptor *)descriptor error:(NSError **)error; 56 | 57 | - (nullable id)kernelStateForKernel:(id)kernel configuration:(nullable id)configuration error:(NSError **)error; 58 | 59 | - (nullable id)valueForPromise:(id)promise inTable:(MTIContextPromiseAssociatedValueTableName)tableName; 60 | 61 | - (void)setValue:(id)value forPromise:(id)promise inTable:(MTIContextPromiseAssociatedValueTableName)tableName; 62 | 63 | - (nullable id)valueForImage:(MTIImage *)image inTable:(MTIContextImageAssociatedValueTableName)tableName; 64 | 65 | - (void)setValue:(id)value forImage:(MTIImage *)image inTable:(MTIContextImageAssociatedValueTableName)tableName; 66 | 67 | @end 68 | 69 | NS_ASSUME_NONNULL_END 70 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIContext+Rendering.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIContext+Rendering.h 3 | // Pods 4 | // 5 | // Created by YuAo on 23/07/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "MTIContext.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @class MTIDrawableRenderingRequest, MTICIImageCreationOptions, MTIRenderTask; 16 | 17 | @interface MTIContext (Rendering) 18 | 19 | - (BOOL)renderImage:(MTIImage *)image toDrawableWithRequest:(MTIDrawableRenderingRequest *)request error:(NSError **)error NS_SWIFT_NAME(render(_:toDrawableWithRequest:)); 20 | 21 | - (nullable CIImage *)createCIImageFromImage:(MTIImage *)image error:(NSError **)error NS_SWIFT_NAME(makeCIImage(from:)); 22 | 23 | - (nullable CIImage *)createCIImageFromImage:(MTIImage *)image options:(MTICIImageCreationOptions *)options error:(NSError **)error NS_SWIFT_NAME(makeCIImage(from:options:)); 24 | 25 | - (BOOL)renderImage:(MTIImage *)image toCVPixelBuffer:(CVPixelBufferRef)pixelBuffer error:(NSError **)error NS_SWIFT_NAME(render(_:to:)); 26 | 27 | - (BOOL)renderImage:(MTIImage *)image toCVPixelBuffer:(CVPixelBufferRef)pixelBuffer sRGB:(BOOL)sRGB error:(NSError **)error NS_SWIFT_NAME(render(_:to:sRGB:)); 28 | 29 | - (nullable CGImageRef)createCGImageFromImage:(MTIImage *)image error:(NSError **)error CF_RETURNS_RETAINED NS_SWIFT_NAME(makeCGImage(from:)); 30 | 31 | - (nullable CGImageRef)createCGImageFromImage:(MTIImage *)image sRGB:(BOOL)sRGB error:(NSError **)error CF_RETURNS_RETAINED NS_SWIFT_NAME(makeCGImage(from:sRGB:)); 32 | 33 | - (nullable MTIRenderTask *)startTaskToRenderImage:(MTIImage *)image toCVPixelBuffer:(CVPixelBufferRef)pixelBuffer sRGB:(BOOL)sRGB error:(NSError **)error NS_SWIFT_NAME(startTask(toRender:to:sRGB:)); 34 | 35 | - (nullable MTIRenderTask *)startTaskToCreateCGImage:(CF_RETURNS_RETAINED __nullable CGImageRef * __nonnull)outImage fromImage:(MTIImage *)image sRGB:(BOOL)sRGB error:(NSError **)error NS_SWIFT_NAME(startTask(toCreate:from:sRGB:));; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIContext.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 "MTIKernel.h" 14 | #import "MTIImagePromise.h" 15 | #import "MTIMemoryWarningObserver.h" 16 | #import "MTICVMetalTextureBridging.h" 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | @class MTICVMetalTextureCache; 21 | 22 | FOUNDATION_EXPORT NSString * const MTIContextDefaultLabel; 23 | 24 | @interface MTIContextOptions : NSObject 25 | 26 | @property (nonatomic,copy,nullable) NSDictionary *coreImageContextOptions; 27 | 28 | @property (nonatomic) MTLPixelFormat workingPixelFormat; 29 | 30 | @property (nonatomic) BOOL enablesRenderGraphOptimization; 31 | 32 | /*! @brief Automatically reclaim resources on memory warning. */ 33 | @property (nonatomic) BOOL automaticallyReclaimResources; 34 | 35 | /*! @brief A string to help identify this object */ 36 | @property (nonatomic, copy) NSString *label; 37 | 38 | @end 39 | 40 | FOUNDATION_EXPORT NSURL * _Nullable MTIDefaultLibraryURLForBundle(NSBundle *bundle); 41 | 42 | @interface MTIContext : NSObject 43 | 44 | - (instancetype)init NS_UNAVAILABLE; 45 | 46 | + (instancetype)new NS_UNAVAILABLE; 47 | 48 | - (nullable instancetype)initWithDevice:(id)device error:(NSError **)error; 49 | 50 | - (nullable instancetype)initWithDevice:(id)device options:(MTIContextOptions *)options error:(NSError **)error NS_DESIGNATED_INITIALIZER; 51 | 52 | @property (nonatomic, readonly) MTLPixelFormat workingPixelFormat; 53 | 54 | @property (nonatomic, readonly) BOOL isRenderGraphOptimizationEnabled; 55 | 56 | @property (nonatomic, copy, readonly) NSString *label; 57 | 58 | @property (nonatomic, readonly) BOOL isMetalPerformanceShadersSupported; 59 | 60 | @property (nonatomic, strong, readonly) id device; 61 | 62 | @property (nonatomic, strong, readonly) id defaultLibrary; 63 | 64 | @property (nonatomic, strong, readonly) id commandQueue; 65 | 66 | @property (nonatomic, strong, readonly) MTKTextureLoader *textureLoader; 67 | 68 | @property (nonatomic, strong, readonly) CIContext *coreImageContext; 69 | 70 | @property (nonatomic, strong, readonly) id coreVideoTextureBridge; 71 | 72 | @property (nonatomic, class, readonly) BOOL defaultMetalDeviceSupportsMPS; 73 | 74 | - (void)reclaimResources; 75 | 76 | @property (nonatomic, readonly) NSUInteger idleResourceSize NS_AVAILABLE(10_13, 11_0); 77 | 78 | @property (nonatomic, readonly) NSUInteger idleResourceCount; 79 | 80 | @end 81 | 82 | @interface MTIContext (MemoryWarningHandling) 83 | 84 | @end 85 | 86 | NS_ASSUME_NONNULL_END 87 | -------------------------------------------------------------------------------- /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) 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) 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 | @end 82 | -------------------------------------------------------------------------------- /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, copy, readonly) NSUUID *identifier; 33 | 34 | @property (nonatomic, weak) id drawableProvider; 35 | 36 | @property (nonatomic) MTIDrawableRenderingResizingMode resizingMode; 37 | 38 | - (instancetype)init; 39 | 40 | @end 41 | 42 | NS_ASSUME_NONNULL_END 43 | 44 | #import 45 | 46 | NS_ASSUME_NONNULL_BEGIN 47 | 48 | @interface MTKView (MTIDrawableProvider) 49 | 50 | @end 51 | 52 | NS_ASSUME_NONNULL_END 53 | -------------------------------------------------------------------------------- /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)init { 14 | if (self = [super init]) { 15 | _identifier = [NSUUID UUID]; 16 | } 17 | return self; 18 | } 19 | 20 | @end 21 | 22 | @implementation MTKView (MTIDrawableProvider) 23 | 24 | - (id)drawableForRequest:(MTIDrawableRenderingRequest *)request { 25 | return self.currentDrawable; 26 | } 27 | 28 | - (MTLRenderPassDescriptor *)renderPassDescriptorForRequest:(MTIDrawableRenderingRequest *)request { 29 | return self.currentRenderPassDescriptor; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /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 | 22 | //Texture loading errors 23 | MTIErrorUnsupportedCVPixelBufferFormat = 2001, 24 | MTIErrorTextureDimensionsMismatch = 2002, 25 | 26 | //Image errors 27 | MTIErrorUnsupportedImageCachePolicy = 3001, 28 | 29 | //Kernel errors 30 | MTIErrorDataBufferSizeMismatch = 4001, 31 | MTIErrorParameterDataTypeNotSupported = 4002, 32 | MTIErrorMPSKernelInputCountMismatch = 4003, 33 | MTIErrorMPSKernelNotSupported = 4004, 34 | 35 | //Render errors 36 | MTIErrorEmptyDrawable = 5001, 37 | MTIErrorFailedToCreateCGImageFromCVPixelBuffer = 5002, 38 | MTIErrorFailedToCreateCVPixelBuffer = 5003, 39 | MTIErrorInvalidCVPixelBufferRenderingAPI = 5004, 40 | MTIErrorFailedToGetRenderedBuffer = 5005, 41 | }; 42 | 43 | /// 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. 44 | FOUNDATION_EXPORT NSError * _MTIErrorCreate(MTIError code, NSString *defaultDescription, NSDictionary * _Nullable userInfo); 45 | 46 | #define MTIErrorCreate(code, userInfo) _MTIErrorCreate(code, @#code, userInfo) 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /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/MTIFunctionDescriptor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIFilterFunctionDescriptor.m 3 | // Pods 4 | // 5 | // Created by YuAo on 25/06/2017. 6 | // 7 | // 8 | 9 | #import "MTIFunctionDescriptor.h" 10 | 11 | @interface MTIFunctionDescriptor () 12 | 13 | @end 14 | 15 | @implementation MTIFunctionDescriptor 16 | 17 | - (instancetype)initWithName:(NSString *)name { 18 | return [self initWithName:name libraryURL:nil]; 19 | } 20 | 21 | - (instancetype)initWithName:(NSString *)name libraryURL:( NSURL * _Nullable )URL { 22 | if (self = [super init]) { 23 | _name = name; 24 | _libraryURL = [URL copy]; 25 | _constantValues = nil; 26 | } 27 | return self; 28 | } 29 | 30 | - (instancetype)initWithName:(NSString *)name constantValues:(MTLFunctionConstantValues *)constantValues libraryURL:(NSURL *)URL { 31 | if (self = [super init]) { 32 | _name = [name copy]; 33 | _libraryURL = [URL copy]; 34 | _constantValues = [constantValues copy]; 35 | } 36 | return self; 37 | } 38 | 39 | - (BOOL)isEqual:(id)object { 40 | if (object == self) { 41 | return YES; 42 | } 43 | 44 | if (![object isKindOfClass:[MTIFunctionDescriptor class]]) { 45 | return NO; 46 | } 47 | 48 | MTIFunctionDescriptor *descriptor = object; 49 | if ([descriptor.name isEqualToString:self.name] && 50 | ((descriptor.libraryURL == nil && self.libraryURL == nil) || [descriptor.libraryURL isEqual:self.libraryURL])) { 51 | if (@available(iOS 10.0, *)) { 52 | if ((descriptor.constantValues == nil && self.constantValues == nil) || [descriptor.constantValues isEqual:self.constantValues]) { 53 | return YES; 54 | } else { 55 | return NO; 56 | } 57 | } else { 58 | return YES; 59 | } 60 | } else { 61 | return NO; 62 | } 63 | } 64 | 65 | - (NSUInteger)hash { 66 | if (@available(iOS 10.0, *)) { 67 | return self.name.hash ^ self.libraryURL.hash ^ self.constantValues.hash; 68 | } else { 69 | return self.name.hash ^ self.libraryURL.hash; 70 | } 71 | } 72 | 73 | - (id)copyWithZone:(NSZone *)zone { 74 | return self; 75 | } 76 | 77 | - (NSString *)description { 78 | if (@available(iOS 10_0, *)) { 79 | return [NSString stringWithFormat:@"<%@: %p; name = %@; constantValues = %@; libraryURL = %@>",self.class, self, self.name, self.constantValues, self.libraryURL]; 80 | } else { 81 | return [NSString stringWithFormat:@"<%@: %p; name = %@; libraryURL = %@>",self.class, self, self.name, self.libraryURL]; 82 | } 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /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 | @protocol MTIGeometry 13 | 14 | @property (nonatomic,readonly) NSUInteger vertexCount; 15 | 16 | @property (nonatomic,readonly) MTLPrimitiveType primitiveType; 17 | 18 | @property (nonatomic,readonly) const void *bufferBytes NS_RETURNS_INNER_POINTER; 19 | @property (nonatomic,readonly) NSUInteger bufferLength; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | 25 | -------------------------------------------------------------------------------- /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/MTIImagePromise.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTIImagePromise.h 3 | // Pods 4 | // 5 | // Created by YuAo on 27/06/2017. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import "MTIColor.h" 15 | #import "MTITextureDimensions.h" 16 | #import "MTIAlphaType.h" 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | FOUNDATION_EXPORT BOOL MTIMTKTextureLoaderCanDecodeImage(CGImageRef image); 21 | 22 | @class MTIImage, MTIImageRenderingContext, MTIFunctionDescriptor, MTITextureDescriptor, MTIImagePromiseRenderTarget, MTIImagePromiseDebugInfo, MTICIImageRenderingOptions, MTIImageProperties; 23 | 24 | @protocol MTIImagePromise 25 | 26 | @property (nonatomic, readonly) MTITextureDimensions dimensions; 27 | 28 | @property (nonatomic, readonly, copy) NSArray *dependencies; 29 | 30 | @property (nonatomic, readonly) MTIAlphaType alphaType; 31 | 32 | - (nullable MTIImagePromiseRenderTarget *)resolveWithContext:(MTIImageRenderingContext *)renderingContext error:(NSError **)error; 33 | 34 | - (instancetype)promiseByUpdatingDependencies:(NSArray *)dependencies; 35 | 36 | @property (nonatomic, strong, readonly) MTIImagePromiseDebugInfo *debugInfo; 37 | 38 | @end 39 | 40 | #pragma mark - Promises 41 | 42 | @interface MTIImageURLPromise : NSObject 43 | 44 | - (nullable instancetype)initWithContentsOfURL:(NSURL *)URL 45 | properties:(MTIImageProperties *)properties 46 | options:(nullable NSDictionary *)options 47 | alphaType:(MTIAlphaType)alphaType; 48 | 49 | @end 50 | 51 | @interface MTICGImagePromise : NSObject 52 | 53 | - (instancetype)initWithCGImage:(CGImageRef)cgImage options:(nullable NSDictionary *)options alphaType:(MTIAlphaType)alphaType; 54 | 55 | @end 56 | 57 | @interface MTITexturePromise : NSObject 58 | 59 | - (instancetype)initWithTexture:(id)texture alphaType:(MTIAlphaType)alphaType; 60 | 61 | @end 62 | 63 | @interface MTICIImagePromise : NSObject 64 | 65 | - (instancetype)initWithCIImage:(CIImage *)ciImage isOpaque:(BOOL)isOpaque options:(MTICIImageRenderingOptions *)options; 66 | 67 | @end 68 | 69 | @interface MTIColorImagePromise: NSObject 70 | 71 | @property (nonatomic, readonly) MTIColor color; 72 | 73 | - (instancetype)initWithColor:(MTIColor)color sRGB:(BOOL)sRGB size:(CGSize)size; 74 | 75 | @end 76 | 77 | @interface MTIBitmapDataImagePromise: NSObject 78 | 79 | - (instancetype)initWithBitmapData:(NSData *)data width:(NSUInteger)width height:(NSUInteger)height bytesPerRow:(NSUInteger)bytesPerRow pixelFormat:(MTLPixelFormat)pixelFormat alphaType:(MTIAlphaType)alphaType; 80 | 81 | @end 82 | 83 | NS_AVAILABLE(10_12, 10_0) 84 | @interface MTINamedImagePromise: NSObject 85 | 86 | @property (nonatomic, copy, readonly) NSString *name; 87 | @property (nonatomic, strong, readonly, nullable) NSBundle *bundle; 88 | @property (nonatomic, readonly) CGFloat scaleFactor; 89 | 90 | - (instancetype)initWithName:(NSString *)name 91 | bundle:(nullable NSBundle *)bundle 92 | size:(CGSize)size 93 | scaleFactor:(CGFloat)scaleFactor 94 | options:(nullable NSDictionary *)options 95 | alphaType:(MTIAlphaType)alphaType; 96 | 97 | @end 98 | 99 | NS_ASSUME_NONNULL_END 100 | 101 | -------------------------------------------------------------------------------- /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.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 | @interface MTIImageRenderingDependencyGraph : NSObject 18 | 19 | - (NSInteger)dependentCountForPromise:(id)promise; 20 | 21 | @end 22 | 23 | @protocol MTIImagePromiseResolution 24 | 25 | @property (nonatomic,readonly) id texture; 26 | 27 | - (void)markAsConsumedBy:(id)consumer; 28 | 29 | @end 30 | 31 | @interface MTIImageRenderingContext : NSObject 32 | 33 | @property (nonatomic, strong, readonly) MTIContext *context; 34 | 35 | @property (nonatomic, strong, readonly) id commandBuffer; 36 | 37 | - (instancetype)init NS_UNAVAILABLE; 38 | 39 | + (instancetype)new NS_UNAVAILABLE; 40 | 41 | - (instancetype)initWithContext:(MTIContext *)context; 42 | 43 | - (nullable id)resolutionForImage:(MTIImage *)image error:(NSError **)error; 44 | 45 | @end 46 | 47 | @interface MTIImageBuffer : NSObject 48 | 49 | - (instancetype)init NS_UNAVAILABLE; 50 | 51 | + (instancetype)new NS_UNAVAILABLE; 52 | 53 | + (nullable MTIImage *)renderedBufferForImage:(MTIImage *)targetImage inContext:(MTIContext *)context; 54 | 55 | @end 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTICompositingLayer.h 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 14/11/2017. 6 | // 7 | 8 | #import 9 | #import 10 | #import "MTIBlendModes.h" 11 | #import "MTIColor.h" 12 | #import "MTIMask.h" 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @class MTIImage; 17 | 18 | typedef NS_ENUM(NSInteger, MTILayerLayoutUnit) { 19 | MTILayerLayoutUnitPixel, 20 | MTILayerLayoutUnitFractionOfBackgroundSize 21 | } NS_SWIFT_NAME(MTILayer.LayoutUnit); 22 | 23 | /// A MTILayer represents a compositing layer for MTIMultilayerCompositingFilter. MTILayers use a UIKit like coordinate system. 24 | @interface MTILayer: NSObject 25 | 26 | @property (nonatomic, strong, readonly) MTIImage *content; 27 | 28 | @property (nonatomic, readonly) BOOL contentIsFlipped; 29 | 30 | @property (nonatomic, readonly) CGRect contentRegion; //pixel 31 | 32 | @property (nonatomic, strong, readonly, nullable) MTIMask *compositingMask; 33 | 34 | @property (nonatomic, readonly) MTILayerLayoutUnit layoutUnit; 35 | 36 | @property (nonatomic, readonly) CGPoint position; 37 | 38 | @property (nonatomic, readonly) CGSize size; 39 | 40 | @property (nonatomic, readonly) float rotation; //rad 41 | 42 | @property (nonatomic, readonly) float opacity; 43 | 44 | @property (nonatomic, copy, readonly) MTIBlendMode blendMode; 45 | 46 | - (instancetype)init NS_UNAVAILABLE; 47 | + (instancetype)new NS_UNAVAILABLE; 48 | 49 | - (instancetype)initWithContent:(MTIImage *)content 50 | layoutUnit:(MTILayerLayoutUnit)layoutUnit 51 | position:(CGPoint)position 52 | size:(CGSize)size 53 | rotation:(float)rotation 54 | opacity:(float)opacity 55 | blendMode:(MTIBlendMode)blendMode; 56 | 57 | - (instancetype)initWithContent:(MTIImage *)content 58 | contentRegion:(CGRect)contentRegion 59 | compositingMask:(nullable MTIMask *)compositingMask 60 | layoutUnit:(MTILayerLayoutUnit)layoutUnit 61 | position:(CGPoint)position 62 | size:(CGSize)size 63 | rotation:(float)rotation 64 | opacity:(float)opacity 65 | blendMode:(MTIBlendMode)blendMode; 66 | 67 | - (instancetype)initWithContent:(MTIImage *)content 68 | contentIsFlipped:(BOOL)contentIsFlipped 69 | contentRegion:(CGRect)contentRegion 70 | compositingMask:(nullable MTIMask *)compositingMask 71 | layoutUnit:(MTILayerLayoutUnit)layoutUnit 72 | position:(CGPoint)position 73 | size:(CGSize)size 74 | rotation:(float)rotation 75 | opacity:(float)opacity 76 | blendMode:(MTIBlendMode)blendMode NS_DESIGNATED_INITIALIZER; 77 | 78 | - (CGSize)sizeInPixelForBackgroundSize:(CGSize)backgroundSize; 79 | 80 | - (CGPoint)positionInPixelForBackgroundSize:(CGSize)backgroundSize; 81 | 82 | @end 83 | 84 | NS_ASSUME_NONNULL_END 85 | 86 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTILayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTICompositingLayer.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 14/11/2017. 6 | // 7 | 8 | #import "MTILayer.h" 9 | #import "MTIImage.h" 10 | 11 | @implementation MTILayer 12 | 13 | - (instancetype)initWithContent:(MTIImage *)content contentRegion:(CGRect)contentRegion compositingMask:(MTIMask *)compositingMask layoutUnit:(MTILayerLayoutUnit)layoutUnit position:(CGPoint)position size:(CGSize)size rotation:(float)rotation opacity:(float)opacity blendMode:(MTIBlendMode)blendMode { 14 | return [self initWithContent:content contentIsFlipped:NO contentRegion:contentRegion compositingMask:compositingMask layoutUnit:layoutUnit position:position size:size rotation:rotation opacity:opacity blendMode:blendMode]; 15 | } 16 | 17 | - (instancetype)initWithContent:(MTIImage *)content contentIsFlipped:(BOOL)contentIsFlipped contentRegion:(CGRect)contentRegion compositingMask:(MTIMask *)compositingMask layoutUnit:(MTILayerLayoutUnit)layoutUnit position:(CGPoint)position size:(CGSize)size rotation:(float)rotation opacity:(float)opacity blendMode:(MTIBlendMode)blendMode { 18 | if (self = [super init]) { 19 | _content = content; 20 | _contentRegion = contentRegion; 21 | _contentIsFlipped = contentIsFlipped; 22 | _compositingMask = compositingMask; 23 | _layoutUnit = layoutUnit; 24 | _position = position; 25 | _size = size; 26 | _rotation = rotation; 27 | _opacity = opacity; 28 | _blendMode = blendMode; 29 | } 30 | return self; 31 | } 32 | 33 | - (instancetype)initWithContent:(MTIImage *)content layoutUnit:(MTILayerLayoutUnit)layoutUnit position:(CGPoint)position size:(CGSize)size rotation:(float)rotation opacity:(float)opacity blendMode:(MTIBlendMode)blendMode { 34 | return [self initWithContent:content contentIsFlipped:NO contentRegion:content.extent compositingMask:nil layoutUnit:layoutUnit position:position size:size rotation:rotation opacity:opacity blendMode:blendMode]; 35 | } 36 | 37 | - (id)copyWithZone:(NSZone *)zone { 38 | return self; 39 | } 40 | 41 | - (CGSize)sizeInPixelForBackgroundSize:(CGSize)backgroundSize { 42 | switch (_layoutUnit) { 43 | case MTILayerLayoutUnitPixel: 44 | return _size; 45 | case MTILayerLayoutUnitFractionOfBackgroundSize: 46 | return CGSizeMake(backgroundSize.width * _size.width, backgroundSize.height * _size.height); 47 | default: 48 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Unknown MTILayerLayoutUnit" userInfo:@{@"Unit": @(_layoutUnit)}]; 49 | } 50 | } 51 | 52 | - (CGPoint)positionInPixelForBackgroundSize:(CGSize)backgroundSize { 53 | switch (_layoutUnit) { 54 | case MTILayerLayoutUnitPixel: 55 | return _position; 56 | case MTILayerLayoutUnitFractionOfBackgroundSize: 57 | return CGPointMake(backgroundSize.width * _position.x, backgroundSize.height * _position.y); 58 | default: 59 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Unknown MTILayerLayoutUnit" userInfo:@{@"Unit": @(_layoutUnit)}]; 60 | } 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /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); 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 | 10 | #if __has_include() 11 | #import 12 | #endif 13 | 14 | @interface MTIMemoryWarningObserver () 15 | 16 | @property (nonatomic, strong, readonly) NSHashTable *handlers; 17 | 18 | @end 19 | 20 | @implementation MTIMemoryWarningObserver 21 | 22 | + (instancetype)sharedObserver { 23 | static MTIMemoryWarningObserver *observer; 24 | static dispatch_once_t onceToken; 25 | dispatch_once(&onceToken, ^{ 26 | observer = [[MTIMemoryWarningObserver alloc] initForSharedObserver]; 27 | }); 28 | return observer; 29 | } 30 | 31 | - (instancetype)initForSharedObserver { 32 | if (self = [super init]) { 33 | _handlers = [NSHashTable weakObjectsHashTable]; 34 | #if __has_include() 35 | [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidReceiveMemoryWarningNotification 36 | object:UIApplication.sharedApplication 37 | queue:nil 38 | usingBlock:^(NSNotification * _Nonnull note) { 39 | [self handleMemoryWarning]; 40 | }]; 41 | #endif 42 | } 43 | return self; 44 | } 45 | 46 | - (void)handleMemoryWarning { 47 | for (id handler in _handlers) { 48 | [handler handleMemoryWarning]; 49 | } 50 | } 51 | 52 | - (void)addMemoryWarningHandler:(id)memoryWarningHandler { 53 | [_handlers addObject:memoryWarningHandler]; 54 | } 55 | 56 | - (void)removeMemoryWarningHandler:(id)memoryWarningHandler { 57 | [_handlers removeObject:memoryWarningHandler]; 58 | } 59 | 60 | + (void)addMemoryWarningHandler:(id)memoryWarningHandler { 61 | [self.sharedObserver addMemoryWarningHandler:memoryWarningHandler]; 62 | } 63 | 64 | + (void)removeMemoryWarningHandler:(id)memoryWarningHandler { 65 | [self.sharedObserver removeMemoryWarningHandler:memoryWarningHandler]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /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; //aliased to MTLPixelFormatInvalid 14 | 15 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P; 16 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P_sRGB; 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_IPHONE 18 | return [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]; 19 | #else 20 | return NO; 21 | #endif 22 | } 23 | -------------------------------------------------------------------------------- /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 | - (instancetype)init NS_UNAVAILABLE; 26 | 27 | + (instancetype)new NS_UNAVAILABLE; 28 | 29 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat; 30 | 31 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction; 32 | 33 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction storeAction:(MTLStoreAction)storeAction NS_DESIGNATED_INITIALIZER; 34 | 35 | - (BOOL)isEqualToOutputDescriptor:(MTIRenderPassOutputDescriptor *)object; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPassOutputDescriptor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTIRenderPipelineOutputDescriptor.m 3 | // Pods 4 | // 5 | // Created by YuAo on 18/11/2017. 6 | // 7 | 8 | #import "MTIRenderPassOutputDescriptor.h" 9 | 10 | @implementation MTIRenderPassOutputDescriptor 11 | 12 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat { 13 | return [self initWithDimensions:dimensions pixelFormat:pixelFormat loadAction:MTLLoadActionDontCare]; 14 | } 15 | 16 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction { 17 | return [self initWithDimensions:dimensions pixelFormat:pixelFormat loadAction:loadAction storeAction:MTLStoreActionStore]; 18 | } 19 | 20 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction storeAction:(MTLStoreAction)storeAction { 21 | if (self = [super init]) { 22 | _dimensions = dimensions; 23 | _pixelFormat = pixelFormat; 24 | _loadAction = loadAction; 25 | _storeAction = storeAction; 26 | } 27 | return self; 28 | } 29 | 30 | - (id)copyWithZone:(NSZone *)zone { 31 | return self; 32 | } 33 | 34 | - (NSUInteger)hash { 35 | return _dimensions.width ^ _dimensions.height ^ _dimensions.depth ^ _pixelFormat ^ _loadAction ^ _storeAction; 36 | } 37 | 38 | - (BOOL)isEqual:(id)object { 39 | if ([object isKindOfClass:[MTIRenderPassOutputDescriptor class]]) { 40 | return [self isEqualToOutputDescriptor:object]; 41 | } 42 | return NO; 43 | } 44 | 45 | - (BOOL)isEqualToOutputDescriptor:(MTIRenderPassOutputDescriptor *)object { 46 | return MTITextureDimensionsEqualToTextureDimensions(_dimensions, object.dimensions) && _pixelFormat == object.pixelFormat && _loadAction == object.loadAction && _storeAction == object.storeAction; 47 | } 48 | 49 | @end 50 | 51 | -------------------------------------------------------------------------------- /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 | @interface MTIRenderTask : NSObject 16 | 17 | @property (readonly) MTLCommandBufferStatus commandBufferStatus; 18 | 19 | - (instancetype)initWithCommandBuffer:(id)commandBuffer NS_DESIGNATED_INITIALIZER; 20 | 21 | - (instancetype)init NS_UNAVAILABLE; 22 | 23 | + (instancetype)new NS_UNAVAILABLE; 24 | 25 | - (void)waitUntilCompleted; 26 | 27 | /*! 28 | @property error 29 | @abstract If an error occurred during execution, the NSError may contain more details about the problem. 30 | */ 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 | 15 | @interface MTISamplerDescriptor : NSObject 16 | 17 | - (instancetype)init NS_UNAVAILABLE; 18 | 19 | + (instancetype)new NS_UNAVAILABLE; 20 | 21 | - (instancetype)initWithMTLSamplerDescriptor:(MTLSamplerDescriptor *)samplerDescriptor NS_DESIGNATED_INITIALIZER; 22 | 23 | - (MTLSamplerDescriptor *)newMTLSamplerDescriptor NS_SWIFT_NAME(makeMTLSamplerDescriptor()); 24 | 25 | @property (nonatomic, readonly, class) MTISamplerDescriptor *defaultSamplerDescriptor; 26 | 27 | + (instancetype)defaultSamplerDescriptorWithAddressMode:(MTLSamplerAddressMode)addressMode; 28 | 29 | @end 30 | 31 | @interface MTLSamplerDescriptor (MTISamplerDescriptor) 32 | 33 | - (MTISamplerDescriptor *)newMTISamplerDescriptor NS_SWIFT_NAME(makeMTISamplerDescriptor()); 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDescriptor.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 MTLTextureDescriptor 14 | 15 | @interface MTITextureDescriptor : NSObject 16 | 17 | - (instancetype)init NS_UNAVAILABLE; 18 | 19 | + (instancetype)new NS_UNAVAILABLE; 20 | 21 | - (instancetype)initWithMTLTextureDescriptor:(MTLTextureDescriptor *)textureDescriptor NS_DESIGNATED_INITIALIZER; 22 | 23 | - (MTLTextureDescriptor *)newMTLTextureDescriptor NS_SWIFT_NAME(makeMTLTextureDescriptor()); 24 | 25 | @property (readonly, nonatomic) MTLTextureType textureType; 26 | 27 | @property (readonly, nonatomic) MTLPixelFormat pixelFormat; 28 | 29 | @property (readonly, nonatomic) NSUInteger width; 30 | 31 | @property (readonly, nonatomic) NSUInteger height; 32 | 33 | @property (readonly, nonatomic) NSUInteger depth; 34 | 35 | @end 36 | 37 | @interface MTLTextureDescriptor (MTITextureDescriptor) 38 | 39 | - (MTITextureDescriptor *)newMTITextureDescriptor NS_SWIFT_NAME(makeMTITextureDescriptor());; 40 | 41 | @end 42 | 43 | NS_ASSUME_NONNULL_END 44 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITextureDescriptor.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDescriptor.m 3 | // Pods 4 | // 5 | // Created by YuAo on 29/06/2017. 6 | // 7 | // 8 | 9 | #import "MTITextureDescriptor.h" 10 | 11 | @interface MTITextureDescriptor () 12 | 13 | @property (nonatomic,copy) MTLTextureDescriptor *metalTextureDescriptor; 14 | 15 | @end 16 | 17 | @implementation MTITextureDescriptor 18 | 19 | - (instancetype)initWithMTLTextureDescriptor:(MTLTextureDescriptor *)textureDescriptor { 20 | if (self = [super init]) { 21 | _metalTextureDescriptor = [textureDescriptor copy]; 22 | } 23 | return self; 24 | } 25 | 26 | - (id)copyWithZone:(NSZone *)zone { 27 | return self; 28 | } 29 | 30 | - (MTLTextureDescriptor *)newMTLTextureDescriptor { 31 | return [_metalTextureDescriptor copy]; 32 | } 33 | 34 | - (BOOL)isEqual:(id)object { 35 | if (self == object) { 36 | return YES; 37 | } 38 | if ([object isKindOfClass:[MTITextureDescriptor class]]) { 39 | return [_metalTextureDescriptor isEqual:((MTITextureDescriptor *)object).metalTextureDescriptor]; 40 | } 41 | return NO; 42 | } 43 | 44 | - (NSUInteger)hash { 45 | return [_metalTextureDescriptor hash]; 46 | } 47 | 48 | - (MTLTextureType)textureType { 49 | return _metalTextureDescriptor.textureType; 50 | } 51 | 52 | - (MTLPixelFormat)pixelFormat { 53 | return _metalTextureDescriptor.pixelFormat; 54 | } 55 | 56 | - (NSUInteger)width { 57 | return _metalTextureDescriptor.width; 58 | } 59 | 60 | - (NSUInteger)height { 61 | return _metalTextureDescriptor.height; 62 | } 63 | 64 | - (NSUInteger)depth { 65 | return _metalTextureDescriptor.depth; 66 | } 67 | 68 | @end 69 | 70 | @implementation MTLTextureDescriptor (MTITextureDescriptor) 71 | 72 | - (MTITextureDescriptor *)newMTITextureDescriptor { 73 | return [[MTITextureDescriptor alloc] initWithMTLTextureDescriptor:self]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /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/MTITextureDimensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTITextureDimensions.swift 3 | // Pods 4 | // 5 | // Created by Yu Ao on 11/10/2017. 6 | // 7 | 8 | extension MTITextureDimensions : Equatable { 9 | public static func == (lhs: MTITextureDimensions, rhs: MTITextureDimensions) -> Bool { 10 | return lhs.isEqual(to: rhs) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTITexturePool.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTITexturePool.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 MTITextureDescriptor; 15 | 16 | @interface MTIReusableTexture : NSObject 17 | 18 | ///Returns the underlining texture. When a reusable texture's texture retain count reachs zero, this method will return nil. 19 | @property (atomic,strong,nullable,readonly) id texture; 20 | 21 | ///Increase the texture's texture retain count. If the retain operation failed, i.e. the texture is already been reused and no longer valid, this method will return `NO`. 22 | - (BOOL)retainTexture; 23 | 24 | - (void)releaseTexture; 25 | 26 | @end 27 | 28 | @interface MTITexturePool : NSObject 29 | 30 | - (instancetype)init NS_UNAVAILABLE; 31 | 32 | + (instancetype)new NS_UNAVAILABLE; 33 | 34 | - (instancetype)initWithDevice:(id)device NS_DESIGNATED_INITIALIZER; 35 | 36 | - (nullable MTIReusableTexture *)newTextureWithDescriptor:(MTITextureDescriptor *)textureDescriptor error:(NSError **)error NS_SWIFT_NAME(makeTexture(descriptor:)); 37 | 38 | /// Frees as many textures from the pool as possible. 39 | - (void)flush; 40 | 41 | /*! 42 | @property allocatedSize 43 | @abstrace The size in bytes occupied by idle resources 44 | */ 45 | @property (nonatomic, readonly) NSUInteger idleResourceSize NS_AVAILABLE(10_13, 11_0); 46 | 47 | @property (nonatomic, readonly) NSUInteger idleResourceCount; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | -------------------------------------------------------------------------------- /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/MTITransform.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTITransform.m 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 28/10/2017. 6 | // 7 | 8 | #import "MTITransform.h" 9 | 10 | simd_float4x4 MTIMakeOrthographicMatrix(float left, float right, float top, float bottom, float near, float far) { 11 | float r_l = right - left; 12 | float t_b = bottom - top; 13 | float f_n = far - near; 14 | float tx = - (right + left) / (right - left); 15 | float ty = - (top + bottom) / (bottom - top); 16 | float tz = - (far + near) / (far - near); 17 | 18 | float scale = 2.0f; 19 | 20 | simd_float4x4 matrix; 21 | 22 | matrix.columns[0][0] = scale / r_l; 23 | matrix.columns[0][1] = 0.0f; 24 | matrix.columns[0][2] = 0.0f; 25 | matrix.columns[0][3] = tx; 26 | 27 | matrix.columns[1][0] = 0.0f; 28 | matrix.columns[1][1] = scale / t_b; 29 | matrix.columns[1][2] = 0.0f; 30 | matrix.columns[1][3] = ty; 31 | 32 | matrix.columns[2][0] = 0.0f; 33 | matrix.columns[2][1] = 0.0f; 34 | matrix.columns[2][2] = scale / f_n; 35 | matrix.columns[2][3] = tz; 36 | 37 | matrix.columns[3][0] = 0.0f; 38 | matrix.columns[3][1] = 0.0f; 39 | matrix.columns[3][2] = 0.0f; 40 | matrix.columns[3][3] = 1.0f; 41 | 42 | return matrix; 43 | } 44 | 45 | simd_float4x4 MTIMakePerspectiveMatrix(float left, float right, float top, float bottom, float near, float far) { 46 | simd_float4x4 matrix; 47 | near = -near; 48 | far = -far; 49 | 50 | matrix.columns[0][0] = 2 * near / (right - left); 51 | matrix.columns[0][1] = 0.0f; 52 | matrix.columns[0][2] = (right + left)/(right - left); 53 | matrix.columns[0][3] = 0; 54 | 55 | matrix.columns[1][0] = 0.0f; 56 | matrix.columns[1][1] = 2 * near/ (bottom - top); 57 | matrix.columns[1][2] = (top + bottom) / (bottom - top); 58 | matrix.columns[1][3] = 0; 59 | 60 | matrix.columns[2][0] = 0.0f; 61 | matrix.columns[2][1] = 0.0f; 62 | matrix.columns[2][2] = - (far) / (far - near); 63 | matrix.columns[2][3] = - (far * near) / (far - near); 64 | 65 | matrix.columns[3][0] = 0.0f; 66 | matrix.columns[3][1] = 0.0f; 67 | matrix.columns[3][2] = -1.0f; 68 | matrix.columns[3][3] = 0.0f; 69 | 70 | return matrix; 71 | } 72 | 73 | simd_float4x4 MTIMakeTransformMatrixFromCATransform3D(CATransform3D transform) { 74 | simd_float4x4 matrix = simd_matrix_from_rows(simd_make_float4((float)transform.m11,(float)transform.m12,(float)transform.m13,(float)transform.m14), 75 | simd_make_float4((float)transform.m21,(float)transform.m22,(float)transform.m23,(float)transform.m24), 76 | simd_make_float4((float)transform.m31,(float)transform.m32,(float)transform.m33,(float)transform.m34), 77 | simd_make_float4((float)transform.m41,(float)transform.m42,(float)transform.m43,(float)transform.m44)); 78 | return matrix; 79 | } 80 | -------------------------------------------------------------------------------- /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) MTIVectorScalarType scalarType; 34 | 35 | @property (readonly) 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/MTIVector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVector.swift 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 2018/7/2. 6 | // 7 | 8 | import Foundation 9 | 10 | extension MTIVector { 11 | 12 | public convenience init(values: [Float]) { 13 | self.init(floatValues: values, count: UInt(values.count)) 14 | } 15 | 16 | public convenience init(values: [Int32]) { 17 | self.init(intValues: values, count: UInt(values.count)) 18 | } 19 | 20 | public convenience init(values: [UInt32]) { 21 | self.init(uintValues: values, count: UInt(values.count)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | 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:)); 19 | FOUNDATION_EXPORT BOOL MTIVertexEqualToVertex(MTIVertex v1, MTIVertex v2) NS_SWIFT_NAME(MTIVertex.isEqual(self:to:)); 20 | 21 | @interface MTIVertices : NSObject 22 | 23 | - (instancetype)init NS_UNAVAILABLE; 24 | 25 | + (instancetype)new NS_UNAVAILABLE; 26 | 27 | - (instancetype)initWithVertices:(const MTIVertex * _Nonnull)vertices count:(NSInteger)count primitiveType:(MTLPrimitiveType)primitiveType NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT; 28 | 29 | + (instancetype)squareVerticesForRect:(CGRect)rect; 30 | 31 | + (instancetype)verticallyFlippedSquareVerticesForRect:(CGRect)rect; 32 | 33 | @property (nonatomic, class, readonly, strong) MTIVertices *fullViewportSquareVertices; 34 | 35 | @end 36 | 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTIVertex.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MTIVertex.swift 3 | // Pods 4 | // 5 | // Created by YuAo on 30/06/2017. 6 | // 7 | // 8 | 9 | import Foundation 10 | import simd 11 | 12 | extension MTIVertex { 13 | public init(position: (Float,Float,Float,Float), textureCoordinate: (Float, Float)) { 14 | self.init() 15 | self.position = float4(position.0, position.1, position.2, position.3) 16 | self.textureCoordinate = float2(textureCoordinate.0, textureCoordinate.1) 17 | } 18 | } 19 | 20 | extension MTIVertex : Equatable { 21 | public static func == (lhs: MTIVertex, rhs: MTIVertex) -> Bool { 22 | return lhs.isEqual(to: rhs) 23 | } 24 | } 25 | 26 | extension MTIVertices { 27 | public convenience init(vertices: [MTIVertex], primitiveType: MTLPrimitiveType = .triangleStrip) { 28 | self.init(__vertices: vertices, count: vertices.count, primitiveType: primitiveType) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 | NSAssert(index != NSNotFound, @""); 63 | if (index != NSNotFound) { 64 | [_items removePointerAtIndex:index]; 65 | } 66 | } 67 | } 68 | 69 | - (void)removeObjectForKey:(id)aKey { 70 | [self setObject:nil forKey:aKey]; 71 | } 72 | 73 | - (void)removeAllObjects { 74 | [self compact]; 75 | for (id key in _items) { 76 | objc_setAssociatedObject(key, (__bridge const void *)(self), nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 77 | } 78 | _items.count = 0; 79 | } 80 | 81 | - (void)compact { 82 | // http://www.openradar.me/15396578 83 | // https://stackoverflow.com/questions/31322290/nspointerarray-weird-compaction 84 | [_items addPointer:nil]; 85 | [_items compact]; 86 | _compactableItemCount = 0; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTKTextureLoaderExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTKTextureLoaderExtension.h 3 | // Pods 4 | // 5 | // Created by Yu Ao on 06/12/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | 13 | MTK_EXTERN MTKTextureLoaderOption __nonnull const MTIMTKTextureLoaderOptionOverrideImageOrientation_iOS9; 14 | 15 | @interface MTIMTKTextureLoaderExtensions: NSObject 16 | 17 | /// MTKTextureLoaderOption + @{ MTIMTKTextureLoaderOptionOverrideImageOrientation_iOS9: @4 } 18 | @property (nonatomic,class) BOOL automaticallyFlipsTextureOniOS9; 19 | 20 | @end 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MTKTextureLoaderExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTKTextureLoaderExtension.m 3 | // Pods 4 | // 5 | // Created by Yu Ao on 06/12/2017. 6 | // 7 | 8 | #import "MTKTextureLoaderExtensions.h" 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | 13 | MTKTextureLoaderOption const MTIMTKTextureLoaderOptionOverrideImageOrientation_iOS9 = @"MTIMTKTextureLoaderOptionOverrideImageOrientation_iOS9"; 14 | 15 | static void class_swizzleSelector(Class class, SEL originalSelector, SEL newSelector) 16 | { 17 | Method origMethod = class_getInstanceMethod(class, originalSelector); 18 | Method newMethod = class_getInstanceMethod(class, newSelector); 19 | if(class_addMethod(class, originalSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { 20 | class_replaceMethod(class, newSelector, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); 21 | } else { 22 | method_exchangeImplementations(origMethod, newMethod); 23 | } 24 | } 25 | 26 | 27 | @implementation MTIMTKTextureLoaderExtensions 28 | 29 | - (BOOL)decodeCGImage_mti:(CGImageRef)image options:(NSDictionary *)options { 30 | return YES; 31 | } 32 | 33 | - (void)setImageOrientation:(NSUInteger)orientation { 34 | 35 | } 36 | 37 | static BOOL _automaticallyFlipsTextureOniOS9 = NO; 38 | 39 | + (void)setAutomaticallyFlipsTextureOniOS9:(BOOL)automaticallyFlipsTextureOniOS9 { 40 | _automaticallyFlipsTextureOniOS9 = automaticallyFlipsTextureOniOS9; 41 | } 42 | 43 | + (BOOL)automaticallyFlipsTextureOniOS9 { 44 | if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_9_x_Max) { 45 | return _automaticallyFlipsTextureOniOS9; 46 | } 47 | return NO; 48 | } 49 | 50 | + (void)load { 51 | static dispatch_once_t onceToken; 52 | dispatch_once(&onceToken, ^{ 53 | @autoreleasepool { 54 | if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_9_x_Max) { 55 | Class MTKTextureLoaderDataClass = NSClassFromString([@"MTKTextureLoader" stringByAppendingString:@"ImageIO"]); 56 | SEL selector = NSSelectorFromString([@"decodeCGImage" stringByAppendingString:@":options:"]); 57 | SEL overrideSelector = @selector(decodeCGImage_mti:options:); 58 | class_addMethod(MTKTextureLoaderDataClass, overrideSelector, imp_implementationWithBlock(^(id _self, CGImageRef image, NSDictionary *options){ 59 | NSNumber *orientation = options[MTIMTKTextureLoaderOptionOverrideImageOrientation_iOS9]; 60 | if (orientation != nil) { 61 | [_self setImageOrientation:[orientation unsignedIntegerValue]]; 62 | } 63 | return [_self decodeCGImage_mti:image options:options]; 64 | }), [MTKTextureLoaderDataClass instanceMethodSignatureForSelector:@selector(selector)].methodReturnType); 65 | class_swizzleSelector(MTKTextureLoaderDataClass, selector, overrideSelector); 66 | } 67 | } 68 | }); 69 | } 70 | 71 | @end 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/MetalPetal.h: -------------------------------------------------------------------------------- 1 | // MetalPetal Umbrella Header 2 | // Auto Generated by umbrella-header-update.sh 3 | 4 | #import 5 | #import 6 | #import 7 | #import 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | #import 32 | #import 33 | #import 34 | #import 35 | #import 36 | #import 37 | #import 38 | #import 39 | #import 40 | #import 41 | #import 42 | #import 43 | #import 44 | #import 45 | #import 46 | #import 47 | #import 48 | #import 49 | #import 50 | #import 51 | #import 52 | #import 53 | #import 54 | #import 55 | #import 56 | #import 57 | #import 58 | #import 59 | #import 60 | #import 61 | #import 62 | #import 63 | #import 64 | #import 65 | #import 66 | #import 67 | #import 68 | #import 69 | #import 70 | #import 71 | #import 72 | #import 73 | #import 74 | #import 75 | #import 76 | #import 77 | #import 78 | #import 79 | #import 80 | #import 81 | 82 | FOUNDATION_EXPORT double MetalPetalVersionNumber; 83 | FOUNDATION_EXPORT const unsigned char MetalPetalVersionString[]; 84 | -------------------------------------------------------------------------------- /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/Shaders/ColorConversionShaders.metal: -------------------------------------------------------------------------------- 1 | // 2 | // ColorConversionShaders.metal 3 | // Pods 4 | // 5 | // Created by jichuan on 2017/7/19. 6 | // 7 | // 8 | 9 | #include 10 | #include 11 | 12 | using namespace metal; 13 | 14 | namespace metalpetal { 15 | namespace yuv2rgbconvert { 16 | typedef struct { 17 | packed_float2 position; 18 | packed_float2 texcoord; 19 | } Vertex; 20 | 21 | typedef struct { 22 | float3x3 matrix; 23 | float3 offset; 24 | } ColorConversion; 25 | 26 | typedef struct { 27 | float4 position [[ position ]]; 28 | float2 texcoord; 29 | } Varyings; 30 | 31 | vertex Varyings colorConversionVertex(const device Vertex * verticies [[ buffer(0) ]], 32 | unsigned int vid [[ vertex_id ]]) { 33 | Varyings out; 34 | Vertex v = verticies[vid]; 35 | out.position = float4(float2(v.position), 0.0, 1.0); 36 | out.texcoord = v.texcoord; 37 | return out; 38 | } 39 | 40 | fragment half4 colorConversionFragment(Varyings in [[ stage_in ]], 41 | texture2d yTexture [[ texture(0) ]], 42 | texture2d cbcrTexture [[ texture(1) ]], 43 | constant ColorConversion &colorConversion [[ buffer(0) ]]) { 44 | 45 | constexpr sampler s(address::clamp_to_edge, filter::linear); 46 | float3 ycbcr = float3(yTexture.sample(s, in.texcoord).r, cbcrTexture.sample(s, in.texcoord).rg); 47 | float3 rgb = colorConversion.matrix * (ycbcr + colorConversion.offset); 48 | return half4(half3(rgb), 1.0); 49 | } 50 | 51 | kernel void colorConversion(uint2 gid [[ thread_position_in_grid ]], 52 | texture2d yTexture [[ texture(0) ]], 53 | texture2d cbcrTexture [[ texture(1) ]], 54 | texture2d outTexture [[ texture(2) ]], 55 | constant ColorConversion &colorConversion [[ buffer(0) ]]) { 56 | 57 | uint2 cbcrCoordinates = uint2(gid.x / 2, gid.y / 2); // half the size because we are using a 4:2:0 chroma subsampling 58 | float y = yTexture.read(gid).r; 59 | float2 cbcr = cbcrTexture.read(cbcrCoordinates).rg; 60 | 61 | float3 ycbcr = float3(y, cbcr); 62 | float3 rgb = colorConversion.matrix * (ycbcr + colorConversion.offset); 63 | 64 | outTexture.write(float4(float3(rgb), 1.0), gid); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Pods/MetalPetal/Frameworks/MetalPetal/Shaders/HighPassSkinSmoothing.metal: -------------------------------------------------------------------------------- 1 | // 2 | // HighPassSkinSmoothing.metal 3 | // MetalPetal 4 | // 5 | // Created by Yu Ao on 15/01/2018. 6 | // 7 | #include "MTIShaderLib.h" 8 | 9 | using namespace metal; 10 | 11 | namespace metalpetal { 12 | 13 | fragment float4 highPassSkinSmoothingGBChannelOverlay( 14 | VertexOut vertexIn [[stage_in]], 15 | texture2d sourceTexture [[texture(0)]], 16 | sampler sourceSampler [[sampler(0)]] 17 | ) { 18 | float4 textureColor = sourceTexture.sample(sourceSampler, vertexIn.textureCoordinate); 19 | textureColor.rgb = textureColor.rgb * pow(2.0, -1.0); 20 | return overlayBlend(float4(float3(textureColor.g), 1.0), float4(float3(textureColor.b), 1.0)); 21 | } 22 | 23 | fragment float4 highPassSkinSmoothingMaskProcessAndComposite( 24 | VertexOut vertexIn [[stage_in]], 25 | texture2d sourceTexture [[texture(0)]], 26 | sampler sourceSampler [[sampler(0)]], 27 | texture2d bgChannelOverlayTexture [[texture(1)]], 28 | sampler bgChannelOverlayTextureSampler [[sampler(1)]], 29 | texture2d blurredBGChannelOverlayTexture [[texture(2)]], 30 | sampler blurredBGChannelOverlayTextureSampler [[sampler(2)]], 31 | texture2d toneCurveLUT [[texture(3)]], 32 | sampler toneCurveLUTSampler [[sampler(3)]], 33 | constant float &amount [[buffer(0)]] 34 | ) { 35 | float4 textureColor = sourceTexture.sample(sourceSampler, vertexIn.textureCoordinate); 36 | 37 | float r = toneCurveLUT.sample(toneCurveLUTSampler, float2((textureColor.r * 255.0 + 0.5)/256.0, 0.5)).r; 38 | float g = toneCurveLUT.sample(toneCurveLUTSampler, float2((textureColor.g * 255.0 + 0.5)/256.0, 0.5)).g; 39 | float b = toneCurveLUT.sample(toneCurveLUTSampler, float2((textureColor.b * 255.0 + 0.5)/256.0, 0.5)).b; 40 | float4 toneCurvedColor = mix(textureColor, float4(r,g,b,textureColor.a), amount); 41 | 42 | float4 bgChannelOverlayColor = bgChannelOverlayTexture.sample(bgChannelOverlayTextureSampler, vertexIn.textureCoordinate); 43 | float4 blurredBGChannelOverlayColor = blurredBGChannelOverlayTexture.sample(blurredBGChannelOverlayTextureSampler, vertexIn.textureCoordinate); 44 | 45 | float3 mask = bgChannelOverlayColor.rgb - blurredBGChannelOverlayColor.rgb + float3(0.5); 46 | mask = hardLightBlend(float4(mask, 1.0), float4(mask, 1.0)).rgb; 47 | mask = hardLightBlend(float4(mask, 1.0), float4(mask, 1.0)).rgb; 48 | mask = hardLightBlend(float4(mask, 1.0), float4(mask, 1.0)).rgb; 49 | 50 | float k = 255.0 / (164.0 - 75.0); 51 | float maskValue = clamp((mask.r - 75.0 / 255.0) * k, 0.0, 1.0); 52 | 53 | return mix(toneCurvedColor, textureColor, maskValue); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /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 "MTIDrawableRendering.h" 12 | 13 | @class MTIImage,MTIContext; 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @interface MTIImageView : UIView 18 | 19 | @property (nonatomic) MTLPixelFormat colorPixelFormat; 20 | 21 | @property (nonatomic) MTLClearColor clearColor; 22 | 23 | @property (nonatomic) MTIDrawableRenderingResizingMode resizingMode; 24 | 25 | @property (nonatomic, strong) MTIContext *context; 26 | 27 | @property (nonatomic, strong, nullable) MTIImage *image; 28 | 29 | @property (nonatomic) BOOL drawsImmediately; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /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/Target Support Files/MetalPetal/MetalPetal-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 | 0.9.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MetalPetal : NSObject 3 | @end 4 | @implementation PodsDummy_MetalPetal 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MetalPetal/MetalPetal-prefix.pch: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/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/Target Support Files/MetalPetal/MetalPetal.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-LUTConverter/Pods-LUTConverter-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-LUTConverter/Pods-LUTConverter-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-LUTConverter/Pods-LUTConverter-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-LUTConverter/Pods-LUTConverter-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_LUTConverter : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_LUTConverter 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-LUTConverter/Pods-LUTConverter-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_LUTConverterVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_LUTConverterVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-LUTConverter/Pods-LUTConverter.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | CODE_SIGN_IDENTITY = 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-LUTConverter/Pods-LUTConverter.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_LUTConverter { 2 | umbrella header "Pods-LUTConverter-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-LUTConverter/Pods-LUTConverter.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | CODE_SIGN_IDENTITY = 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/MetalPetal/MetalPetal.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "MetalPetal" 8 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 9 | PODS_BUILD_DIR = ${BUILD_DIR} 10 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 12 | PODS_ROOT = ${SRCROOT}/Pods 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorLookupTable2Cube 2 | Convert color lookup table images to Adobe Cube LUT files (.cube) 3 | --------------------------------------------------------------------------------