Skip to content

Commit

Permalink
Update Xcode to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tattn committed Sep 13, 2024
1 parent 50ce90a commit 23b0ca1
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 27 deletions.
18 changes: 18 additions & 0 deletions app/xcode/Sources/VCamEntity/BlendShape.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// BlendShape.swift
//
//
// Created by Tatsuya Tanaka on 2024/09/13.
//

import Foundation

public struct BlendShape: Identifiable, Hashable {
public var name: String

public var id: String { name }

public init(name: String) {
self.name = name
}
}
2 changes: 1 addition & 1 deletion app/xcode/Sources/VCamEntity/FourCharCode+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

extension FourCharCode: ExpressibleByStringLiteral {
extension FourCharCode: @retroactive ExpressibleByStringLiteral {
public init(stringLiteral value: StringLiteralType) {
var code: FourCharCode = 0
if value.count == 4, value.utf8.count == 4 {
Expand Down
2 changes: 2 additions & 0 deletions app/xcode/Sources/VCamEntity/NSImage+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import AppKit
import CoreImage

extension NSImage : @unchecked @retroactive Sendable {}

public extension NSImage {
convenience init(color: NSColor, size: NSSize) {
self.init(size: size)
Expand Down
2 changes: 1 addition & 1 deletion app/xcode/Sources/VCamUI/Extensions/AVCaptureDevice+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import AVFoundation

extension AVCaptureDevice: Identifiable {
extension AVCaptureDevice: @retroactive Identifiable {
public var id: String {
self.uniqueID
}
Expand Down
4 changes: 0 additions & 4 deletions app/xcode/Sources/VCamUI/Extensions/String+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ public extension String {
return image
}
}

extension String: Identifiable {
public var id: Self { self }
}
4 changes: 2 additions & 2 deletions app/xcode/Sources/VCamUI/Extensions/UniBridge+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ extension UniBridge {
return .init(width: CGFloat(size[0]), height: CGFloat(size[1]))
}

public static var cachedBlendShapes: [String] = []
public var cachedBlendShapes: [String] {
public static var cachedBlendShapes: [BlendShape] = []
public var cachedBlendShapes: [BlendShape] {
Self.cachedBlendShapes
}
}
6 changes: 3 additions & 3 deletions app/xcode/Sources/VCamUI/RenderTextureRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol RenderTextureRenderer: AnyObject {
var filter: ImageFilter? { get set }

func setRenderTexture(updator: @escaping (CIImage) -> Void)
func snapshot() -> CIImage
func snapshot() async -> CIImage
func updateTextureSizeIfNeeded(imageWidth: CGFloat, imageHeight: CGFloat) -> Bool

func disableRenderTexture()
Expand All @@ -30,8 +30,8 @@ public extension RenderTextureRenderer {
false
}

func croppedSnapshot() -> NSImage {
let image = snapshot()
func croppedSnapshot() async -> NSImage {
let image = await snapshot()
return cropped(of: image).nsImage()
}

Expand Down
9 changes: 4 additions & 5 deletions app/xcode/Sources/VCamUI/ScreenRecorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,8 @@ extension ScreenRecorder: RenderTextureRenderer {
}
}

@MainActor
public func snapshot() -> CIImage {
guard let frame = latestFrame else { return .init() }
public func snapshot() async -> CIImage {
guard let frame = await latestFrame else { return .init() }
return frame.croppedCIImage
}

Expand Down Expand Up @@ -440,13 +439,13 @@ public extension ScreenRecorder {
}
}

extension SCDisplay: Identifiable {
extension SCDisplay: @retroactive Identifiable {
public var id: String {
return String(CGDisplaySerialNumber(displayID))
}
}

extension SCWindow: Identifiable {
extension SCWindow: @retroactive Identifiable {
public var id: String {
guard let infoList = CGWindowListCopyWindowInfo(.optionIncludingWindow, windowID) as? [NSDictionary],
let info = infoList.first,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct VCamShortcutBuilderActionItemEditView: View {
case let .motion(configuration):
VCamActionEditorPicker(item: .init(configuration, keyPath: \.motion, to: $configuration), items: VCamAvatarMotion.allCases)
case let .blendShape(configuration):
VCamActionEditorPicker(item: .init(configuration, keyPath: \.blendShape, to: $configuration), items: UniBridge.shared.cachedBlendShapes)
VCamActionEditorPicker(item: .init(configuration, keyPath: \.blendShape, to: $configuration), items: UniBridge.shared.cachedBlendShapes.map(\.name))
case let .wait(configuration):
VCamActionEditorDurationField(value: .init(configuration, keyPath: \.duration, to: $configuration))
case .resetCamera:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@

import SwiftUI
import VCamBridge
import VCamEntity

public struct VCamMainToolbarBlendShapePicker: View {
public init(blendShapes: [String] = UniBridge.cachedBlendShapes) {
public init(blendShapes: [BlendShape] = UniBridge.cachedBlendShapes) {
self.blendShapes = blendShapes
}

let blendShapes: [String]
let blendShapes: [BlendShape]
@ExternalStateBinding(.currentBlendShape) private var currentBlendShape

public var body: some View {
ScrollView(.vertical, showsIndicators: true) {
GroupBox {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 60))]) {
ForEach(blendShapes) { blendShape in
HoverToggle(text: blendShape, isOn: $currentBlendShape.map(
get: { blendShape == $0 },
set: { $0 ? blendShape : "" }
HoverToggle(text: blendShape.name, isOn: $currentBlendShape.map(
get: { blendShape.name == $0 },
set: { $0 ? blendShape.name : "" }
))
}
}
Expand Down Expand Up @@ -73,5 +74,5 @@ extension VCamMainToolbarBlendShapePicker: MacWindow {
}

#Preview {
VCamMainToolbarBlendShapePicker(blendShapes: ["natural", "joy"])
VCamMainToolbarBlendShapePicker(blendShapes: ["natural", "joy"].map { BlendShape(name: $0) })
}
2 changes: 2 additions & 0 deletions app/xcode/Sources/VCamUI/UnityCallback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import VCamBridge
import VCamCamera
import VCamTracking
import VCamLogger
import VCamEntity

@_cdecl("uniOnVCamSystemStart")
public func uniOnVCamSystemStart() {
Expand All @@ -37,6 +38,7 @@ public func uniOnApplyCaptureSystem() {
Tracking.shared.updateLipSyncIfNeeded()

UniBridge.cachedBlendShapes = UniBridge.shared.blendShapes.components(separatedBy: ",")
.map { VCamEntity.BlendShape(name: $0) }
}

@_cdecl("uniUseAutoConvertVRM1")
Expand Down
10 changes: 6 additions & 4 deletions app/xcode/Sources/VCamUI/VCamMainObjectListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ private struct FilterSceneObjectButton: View {
let filter: (ImageFilter) -> Void
var body: some View {
Button {
let image = RenderTextureManager.shared.drawer(id: object.id)?.croppedSnapshot() ?? .init()
showImageFilterView(image: image, configuration: configuration) { filter in
RenderTextureManager.shared.drawer(id: object.id)?.filter = filter
self.filter(filter)
Task { @MainActor in
let image = await RenderTextureManager.shared.drawer(id: object.id)?.croppedSnapshot() ?? .init()
showImageFilterView(image: image, configuration: configuration) { filter in
RenderTextureManager.shared.drawer(id: object.id)?.filter = filter
self.filter(filter)
}
}
} label: {
Image(systemName: "wand.and.stars")
Expand Down

0 comments on commit 23b0ca1

Please sign in to comment.