Browse Source

Attempt to optimize

Equbuxu 3 years ago
parent
commit
c612fc75ee
1 changed files with 7 additions and 1 deletions
  1. 7 1
      PixiEditor/Models/Controllers/BitmapManager.cs

+ 7 - 1
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -240,12 +240,18 @@ namespace PixiEditor.Models.Controllers
             {
                 ActiveDocument.PreviewLayer = null;
             }
-            else
+            else if (ActiveDocument.PreviewLayer == null)
             {
                 ActiveDocument.GeneratePreviewLayer();
                 ActiveDocument.PreviewLayer.SetPixels(
                     BitmapPixelChanges.FromSingleColoredArray(highlightArea, new SKColor(0, 0, 0, 77)));
             }
+            else
+            {
+                ActiveDocument.PreviewLayer.Clear();
+                ActiveDocument.PreviewLayer.SetPixels(
+                    BitmapPixelChanges.FromSingleColoredArray(highlightArea, new SKColor(0, 0, 0, 77)));
+            }
         }
 
         private bool CanChangeHighlightOffset(IEnumerable<Coordinates> highlightArea)