-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add mtltexture to cvpixelbuffer conversion * update version to 0.11.6 * move extension to CVPixelFormat+MTLTexture.swift * remove unsused error type
- Loading branch information
1 parent
34338da
commit e146427
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// MTLPixelFormat+CVPixelFormat.swift | ||
// Alloy | ||
// | ||
// Created by Eugene Bokhan on 19.12.2019. | ||
// | ||
|
||
import Metal | ||
|
||
public extension MTLPixelFormat { | ||
|
||
var compatibleCVPixelFormat: OSType? { | ||
switch self { | ||
case .r8Unorm: return kCVPixelFormatType_OneComponent8 | ||
case .r16Float: return kCVPixelFormatType_OneComponent16Half | ||
case .r32Float: return kCVPixelFormatType_OneComponent32Float | ||
|
||
case .rg8Unorm: return kCVPixelFormatType_TwoComponent8 | ||
case .rg16Float: return kCVPixelFormatType_TwoComponent16Half | ||
case .rg32Float: return kCVPixelFormatType_TwoComponent32Float | ||
|
||
case .bgra8Unorm: return kCVPixelFormatType_32BGRA | ||
case .rgba8Unorm: return kCVPixelFormatType_32RGBA | ||
case .rgba16Float: return kCVPixelFormatType_64RGBAHalf | ||
case .rgba32Float: return kCVPixelFormatType_128RGBAFloat | ||
|
||
case .depth32Float: return kCVPixelFormatType_DepthFloat32 | ||
default: return nil | ||
} | ||
} | ||
|
||
} |