From 9c615bf687aeb3437542e839e6ce0e282dea6334 Mon Sep 17 00:00:00 2001 From: Cal Stephens Date: Wed, 3 Aug 2022 17:08:51 -0700 Subject: [PATCH] Ignore masks with `MaskMode.none` (#1693) --- .../Private/CoreAnimation/Layers/BaseCompositionLayer.swift | 3 ++- .../LayerContainers/CompLayers/CompositionLayer.swift | 2 +- Tests/Samples/Issues/issue_1603.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Tests/Samples/Issues/issue_1603.json diff --git a/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift b/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift index 67b6bab151..7359c8e58e 100644 --- a/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +++ b/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift @@ -78,7 +78,8 @@ class BaseCompositionLayer: BaseAnimationLayer { private func setupSublayers() { if renderLayerContents, - let masks = baseLayerModel.masks + let masks = baseLayerModel.masks?.filter({ $0.mode != .none }), + !masks.isEmpty { mask = MaskCompositionLayer(masks: masks) } diff --git a/Sources/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift b/Sources/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift index 38c27093b4..455d236688 100644 --- a/Sources/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +++ b/Sources/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift @@ -17,7 +17,7 @@ class CompositionLayer: CALayer, KeypathSearchable { init(layer: LayerModel, size: CGSize) { transformNode = LayerTransformNode(transform: layer.transform) - if let masks = layer.masks { + if let masks = layer.masks?.filter({ $0.mode != .none }), !masks.isEmpty { maskLayer = MaskContainerLayer(masks: masks) } else { maskLayer = nil diff --git a/Tests/Samples/Issues/issue_1603.json b/Tests/Samples/Issues/issue_1603.json new file mode 100644 index 0000000000..320df9e035 --- /dev/null +++ b/Tests/Samples/Issues/issue_1603.json @@ -0,0 +1 @@ +{"v":"4.8.0","meta":{"g":"LottieFiles AE ","a":"","k":"","d":"","tc":""},"fr":30,"ip":0,"op":33,"w":320,"h":568,"nm":"Second-Loss-Pulse","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":45,"ix":10},"p":{"a":0,"k":[160.13,283.14,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[79,79,100],"ix":6}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"n","pt":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-184.706,-189.133],[-184.706,2.903],[191.886,2.903],[191.886,-189.133]],"c":true},"ix":1},"o":{"a":0,"k":100,"ix":3},"x":{"a":0,"k":0,"ix":4},"nm":"Mask 1"}],"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":1,"k":[{"i":{"x":[0,0],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"t":0,"s":[100,209.333]},{"t":30,"s":[213,324.613]}],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[20]},{"t":30,"s":[58]}],"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[0,0,0,1],"ix":3},"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":15.254,"s":[50]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":19.83,"s":[34.483]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":22.373,"s":[25.862]},{"t":30,"s":[0]}],"ix":4},"w":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":15,"s":[80]}],"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0.886,-1.133],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"SecondPulse Mismatch","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[158.5,236.50000000000003,0],"ix":2},"a":{"a":0,"k":[160,284,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":320,"h":568,"ip":0,"op":60,"st":0,"bm":0}],"markers":[]}