mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-24 18:31:23 +01:00
refactor: clean up
This commit is contained in:
@@ -29,7 +29,7 @@ final class GraphicContext: @unchecked Sendable {
|
||||
|
||||
var erasers: [URL: EraserStroke] = [:]
|
||||
|
||||
let concurrentQueue = DispatchQueue(label: "com.dispatchBarrier", attributes: .concurrent)
|
||||
let barrierQueue = DispatchQueue(label: "com.memola.app.graphic-context", attributes: .concurrent)
|
||||
|
||||
init() {
|
||||
setViewPortVertices()
|
||||
|
||||
@@ -84,7 +84,7 @@ final class PenStroke: Stroke, @unchecked Sendable {
|
||||
eraserStrokes = Set(object.erasers.compactMap { [graphicContext] eraser -> EraserStroke? in
|
||||
guard let eraser = eraser as? EraserObject else { return nil }
|
||||
let url = eraser.objectID.uriRepresentation()
|
||||
return graphicContext.concurrentQueue.sync(flags: .barrier) {
|
||||
return graphicContext.barrierQueue.sync(flags: .barrier) {
|
||||
if graphicContext.erasers[url] == nil {
|
||||
let _stroke = EraserStroke(object: eraser)
|
||||
_stroke.loadQuads(from: eraser)
|
||||
|
||||
@@ -100,5 +100,18 @@ class GraphicRenderPass: RenderPass {
|
||||
}
|
||||
graphicContext.previousStroke = nil
|
||||
}
|
||||
|
||||
let eraserStrokes = graphicContext.eraserStrokes
|
||||
for eraserStroke in eraserStrokes {
|
||||
if eraserStroke.finishesSaving {
|
||||
graphicContext.eraserStrokes.remove(eraserStroke)
|
||||
continue
|
||||
}
|
||||
descriptor.colorAttachments[0].loadAction = clearsTexture ? .clear : .load
|
||||
clearsTexture = false
|
||||
eraserRenderPass.stroke = eraserStroke
|
||||
eraserRenderPass.descriptor = descriptor
|
||||
eraserRenderPass.draw(on: canvas, with: renderer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user