Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ark-render] refactor: use more general canvas return type #101

Merged
merged 2 commits into from
Apr 21, 2024
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
4 changes: 2 additions & 2 deletions ArkKit/ark-render-kit/CanvasContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ protocol CanvasContext<View> {
var arkView: (any ArkView<View>)? { get }
var memo: [EntityID: [RenderableComponentType: (any RenderableComponent, any Renderable)]] { get }

func getFlatCanvas() -> ArkFlatCanvas
func getFlatCanvas() -> any Canvas
func render(_ canvas: any Canvas, using renderer: any RenderableBuilder<View>)
}

Expand Down Expand Up @@ -62,7 +62,7 @@ class ArkCanvasContext<View>: CanvasContext {
}

/// Outputs a logical canvas with the relevant entities in the canvas and their renderable components only
func getFlatCanvas() -> ArkFlatCanvas {
func getFlatCanvas() -> any Canvas {
var arkCanvas = ArkFlatCanvas()
for renderableCompType in ArkCanvasSystem.renderableComponentTypes {
let renderableEntities = ecs.getEntities(with: [renderableCompType])
Expand Down
3 changes: 3 additions & 0 deletions ArkKit/ark-render-kit/canvas/Canvas.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ protocol Canvas {
typealias RenderableComponentType = ObjectIdentifier
typealias CanvasElements = [EntityID: [RenderableComponentType: any RenderableComponent]]
var canvasElements: CanvasElements { get }
mutating func addEntityRenderableToCanvas(entityId: EntityID,
componentType: RenderableComponentType,
renderableComponent: any RenderableComponent)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OrderedDictionaryTests: XCTestCase {
iteratedKeys.append(key)
}

XCTAssertEqual(iteratedKeys, ["one", "two", "three"],
XCTAssertEqual(iteratedKeys, ["one", "two", "three"],
"Keys should be iterated in the order they were inserted.")
}

Expand Down
Loading