Browse Source

Merge branch 'fixes/2.0.1.7' into development

Krzysztof Krysiński 1 month ago
parent
commit
f678e7ba4a

+ 41 - 3
src/ChunkyImageLib/ChunkyImage.cs

@@ -268,10 +268,10 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
                 return FindTightCommittedBounds(suggestedResolution, fallbackToChunkAligned);
                 return FindTightCommittedBounds(suggestedResolution, fallbackToChunkAligned);
             }
             }
 
 
-            if (lastLatestBoundsCacheHash == GetCacheHash())
+            /*if (lastLatestBoundsCacheHash == GetCacheHash())
             {
             {
                 return cachedPreciseLatestBounds;
                 return cachedPreciseLatestBounds;
-            }
+            }*/
 
 
             var chunkSize = suggestedResolution.PixelSize();
             var chunkSize = suggestedResolution.PixelSize();
             var multiplier = suggestedResolution.Multiplier();
             var multiplier = suggestedResolution.Multiplier();
@@ -288,7 +288,37 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
 
 
             foreach (var chunkPos in possibleChunks)
             foreach (var chunkPos in possibleChunks)
             {
             {
-                var chunk = GetLatestChunk(chunkPos, suggestedResolution) ?? GetCommittedChunk(chunkPos, suggestedResolution);
+                var committedChunk = GetCommittedChunk(chunkPos, suggestedResolution);
+                var latestChunk = GetLatestChunk(chunkPos, suggestedResolution);
+
+                Chunk? chunk;
+                bool isTempChunk = false;
+
+                if (latestChunk != null && committedChunk != null)
+                {
+                    // both exist, need to merge
+                    var tempChunk = Chunk.Create(ProcessingColorSpace, suggestedResolution);
+                    tempChunk.Surface.DrawingSurface.Canvas.DrawSurface(committedChunk.Surface.DrawingSurface, 0, 0,
+                        ReplacingPaint);
+                    blendModePaint.BlendMode = blendMode;
+                    tempChunk.Surface.DrawingSurface.Canvas.DrawSurface(latestChunk.Surface.DrawingSurface, 0, 0,
+                        blendModePaint);
+                    if (lockTransparency)
+                        OperationHelper.ClampAlpha(tempChunk.Surface.DrawingSurface,
+                            committedChunk.Surface.DrawingSurface);
+                    chunk = tempChunk;
+                    isTempChunk = true;
+                }
+                else if (latestChunk != null)
+                {
+                    chunk = latestChunk;
+                }
+                else
+                {
+                    chunk = committedChunk;
+                }
+
+
                 if (chunk != null)
                 if (chunk != null)
                 {
                 {
                     RectI visibleArea = new RectI(chunkPos * chunkSize, new VecI(chunkSize))
                     RectI visibleArea = new RectI(chunkPos * chunkSize, new VecI(chunkSize))
@@ -301,6 +331,11 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
 
 
                     preciseBounds ??= globalChunkBounds;
                     preciseBounds ??= globalChunkBounds;
                     preciseBounds = preciseBounds.Value.Union(globalChunkBounds);
                     preciseBounds = preciseBounds.Value.Union(globalChunkBounds);
+
+                    if (isTempChunk)
+                    {
+                        chunk.Dispose();
+                    }
                 }
                 }
                 else
                 else
                 {
                 {
@@ -1599,10 +1634,13 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
         hash.Add(commitCounter);
         hash.Add(commitCounter);
         hash.Add(queuedOperations.Count);
         hash.Add(queuedOperations.Count);
         hash.Add(operationCounter);
         hash.Add(operationCounter);
+
         foreach (var queuedOperation in queuedOperations)
         foreach (var queuedOperation in queuedOperations)
         {
         {
             hash.Add(queuedOperation.affectedArea.GlobalArea?.GetHashCode() ?? 0);
             hash.Add(queuedOperation.affectedArea.GlobalArea?.GetHashCode() ?? 0);
+            hash.Add(queuedOperation.operation.GetHashCode());
         }
         }
+
         hash.Add(activeClips.Count);
         hash.Add(activeClips.Count);
         hash.Add((int)blendMode);
         hash.Add((int)blendMode);
         hash.Add(lockTransparency);
         hash.Add(lockTransparency);

+ 10 - 4
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/TransformSelectedExecutor.cs

@@ -200,7 +200,8 @@ internal class TransformSelectedExecutor : UpdateableChangeExecutor, ITransforma
             }
             }
             else
             else
             {
             {
-                if (document.SoftSelectedStructureMembers.Contains(topMost) || document.SelectedStructureMember?.Id == topMost.Id)
+                if (document.SoftSelectedStructureMembers.Contains(topMost) ||
+                    document.SelectedStructureMember?.Id == topMost.Id)
                 {
                 {
                     Deselect(smallestSizeDifferenceList);
                     Deselect(smallestSizeDifferenceList);
                 }
                 }
@@ -253,15 +254,20 @@ internal class TransformSelectedExecutor : UpdateableChangeExecutor, ITransforma
             bool deselectingWasMain = document.SelectedStructureMember?.Id == topMost.Id;
             bool deselectingWasMain = document.SelectedStructureMember?.Id == topMost.Id;
             if (deselectingWasMain)
             if (deselectingWasMain)
             {
             {
-                Guid? nextMain = document.SoftSelectedStructureMembers.FirstOrDefault()?.Id;
-                List<Guid> softSelected = document.SoftSelectedStructureMembers
+                Guid? nextMain = document.SoftSelectedStructureMembers?.FirstOrDefault()?.Id;
+                List<Guid> softSelected = document.SoftSelectedStructureMembers?
                     .Select(x => x.Id).Where(x => x != nextMain.Value).ToList();
                     .Select(x => x.Id).Where(x => x != nextMain.Value).ToList();
 
 
                 document.Operations.ClearSoftSelectedMembers();
                 document.Operations.ClearSoftSelectedMembers();
-                document.Operations.SetSelectedMember(nextMain.Value);
+                if (nextMain.HasValue)
+                {
+                    document.Operations.SetSelectedMember(nextMain.Value);
+                }
 
 
                 foreach (var guid in softSelected)
                 foreach (var guid in softSelected)
                 {
                 {
+                    if (guid == Guid.Empty) continue;
+
                     document.Operations.AddSoftSelectedMember(guid);
                     document.Operations.AddSoftSelectedMember(guid);
                 }
                 }
             }
             }