├── .gitignore
├── Assets
└── renderer.zip
├── BoilerplateGenerator
├── .gitignore
├── Package.resolved
├── Package.swift
└── Sources
│ └── BoilerplateGenerator
│ ├── SIMDKVCSupport.swift
│ └── main.swift
├── Example
├── MetalPetalJS.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── MetalPetalJS-Example.xcscheme
├── MetalPetalJS.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── WorkspaceSettings.xcsettings
├── MetalPetalJS
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── MTIAppDelegate.h
│ ├── MTIAppDelegate.m
│ ├── MTIViewController.h
│ ├── MTIViewController.m
│ ├── MetalPetalJS-Info.plist
│ ├── MetalPetalJS-Prefix.pch
│ ├── Unzip.swift
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ ├── main.m
│ ├── mask.png
│ ├── script.js
│ ├── shader.metal
│ └── test.jpg
├── Podfile
├── Podfile.lock
└── Pods
│ ├── Local Podspecs
│ └── MetalPetalJS.podspec.json
│ ├── Manifest.lock
│ ├── MetalPetal
│ ├── Frameworks
│ │ └── MetalPetal
│ │ │ ├── Filters
│ │ │ ├── MTIAlphaPremultiplicationFilter.h
│ │ │ ├── MTIAlphaPremultiplicationFilter.m
│ │ │ ├── MTIBlendFilter.h
│ │ │ ├── MTIBlendFilter.m
│ │ │ ├── MTIBlendWithMaskFilter.h
│ │ │ ├── MTIBlendWithMaskFilter.m
│ │ │ ├── MTIBulgeDistortionFilter.h
│ │ │ ├── MTIBulgeDistortionFilter.m
│ │ │ ├── MTICLAHEFilter.h
│ │ │ ├── MTICLAHEFilter.m
│ │ │ ├── MTIChromaKeyBlendFilter.h
│ │ │ ├── MTIChromaKeyBlendFilter.m
│ │ │ ├── MTIColorHalftoneFilter.h
│ │ │ ├── MTIColorHalftoneFilter.m
│ │ │ ├── MTIColorLookupFilter.h
│ │ │ ├── MTIColorLookupFilter.m
│ │ │ ├── MTIColorMatrixFilter.h
│ │ │ ├── MTIColorMatrixFilter.m
│ │ │ ├── MTICropFilter.h
│ │ │ ├── MTICropFilter.m
│ │ │ ├── MTIDotScreenFilter.h
│ │ │ ├── MTIDotScreenFilter.m
│ │ │ ├── MTIFilter.h
│ │ │ ├── MTIFilter.m
│ │ │ ├── MTIHexagonalBokehBlurFilter.h
│ │ │ ├── MTIHexagonalBokehBlurFilter.m
│ │ │ ├── MTIHighPassSkinSmoothingFilter.h
│ │ │ ├── MTIHighPassSkinSmoothingFilter.m
│ │ │ ├── MTIImage+Filters.h
│ │ │ ├── MTIImage+Filters.m
│ │ │ ├── MTIMPSBoxBlurFilter.h
│ │ │ ├── MTIMPSBoxBlurFilter.m
│ │ │ ├── MTIMPSConvolutionFilter.h
│ │ │ ├── MTIMPSConvolutionFilter.m
│ │ │ ├── MTIMPSDefinitionFilter.h
│ │ │ ├── MTIMPSDefinitionFilter.m
│ │ │ ├── MTIMPSGaussianBlurFilter.h
│ │ │ ├── MTIMPSGaussianBlurFilter.m
│ │ │ ├── MTIMPSHistogramFilter.h
│ │ │ ├── MTIMPSHistogramFilter.m
│ │ │ ├── MTIMPSSobelFilter.h
│ │ │ ├── MTIMPSSobelFilter.m
│ │ │ ├── MTIMPSUnsharpMaskFilter.h
│ │ │ ├── MTIMPSUnsharpMaskFilter.m
│ │ │ ├── MTIMultilayerCompositingFilter.h
│ │ │ ├── MTIMultilayerCompositingFilter.m
│ │ │ ├── MTIPixellateFilter.h
│ │ │ ├── MTIPixellateFilter.m
│ │ │ ├── MTIRGBColorSpaceConversionFilter.h
│ │ │ ├── MTIRGBColorSpaceConversionFilter.m
│ │ │ ├── MTIRGBToneCurveFilter.h
│ │ │ ├── MTIRGBToneCurveFilter.m
│ │ │ ├── MTITransformFilter.h
│ │ │ ├── MTITransformFilter.m
│ │ │ ├── MTIUnaryImageRenderingFilter.h
│ │ │ ├── MTIUnaryImageRenderingFilter.m
│ │ │ ├── MTIVibranceFilter.h
│ │ │ └── MTIVibranceFilter.m
│ │ │ ├── Kernels
│ │ │ ├── MTIComputePipelineKernel.h
│ │ │ ├── MTIComputePipelineKernel.m
│ │ │ ├── MTIKernel.h
│ │ │ ├── MTIKernel.m
│ │ │ ├── MTIMPSKernel.h
│ │ │ ├── MTIMPSKernel.m
│ │ │ ├── MTIMultilayerCompositeKernel.h
│ │ │ ├── MTIMultilayerCompositeKernel.m
│ │ │ ├── MTIRenderCommand.h
│ │ │ ├── MTIRenderCommand.m
│ │ │ ├── MTIRenderPipelineKernel.h
│ │ │ └── MTIRenderPipelineKernel.m
│ │ │ ├── MTIAlphaType.h
│ │ │ ├── MTIAlphaType.m
│ │ │ ├── MTIBlendModes.h
│ │ │ ├── MTIBlendModes.m
│ │ │ ├── MTIBuffer.h
│ │ │ ├── MTIBuffer.m
│ │ │ ├── MTICVMetalTextureBridge.h
│ │ │ ├── MTICVMetalTextureBridge.m
│ │ │ ├── MTICVMetalTextureBridging.h
│ │ │ ├── MTICVMetalTextureCache.h
│ │ │ ├── MTICVMetalTextureCache.m
│ │ │ ├── MTICVPixelBufferPool.h
│ │ │ ├── MTICVPixelBufferPool.m
│ │ │ ├── MTICVPixelBufferPromise.h
│ │ │ ├── MTICVPixelBufferPromise.m
│ │ │ ├── MTICVPixelBufferRendering.h
│ │ │ ├── MTICVPixelBufferRendering.m
│ │ │ ├── MTIColor.h
│ │ │ ├── MTIColor.m
│ │ │ ├── MTIColorMatrix.h
│ │ │ ├── MTIColorMatrix.m
│ │ │ ├── MTIComputePipeline.h
│ │ │ ├── MTIComputePipeline.m
│ │ │ ├── MTIContext+Internal.h
│ │ │ ├── MTIContext+Rendering.h
│ │ │ ├── MTIContext+Rendering.m
│ │ │ ├── MTIContext.h
│ │ │ ├── MTIContext.m
│ │ │ ├── MTICoreImageRendering.h
│ │ │ ├── MTICoreImageRendering.m
│ │ │ ├── MTIDefer.h
│ │ │ ├── MTIDefer.m
│ │ │ ├── MTIDrawableRendering.h
│ │ │ ├── MTIDrawableRendering.m
│ │ │ ├── MTIError.h
│ │ │ ├── MTIError.m
│ │ │ ├── MTIFunctionDescriptor.h
│ │ │ ├── MTIFunctionDescriptor.m
│ │ │ ├── MTIGeometry.h
│ │ │ ├── MTIGeometry.m
│ │ │ ├── MTIHasher.h
│ │ │ ├── MTIHasher.m
│ │ │ ├── MTIImage+Promise.h
│ │ │ ├── MTIImage.h
│ │ │ ├── MTIImage.m
│ │ │ ├── MTIImageOrientation.h
│ │ │ ├── MTIImageOrientation.m
│ │ │ ├── MTIImagePromise.h
│ │ │ ├── MTIImagePromise.m
│ │ │ ├── MTIImagePromiseDebug.h
│ │ │ ├── MTIImagePromiseDebug.m
│ │ │ ├── MTIImageProperties.h
│ │ │ ├── MTIImageProperties.m
│ │ │ ├── MTIImageRenderingContext.h
│ │ │ ├── MTIImageRenderingContext.mm
│ │ │ ├── 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
│ │ │ ├── MTITextureLoader.h
│ │ │ ├── MTITextureLoader.m
│ │ │ ├── MTITextureLoaderForiOS9.h
│ │ │ ├── MTITextureLoaderForiOS9.m
│ │ │ ├── MTITexturePool.h
│ │ │ ├── MTITexturePool.mm
│ │ │ ├── MTITransform.h
│ │ │ ├── MTITransform.m
│ │ │ ├── MTIVector+SIMD.h
│ │ │ ├── MTIVector+SIMD.m
│ │ │ ├── MTIVector.h
│ │ │ ├── MTIVector.m
│ │ │ ├── MTIVertex.h
│ │ │ ├── MTIVertex.m
│ │ │ ├── MTIWeakToStrongObjectsMapTable.h
│ │ │ ├── MTIWeakToStrongObjectsMapTable.m
│ │ │ ├── MetalPetal.h
│ │ │ ├── MetalPetal.modulemap
│ │ │ ├── SceneKit
│ │ │ ├── MTISCNSceneRenderer.h
│ │ │ └── MTISCNSceneRenderer.m
│ │ │ ├── Shaders
│ │ │ ├── BlendingShaders.metal
│ │ │ ├── CLAHE.metal
│ │ │ ├── ColorConversionShaders.metal
│ │ │ ├── Halftone.metal
│ │ │ ├── HighPassSkinSmoothing.metal
│ │ │ ├── LensBlur.metal
│ │ │ ├── MTIShaderLib.h
│ │ │ ├── MultilayerCompositeShaders.metal
│ │ │ └── Shaders.metal
│ │ │ └── UI
│ │ │ ├── MTIImageView.h
│ │ │ └── MTIImageView.m
│ ├── LICENSE
│ └── README.md
│ ├── Pods.xcodeproj
│ └── project.pbxproj
│ ├── Target Support Files
│ ├── MetalPetal
│ │ ├── Info.plist
│ │ ├── MetalPetal-Info.plist
│ │ ├── MetalPetal-dummy.m
│ │ ├── MetalPetal.modulemap
│ │ └── MetalPetal.xcconfig
│ ├── MetalPetalJS
│ │ ├── Info.plist
│ │ ├── MetalPetalJS-Info.plist
│ │ ├── MetalPetalJS-dummy.m
│ │ ├── MetalPetalJS-prefix.pch
│ │ ├── MetalPetalJS-umbrella.h
│ │ ├── MetalPetalJS.modulemap
│ │ ├── MetalPetalJS.xcconfig
│ │ └── ResourceBundle-MetalPetalJS-Info.plist
│ ├── Pods-MetalPetalJS_Example
│ │ ├── Info.plist
│ │ ├── Pods-MetalPetalJS_Example-Info.plist
│ │ ├── Pods-MetalPetalJS_Example-acknowledgements.markdown
│ │ ├── Pods-MetalPetalJS_Example-acknowledgements.plist
│ │ ├── Pods-MetalPetalJS_Example-dummy.m
│ │ ├── Pods-MetalPetalJS_Example-frameworks.sh
│ │ ├── Pods-MetalPetalJS_Example-resources.sh
│ │ ├── Pods-MetalPetalJS_Example-umbrella.h
│ │ ├── Pods-MetalPetalJS_Example.debug.xcconfig
│ │ ├── Pods-MetalPetalJS_Example.modulemap
│ │ └── Pods-MetalPetalJS_Example.release.xcconfig
│ └── ZIPFoundation
│ │ ├── ZIPFoundation-Info.plist
│ │ ├── ZIPFoundation-dummy.m
│ │ ├── ZIPFoundation-prefix.pch
│ │ ├── ZIPFoundation-umbrella.h
│ │ ├── ZIPFoundation.modulemap
│ │ └── ZIPFoundation.xcconfig
│ └── ZIPFoundation
│ ├── LICENSE
│ ├── README.md
│ └── Sources
│ └── ZIPFoundation
│ ├── Archive+Reading.swift
│ ├── Archive+Writing.swift
│ ├── Archive.swift
│ ├── Data+Compression.swift
│ ├── Data+Serialization.swift
│ ├── Entry.swift
│ └── FileManager+ZIP.swift
├── LICENSE
├── MetalPetalJS.podspec
├── MetalPetalJS
├── Assets
│ ├── .gitkeep
│ └── MetalPetal.js
└── Classes
│ ├── .gitkeep
│ ├── MTIFilterJSSupport.h
│ ├── MTIFilterJSSupport.m
│ ├── MTIImageJSSupport.h
│ ├── MTIImageJSSupport.m
│ ├── MTIJSExtension.h
│ ├── MTIJSExtension.m
│ ├── MTIKernelJSSupport.h
│ ├── MTIKernelJSSupport.m
│ ├── MTILayerJSSupport.h
│ ├── MTILayerJSSupport.m
│ ├── MTIMaskJSSupport.h
│ ├── MTIMaskJSSupport.m
│ ├── MTIRenderCommandJSSupport.h
│ ├── MTIRenderCommandJSSupport.m
│ ├── MTISIMDTypeKVCSupport.h
│ ├── MTISIMDTypeKVCSupport.m
│ ├── MTIVectorJSSupport.h
│ ├── MTIVectorJSSupport.m
│ ├── MTIVerticesJSSupport.h
│ └── MTIVerticesJSSupport.m
├── README.md
├── _Pods.xcodeproj
└── generate-boilerplate.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | .DS_Store
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 |
22 | ## Other
23 | *.moved-aside
24 | *.xccheckout
25 | *.xcscmblueprint
26 |
27 | ## Obj-C/Swift specific
28 | *.hmap
29 | *.ipa
30 | *.dSYM.zip
31 | *.dSYM
32 |
33 | # CocoaPods
34 | #
35 | # We recommend against adding the Pods directory to your .gitignore. However
36 | # you should judge for yourself, the pros and cons are mentioned at:
37 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
38 | #
39 | # Pods/
40 |
41 | # Carthage
42 | #
43 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
44 | # Carthage/Checkouts
45 |
46 | Carthage/Build
47 |
48 | # fastlane
49 | #
50 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
51 | # screenshots whenever they are needed.
52 | # For more information about the recommended setup visit:
53 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
54 |
55 | fastlane/report.xml
56 | fastlane/Preview.html
57 | fastlane/screenshots/**/*.png
58 | fastlane/test_output
59 |
60 | # Code Injection
61 | #
62 | # After new code Injection tools there's a generated folder /iOSInjectionProject
63 | # https://github.com/johnno1962/injectionforxcode
64 |
65 | iOSInjectionProject/
66 |
--------------------------------------------------------------------------------
/Assets/renderer.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetalPetal/MetalPetalJS/aa04bd662adfa3b937ebf0f7712b92f5fa730842/Assets/renderer.zip
--------------------------------------------------------------------------------
/BoilerplateGenerator/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 |
--------------------------------------------------------------------------------
/BoilerplateGenerator/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "object": {
3 | "pins": [
4 | {
5 | "package": "SIMDType",
6 | "repositoryURL": "https://github.com/MetalPetal/SIMDType",
7 | "state": {
8 | "branch": "master",
9 | "revision": "707ea53ee6142023e2d83490a64212a10c94f3b1",
10 | "version": null
11 | }
12 | }
13 | ]
14 | },
15 | "version": 1
16 | }
17 |
--------------------------------------------------------------------------------
/BoilerplateGenerator/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:4.0
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "BoilerplateGenerator",
8 | dependencies: [
9 | // Dependencies declare other packages that this package depends on.
10 | .package(url: "https://github.com/MetalPetal/SIMDType", .branch("master")),
11 | ],
12 | targets: [
13 | // Targets are the basic building blocks of a package. A target can define a module or a test suite.
14 | // Targets can depend on other targets in this package, and on products in packages which this package depends on.
15 | .target(
16 | name: "BoilerplateGenerator",
17 | dependencies: ["SIMDType"]),
18 | ]
19 | )
20 |
--------------------------------------------------------------------------------
/BoilerplateGenerator/Sources/BoilerplateGenerator/main.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | if CommandLine.arguments.count > 1 {
4 | //running in command line mode
5 | let sourceDirectory = URL(fileURLWithPath: CommandLine.arguments[1])
6 | let fileDirectory = sourceDirectory.appendingPathComponent("Classes")
7 | for (file, content) in SIMDTypeKVCSupportCodeGenerator.generate() {
8 | let url = fileDirectory.appendingPathComponent(file)
9 | try! content.write(to: url, atomically: true, encoding: .utf8)
10 | }
11 | } else {
12 | //running in playground mode
13 | print(SIMDTypeKVCSupportCodeGenerator.generate())
14 | }
15 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/MTIAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIAppDelegate.h
3 | // MetalPetalJS
4 | //
5 | // Created by yuao on 06/25/2018.
6 | // Copyright (c) 2018 yuao. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface MTIAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/MTIAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIAppDelegate.m
3 | // MetalPetalJS
4 | //
5 | // Created by yuao on 06/25/2018.
6 | // Copyright (c) 2018 yuao. All rights reserved.
7 | //
8 |
9 | #import "MTIAppDelegate.h"
10 |
11 | @implementation MTIAppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application
42 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/MTIViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIViewController.h
3 | // MetalPetalJS
4 | //
5 | // Created by yuao on 06/25/2018.
6 | // Copyright (c) 2018 yuao. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface MTIViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/MetalPetalJS-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
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 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UIStatusBarHidden
36 |
37 | UISupportedInterfaceOrientations
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationLandscapeLeft
41 | UIInterfaceOrientationLandscapeRight
42 |
43 | UISupportedInterfaceOrientations~ipad
44 |
45 | UIInterfaceOrientationPortrait
46 | UIInterfaceOrientationPortraitUpsideDown
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/MetalPetalJS-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | @import UIKit;
15 | @import Foundation;
16 | #endif
17 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/Unzip.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Unzip.swift
3 | // MetalPetalJS_Example
4 | //
5 | // Created by Yu Ao on 2019/3/28.
6 | // Copyright © 2019 yuao. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import ZIPFoundation
11 |
12 | @objc public class Unzip: NSObject {
13 |
14 | private override init() {
15 | super.init()
16 | }
17 |
18 | @objc(unzipFileAtURL:toURL:error:) public static func unzip(_ file: URL, to url: URL) throws {
19 | try FileManager().unzipItem(at: file, to: url)
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // MetalPetalJS
4 | //
5 | // Created by yuao on 06/25/2018.
6 | // Copyright (c) 2018 yuao. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 | #import "MTIAppDelegate.h"
11 |
12 | int main(int argc, char * argv[])
13 | {
14 | @autoreleasepool {
15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MTIAppDelegate class]));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetalPetal/MetalPetalJS/aa04bd662adfa3b937ebf0f7712b92f5fa730842/Example/MetalPetalJS/mask.png
--------------------------------------------------------------------------------
/Example/MetalPetalJS/script.js:
--------------------------------------------------------------------------------
1 | function render(image, options) {
2 |
3 | var filter = MTINativeFilter("MTIMPSBoxBlurFilter");
4 | filter.size$int2 = MTIVector.fromIntValues([5,5]);
5 | filter.inputImage = image;
6 |
7 | var blurredImage = filter.outputImage;
8 |
9 | var maskImage = MTIImage.build({
10 | filePath: MTIJSUtilities.joinPath(MTIJSEnvironment.mainBundlePath, "mask.png"),
11 | options: { MTKTextureLoaderOptionSRGB: false },
12 | alphaType: MTIAlphaType.alphaIsOne
13 | });
14 |
15 | var blendFilter = MTINativeFilter.build({
16 | name: "MTIBlendFilter",
17 | options: {"blendMode": "Multiply"}
18 | });
19 |
20 | blendFilter.intensity = 1.0;
21 | blendFilter.inputBackgroundImage = blurredImage;
22 | blendFilter.inputImage = maskImage;
23 |
24 | var vignetteImage = blendFilter.outputImage;
25 |
26 | var geometry = MTIVertices.fullViewportSquareVertices();
27 |
28 | var kernel = MTIRenderPipelineKernel.build({
29 | fragmentFunction: {
30 | name: "shader",
31 | library: MTIJSUtilities.joinPath(options.resourcePath, "default.metallib")
32 | },
33 | vertexFunction: {
34 | name: "passthroughVertex"
35 | }
36 | });
37 |
38 | var command = MTIRenderCommand.build({
39 | kernel,
40 | geometry,
41 | images: [vignetteImage],
42 | parameters: {"offset": MTIVector.vectorWithFloatValues([0.008]) }
43 | });
44 |
45 | var descriptor = MTIRenderPassOutputDescriptor.build({
46 | size: blurredImage.size,
47 | pixelFormat: 0
48 | });
49 |
50 | var outputImage = MTIRenderCommand.perform({
51 | commands: [command],
52 | outputDescriptors: [descriptor]
53 | })[0];
54 |
55 | return outputImage;
56 | }
57 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/shader.metal:
--------------------------------------------------------------------------------
1 | //
2 | // shader.metal
3 | // MetalPetalJS_Example
4 | //
5 | // Created by Jackie on 2018/6/25.
6 | //
7 |
8 | #include "MTIShaderLib.h"
9 |
10 | using namespace metalpetal;
11 |
12 | fragment float4 shader(VertexOut vertexIn [[ stage_in ]],
13 | texture2d inputTexture [[ texture(0) ]],
14 | constant float &offset [[buffer(0)]],
15 | sampler s [[ sampler(0) ]]) {
16 | float4 colorR = inputTexture.sample(s, vertexIn.textureCoordinate + float2(offset));
17 | float4 colorG = inputTexture.sample(s, vertexIn.textureCoordinate);
18 | float4 colorB = inputTexture.sample(s, vertexIn.textureCoordinate - float2(offset));
19 | return float4(colorR.r, colorG.g, colorB.b, 1.0);
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/Example/MetalPetalJS/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetalPetal/MetalPetalJS/aa04bd662adfa3b937ebf0f7712b92f5fa730842/Example/MetalPetalJS/test.jpg
--------------------------------------------------------------------------------
/Example/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '9.0'
2 |
3 | use_frameworks!
4 |
5 | target 'MetalPetalJS_Example' do
6 | pod 'MetalPetalJS', :path => '../'
7 | pod 'ZIPFoundation'
8 | end
9 |
--------------------------------------------------------------------------------
/Example/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - MetalPetal (1.4.0):
3 | - MetalPetal/Core (= 1.4.0)
4 | - MetalPetal/Core (1.4.0)
5 | - MetalPetalJS (0.1.0):
6 | - MetalPetal
7 | - ZIPFoundation (0.9.8)
8 |
9 | DEPENDENCIES:
10 | - MetalPetalJS (from `../`)
11 | - ZIPFoundation
12 |
13 | SPEC REPOS:
14 | https://github.com/cocoapods/specs.git:
15 | - MetalPetal
16 | - ZIPFoundation
17 |
18 | EXTERNAL SOURCES:
19 | MetalPetalJS:
20 | :path: "../"
21 |
22 | SPEC CHECKSUMS:
23 | MetalPetal: 92eea965b9b2f0c677d82618c2e78fa7e4347846
24 | MetalPetalJS: 1e77efce45a497c59ebb09e34fcba00a40ff3950
25 | ZIPFoundation: b1f07e4409baf1641f3fe5948b2a1c3f5c500cb1
26 |
27 | PODFILE CHECKSUM: c3412dc6ebc59ce2634c44fc54a282335e01067b
28 |
29 | COCOAPODS: 1.7.0.beta.2
30 |
--------------------------------------------------------------------------------
/Example/Pods/Local Podspecs/MetalPetalJS.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "MetalPetalJS",
3 | "version": "0.1.0",
4 | "summary": "A short description of MetalPetalJS.",
5 | "description": "TODO: Add long description of the pod here.",
6 | "homepage": "https://github.com/MetalPetal/MetalPetalJS",
7 | "license": {
8 | "type": "MIT",
9 | "file": "LICENSE"
10 | },
11 | "authors": {
12 | "yuao": "me@imyuao.com"
13 | },
14 | "source": {
15 | "git": "https://github.com/MetalPetal/MetalPetalJS.git",
16 | "tag": "0.1.0"
17 | },
18 | "requires_arc": true,
19 | "prefix_header_file": false,
20 | "platforms": {
21 | "ios": "9.0"
22 | },
23 | "source_files": "MetalPetalJS/Classes/**/*",
24 | "resources": "MetalPetalJS/Assets/*.{png,js}",
25 | "dependencies": {
26 | "MetalPetal": [
27 |
28 | ]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Example/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - MetalPetal (1.4.0):
3 | - MetalPetal/Core (= 1.4.0)
4 | - MetalPetal/Core (1.4.0)
5 | - MetalPetalJS (0.1.0):
6 | - MetalPetal
7 | - ZIPFoundation (0.9.8)
8 |
9 | DEPENDENCIES:
10 | - MetalPetalJS (from `../`)
11 | - ZIPFoundation
12 |
13 | SPEC REPOS:
14 | https://github.com/cocoapods/specs.git:
15 | - MetalPetal
16 | - ZIPFoundation
17 |
18 | EXTERNAL SOURCES:
19 | MetalPetalJS:
20 | :path: "../"
21 |
22 | SPEC CHECKSUMS:
23 | MetalPetal: 92eea965b9b2f0c677d82618c2e78fa7e4347846
24 | MetalPetalJS: 1e77efce45a497c59ebb09e34fcba00a40ff3950
25 | ZIPFoundation: b1f07e4409baf1641f3fe5948b2a1c3f5c500cb1
26 |
27 | PODFILE CHECKSUM: c3412dc6ebc59ce2634c44fc54a282335e01067b
28 |
29 | COCOAPODS: 1.7.0.beta.2
30 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIAlphaPremultiplicationFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIUnpremultiplyAlphaFilter.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 30/09/2017.
6 | //
7 |
8 | #import "MTIFilter.h"
9 | #import "MTIUnaryImageRenderingFilter.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface MTIUnpremultiplyAlphaFilter : MTIUnaryImageRenderingFilter
14 |
15 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image;
16 |
17 | @end
18 |
19 | @interface MTIPremultiplyAlphaFilter : MTIUnaryImageRenderingFilter
20 |
21 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image;
22 |
23 | @end
24 |
25 | /// Unpremultiply alpha and convert to linear RGB
26 | @interface MTIUnpremultiplyAlphaWithSRGBToLinearRGBFilter : MTIUnaryImageRenderingFilter
27 |
28 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image;
29 |
30 | @end
31 |
32 | NS_ASSUME_NONNULL_END
33 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBulgeDistortionFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIBulgeDistortionFilter.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/2/14.
6 | //
7 |
8 | #import "MTIUnaryImageRenderingFilter.h"
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface MTIBulgeDistortionFilter : MTIUnaryImageRenderingFilter
14 |
15 | @property (nonatomic) simd_float2 center; //in pixels
16 |
17 | @property (nonatomic) float radius; //in pixels
18 |
19 | @property (nonatomic) float scale;
20 |
21 |
22 | @end
23 |
24 | NS_ASSUME_NONNULL_END
25 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIBulgeDistortionFilter.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIBulgeDistortionFilter.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/2/14.
6 | //
7 |
8 | #import "MTIBulgeDistortionFilter.h"
9 | #import "MTIFunctionDescriptor.h"
10 | #import "MTIVector+SIMD.h"
11 |
12 | @implementation MTIBulgeDistortionFilter
13 |
14 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor {
15 | return [[MTIFunctionDescriptor alloc] initWithName:@"bulgeDistortion"];
16 | }
17 |
18 | - (NSDictionary *)parameters {
19 | return @{@"center": [MTIVector vectorWithFloat2:_center],
20 | @"radius": @(_radius),
21 | @"scale": @(_scale)};
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIFilter.h
3 | // Pods
4 | //
5 | // Created by YuAo on 25/06/2017.
6 | //
7 | //
8 |
9 | #import
10 | #import
11 | #import "MTIPixelFormat.h"
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | FOUNDATION_EXPORT NSString * const MTIFilterPassthroughVertexFunctionName;
16 | FOUNDATION_EXPORT NSString * const MTIFilterPassthroughFragmentFunctionName;
17 |
18 | FOUNDATION_EXPORT NSString * const MTIFilterUnpremultiplyAlphaFragmentFunctionName;
19 | FOUNDATION_EXPORT NSString * const MTIFilterUnpremultiplyAlphaWithSRGBToLinearRGBFragmentFunctionName;
20 | FOUNDATION_EXPORT NSString * const MTIFilterPremultiplyAlphaFragmentFunctionName;
21 |
22 | FOUNDATION_EXPORT NSString * const MTIFilterColorMatrixFragmentFunctionName;
23 |
24 | @class MTIImage;
25 |
26 | @protocol MTIFilter
27 |
28 | @property (nonatomic) MTLPixelFormat outputPixelFormat; //Default: MTIPixelFormatUnspecified aka MTLPixelFormatInvalid
29 |
30 | @property (nonatomic, readonly, nullable) MTIImage *outputImage;
31 |
32 | @end
33 |
34 | @protocol MTIUnaryFilter
35 |
36 | @property (nonatomic, strong, nullable) MTIImage *inputImage;
37 |
38 | @end
39 |
40 | NS_ASSUME_NONNULL_END
41 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIFilter.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIFilter.m
3 | // Pods
4 | //
5 | // Created by YuAo on 25/06/2017.
6 | //
7 | //
8 |
9 | #import "MTIFilter.h"
10 | #import "MTIVertex.h"
11 | #import "MTIImage.h"
12 | #import "MTIFunctionDescriptor.h"
13 |
14 | NSString * const MTIFilterPassthroughVertexFunctionName = @"passthroughVertex";
15 | NSString * const MTIFilterPassthroughFragmentFunctionName = @"passthrough";
16 |
17 | NSString * const MTIFilterUnpremultiplyAlphaFragmentFunctionName = @"unpremultiplyAlpha";
18 | NSString * const MTIFilterUnpremultiplyAlphaWithSRGBToLinearRGBFragmentFunctionName = @"unpremultiplyAlphaWithSRGBToLinearRGB";
19 | NSString * const MTIFilterPremultiplyAlphaFragmentFunctionName = @"premultiplyAlpha";
20 |
21 | NSString * const MTIFilterColorMatrixFragmentFunctionName = @"colorMatrixProjection";
22 |
23 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSDefinitionFilter.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIMPSDefinitionFilter.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2018/8/21.
6 | //
7 |
8 | #import "MTIMPSDefinitionFilter.h"
9 | #import "MTIMPSGaussianBlurFilter.h"
10 | #import "MTIRenderPipelineKernel.h"
11 | #import "MTIFunctionDescriptor.h"
12 | #import "MTIImage.h"
13 |
14 | @interface MTIMPSDefinitionFilter ()
15 |
16 | @property (nonatomic, strong) MTIMPSGaussianBlurFilter *blurFilter;
17 |
18 | @end
19 |
20 | @implementation MTIMPSDefinitionFilter
21 | @synthesize inputImage = _inputImage;
22 | @synthesize outputPixelFormat = _outputPixelFormat;
23 |
24 | + (MTIRenderPipelineKernel *)kernel {
25 | return [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName]
26 | fragmentFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:@"clarity"]];
27 | }
28 |
29 | - (instancetype)init {
30 | if (self = [super init]) {
31 | _blurFilter = [[MTIMPSGaussianBlurFilter alloc] init];
32 | }
33 | return self;
34 | }
35 |
36 | - (void)setInputImage:(MTIImage *)inputImage {
37 | _inputImage = inputImage;
38 | _blurFilter.inputImage = inputImage;
39 | }
40 |
41 | - (MTIImage *)outputImage {
42 | if (!self.inputImage) {
43 | return nil;
44 | }
45 |
46 | if (self.intensity <= 0) {
47 | return self.inputImage;
48 | }
49 |
50 | self.blurFilter.radius = self.inputImage.size.width / 1024.0 * 32.0;
51 | MTIImage *blurredImage = self.blurFilter.outputImage;
52 |
53 | return [MTIMPSDefinitionFilter.kernel applyToInputImages:@[self.inputImage, blurredImage]
54 | parameters:@{@"intensity": @(self.intensity)}
55 | outputTextureDimensions:self.inputImage.dimensions
56 | outputPixelFormat:self.outputPixelFormat];
57 | }
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMPSUnsharpMaskFilter.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIUSMSharpenFilter.m
3 | // MetalPetal
4 | //
5 | // Created by yi chen on 2018/2/7.
6 | //
7 |
8 | #import "MTIMPSUnsharpMaskFilter.h"
9 | #import "MTIMPSGaussianBlurFilter.h"
10 | #import "MTIRenderPipelineKernel.h"
11 | #import "MTIFunctionDescriptor.h"
12 | #import "MTIImage.h"
13 |
14 | @interface MTIMPSUnsharpMaskFilter ()
15 |
16 | @property (nonatomic,strong) MTIMPSGaussianBlurFilter *gaussianBlurFilter;
17 |
18 | @end
19 |
20 | @implementation MTIMPSUnsharpMaskFilter
21 | @synthesize outputPixelFormat = _outputPixelFormat;
22 | @synthesize inputImage = _inputImage;
23 |
24 | - (instancetype)init
25 | {
26 | self = [super init];
27 | if (self) {
28 | _scale = 0.5;
29 | _threshold = 0;
30 | _radius = 2.0;
31 | _gaussianBlurFilter = [[MTIMPSGaussianBlurFilter alloc] init];
32 | _gaussianBlurFilter.radius = _radius;
33 | }
34 | return self;
35 | }
36 |
37 | + (MTIRenderPipelineKernel *)kernel {
38 | static MTIRenderPipelineKernel *kernel;
39 | static dispatch_once_t onceToken;
40 | dispatch_once(&onceToken, ^{
41 | kernel = [[MTIRenderPipelineKernel alloc] initWithVertexFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:MTIFilterPassthroughVertexFunctionName]
42 | fragmentFunctionDescriptor:[[MTIFunctionDescriptor alloc] initWithName:@"usmSecondPass"]];
43 | });
44 | return kernel;
45 | }
46 |
47 | - (void)setInputImage:(MTIImage *)inputImage {
48 | _inputImage = inputImage;
49 | _gaussianBlurFilter.inputImage = inputImage;
50 | }
51 |
52 | - (void)setRadius:(float)radius {
53 | _radius = radius;
54 | _gaussianBlurFilter.radius = radius;
55 | }
56 |
57 | - (MTIImage *)outputImage {
58 | if (!self.inputImage) {
59 | return nil;
60 | }
61 |
62 | MTIImage *blurImage = self.gaussianBlurFilter.outputImage;
63 |
64 | return [[[self class] kernel] applyToInputImages:@[self.inputImage, blurImage]
65 | parameters:@{@"scale": @(self.scale), @"threshold": @(self.threshold)}
66 | outputTextureDimensions: MTITextureDimensionsMake2DFromCGSize(self.inputImage.size)
67 | outputPixelFormat:_outputPixelFormat];
68 |
69 | return nil;
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIMultilayerCompositingFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIMultilayerCompositingFilter.h
3 | // Pods
4 | //
5 | // Created by YuAo on 27/09/2017.
6 | //
7 |
8 | #import "MTIFilter.h"
9 | #import "MTILayer.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface MTIMultilayerCompositingFilter : NSObject
14 |
15 | @property (nonatomic, strong, nullable) MTIImage *inputBackgroundImage;
16 |
17 | @property (nonatomic, copy) NSArray *layers;
18 |
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBColorSpaceConversionFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIRGBColorSpaceConversionFilter.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/2/11.
6 | //
7 |
8 | #import "MTIUnaryImageRenderingFilter.h"
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface MTILinearToSRGBToneCurveFilter : MTIUnaryImageRenderingFilter
13 |
14 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image;
15 |
16 | @end
17 |
18 | @interface MTISRGBToneCurveToLinearFilter: MTIUnaryImageRenderingFilter
19 |
20 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image;
21 |
22 | @end
23 |
24 | NS_ASSUME_NONNULL_END
25 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Filters/MTIRGBColorSpaceConversionFilter.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIRGBColorSpaceConversionFilter.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/2/11.
6 | //
7 |
8 | #import "MTIRGBColorSpaceConversionFilter.h"
9 | #import "MTIFunctionDescriptor.h"
10 |
11 | @implementation MTILinearToSRGBToneCurveFilter
12 |
13 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor {
14 | return [[MTIFunctionDescriptor alloc] initWithName:@"convertLinearRGBToSRGB"];
15 | }
16 |
17 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image {
18 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified];
19 | }
20 |
21 | @end
22 |
23 | @implementation MTISRGBToneCurveToLinearFilter
24 |
25 | + (MTIFunctionDescriptor *)fragmentFunctionDescriptor {
26 | return [[MTIFunctionDescriptor alloc] initWithName:@"convertSRGBToLinearRGB"];
27 | }
28 |
29 | + (MTIImage *)imageByProcessingImage:(MTIImage *)image {
30 | return [self imageByProcessingImage:image withInputParameters:@{} outputPixelFormat:MTIPixelFormatUnspecified];
31 | }
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIComputePipelineKernel.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIComputePipelineKernel.h
3 | // Pods
4 | //
5 | // Created by yi chen on 2017/7/27.
6 | //
7 | //
8 | #import
9 | #import "MTIKernel.h"
10 | #import "MTITextureDimensions.h"
11 | #import "MTIPixelFormat.h"
12 | #import "MTIAlphaType.h"
13 |
14 | NS_ASSUME_NONNULL_BEGIN
15 |
16 | @class MTIComputePipeline, MTIFunctionDescriptor, MTIImage;
17 |
18 | @interface MTIComputeFunctionDispatchOptions : NSObject
19 |
20 | + (instancetype)new NS_UNAVAILABLE;
21 |
22 | - (instancetype)init NS_UNAVAILABLE;
23 |
24 | - (instancetype)initWithThreads:(MTLSize)threads threadgroups:(MTLSize)threadgroups threadsPerThreadgroup:(MTLSize)threadsPerThreadgroup;
25 |
26 | - (instancetype)initWithGenerator:(void (^)(id pipelineState, MTLSize *threads, MTLSize *threadgroups, MTLSize *threadsPerThreadgroup))block NS_REFINED_FOR_SWIFT;
27 |
28 | @end
29 |
30 | @interface MTIComputePipelineKernel : NSObject
31 |
32 | - (instancetype)init NS_UNAVAILABLE;
33 |
34 | + (instancetype)new NS_UNAVAILABLE;
35 |
36 | @property (nonatomic,copy,readonly) MTIAlphaTypeHandlingRule *alphaTypeHandlingRule;
37 |
38 | @property (nonatomic, copy, readonly) MTIFunctionDescriptor *computeFunctionDescriptor;
39 |
40 | - (instancetype)initWithComputeFunctionDescriptor:(MTIFunctionDescriptor *)computeFunctionDescriptor;
41 |
42 | - (instancetype)initWithComputeFunctionDescriptor:(MTIFunctionDescriptor *)computeFunctionDescriptor alphaTypeHandlingRule:(MTIAlphaTypeHandlingRule *)alphaTypeHandlingRule NS_DESIGNATED_INITIALIZER;
43 |
44 | - (MTIImage *)applyToInputImages:(NSArray *)images
45 | parameters:(NSDictionary *)parameters
46 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions
47 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat;
48 |
49 | - (MTIImage *)applyToInputImages:(NSArray *)images
50 | parameters:(NSDictionary *)parameters
51 | dispatchOptions:(nullable MTIComputeFunctionDispatchOptions *)dispatchOptions
52 | outputTextureDimensions:(MTITextureDimensions)outputTextureDimensions
53 | outputPixelFormat:(MTLPixelFormat)outputPixelFormat;
54 |
55 | @end
56 |
57 | NS_ASSUME_NONNULL_END
58 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/Kernels/MTIRenderCommand.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIRenderCommand.m
3 | // Pods
4 | //
5 | // Created by Yu Ao on 26/11/2017.
6 | //
7 |
8 | #import "MTIRenderCommand.h"
9 | #import "MTIRenderPipelineKernel.h"
10 | #import "MTIImage.h"
11 |
12 | @implementation MTIRenderCommand
13 |
14 | - (instancetype)initWithKernel:(MTIRenderPipelineKernel *)kernel geometry:(id)geometry images:(NSArray *)images parameters:(NSDictionary *)parameters {
15 | if (self = [super init]) {
16 | NSParameterAssert(kernel);
17 | NSParameterAssert(images);
18 | NSParameterAssert(parameters);
19 | NSParameterAssert(geometry);
20 | NSParameterAssert({
21 | /* Alpha Type Assert */
22 | BOOL canAcceptAlphaType = YES;
23 | for (MTIImage *image in images) {
24 | if (![kernel.alphaTypeHandlingRule canAcceptAlphaType:image.alphaType]) {
25 | canAcceptAlphaType = NO;
26 | break;
27 | }
28 | }
29 | canAcceptAlphaType;
30 | });
31 | _kernel = kernel;
32 | _geometry = [geometry copyWithZone:nil];
33 | _images = [images copy];
34 | _parameters = [parameters copy];
35 | }
36 | return self;
37 | }
38 |
39 | - (id)copyWithZone:(NSZone *)zone {
40 | return self;
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIAlphaType.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIAlphaType.h
3 | // Pods
4 | //
5 | // Created by Yu Ao on 23/10/2017.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | /// Describe different ways to represent the opacity of a color value. See also: https://microsoft.github.io/Win2D/html/PremultipliedAlpha.htm
13 | typedef NS_ENUM(NSInteger, MTIAlphaType) {
14 | /// MTIAlphaTypeUnknown The alpha type is unknown.
15 | MTIAlphaTypeUnknown = 0,
16 |
17 | /// RGB values specify the color of the thing being drawn. The alpha value specifies how solid it is.
18 | MTIAlphaTypeNonPremultiplied = 1,
19 |
20 | /// RGB specifies how much color the thing being drawn contributes to the output. The alpha value specifies how much it obscures whatever is behind it.
21 | MTIAlphaTypePremultiplied = 2,
22 |
23 | /// There is no alpha channel or the alpha value is one.
24 | MTIAlphaTypeAlphaIsOne = 3
25 | };
26 |
27 | FOUNDATION_EXPORT NSString * MTIAlphaTypeGetDescription(MTIAlphaType alphaType);
28 |
29 | @class MTIImage;
30 |
31 | typedef MTIAlphaType (^MTIAlphaTypeHandlingOutputAlphaTypeRule)(NSArray *inputAlphaTypes);
32 |
33 | /// Describes how a image processing unit handles alpha type.
34 | @interface MTIAlphaTypeHandlingRule: NSObject
35 |
36 | /// Acceptable alpha types.
37 | @property (nonatomic, copy, readonly) NSArray *acceptableAlphaTypes NS_REFINED_FOR_SWIFT;
38 |
39 | - (instancetype)init NS_UNAVAILABLE;
40 |
41 | + (instancetype)new NS_UNAVAILABLE;
42 |
43 | - (BOOL)canAcceptAlphaType:(MTIAlphaType)alphaType;
44 |
45 | - (MTIAlphaType)outputAlphaTypeForInputAlphaTypes:(NSArray *)inputAlphaTypes NS_REFINED_FOR_SWIFT;
46 |
47 | - (MTIAlphaType)outputAlphaTypeForInputImages:(NSArray *)inputImages;
48 |
49 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaTypeHandler:(MTIAlphaTypeHandlingOutputAlphaTypeRule)outputAlphaTypeHandler NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT;
50 |
51 | - (instancetype)initWithAcceptableAlphaTypes:(NSArray *)acceptableAlphaTypes outputAlphaType:(MTIAlphaType)outputAlphaType NS_DESIGNATED_INITIALIZER NS_REFINED_FOR_SWIFT;
52 |
53 | /// Accepts MTIAlphaTypeNonPremultiplied, MTIAlphaTypeAlphaIsOne. Outputs MTIAlphaTypeNonPremultiplied.
54 | @property (nonatomic, copy, class, readonly) MTIAlphaTypeHandlingRule *generalAlphaTypeHandlingRule;
55 |
56 | /// Accepts all alpha types. The output alpha type is the same as input alpha type.
57 | @property (nonatomic, copy, class, readonly) MTIAlphaTypeHandlingRule *passthroughAlphaTypeHandlingRule;
58 |
59 |
60 | @end
61 |
62 | NS_ASSUME_NONNULL_END
63 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIBuffer.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIBuffer.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/1/22.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | /// A GPU mutable data buffer. You can pass a `MTIDataBuffer` instance to multiple processing units, they can all read and write the buffer's content. However, accessing a `MTIDataBuffer`'s contents using CPU is not safe. You must ensure all the GPU reads/writes to this buffer is completed. e.g. call a render task's waitUntilCompleted. For one `MTIDataBuffer` instance, one and only one underlaying `MTLBuffer` will be created for one GPU device.
13 | @interface MTIDataBuffer : NSObject
14 |
15 | + (instancetype)new NS_UNAVAILABLE;
16 |
17 | - (instancetype)init NS_UNAVAILABLE;
18 |
19 | - (nullable instancetype)initWithBytes:(const void *)bytes
20 | length:(NSUInteger)length
21 | options:(MTLResourceOptions)options;
22 |
23 | - (nullable instancetype)initWithData:(NSData *)data options:(MTLResourceOptions)options;
24 |
25 | - (nullable instancetype)initWithLength:(NSUInteger)length options:(MTLResourceOptions)options NS_DESIGNATED_INITIALIZER;
26 |
27 | @property (nonatomic, readonly) NSUInteger length;
28 |
29 | @property (nonatomic, readonly) MTLResourceOptions options;
30 |
31 | - (nullable id)bufferForDevice:(id)device NS_SWIFT_NAME(buffer(for:));
32 |
33 | /// Accessing contents from CPU is unsafe.
34 | - (void)unsafeAccess:(void (NS_NOESCAPE ^)(void *contents, NSUInteger length))block;
35 |
36 | @end
37 |
38 | NS_ASSUME_NONNULL_END
39 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 * __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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferPool.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTICVPixelBufferPool.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2018/12/7.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | FOUNDATION_EXPORT NSString * const MTICVPixelBufferPoolErrorDomain;
14 |
15 | typedef NS_ERROR_ENUM(MTICVPixelBufferPoolErrorDomain, MTICVPixelBufferPoolError) {
16 | MTICVPixelBufferPoolErrorNone = kCVReturnSuccess,
17 | MTICVPixelBufferPoolErrorWouldExceedAllocationThreshold = kCVReturnWouldExceedAllocationThreshold,
18 | MTICVPixelBufferPoolErrorPoolAllocationFailed = kCVReturnPoolAllocationFailed,
19 | MTICVPixelBufferPoolErrorInvalidPoolAttributes = kCVReturnInvalidPoolAttributes,
20 | MTICVPixelBufferPoolErrorRetry = kCVReturnRetry
21 | };
22 |
23 | @interface MTICVPixelBufferPool : NSObject
24 |
25 | @property (nonatomic, readonly) size_t pixelBufferWidth;
26 | @property (nonatomic, readonly) size_t pixelBufferHeight;
27 |
28 | @property (nonatomic, readonly) NSUInteger minimumBufferCount;
29 |
30 | @property (nonatomic, readonly) OSType pixelFormatType;
31 |
32 | @property (nonatomic, copy, readonly) NSString *pixelFormatDescription;
33 |
34 | @property (nonatomic, copy, readonly) NSDictionary *poolAttributes;
35 | @property (nonatomic, copy, readonly) NSDictionary *pixelBufferAttributes;
36 |
37 | @property (nonatomic, readonly) CVPixelBufferPoolRef internalPool NS_RETURNS_INNER_POINTER;
38 |
39 | - (instancetype)init NS_UNAVAILABLE;
40 |
41 | - (nullable instancetype)initWithPixelBufferWidth:(size_t)width pixelBufferHeight:(size_t)height pixelFormatType:(OSType)pixelFormatType minimumBufferCount:(NSUInteger)minimumBufferCount error:(NSError **)error;
42 |
43 | - (nullable instancetype)initWithPoolAttributes:(NSDictionary *)poolAttributes pixelBufferAttributes:(NSDictionary *)pixelBufferAttributes error:(NSError **)error;
44 |
45 | - (instancetype)initWithCVPixelBufferPool:(CVPixelBufferPoolRef)pixelBufferPool NS_DESIGNATED_INITIALIZER;
46 |
47 | - (nullable CVPixelBufferRef)newPixelBufferWithAllocationThreshold:(NSUInteger)allocationThreshold error:(NSError **)error CF_RETURNS_RETAINED NS_SWIFT_NAME(makePixelBuffer(allocationThreshold:));
48 |
49 | - (void)flush:(CVPixelBufferPoolFlushFlags)flags;
50 |
51 | @end
52 |
53 | NS_ASSUME_NONNULL_END
54 |
55 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTICVPixelBufferPromise.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTICVPixelBufferPromise.h
3 | // Pods
4 | //
5 | // Created by YuAo on 21/07/2017.
6 | //
7 | //
8 |
9 | #import
10 | #import "MTIImagePromise.h"
11 | #import "MTICVPixelBufferRendering.h"
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface MTICVPixelBufferPromise : NSObject
16 |
17 | @property (nonatomic, readonly) MTICVPixelBufferRenderingAPI renderingAPI;
18 |
19 | @property (nonatomic, readonly) BOOL sRGB;
20 |
21 | - (instancetype)init NS_UNAVAILABLE;
22 |
23 | + (instancetype)new NS_UNAVAILABLE;
24 |
25 | - (instancetype)initWithCVPixelBuffer:(CVPixelBufferRef)pixelBuffer options:(MTICVPixelBufferRenderingOptions *)options alphaType:(MTIAlphaType)alphaType;
26 |
27 | @end
28 |
29 | @interface MTICVPixelBufferDirectBridgePromise : NSObject
30 |
31 | - (instancetype)init NS_UNAVAILABLE;
32 |
33 | + (instancetype)new NS_UNAVAILABLE;
34 |
35 | - (instancetype)initWithCVPixelBuffer:(CVPixelBufferRef)pixelBuffer planeIndex:(NSUInteger)planeIndex textureDescriptor:(MTLTextureDescriptor *)textureDescriptor alphaType:(MTIAlphaType)alphaType NS_DESIGNATED_INITIALIZER;
36 |
37 | @end
38 |
39 | NS_ASSUME_NONNULL_END
40 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIColor.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIColor.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 10/10/2017.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | typedef NS_ENUM(NSInteger, MTIColorComponent) {
12 | MTIColorComponentRed,
13 | MTIColorComponentGreen,
14 | MTIColorComponentBlue,
15 | MTIColorComponentAlpha
16 | };
17 |
18 | struct MTIColor {
19 | float red;
20 | float green;
21 | float blue;
22 | float alpha;
23 | };
24 | typedef struct MTIColor MTIColor;
25 |
26 | FOUNDATION_EXPORT MTIColor MTIColorMake(float red, float green, float blue, float alpha) NS_SWIFT_UNAVAILABLE("Use MTIColor.init instead.");
27 |
28 | FOUNDATION_EXPORT simd_float4 MTIColorToFloat4(MTIColor color) NS_SWIFT_NAME(MTIColor.toFloat4(self:));
29 |
30 | FOUNDATION_EXPORT MTIColor const MTIColorWhite NS_SWIFT_NAME(MTIColor.white);
31 | FOUNDATION_EXPORT MTIColor const MTIColorBlack NS_SWIFT_NAME(MTIColor.black);
32 | FOUNDATION_EXPORT MTIColor const MTIColorClear NS_SWIFT_NAME(MTIColor.clear);
33 |
34 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransformDefault; //MTIGrayColorTransform_ITU_R_601
35 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransform_ITU_R_601; //0.299, 0.587, 0.114
36 | FOUNDATION_EXPORT simd_float3 const MTIGrayColorTransform_ITU_R_709; //0.2126, 0.7152, 0.0722
37 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIColor.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIColor.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 10/10/2017.
6 | //
7 |
8 | #import "MTIColor.h"
9 |
10 | MTIColor MTIColorMake(float red, float green, float blue, float alpha) {
11 | return (MTIColor){red,green,blue,alpha};
12 | }
13 |
14 | simd_float4 MTIColorToFloat4(MTIColor color) {
15 | return simd_make_float4(color.red, color.green, color.blue, color.alpha);
16 | }
17 |
18 | MTIColor const MTIColorWhite = (MTIColor){.red = 1, .green = 1, .blue = 1, .alpha = 1};
19 | MTIColor const MTIColorBlack = (MTIColor){.red = 0, .green = 0, .blue = 0, .alpha = 1};
20 | MTIColor const MTIColorClear = (MTIColor){.red = 0, .green = 0, .blue = 0, .alpha = 0};
21 |
22 | simd_float3 const MTIGrayColorTransform_ITU_R_601 = (simd_float3){0.299f, 0.587f, 0.114f};
23 | simd_float3 const MTIGrayColorTransform_ITU_R_709 = (simd_float3){0.2126f, 0.7152f, 0.0722f};
24 |
25 | simd_float3 const MTIGrayColorTransformDefault = MTIGrayColorTransform_ITU_R_601;
26 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTICoreImageRendering.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTICoreImageRendering.h
3 | // Pods
4 | //
5 | // Created by Yu Ao on 04/04/2018.
6 | //
7 |
8 | #import
9 | #import
10 | #import
11 | #import
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface MTICIImageRenderingOptions : NSObject
16 |
17 | @property (nullable, nonatomic, readonly) CGColorSpaceRef colorSpace;
18 |
19 | @property (getter=isFlipped, readonly, nonatomic) BOOL flipped;
20 |
21 | @property (nonatomic, readonly) MTLPixelFormat destinationPixelFormat;
22 |
23 | @property (nonatomic, readonly) CIRenderDestinationAlphaMode alphaMode NS_AVAILABLE(10_13, 11_0);
24 |
25 | - (instancetype)init NS_UNAVAILABLE;
26 |
27 | + (instancetype)new NS_UNAVAILABLE;
28 |
29 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat colorSpace:(nullable CGColorSpaceRef)colorSpace flipped:(BOOL)flipped NS_DESIGNATED_INITIALIZER;
30 |
31 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat alphaMode:(CIRenderDestinationAlphaMode)alphaMode colorSpace:(nullable CGColorSpaceRef)colorSpace flipped:(BOOL)flipped NS_DESIGNATED_INITIALIZER NS_AVAILABLE(10_13, 11_0);
32 |
33 | @property (nonatomic, strong, class, readonly) MTICIImageRenderingOptions *defaultOptions;
34 |
35 | @end
36 |
37 | @interface MTICIImageCreationOptions: NSObject
38 |
39 | @property (nonatomic, nullable, readonly) CGColorSpaceRef colorSpace;
40 |
41 | @property (getter=isFlipped, readonly, nonatomic) BOOL flipped;
42 |
43 | - (instancetype)init NS_UNAVAILABLE;
44 |
45 | + (instancetype)new NS_UNAVAILABLE;
46 |
47 | - (instancetype)initWithColorSpace:(nullable CGColorSpaceRef)colorSpace flipped:(BOOL)flipped NS_DESIGNATED_INITIALIZER;
48 |
49 | @property (nonatomic, strong, class, readonly) MTICIImageCreationOptions *defaultOptions;
50 |
51 | @end
52 |
53 | NS_ASSUME_NONNULL_END
54 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTICoreImageRendering.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTICoreImageRendering.m
3 | // Pods
4 | //
5 | // Created by Yu Ao on 04/04/2018.
6 | //
7 |
8 | #import "MTICoreImageRendering.h"
9 |
10 | @implementation MTICIImageRenderingOptions
11 |
12 | - (void)dealloc {
13 | CGColorSpaceRelease(_colorSpace);
14 | }
15 |
16 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat colorSpace:(CGColorSpaceRef)colorSpace flipped:(BOOL)flipped {
17 | if (self = [super init]) {
18 | _destinationPixelFormat = pixelFormat;
19 | _alphaMode = CIRenderDestinationAlphaPremultiplied;
20 | _colorSpace = CGColorSpaceRetain(colorSpace);
21 | _flipped = flipped;
22 | }
23 | return self;
24 | }
25 |
26 | - (instancetype)initWithDestinationPixelFormat:(MTLPixelFormat)pixelFormat alphaMode:(CIRenderDestinationAlphaMode)alphaMode colorSpace:(CGColorSpaceRef)colorSpace flipped:(BOOL)flipped {
27 | if (self = [super init]) {
28 | _destinationPixelFormat = pixelFormat;
29 | _alphaMode = alphaMode;
30 | _colorSpace = CGColorSpaceRetain(colorSpace);
31 | _flipped = flipped;
32 | }
33 | return self;
34 | }
35 |
36 | - (id)copyWithZone:(NSZone *)zone {
37 | return self;
38 | }
39 |
40 | + (MTICIImageRenderingOptions *)defaultOptions {
41 | static MTICIImageRenderingOptions *defaultOptions;
42 | static dispatch_once_t onceToken;
43 | dispatch_once(&onceToken, ^{
44 | CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
45 | defaultOptions = [[MTICIImageRenderingOptions alloc] initWithDestinationPixelFormat:MTLPixelFormatBGRA8Unorm colorSpace:colorspace flipped:YES];
46 | CGColorSpaceRelease(colorspace);
47 | });
48 | return defaultOptions;
49 | }
50 |
51 | @end
52 |
53 | @implementation MTICIImageCreationOptions
54 |
55 | - (void)dealloc {
56 | CGColorSpaceRelease(_colorSpace);
57 | }
58 |
59 | - (instancetype)initWithColorSpace:(CGColorSpaceRef)colorSpace flipped:(BOOL)flipped {
60 | if (self = [super init]) {
61 | _colorSpace = CGColorSpaceRetain(colorSpace);
62 | _flipped = flipped;
63 | }
64 | return self;
65 | }
66 |
67 | - (id)copyWithZone:(NSZone *)zone {
68 | return self;
69 | }
70 |
71 | + (MTICIImageCreationOptions *)defaultOptions {
72 | static MTICIImageCreationOptions *defaultOptions;
73 | static dispatch_once_t onceToken;
74 | dispatch_once(&onceToken, ^{
75 | CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
76 | defaultOptions = [[MTICIImageCreationOptions alloc] initWithColorSpace:colorspace flipped:YES];
77 | CGColorSpaceRelease(colorspace);
78 | });
79 | return defaultOptions;
80 | }
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIError.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIError.h
3 | // Pods
4 | //
5 | // Created by YuAo on 10/08/2017.
6 | //
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | FOUNDATION_EXPORT NSString * const MTIErrorDomain;
14 |
15 | typedef NS_ERROR_ENUM(MTIErrorDomain, MTIError) {
16 | //Core errors
17 | MTIErrorDeviceNotFound = 1001,
18 | MTIErrorFunctionNotFound = 1002,
19 | MTIErrorFailedToCreateSamplerState = 1003,
20 | MTIErrorFailedToCreateTexture = 1004,
21 | MTIErrorFailedToCreateCommandEncoder = 1005,
22 |
23 | //Texture loading errors
24 | MTIErrorUnsupportedCVPixelBufferFormat = 2001,
25 | MTIErrorTextureDimensionsMismatch = 2002,
26 |
27 | //Image errors
28 | MTIErrorUnsupportedImageCachePolicy = 3001,
29 |
30 | //Kernel errors
31 | MTIErrorDataBufferSizeMismatch = 4001,
32 | MTIErrorParameterDataTypeNotSupported = 4002,
33 | MTIErrorMPSKernelInputCountMismatch = 4003,
34 | MTIErrorMPSKernelNotSupported = 4004,
35 |
36 | //Render errors
37 | MTIErrorEmptyDrawable = 5001,
38 | MTIErrorFailedToCreateCGImageFromCVPixelBuffer = 5002,
39 | MTIErrorFailedToCreateCVPixelBuffer = 5003,
40 | MTIErrorInvalidCVPixelBufferRenderingAPI = 5004,
41 | MTIErrorFailedToGetRenderedBuffer = 5005,
42 |
43 | //For operations do not support cross device or cross context rendering, we report these errors.
44 | MTIErrorCrossDeviceRendering = 5006,
45 | MTIErrorCrossContextRendering = 5007
46 | };
47 |
48 | /// 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.
49 | FOUNDATION_EXPORT NSError * _MTIErrorCreate(MTIError code, NSString *defaultDescription, NSDictionary * _Nullable userInfo);
50 |
51 | #define MTIErrorCreate(code, userInfo) _MTIErrorCreate(code, @#code, userInfo)
52 |
53 | NS_ASSUME_NONNULL_END
54 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometry.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIGeometry.h
3 | // Pods
4 | //
5 | // Created by Yu Ao on 2018/5/6.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @class MTIRenderPipeline;
13 |
14 | @protocol MTIGeometryRenderingContext
15 |
16 | @property (nonatomic, readonly, strong) MTIRenderPipeline *renderPipeline;
17 |
18 | @property (nonatomic, readonly, strong) id device;
19 |
20 | @end
21 |
22 | @protocol MTIGeometry
23 |
24 | - (void)encodeDrawCallWithCommandEncoder:(id)commandEncoder
25 | context:(id)context;
26 |
27 | @end
28 |
29 | NS_ASSUME_NONNULL_END
30 |
31 |
32 | #import "MTIRenderPipeline.h"
33 |
34 | NS_ASSUME_NONNULL_BEGIN
35 |
36 | @interface MTIRenderPipeline (MTIGeometryRenderingContext)
37 |
38 | @end
39 |
40 | NS_ASSUME_NONNULL_END
41 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIGeometry.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIGeometry.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/2/2.
6 | //
7 |
8 | #import "MTIGeometry.h"
9 |
10 | @implementation MTIRenderPipeline (MTIGeometryRenderingContext)
11 |
12 | - (MTIRenderPipeline *)renderPipeline {
13 | return self;
14 | }
15 |
16 | - (id)device {
17 | return self.state.device;
18 | }
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIHasher.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIHasher.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/1/7.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | struct MTIHasher {
13 | uint64_t _seed;
14 | BOOL _finalized;
15 | };
16 | typedef struct MTIHasher MTIHasher;
17 |
18 | static inline MTIHasher MTIHasherMake(NSUInteger seed) {
19 | //MTIHasher is designed to work on 64-bit systems.
20 | assert(sizeof(NSUInteger) == 8);
21 | return (MTIHasher){._seed = seed, ._finalized = NO};
22 | }
23 |
24 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, uint64_t value) {
25 | //Ref boost::hash_combine
26 | //Ref https://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine
27 | hasher -> _seed ^= value + 0x9e3779b97f4a7c15 + (hasher -> _seed << 6) + (hasher -> _seed >> 2);
28 | }
29 |
30 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, unsigned int intValue) {
31 | uint64_t value = intValue;
32 | MTIHasherCombine(hasher, value);
33 | }
34 |
35 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, unsigned long intValue) {
36 | uint64_t value = intValue;
37 | MTIHasherCombine(hasher, value);
38 | }
39 |
40 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, double doubleValue) {
41 | //in .m file: static_assert(sizeof(uint64_t) == sizeof(double), "")
42 | uint64_t value = *(uint64_t *)&doubleValue;
43 | MTIHasherCombine(hasher, value);
44 | }
45 |
46 | static inline __attribute__((__overloadable__)) void MTIHasherCombine(MTIHasher *hasher, float floatValue) {
47 | double doubleValue = floatValue;
48 | MTIHasherCombine(hasher, doubleValue);
49 | }
50 |
51 | static inline __attribute__((__overloadable__)) NSUInteger MTIHasherFinalize(MTIHasher *hasher) {
52 | NSCParameterAssert(hasher -> _finalized == NO);
53 | hasher -> _finalized = YES;
54 | return (NSUInteger)hasher -> _seed;
55 | }
56 |
57 | NS_ASSUME_NONNULL_END
58 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIHasher.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIHasher.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/1/7.
6 | //
7 |
8 | #import "MTIHasher.h"
9 |
10 | static_assert(sizeof(uint64_t) == sizeof(double), "");
11 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIImageRenderingContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIImageRenderingContext.h
3 | // Pods
4 | //
5 | // Created by YuAo on 25/06/2017.
6 | //
7 | //
8 |
9 | #import
10 | #import
11 | #import "MTIImagePromise.h"
12 |
13 | @class MTIImage, MTIContext;
14 |
15 | NS_ASSUME_NONNULL_BEGIN
16 |
17 | /*! @brief Rendering context related constant for MTIContextImageAssociatedValueTableName. */
18 | FOUNDATION_EXPORT NSString * const MTIContextImagePersistentResolutionHolderTableName;
19 |
20 | @protocol MTIImagePromiseResolution
21 |
22 | @property (nonatomic,readonly) id texture;
23 |
24 | - (void)markAsConsumedBy:(id)consumer;
25 |
26 | @end
27 |
28 | @interface MTIImageRenderingContext : NSObject
29 |
30 | @property (nonatomic, strong, readonly) MTIContext *context;
31 |
32 | @property (nonatomic, strong, readonly) id commandBuffer;
33 |
34 | - (instancetype)init NS_UNAVAILABLE;
35 |
36 | + (instancetype)new NS_UNAVAILABLE;
37 |
38 | - (instancetype)initWithContext:(MTIContext *)context;
39 |
40 | - (nullable id)resolutionForImage:(MTIImage *)image error:(NSError **)error;
41 |
42 | @end
43 |
44 | NS_ASSUME_NONNULL_END
45 |
46 |
47 | #import "MTIContext.h"
48 |
49 | NS_ASSUME_NONNULL_BEGIN
50 |
51 | @interface MTIContext (RenderedImageBuffer)
52 |
53 | - (nullable MTIImage *)renderedBufferForImage:(MTIImage *)targetImage;
54 |
55 | @end
56 |
57 | NS_ASSUME_NONNULL_END
58 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIMemoryWarningObserver.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTIMemoryWarningObserver.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2018/8/27.
6 | //
7 |
8 | #import "MTIMemoryWarningObserver.h"
9 | #import "MTILock.h"
10 |
11 | #if __has_include()
12 | #import
13 | #endif
14 |
15 | @interface MTIMemoryWarningObserver ()
16 |
17 | @property (nonatomic, strong, readonly) NSHashTable *handlers;
18 | @property (nonatomic, strong, readonly) id lock;
19 |
20 | @end
21 |
22 | @implementation MTIMemoryWarningObserver
23 |
24 | + (instancetype)sharedObserver {
25 | static MTIMemoryWarningObserver *observer;
26 | static dispatch_once_t onceToken;
27 | dispatch_once(&onceToken, ^{
28 | observer = [[MTIMemoryWarningObserver alloc] initForSharedObserver];
29 | });
30 | return observer;
31 | }
32 |
33 | - (instancetype)initForSharedObserver {
34 | if (self = [super init]) {
35 | _handlers = [NSHashTable weakObjectsHashTable];
36 | _lock = MTILockCreate();
37 | #if __has_include()
38 | [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidReceiveMemoryWarningNotification
39 | object:nil
40 | queue:nil
41 | usingBlock:^(NSNotification * _Nonnull note) {
42 | [self handleMemoryWarning];
43 | }];
44 | #endif
45 | }
46 | return self;
47 | }
48 |
49 | - (void)handleMemoryWarning {
50 | [_lock lock];
51 | for (id handler in _handlers) {
52 | [handler handleMemoryWarning];
53 | }
54 | [_lock unlock];
55 | }
56 |
57 | - (void)addMemoryWarningHandler:(id)memoryWarningHandler {
58 | [_lock lock];
59 | [_handlers addObject:memoryWarningHandler];
60 | [_lock unlock];
61 | }
62 |
63 | - (void)removeMemoryWarningHandler:(id)memoryWarningHandler {
64 | [_lock lock];
65 | [_handlers removeObject:memoryWarningHandler];
66 | [_lock unlock];
67 | }
68 |
69 | + (void)addMemoryWarningHandler:(id)memoryWarningHandler {
70 | [self.sharedObserver addMemoryWarningHandler:memoryWarningHandler];
71 | }
72 |
73 | + (void)removeMemoryWarningHandler:(id)memoryWarningHandler {
74 | [self.sharedObserver removeMemoryWarningHandler:memoryWarningHandler];
75 | }
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIPixelFormat.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIPixelFormat.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 11/10/2017.
6 | //
7 |
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatUnspecified NS_REFINED_FOR_SWIFT; //aliased to MTLPixelFormatInvalid
14 |
15 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P NS_REFINED_FOR_SWIFT;
16 | FOUNDATION_EXPORT MTLPixelFormat const MTIPixelFormatYCBCR8_420_2P_sRGB NS_REFINED_FOR_SWIFT;
17 |
18 | FOUNDATION_EXPORT BOOL MTIDeviceSupportsYCBCRPixelFormat(id device);
19 |
20 | NS_ASSUME_NONNULL_END
21 |
22 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderPassOutputDescriptor.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIRenderPipelineOutputDescriptor.h
3 | // Pods
4 | //
5 | // Created by YuAo on 18/11/2017.
6 | //
7 |
8 | #import
9 | #import
10 | #import "MTITextureDimensions.h"
11 | #import "MTIPixelFormat.h"
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface MTIRenderPassOutputDescriptor: NSObject
16 |
17 | @property (nonatomic,readonly) MTITextureDimensions dimensions;
18 |
19 | @property (nonatomic,readonly) MTLPixelFormat pixelFormat;
20 |
21 | @property (nonatomic,readonly) MTLLoadAction loadAction;
22 |
23 | @property (nonatomic,readonly) MTLStoreAction storeAction;
24 |
25 | @property (nonatomic,readonly) MTLClearColor clearColor;
26 |
27 | - (instancetype)init NS_UNAVAILABLE;
28 |
29 | + (instancetype)new NS_UNAVAILABLE;
30 |
31 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat;
32 |
33 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction;
34 |
35 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat loadAction:(MTLLoadAction)loadAction storeAction:(MTLStoreAction)storeAction;
36 |
37 | - (instancetype)initWithDimensions:(MTITextureDimensions)dimensions pixelFormat:(MTLPixelFormat)pixelFormat clearColor:(MTLClearColor)clearColor loadAction:(MTLLoadAction)loadAction storeAction:(MTLStoreAction)storeAction NS_DESIGNATED_INITIALIZER;
38 |
39 | - (BOOL)isEqualToOutputDescriptor:(MTIRenderPassOutputDescriptor *)object;
40 |
41 | @end
42 |
43 | NS_ASSUME_NONNULL_END
44 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTIRenderTask.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTIRenderTask.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2018/5/22.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @class MTIImageRenderingContext;
14 |
15 | /// Represents a GPU render task - i.e., commands in a command buffer.
16 | @interface MTIRenderTask : NSObject
17 |
18 | /// Status of the underlaying command buffer.
19 | @property (readonly) MTLCommandBufferStatus commandBufferStatus;
20 |
21 | - (instancetype)initWithCommandBuffer:(id)commandBuffer NS_DESIGNATED_INITIALIZER;
22 |
23 | - (instancetype)init NS_UNAVAILABLE;
24 |
25 | + (instancetype)new NS_UNAVAILABLE;
26 |
27 | /// Synchronously blocks execution until the task either completes or fails (with error).
28 | - (void)waitUntilCompleted;
29 |
30 | /// If an error occurred during execution, the NSError may contain more details about the problem.
31 | @property (nullable, readonly) NSError *error;
32 |
33 | @end
34 |
35 | NS_ASSUME_NONNULL_END
36 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTISamplerDescriptor.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTISamplerDescriptor.h
3 | // Pods
4 | //
5 | // Created by YuAo on 29/06/2017.
6 | //
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | /// An immutable wrapper for MTLSamplerDescriptor.
14 | @interface MTISamplerDescriptor : NSObject
15 |
16 | - (instancetype)init NS_UNAVAILABLE;
17 |
18 | + (instancetype)new NS_UNAVAILABLE;
19 |
20 | - (instancetype)initWithMTLSamplerDescriptor:(MTLSamplerDescriptor *)samplerDescriptor NS_DESIGNATED_INITIALIZER;
21 |
22 | - (MTLSamplerDescriptor *)newMTLSamplerDescriptor NS_SWIFT_NAME(makeMTLSamplerDescriptor());
23 |
24 | @property (nonatomic, readonly, class) MTISamplerDescriptor *defaultSamplerDescriptor;
25 |
26 | + (instancetype)defaultSamplerDescriptorWithAddressMode:(MTLSamplerAddressMode)addressMode;
27 |
28 | @end
29 |
30 | @interface MTLSamplerDescriptor (MTISamplerDescriptor)
31 |
32 | - (MTISamplerDescriptor *)newMTISamplerDescriptor NS_SWIFT_NAME(makeMTISamplerDescriptor());
33 |
34 | @end
35 |
36 | NS_ASSUME_NONNULL_END
37 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTITextureLoader.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTITextureLoader.h
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/1/10.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | /// Abstract interface for texture loader.
13 | @protocol MTITextureLoader
14 |
15 | + (instancetype)newTextureLoaderWithDevice:(id )device;
16 |
17 | - (nullable id )newTextureWithCGImage:(nonnull CGImageRef)cgImage
18 | options:(nullable NSDictionary *)options
19 | error:(NSError *__nullable *__nullable)error;
20 |
21 | - (nullable id )newTextureWithContentsOfURL:(nonnull NSURL *)URL
22 | options:(nullable NSDictionary *)options
23 | error:(NSError *__nullable *__nullable)error;
24 |
25 | - (nullable id )newTextureWithName:(nonnull NSString *)name
26 | scaleFactor:(CGFloat)scaleFactor
27 | bundle:(nullable NSBundle *)bundle
28 | options:(nullable NSDictionary *)options
29 | error:(NSError *__nullable *__nullable)error;
30 |
31 | @end
32 |
33 | @interface MTKTextureLoader (MTITextureLoader)
34 |
35 | @end
36 |
37 | NS_ASSUME_NONNULL_END
38 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTITextureLoader.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTITextureLoader.m
3 | // MetalPetal
4 | //
5 | // Created by Yu Ao on 2019/1/10.
6 | //
7 |
8 | #import "MTITextureLoader.h"
9 |
10 | @implementation MTKTextureLoader (MTITextureLoader)
11 |
12 | + (instancetype)newTextureLoaderWithDevice:(id)device {
13 | return [[MTKTextureLoader alloc] initWithDevice:device];
14 | }
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/Example/Pods/MetalPetal/Frameworks/MetalPetal/MTITextureLoaderForiOS9.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTKTextureLoaderExtension.h
3 | // Pods
4 | //
5 | // Created by Yu Ao on 06/12/2017.
6 | //
7 |
8 | #import
9 | #import
10 | #import "MTITextureLoader.h"
11 |
12 | #if TARGET_OS_IPHONE
13 |
14 | NS_ASSUME_NONNULL_BEGIN
15 |
16 | /*!
17 | @brief A custom implemented texture loader for iOS 9, which loads images without filpping them vertically. This matches the behavior of `MTKTextureLoader` on iOS 10 and above.
18 |
19 | @discussion To use this texture loader, assgin MTITextureLoaderForiOS9WithImageOrientationFix.class to MTIContextOptions.defaultTextureLoaderClass on iOS 9 only.
20 |
21 | @code
22 | if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_9_x_Max) {
23 | MTIContextOptions.defaultTextureLoaderClass = MTITextureLoaderForiOS9WithImageOrientationFix.class;
24 | }
25 | */
26 |
27 | NS_CLASS_DEPRECATED_IOS(9_0, 10_0, "Use MTKTextureLoader instead.") __TVOS_PROHIBITED
28 | @interface MTITextureLoaderForiOS9WithImageOrientationFix : NSObject