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