-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
RenderImageView.swift
46 lines (39 loc) · 1 KB
/
RenderImageView.swift
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// RenderView.swift
// Harbeth
//
// Created by Condy on 2024/3/20.
//
import Foundation
import MetalKit
public final class RenderImageView: C7ImageView, Renderable {
public typealias Element = C7Image
public override var image: C7Image? {
didSet {
if lockedSource {
return
}
self.setupInputSource()
self.filtering()
}
}
}
extension Renderable where Self: C7ImageView {
public func setupInputSource() {
if lockedSource {
return
}
if let image = self.image {
self.inputSource = try? TextureLoader(with: image).texture
}
}
public func setupOutputDest(_ dest: MTLTexture) {
DispatchQueue.main.async {
if let image = self.image {
self.lockedSource = true
self.image = try? dest.c7.fixImageOrientation(refImage: image)
self.lockedSource = false
}
}
}
}