Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions Sources/OpenSwiftUICore/Graphic/Color/ColorRenderingMode.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,3 @@ extension GraphicsImage: ProtobufMessage {
}
}
package struct ResolvedShadowStyle {}

package struct RasterizationOptions {}
package protocol RBDisplayListContents {} // RenderBox.RBDisplayListContents
public struct PlatformDrawableOptions {}
public protocol PlatformDrawable : AnyObject {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// PlatformViewDefinition.swift
// DisplayListViewPlatform.swift
// OpenSwiftUICore
//
// Audited for 6.0.87
Expand Down
150 changes: 150 additions & 0 deletions Sources/OpenSwiftUICore/Render/PlatformDrawable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
//
// PlatformDrawable.swift
// OpenSwiftUICore
//
// Audited for 6.5.4
// Status: WIP

import OpenAttributeGraphShims
import OpenRenderBoxShims
public import OpenCoreGraphicsShims
#if canImport(QuarzCore)
public import QuartzCore
import CoreAnimation_Private
#endif

// MARK: - PlatformDrawable

@_spi(DisplayList_ViewSystem)
@available(OpenSwiftUI_v6_0, *)
public protocol PlatformDrawable: AnyObject {
var options: PlatformDrawableOptions { get set }

static var allowsContentsMultiplyColor: Bool { get }

func update(content: PlatformDrawableContent?, required: Bool) -> Bool

#if canImport(QuarzCore)
func makeAsyncUpdate(
content: PlatformDrawableContent,
required: Bool,
layer: CALayer,
bounds: CGRect
) -> (() -> Void)?
#endif

func setContentsScale(_ scale: CGFloat)

func drawForTesting(in: RBDisplayList) -> ()
}

// MARK: - PlatformDrawableContent [WIP]

@_spi(DisplayList_ViewSystem)
@available(OpenSwiftUI_v6_0, *)
public struct PlatformDrawableContent: @unchecked Sendable {
enum Storage {
case graphicsCallback((inout GraphicsContext, CGSize) -> ())
case platformCallback((CGSize) -> ())
case displayList(DisplayList, CGPoint, Time)
case rbDisplayList(RBDisplayListContents, CGPoint)
case rbInterpolator(RBDisplayListInterpolator, Float, CGPoint)
case empty
}

private var storage: Storage = .empty

public struct State {
package var mode: DisplayList.GraphicsRenderer.PlatformViewMode

package var _renderer: DisplayList.GraphicsRenderer?

package init() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlatformDrawableContent.State is public but its initializers are package, and PlatformDrawableContent.draw(...) requires an inout State; SPI clients outside this package may have no way to create/retain a State. If draw is intended for external PlatformDrawable implementers, it likely needs a constructible state type.

🤖 Was this useful? React with 👍 or 👎

mode = .unsupported
_renderer = nil
}

package init(platformViewMode: DisplayList.GraphicsRenderer.PlatformViewMode) {
mode = platformViewMode
_renderer = nil
}

package mutating func renderer() -> DisplayList.GraphicsRenderer {
guard let _renderer else {
let render = DisplayList.GraphicsRenderer(platformViewMode: mode)
_renderer = render
return render
}
return _renderer
}
}

public init() {
_openSwiftUIEmptyStub()
}

#if canImport(CoreGraphics)
public func draw(
in ctx: CGContext,
size: CGSize,
contentsScale: CGFloat,
state: inout PlatformDrawableContent.State
) {
_openSwiftUIUnimplementedFailure()
}
#endif

public func draw(
in list: RBDisplayList,
size: CGSize,
state: inout PlatformDrawableContent.State
) {
_openSwiftUIUnimplementedFailure()
}
}

@_spi(DisplayList_ViewSystem)
@available(*, unavailable)
extension PlatformDrawableContent.State: Sendable {}

// MARK: - PlatformDrawableOptions [Blocked by RBLayer]

@_spi(DisplayList_ViewSystem)
@available(OpenSwiftUI_v6_0, *)
public struct PlatformDrawableOptions: Equatable, Sendable {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlatformDrawableOptions is public SPI and PlatformDrawable.options is get set, but there’s no public/SPI initializer (and base is internal), which can make it impossible for external adopters to initialize their stored options. If the intent is framework-owned mutation only, consider making that contract explicit.

🤖 Was this useful? React with 👍 or 👎

var base: RasterizationOptions

public var isAccelerated: Bool {
base.isAccelerated
}

public var isOpaque: Bool {
base.isOpaque
}

public var rendersAsynchronously: Bool {
base.rendersAsynchronously
}

public var rendersFirstFrameAsynchronously: Bool {
base.rendersFirstFrameAsynchronously
}

#if canImport(QuarzCore)
public var caLayerContentsFormat: CALayerContentsFormat {
var format = CALayerContentsFormat.automatic
if base.flags.contains(.rgbaContext) {
format = .RGBA8Uint
}
if base.flags.contains(.alphaOnly) {
format = .A8
}
return format
}
#endif

public func update(rbLayer: AnyObject) {
// TODO: RBLayer
_openSwiftUIUnimplementedFailure()
}
}
Loading
Loading