apple-cf 0.9.0

Safe Rust bindings for Apple's shared Core* frameworks (CoreFoundation, CoreMedia, CoreVideo, CoreGraphics, IOSurface, Dispatch).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import CoreVideo
import Foundation
import Metal

@_cdecl("cv_metal_texture_cache_create_system_default")
public func cv_metal_texture_cache_create_system_default() -> UnsafeMutableRawPointer? {
    guard let device = MTLCreateSystemDefaultDevice() else { return nil }
    var cache: CVMetalTextureCache?
    let status = CVMetalTextureCacheCreate(nil, nil, device, nil, &cache)
    guard status == kCVReturnSuccess, let cache else { return nil }
    return Unmanaged.passRetained(cache).toOpaque()
}

@_cdecl("cv_metal_texture_cache_flush")
public func cv_metal_texture_cache_flush(_ cache: UnsafeMutableRawPointer) {
    let cache = Unmanaged<CVMetalTextureCache>.fromOpaque(cache).takeUnretainedValue()
    CVMetalTextureCacheFlush(cache, 0)
}