-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathPlatformViewDefinition.swift
93 lines (84 loc) · 3.36 KB
/
PlatformViewDefinition.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// PlatformViewDefinition.swift
// OpenSwiftUICore
//
// Audited for RELEASE_2024
// Status: Blocked by PlatformDrawable and GraphicsContext
internal import OpenSwiftUI_SPI
#if canImport(Darwin)
import QuartzCore
#endif
@_spi(DisplayList_ViewSystem)
open class PlatformViewDefinition: @unchecked Sendable {
public struct System: Hashable, Sendable {
public static let uiView = PlatformViewDefinition.System(base: .uiView)
public static let nsView = PlatformViewDefinition.System(base: .nsView)
var base: ViewSystem
}
public enum ViewKind: Sendable {
case inherited
case color
case image
case shape
case shadow
case backdrop
case chameleonColor
case drawing
case compositing
case geometry
case projection
case affine3D
case mask
case platformView
case platformGroup
case platformLayer
case platformEffect
public var isContainer: Bool {
switch self {
case .inherited, .compositing, .geometry, .projection, .affine3D, .mask, .platformGroup, .platformEffect:
return true
case .color, .image, .shape, .shadow, .backdrop, .chameleonColor, .drawing, .platformView, .platformLayer:
return false
}
}
}
open class var system: PlatformViewDefinition.System { .init(base: .swiftUIView) }
open class func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { fatalError() }
#if canImport(Darwin)
open class func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { fatalError() }
#endif
open class func makePlatformView(view: AnyObject, kind: PlatformViewDefinition.ViewKind) { fatalError() }
// open class func makeDrawingView(options: PlatformDrawableOptions) -> any PlatformDrawable { fatalError() }
open class func setPath(_ path: Path, shapeView: AnyObject) { fatalError() }
open class func setProjectionTransform(_ transform: ProjectionTransform, projectionView: AnyObject) { fatalError() }
open class func getRBLayer(drawingView: AnyObject) -> AnyObject? { fatalError() }
open class func setIgnoresEvents(_ state: Bool, of view: AnyObject) { fatalError() }
open class func setAllowsWindowActivationEvents(_ value: Bool?, for view: AnyObject) { fatalError() }
open class func setHitTestsAsOpaque(_ value: Bool, for view: AnyObject) { fatalError() }
}
extension DisplayList.ViewUpdater {
package struct Platform {
let rawValue: UInt
}
}
extension DisplayList.ViewUpdater.Platform {
package init(definition: PlatformViewDefinition.Type) {
self.init(rawValue: UInt(bitPattern: ObjectIdentifier(definition)) | UInt(definition.system.base.rawValue))
}
@inline(__always)
var definition: PlatformViewDefinition.Type {
return unsafeBitCast(rawValue & ~3, to: PlatformViewDefinition.Type.self)
}
}
extension DisplayList.GraphicsRenderer {
#if canImport(Darwin)
final package func drawPlatformLayer(_ layer: CALayer, in ctx: GraphicsContext, size: CGSize, update: Bool) {
if update {
layer.bounds = CGRect(origin: .zero, size: size)
layer.layoutIfNeeded()
}
fatalError("Blocked by GraphicsContext")
// ctx.drawLayer
}
#endif
}