Browse Source

Removed unnecessary stuff from render context

flabbet 10 months ago
parent
commit
d3e93efecb

+ 4 - 5
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ImageLayerNode.cs

@@ -35,7 +35,6 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
 
 
     protected override bool AffectedByChunkResolution => true;
     protected override bool AffectedByChunkResolution => true;
 
 
-    protected override bool AffectedByChunkToUpdate => true;
 
 
     private Dictionary<ChunkResolution, Texture> renderedSurfaces = new();
     private Dictionary<ChunkResolution, Texture> renderedSurfaces = new();
 
 
@@ -96,7 +95,7 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         bool shouldClear, Paint paint)
         bool shouldClear, Paint paint)
     {
     {
         // TODO: Implement non-chunk rendering
         // TODO: Implement non-chunk rendering
-        var frameImage = GetFrameWithImage(context.FrameTime).Data as ChunkyImage;
+        /*var frameImage = GetFrameWithImage(context.FrameTime).Data as ChunkyImage;
 
 
         VecI chunkToUpdate = context.ChunkToUpdate.Value;
         VecI chunkToUpdate = context.ChunkToUpdate.Value;
 
 
@@ -189,7 +188,7 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
 
 
         DrawChunk(frameImage, context, tempSurface, new VecI(0, 0), paint);
         DrawChunk(frameImage, context, tempSurface, new VecI(0, 0), paint);
 
 
-        workingSurface.Canvas.DrawSurface(tempSurface.DrawingSurface, VecI.Zero, paint);
+        workingSurface.Canvas.DrawSurface(tempSurface.DrawingSurface, VecI.Zero, paint);*/
     }
     }
 
 
     public override bool RenderPreview(Texture renderOn, VecI chunk, ChunkResolution resolution, int frame)
     public override bool RenderPreview(Texture renderOn, VecI chunk, ChunkResolution resolution, int frame)
@@ -215,7 +214,7 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
     private void DrawChunk(ChunkyImage frameImage, RenderContext context, Texture tempSurface, VecI vecI,
     private void DrawChunk(ChunkyImage frameImage, RenderContext context, Texture tempSurface, VecI vecI,
         Paint paint)
         Paint paint)
     {
     {
-        VecI chunkPos = context.ChunkToUpdate.Value + vecI;
+        /*VecI chunkPos = context.ChunkToUpdate.Value + vecI;
         if (frameImage.LatestOrCommittedChunkExists(chunkPos))
         if (frameImage.LatestOrCommittedChunkExists(chunkPos))
         {
         {
             frameImage.DrawMostUpToDateChunkOn(
             frameImage.DrawMostUpToDateChunkOn(
@@ -224,7 +223,7 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
                 tempSurface.DrawingSurface,
                 tempSurface.DrawingSurface,
                 chunkPos * context.ChunkResolution.PixelSize(),
                 chunkPos * context.ChunkResolution.PixelSize(),
                 paint);
                 paint);
-        }
+        }*/
     }
     }
 
 
     private KeyFrameData GetFrameWithImage(KeyFrameTime frame)
     private KeyFrameData GetFrameWithImage(KeyFrameTime frame)

+ 0 - 6
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/LayerNode.cs

@@ -60,12 +60,6 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode
     {
     {
         if (Output.Connections.Count > 0)
         if (Output.Connections.Count > 0)
         {
         {
-            if (context.ChunkToUpdate == null)
-            {
-                DrawLayer(context, renderOnto, shouldClear);
-                return;
-            }
-
             if (!HasOperations())
             if (!HasOperations())
             {
             {
                 if (Background.Value != null)
                 if (Background.Value != null)

+ 0 - 4
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Node.cs

@@ -30,7 +30,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
 
 
     protected virtual bool AffectedByChunkResolution { get; }
     protected virtual bool AffectedByChunkResolution { get; }
 
 
-    protected virtual bool AffectedByChunkToUpdate { get; }
 
 
     IReadOnlyList<IInputProperty> IReadOnlyNode.InputProperties => inputs;
     IReadOnlyList<IInputProperty> IReadOnlyNode.InputProperties => inputs;
     IReadOnlyList<IOutputProperty> IReadOnlyNode.OutputProperties => outputs;
     IReadOnlyList<IOutputProperty> IReadOnlyNode.OutputProperties => outputs;
@@ -45,7 +44,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
 
 
     private KeyFrameTime _lastFrameTime = new KeyFrameTime(-1, 0);
     private KeyFrameTime _lastFrameTime = new KeyFrameTime(-1, 0);
     private ChunkResolution? _lastResolution;
     private ChunkResolution? _lastResolution;
-    private VecI? _lastChunkPos;
     private bool _keyFramesDirty;
     private bool _keyFramesDirty;
     private Texture? _lastCachedResult;
     private Texture? _lastCachedResult;
     private bool _isDisposed;
     private bool _isDisposed;
@@ -73,7 +71,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
         return (!context.FrameTime.Equals(_lastFrameTime) && AffectedByAnimation)
         return (!context.FrameTime.Equals(_lastFrameTime) && AffectedByAnimation)
                || (AffectedByAnimation && _keyFramesDirty)
                || (AffectedByAnimation && _keyFramesDirty)
                || (context.ChunkResolution != _lastResolution && AffectedByChunkResolution)
                || (context.ChunkResolution != _lastResolution && AffectedByChunkResolution)
-               || (context.ChunkToUpdate != _lastChunkPos && AffectedByChunkToUpdate)
                || inputs.Any(x => x.CacheChanged);
                || inputs.Any(x => x.CacheChanged);
     }
     }
 
 
@@ -86,7 +83,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
 
 
         _lastFrameTime = context.FrameTime;
         _lastFrameTime = context.FrameTime;
         _lastResolution = context.ChunkResolution;
         _lastResolution = context.ChunkResolution;
-        _lastChunkPos = context.ChunkToUpdate;
         _keyFramesDirty = false;
         _keyFramesDirty = false;
     }
     }
 
 

+ 21 - 16
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/StructureNode.cs

@@ -45,7 +45,7 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
     }
     }
 
 
     private Paint maskPaint = new Paint() { BlendMode = DrawingApi.Core.Surfaces.BlendMode.DstIn };
     private Paint maskPaint = new Paint() { BlendMode = DrawingApi.Core.Surfaces.BlendMode.DstIn };
-    protected Paint blendPaint = new Paint() { BlendMode = DrawingApi.Core.Surfaces.BlendMode.SrcOver};
+    protected Paint blendPaint = new Paint() { BlendMode = DrawingApi.Core.Surfaces.BlendMode.SrcOver };
 
 
     private int maskCacheHash = 0;
     private int maskCacheHash = 0;
 
 
@@ -66,25 +66,24 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
     }
     }
 
 
     protected override bool AffectedByChunkResolution => true;
     protected override bool AffectedByChunkResolution => true;
-    protected override bool AffectedByChunkToUpdate => true;
 
 
     protected override void OnExecute(RenderContext context)
     protected override void OnExecute(RenderContext context)
     {
     {
         RectD localBounds = new RectD(0, 0, SceneSize.X, SceneSize.Y);
         RectD localBounds = new RectD(0, 0, SceneSize.X, SceneSize.Y);
 
 
         DrawingSurface sceneSurface = Background.Value ?? context.TargetSurface;
         DrawingSurface sceneSurface = Background.Value ?? context.TargetSurface;
-        
+
         int savedNum = sceneSurface.Canvas.Save();
         int savedNum = sceneSurface.Canvas.Save();
         sceneSurface.Canvas.ClipRect(RectD.Create((VecI)ScenePosition.Floor(), (VecI)SceneSize.Ceiling()));
         sceneSurface.Canvas.ClipRect(RectD.Create((VecI)ScenePosition.Floor(), (VecI)SceneSize.Ceiling()));
         sceneSurface.Canvas.Translate((float)ScenePosition.X, (float)ScenePosition.Y);
         sceneSurface.Canvas.Translate((float)ScenePosition.X, (float)ScenePosition.Y);
-        
-        SceneObjectRenderContext renderObjectContext = new SceneObjectRenderContext(sceneSurface, localBounds, 
-            context.FrameTime, context.ChunkResolution, context.DocumentSize) { ChunkToUpdate = context.ChunkToUpdate, VisibleChunks = context.VisibleChunks };
-        
+
+        SceneObjectRenderContext renderObjectContext = new SceneObjectRenderContext(sceneSurface, localBounds,
+            context.FrameTime, context.ChunkResolution, context.DocumentSize);
+
         Render(renderObjectContext);
         Render(renderObjectContext);
-        
+
         sceneSurface.Canvas.RestoreToCount(savedNum);
         sceneSurface.Canvas.RestoreToCount(savedNum);
-        
+
         Output.Value = sceneSurface;
         Output.Value = sceneSurface;
     }
     }
 
 
@@ -100,12 +99,14 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
             }
             }
             else if (EmbeddedMask != null)
             else if (EmbeddedMask != null)
             {
             {
-                EmbeddedMask.DrawMostUpToDateChunkOn(
+                // TODO: Handle mask
+                /*EmbeddedMask.DrawMostUpToDateChunkOn(
                     context.ChunkToUpdate.Value,
                     context.ChunkToUpdate.Value,
                     context.ChunkResolution,
                     context.ChunkResolution,
                     surface,
                     surface,
                     context.ChunkToUpdate.Value * context.ChunkResolution.PixelSize(),
                     context.ChunkToUpdate.Value * context.ChunkResolution.PixelSize(),
                     maskPaint);
                     maskPaint);
+            }*/
             }
             }
         }
         }
     }
     }
@@ -155,15 +156,15 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
         RectI targetRect = CalculateDestinationRect(context);
         RectI targetRect = CalculateDestinationRect(context);
         using var snapshot = source.DrawingSurface.Snapshot(sourceRect);
         using var snapshot = source.DrawingSurface.Snapshot(sourceRect);
         */
         */
-        
+
         blendPaint.SetFilters(filter);
         blendPaint.SetFilters(filter);
-        
+
         workingSurface.Canvas.DrawSurface(source, source.DeviceClipBounds.X, source.DeviceClipBounds.Y, blendPaint);
         workingSurface.Canvas.DrawSurface(source, source.DeviceClipBounds.X, source.DeviceClipBounds.Y, blendPaint);
     }
     }
 
 
     protected RectI CalculateSourceRect(VecI targetSize, VecI sourceSize, RenderContext context)
     protected RectI CalculateSourceRect(VecI targetSize, VecI sourceSize, RenderContext context)
     {
     {
-        float divider = 1;
+        /*float divider = 1;
 
 
         if (sourceSize.X < targetSize.X || sourceSize.Y < targetSize.Y)
         if (sourceSize.X < targetSize.X || sourceSize.Y < targetSize.Y)
         {
         {
@@ -181,12 +182,14 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
         x = Math.Clamp(x, 0, Math.Max(sourceSize.X - width, 0));
         x = Math.Clamp(x, 0, Math.Max(sourceSize.X - width, 0));
         y = Math.Clamp(y, 0, Math.Max(sourceSize.Y - height, 0));
         y = Math.Clamp(y, 0, Math.Max(sourceSize.Y - height, 0));
 
 
-        return new RectI(x, y, width, height);
+        return new RectI(x, y, width, height);*/
+        
+        return new RectI(0, 0, sourceSize.X, sourceSize.Y);
     }
     }
 
 
     protected RectI CalculateDestinationRect(RenderContext context)
     protected RectI CalculateDestinationRect(RenderContext context)
     {
     {
-        int chunkSize = context.ChunkResolution.PixelSize();
+        /*int chunkSize = context.ChunkResolution.PixelSize();
         VecI chunkPos = context.ChunkToUpdate.Value;
         VecI chunkPos = context.ChunkToUpdate.Value;
 
 
         int x = chunkPos.X * chunkSize;
         int x = chunkPos.X * chunkSize;
@@ -194,7 +197,9 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
         int width = chunkSize;
         int width = chunkSize;
         int height = chunkSize;
         int height = chunkSize;
 
 
-        return new RectI(x, y, width, height);
+        return new RectI(x, y, width, height);*/
+        
+        return new RectI(0, 0, context.DocumentSize.X, context.DocumentSize.Y);
     }
     }
 
 
     public abstract RectD? GetTightBounds(KeyFrameTime frameTime);
     public abstract RectD? GetTightBounds(KeyFrameTime frameTime);

+ 0 - 2
src/PixiEditor.ChangeableDocument/Rendering/RenderContext.cs

@@ -19,8 +19,6 @@ public class RenderContext : IDisposable
     public Paint ReplacingPaintWithOpacity = new() { BlendMode = DrawingApiBlendMode.Src };
     public Paint ReplacingPaintWithOpacity = new() { BlendMode = DrawingApiBlendMode.Src };
 
 
     public KeyFrameTime FrameTime { get; }
     public KeyFrameTime FrameTime { get; }
-    public VecI? ChunkToUpdate { get; set; }
-    public HashSet<VecI> VisibleChunks { get; set; } = new();
     public ChunkResolution ChunkResolution { get; }
     public ChunkResolution ChunkResolution { get; }
     public VecI DocumentSize { get; set; }
     public VecI DocumentSize { get; set; }
     
     

+ 1 - 2
src/PixiEditor.ChangeableDocument/Rendering/SceneRenderer.cs

@@ -9,7 +9,6 @@ public class SceneRenderer
 {
 {
     public IReadOnlyDocument Document { get; }
     public IReadOnlyDocument Document { get; }
     public ChunkResolution Resolution { get; set; }
     public ChunkResolution Resolution { get; set; }
-    public HashSet<VecI> VisibleChunks { get; set; }
 
 
     private readonly Func<KeyFrameTime> getActiveFrameTime;
     private readonly Func<KeyFrameTime> getActiveFrameTime;
     
     
@@ -21,7 +20,7 @@ public class SceneRenderer
 
 
     public void RenderScene(DrawingSurface target)
     public void RenderScene(DrawingSurface target)
     {
     {
-        using RenderContext ctx = new(target, getActiveFrameTime(), Resolution, Document.Size) { VisibleChunks = this.VisibleChunks};
+        using RenderContext ctx = new(target, getActiveFrameTime(), Resolution, Document.Size); 
         Document.NodeGraph.Execute(ctx);
         Document.NodeGraph.Execute(ctx);
     }
     }
 }
 }

+ 0 - 12
src/PixiEditor/Views/Rendering/Scene.cs

@@ -150,17 +150,6 @@ internal class Scene : Zoombox.Zoombox, ICustomHitTest
         return ChunkResolution.Full;
         return ChunkResolution.Full;
     }
     }
 
 
-    private HashSet<VecI> FindChunksVisibleOnViewports()
-    {
-        var viewportChunks = OperationHelper.FindChunksTouchingRectangle(
-            Center,
-            Dimensions,
-            -AngleRadians,
-            ChunkResolution.Full.PixelSize());
-
-        return viewportChunks;
-    }
-
     public override void Render(DrawingContext context)
     public override void Render(DrawingContext context)
     {
     {
         if (Document == null) return;
         if (Document == null) return;
@@ -173,7 +162,6 @@ internal class Scene : Zoombox.Zoombox, ICustomHitTest
         Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
 
 
         SceneRenderer.Resolution = CalculateResolution();
         SceneRenderer.Resolution = CalculateResolution();
-        SceneRenderer.VisibleChunks = FindChunksVisibleOnViewports();
 
 
         using var operation = new DrawSceneOperation(SceneRenderer.RenderScene, Document, CanvasPos,
         using var operation = new DrawSceneOperation(SceneRenderer.RenderScene, Document, CanvasPos,
             Scale * resolutionScale,
             Scale * resolutionScale,