Browse Source

Handle clip to layer below better when merging

Equbuxu 3 years ago
parent
commit
aedb628429

+ 4 - 1
src/PixiEditor.ChangeableDocument/Changeables/Folder.cs

@@ -24,7 +24,10 @@ internal class Folder : StructureMember, IReadOnlyFolder
             Name = Name,
             Name = Name,
             Opacity = Opacity,
             Opacity = Opacity,
             Children = builder.ToImmutable(),
             Children = builder.ToImmutable(),
-            Mask = Mask?.CloneFromCommitted()
+            Mask = Mask?.CloneFromCommitted(),
+            BlendMode = BlendMode,
+            ClipToMemberBelow = ClipToMemberBelow,
+            MaskIsVisible = MaskIsVisible
         };
         };
     }
     }
 
 

+ 4 - 0
src/PixiEditor.ChangeableDocument/Changeables/Layer.cs

@@ -33,6 +33,10 @@ internal class Layer : StructureMember, IReadOnlyLayer
             Name = Name,
             Name = Name,
             Opacity = Opacity,
             Opacity = Opacity,
             Mask = Mask?.CloneFromCommitted(),
             Mask = Mask?.CloneFromCommitted(),
+            ClipToMemberBelow = ClipToMemberBelow,
+            MaskIsVisible = MaskIsVisible,
+            BlendMode = BlendMode,
+            LockTransparency = LockTransparency
         };
         };
     }
     }
 }
 }

+ 4 - 4
src/PixiEditor.ChangeableDocument/Rendering/ChunkRenderer.cs

@@ -154,9 +154,6 @@ public static class ChunkRenderer
         if (folder.Children.Count == 0)
         if (folder.Children.Count == 0)
             return new EmptyChunk();
             return new EmptyChunk();
 
 
-        // clipping to member below doesn't make sense if we are skipping some of them
-        bool ignoreClipToBelow = membersToMerge.IsT1;
-
         Chunk targetChunk = Chunk.Create(resolution);
         Chunk targetChunk = Chunk.Create(resolution);
         targetChunk.Surface.SkiaSurface.Canvas.Clear();
         targetChunk.Surface.SkiaSurface.Canvas.Clear();
 
 
@@ -167,7 +164,6 @@ public static class ChunkRenderer
 
 
             // next child might use clip to member below in which case we need to save the clip image
             // next child might use clip to member below in which case we need to save the clip image
             bool needToSaveClippingChunk =
             bool needToSaveClippingChunk =
-                !ignoreClipToBelow &&
                 i < folder.Children.Count - 1 &&
                 i < folder.Children.Count - 1 &&
                 !child.ClipToMemberBelow &&
                 !child.ClipToMemberBelow &&
                 folder.Children[i + 1].ClipToMemberBelow;
                 folder.Children[i + 1].ClipToMemberBelow;
@@ -194,6 +190,10 @@ public static class ChunkRenderer
                 }
                 }
                 continue;
                 continue;
             }
             }
+            else if (child is IReadOnlyLayer && needToSaveClippingChunk)
+            {
+                clippingChunk = new FilledChunk();
+            }
 
 
             // folder
             // folder
             if (child is IReadOnlyFolder innerFolder)
             if (child is IReadOnlyFolder innerFolder)