Browse Source

Rename DocumentViewModel.Bitmaps to DocumentViewModel.LazyBitmaps

Equbuxu 2 years ago
parent
commit
843f37679b

+ 3 - 3
src/PixiEditor/Models/DocumentModels/ActionAccumulator.cs

@@ -115,7 +115,7 @@ internal class ActionAccumulator
             var renderResult = await renderer.UpdateGatheredChunks(affectedChunks, undoBoundaryPassed);
             
             // lock bitmaps
-            foreach (var (_, bitmap) in document.Bitmaps)
+            foreach (var (_, bitmap) in document.LazyBitmaps)
             {
                 bitmap.Lock();
             }
@@ -126,7 +126,7 @@ internal class ActionAccumulator
             AddDirtyRects(renderResult);
 
             // unlock bitmaps
-            foreach (var (_, bitmap) in document.Bitmaps)
+            foreach (var (_, bitmap) in document.LazyBitmaps)
             {
                 bitmap.Unlock();
             }
@@ -191,7 +191,7 @@ internal class ActionAccumulator
             {
                 case DirtyRect_RenderInfo info:
                     {
-                        var bitmap = document.Bitmaps[info.Resolution];
+                        var bitmap = document.LazyBitmaps[info.Resolution];
                         RectI finalRect = new RectI(VecI.Zero, new(bitmap.PixelWidth, bitmap.PixelHeight));
 
                         RectI dirtyRect = new RectI(info.Pos, info.Size).Intersect(finalRect);

+ 2 - 2
src/PixiEditor/Models/DocumentModels/DocumentUpdater.cs

@@ -304,7 +304,7 @@ internal class DocumentUpdater
             doc.Surfaces[res] = CreateDrawingSurface(newBitmaps[res]);
         }
 
-        doc.Bitmaps = newBitmaps;
+        doc.LazyBitmaps = newBitmaps;
 
         doc.InternalSetSize(info.Size);
         doc.InternalSetVerticalSymmetryAxisX(info.VerticalSymmetryAxisX);
@@ -315,7 +315,7 @@ internal class DocumentUpdater
         doc.PreviewBitmap = CreateBitmap(previewSize);
         doc.PreviewSurface = CreateDrawingSurface(doc.PreviewBitmap);
 
-        doc.RaisePropertyChanged(nameof(doc.Bitmaps));
+        doc.RaisePropertyChanged(nameof(doc.LazyBitmaps));
         doc.RaisePropertyChanged(nameof(doc.PreviewBitmap));
 
         UpdateMemberBitmapsRecursively(doc.StructureRoot, previewSize);

+ 1 - 1
src/PixiEditor/Models/IO/Exporter.cs

@@ -66,7 +66,7 @@ internal class Exporter
 
         if (finalType != FileType.Pixi)
         {
-            var bitmap = document.Bitmaps[ChunkResolution.Full];
+            var bitmap = document.LazyBitmaps[ChunkResolution.Full];
             SaveAs(encodersFactory[finalType](), path, bitmap.PixelWidth, bitmap.PixelHeight, bitmap);
         }
         else if (Directory.Exists(Path.GetDirectoryName(path)))

+ 2 - 2
src/PixiEditor/ViewModels/SubViewModels/Document/DocumentViewModel.cs

@@ -123,7 +123,7 @@ internal partial class DocumentViewModel : NotifyableObject
     public StructureMemberViewModel? SelectedStructureMember { get; private set; } = null;
 
     public Dictionary<ChunkResolution, DrawingSurface> Surfaces { get; set; } = new();
-    public Dictionary<ChunkResolution, WriteableBitmap> Bitmaps { get; set; } = new()
+    public Dictionary<ChunkResolution, WriteableBitmap> LazyBitmaps { get; set; } = new()
     {
         [ChunkResolution.Full] = new WriteableBitmap(64, 64, 96, 96, PixelFormats.Pbgra32, null),
         [ChunkResolution.Half] = new WriteableBitmap(32, 32, 96, 96, PixelFormats.Pbgra32, null),
@@ -162,7 +162,7 @@ internal partial class DocumentViewModel : NotifyableObject
         LineToolOverlayViewModel = new();
         LineToolOverlayViewModel.LineMoved += (_, args) => Internals.ChangeController.LineOverlayMovedInlet(args.Item1, args.Item2);
 
-        foreach (KeyValuePair<ChunkResolution, WriteableBitmap> bitmap in Bitmaps)
+        foreach (KeyValuePair<ChunkResolution, WriteableBitmap> bitmap in LazyBitmaps)
         {
             DrawingSurface? surface = DrawingSurface.Create(
                 new ImageInfo(bitmap.Value.PixelWidth, bitmap.Value.PixelHeight, ColorType.Bgra8888, AlphaType.Premul, ColorSpace.CreateSrgb()),

+ 1 - 1
src/PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs

@@ -295,7 +295,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
         if (doc is null)
             return;
 
-        var bitmap = doc.Bitmaps[ChunkResolution.Full];
+        var bitmap = doc.LazyBitmaps[ChunkResolution.Full];
         if (Exporter.Export(bitmap, new VecI(bitmap.PixelWidth, bitmap.PixelHeight), out string path))
         {
             ProcessHelper.OpenInExplorer(path);

+ 1 - 1
src/PixiEditor/Views/UserControls/FixedViewport.xaml.cs

@@ -43,7 +43,7 @@ internal partial class FixedViewport : UserControl, INotifyPropertyChanged
 
     public WriteableBitmap? TargetBitmap
     {
-        get => Document?.Bitmaps.TryGetValue(CalculateResolution(), out WriteableBitmap? value) == true ? value : null;
+        get => Document?.LazyBitmaps.TryGetValue(CalculateResolution(), out WriteableBitmap? value) == true ? value : null;
     }
 
     public Guid GuidValue { get; } = Guid.NewGuid();

+ 1 - 1
src/PixiEditor/Views/UserControls/Viewport.xaml.cs

@@ -269,7 +269,7 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
     {
         get
         {
-            return Document?.Bitmaps.TryGetValue(CalculateResolution(), out WriteableBitmap? value) == true ? value : null;
+            return Document?.LazyBitmaps.TryGetValue(CalculateResolution(), out WriteableBitmap? value) == true ? value : null;
         }
     }