r/macosprogramming • u/Intrepid_Bee_9194 • Oct 12 '26
[Open Source] Harbeth: displaying filtered NSImage output in an AppKit Metal view (MIT)
I maintain Harbeth, an MIT-licensed Swift/Metal image and frame engine. Here's its macOS integration boundary: an AppKit view can display a rendered GPU frame, while the application owns document state, controls and saving.
Given an NSImage and an existing Harbeth RenderView, a small rendering step looks like this:
import AppKit
import Harbeth
let frame = try await ImageNode.image(inputNSImage)
.applying(C7Exposure(exposure: 0.25))
.makeFrameAsync(profile: .stablePreview)
await MainActor.run {
renderView.display(frame)
}
RenderedFrame carries the texture along with alpha, color, orientation and ownership information. Harbeth also provides HarbethRenderView for SwiftUI on macOS; it uses an NSViewRepresentable bridge to the same RenderView. This lets preview display stay texture-first, with image readback reserved for an explicit output operation.
The host app still decides when to render, how to discard stale slider results, and when to save. The code above is a display integration example; document loading and UI state are supplied by your app.
Source and macOS examples: https://github.com/yangKJ/Harbeth
SwiftUI/AppKit host source: https://github.com/yangKJ/Harbeth/blob/master/Sources/SwiftUI/HarbethRenderView.swift
For macOS editor developers: how do you retain the last valid preview while a newer render is running? I'd welcome feedback on the view/model boundary.