mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-21 00:49:27 +01:00
refactor: clean up
This commit is contained in:
@@ -20,7 +20,7 @@ final class Canvas: NSManagedObject, Identifiable {
|
||||
|
||||
let gridContext = GridContext()
|
||||
let viewPortContext = ViewPortContext()
|
||||
let maximumZoomScale: CGFloat = 25
|
||||
let maximumZoomScale: CGFloat = 28
|
||||
let minimumZoomScale: CGFloat = 3.1
|
||||
|
||||
var transform: simd_float4x4 = .init()
|
||||
@@ -42,11 +42,11 @@ final class Canvas: NSManagedObject, Identifiable {
|
||||
// MARK: - Actions
|
||||
extension Canvas {
|
||||
func load() {
|
||||
state = .loading
|
||||
let start = Date().formatted(.dateTime.minute().second().secondFraction(.fractional(5)))
|
||||
for stroke in graphicContext.strokes {
|
||||
if let stroke = stroke as? Stroke {
|
||||
stroke.loadVertices()
|
||||
NSLog("[Memola] - \(stroke.quads.count) quads")
|
||||
}
|
||||
}
|
||||
let end = Date().formatted(.dateTime.minute().second().secondFraction(.fractional(5)))
|
||||
|
||||
@@ -85,9 +85,6 @@ extension Stroke: Drawable {
|
||||
}
|
||||
|
||||
func draw(device: MTLDevice, renderEncoder: MTLRenderCommandEncoder) {
|
||||
if isEmpty {
|
||||
loadVertices()
|
||||
}
|
||||
guard !isEmpty else { return }
|
||||
prepare(device: device)
|
||||
renderEncoder.setFragmentTexture(texture, index: 0)
|
||||
|
||||
@@ -19,6 +19,12 @@ class Persistence {
|
||||
shared.persistentContainer.viewContext
|
||||
}()
|
||||
|
||||
static var backgroundContext: NSManagedObjectContext = {
|
||||
let context = shared.persistentContainer.newBackgroundContext()
|
||||
context.automaticallyMergesChangesFromParent = true
|
||||
return context
|
||||
}()
|
||||
|
||||
private lazy var viewContext: NSManagedObjectContext = {
|
||||
persistentContainer.viewContext
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user