mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 05:05:23 +03:00
Merge pull request #551 from f3dm76/task/topLayers
Replace top renderers with top layers
This commit is contained in:
commit
586bf9b5a8
@ -235,8 +235,6 @@
|
||||
58944BDA20AC8A9A00657640 /* logo_base64.txt in Resources */ = {isa = PBXBuildFile; fileRef = 57B7A4E01EE70DA5009D78D7 /* logo_base64.txt */; };
|
||||
58944BDB20AC8A9A00657640 /* clip.svg in Resources */ = {isa = PBXBuildFile; fileRef = C43B064C1F9738EF00787A35 /* clip.svg */; };
|
||||
58B0523920E10E7100D45008 /* ColorMatrix.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5874CCB620DA8A860090DBD5 /* ColorMatrix.swift */; };
|
||||
5B0AEEEC223FAE0E00318A39 /* WeakThing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B0AEEEB223FAE0E00318A39 /* WeakThing.swift */; };
|
||||
5B0AEEEF223FC17800318A39 /* WeakThing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B0AEEEB223FAE0E00318A39 /* WeakThing.swift */; };
|
||||
5B1A8C7620A15F7300E5FFAE /* SVGNodeLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1A8C7520A15F7300E5FFAE /* SVGNodeLayout.swift */; };
|
||||
5B1A8C7720A15F7300E5FFAE /* SVGNodeLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1A8C7520A15F7300E5FFAE /* SVGNodeLayout.swift */; };
|
||||
5B1AE23220B6A669007EECCB /* text-align-01-b-manual.svg in Resources */ = {isa = PBXBuildFile; fileRef = 5B1AE18420B6A669007EECCB /* text-align-01-b-manual.svg */; };
|
||||
@ -674,7 +672,6 @@
|
||||
585288F320AD96A2003E51D1 /* ContentLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentLayout.swift; sourceTree = "<group>"; };
|
||||
5852891520B29D67003E51D1 /* TransformedLocus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransformedLocus.swift; sourceTree = "<group>"; };
|
||||
5874CCB620DA8A860090DBD5 /* ColorMatrix.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorMatrix.swift; sourceTree = "<group>"; };
|
||||
5B0AEEEB223FAE0E00318A39 /* WeakThing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeakThing.swift; sourceTree = "<group>"; };
|
||||
5B1A8C7520A15F7300E5FFAE /* SVGNodeLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SVGNodeLayout.swift; sourceTree = "<group>"; };
|
||||
5B1AE18420B6A669007EECCB /* text-align-01-b-manual.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "text-align-01-b-manual.svg"; sourceTree = "<group>"; };
|
||||
5B1AE18520B6A669007EECCB /* paths-data-06-t-manual.reference */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "paths-data-06-t-manual.reference"; sourceTree = "<group>"; };
|
||||
@ -1006,7 +1003,6 @@
|
||||
57900FF81EA0DEBF00809FFB /* UIImage2Image.swift */,
|
||||
3081E77C20DB58B100640F96 /* DescriptionExtensions.swift */,
|
||||
3002331B20CC0BDD00EFD92D /* BoundsUtils.swift */,
|
||||
5B0AEEEB223FAE0E00318A39 /* WeakThing.swift */,
|
||||
);
|
||||
path = utils;
|
||||
sourceTree = "<group>";
|
||||
@ -2077,7 +2073,6 @@
|
||||
57614B3A1F83D15600875933 /* AnimationProducer.swift in Sources */,
|
||||
585288F620AD96A2003E51D1 /* ContentLayout.swift in Sources */,
|
||||
57614B3C1F83D15600875933 /* ShapeInterpolation.swift in Sources */,
|
||||
5B0AEEEF223FC17800318A39 /* WeakThing.swift in Sources */,
|
||||
57614B3D1F83D15600875933 /* Graphics_iOS.swift in Sources */,
|
||||
57614BDB1F8739EE00875933 /* MacawView+PDF.swift in Sources */,
|
||||
57614B411F83D15600875933 /* Text.swift in Sources */,
|
||||
@ -2218,7 +2213,6 @@
|
||||
57A27BD51E44C5840057BD3A /* ShapeInterpolation.swift in Sources */,
|
||||
A718CD471F45C28700966E06 /* Graphics_iOS.swift in Sources */,
|
||||
57614BDA1F8739EE00875933 /* MacawView+PDF.swift in Sources */,
|
||||
5B0AEEEC223FAE0E00318A39 /* WeakThing.swift in Sources */,
|
||||
57E5E1A21E3B393900D1CB28 /* Text.swift in Sources */,
|
||||
57F1087C1F53CA7E00DC365B /* MDisplayLink_iOS.swift in Sources */,
|
||||
57E5E1A61E3B393900D1CB28 /* RenderContext.swift in Sources */,
|
||||
|
@ -18,7 +18,7 @@ class AnimationProducer {
|
||||
let animation: ContentsAnimation
|
||||
let layer: CALayer
|
||||
weak var cache: AnimationCache?
|
||||
let topRenderers: [WeakThing<NodeRenderer>]
|
||||
let topLayers: [ShapeLayer]
|
||||
let startDate: Date
|
||||
let finishDate: Date
|
||||
let completion: (() -> Void)?
|
||||
@ -272,10 +272,12 @@ class AnimationProducer {
|
||||
}
|
||||
let bottomRenderer = animationRenderers.min { $0.zPosition < $1.zPosition }
|
||||
|
||||
var topRenderers = [WeakThing<NodeRenderer>]()
|
||||
var topLayers = [ShapeLayer]()
|
||||
if let bottomRenderer = bottomRenderer, let allRenderers = allRenderers {
|
||||
for renderer in allRenderers where !(renderer is GroupRenderer) && renderer.zPosition > bottomRenderer.zPosition {
|
||||
topRenderers.append(WeakThing(renderer))
|
||||
if let layer = cache?.layerForNodeRenderer(renderer, context, animation: contentsAnimation) {
|
||||
topLayers.append(layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,7 +285,7 @@ class AnimationProducer {
|
||||
animation: contentsAnimation,
|
||||
layer: layer,
|
||||
cache: cache,
|
||||
topRenderers: topRenderers,
|
||||
topLayers: topLayers,
|
||||
startDate: Date(),
|
||||
finishDate: Date(timeInterval: contentsAnimation.duration, since: startDate),
|
||||
completion: completion
|
||||
@ -340,6 +342,9 @@ class AnimationProducer {
|
||||
contentsAnimations.remove(at: count - 1 - index)
|
||||
animationDesc.cache?.freeLayer(renderer)
|
||||
animationDesc.completion?()
|
||||
for layer in animationDesc.topLayers {
|
||||
animationDesc.cache?.freeLayer(layer: layer)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@ -362,12 +367,9 @@ class AnimationProducer {
|
||||
}
|
||||
}
|
||||
|
||||
for weakRenderer in animationDesc.topRenderers {
|
||||
if let renderer = weakRenderer.value {
|
||||
let layer = animationDesc.cache?.layerForNodeRenderer(renderer, context, animation: animationDesc.animation)
|
||||
layer?.setNeedsDisplay()
|
||||
layer?.displayIfNeeded()
|
||||
}
|
||||
for layer in animationDesc.topLayers {
|
||||
layer.setNeedsDisplay()
|
||||
layer.displayIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,31 @@ class AnimationCache {
|
||||
layer.removeFromSuperlayer()
|
||||
}
|
||||
|
||||
func freeLayer(layer: ShapeLayer) {
|
||||
var cached: CachedLayer?
|
||||
var renderer: NodeRenderer?
|
||||
layerCache.forEach { key, value in
|
||||
if value.layer === layer {
|
||||
cached = value
|
||||
renderer = key
|
||||
}
|
||||
}
|
||||
guard let cachedLayer = cached, let nodeRenderer = renderer else {
|
||||
return
|
||||
}
|
||||
|
||||
cachedLayer.linksCounter -= 1
|
||||
|
||||
if cachedLayer.linksCounter != 0 {
|
||||
return
|
||||
}
|
||||
|
||||
let layer = cachedLayer.layer
|
||||
layerCache.removeValue(forKey: nodeRenderer)
|
||||
sceneLayer?.setNeedsDisplay()
|
||||
layer.removeFromSuperlayer()
|
||||
}
|
||||
|
||||
func freeLayer(_ renderer: NodeRenderer) {
|
||||
guard let cachedLayer = layerCache[renderer] else {
|
||||
return
|
||||
|
@ -1,8 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
struct WeakThing<T: AnyObject> {
|
||||
weak var value: T?
|
||||
init(_ value: T) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user