Browse Source

Resolution rendering fixes

flabbet 10 months ago
parent
commit
1ce1f27eb0

+ 10 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ImageLayerNode.cs

@@ -82,6 +82,16 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         return (GetFrameWithImage(ctx.FrameTime).Data as ChunkyImage).LatestSize;
         return (GetFrameWithImage(ctx.FrameTime).Data as ChunkyImage).LatestSize;
     }
     }
 
 
+    protected internal override void DrawLayer(SceneObjectRenderContext ctx, DrawingSurface workingSurface, bool shouldClear, bool useFilters = true)
+    {
+        int scaled = workingSurface.Canvas.Save();
+        float multiplier = (float)ctx.ChunkResolution.InvertedMultiplier();
+        workingSurface.Canvas.Scale(multiplier, multiplier);
+        base.DrawLayer(ctx, workingSurface, shouldClear, useFilters);
+        
+        workingSurface.Canvas.RestoreToCount(scaled);
+    }
+
     protected override void DrawWithoutFilters(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
     protected override void DrawWithoutFilters(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
         bool shouldClear,
         bool shouldClear,
         Paint paint)
         Paint paint)

+ 2 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/StructureNode.cs

@@ -73,7 +73,8 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IBackgroundI
 
 
         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);
 
 

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/VectorLayerNode.cs

@@ -49,7 +49,7 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
 
 
     public override void Render(SceneObjectRenderContext sceneContext)
     public override void Render(SceneObjectRenderContext sceneContext)
     {
     {
-        Rasterize(sceneContext.TargetSurface, ChunkResolution.Full, blendPaint);
+        Rasterize(sceneContext.TargetSurface, sceneContext.ChunkResolution, blendPaint);
     }
     }
 
 
     protected override VecI GetTargetSize(RenderContext ctx)
     protected override VecI GetTargetSize(RenderContext ctx)

+ 1 - 7
src/PixiEditor/Views/Rendering/Scene.cs

@@ -159,7 +159,7 @@ internal class Scene : Zoombox.Zoombox, ICustomHitTest
         float resolutionScale = CalculateResolutionScale();
         float resolutionScale = CalculateResolutionScale();
 
 
         RectD dirtyBounds = new RectD(0, 0, Document.Width, Document.Height);
         RectD dirtyBounds = new RectD(0, 0, Document.Width, Document.Height);
-        Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
+        Rect dirtyRect = new Rect(0, 0, Document.Width, Document.Height);
 
 
         SceneRenderer.Resolution = CalculateResolution();
         SceneRenderer.Resolution = CalculateResolution();
 
 
@@ -175,21 +175,15 @@ internal class Scene : Zoombox.Zoombox, ICustomHitTest
         context.PushTransform(matrix);
         context.PushTransform(matrix);
         context.PushRenderOptions(new RenderOptions { BitmapInterpolationMode = BitmapInterpolationMode.None });
         context.PushRenderOptions(new RenderOptions { BitmapInterpolationMode = BitmapInterpolationMode.None });
 
 
-        //var resolutionTransformation = context.PushTransform(Matrix.CreateScale(resolutionScale, resolutionScale));
-
         DrawCheckerboard(context, dirtyRect,
         DrawCheckerboard(context, dirtyRect,
             new RectI(0, 0, operation.Document.SizeBindable.X, operation.Document.SizeBindable.Y));
             new RectI(0, 0, operation.Document.SizeBindable.X, operation.Document.SizeBindable.Y));
 
 
-        //resolutionTransformation.Dispose();
-
         Cursor = DefaultCursor;
         Cursor = DefaultCursor;
 
 
         DrawOverlays(context, dirtyBounds, OverlayRenderSorting.Background);
         DrawOverlays(context, dirtyBounds, OverlayRenderSorting.Background);
 
 
-        var resolutionTransformation = context.PushTransform(Matrix.CreateScale(resolutionScale, resolutionScale));
         context.Custom(operation);
         context.Custom(operation);
 
 
-        resolutionTransformation.Dispose();
         DrawOverlays(context, dirtyBounds, OverlayRenderSorting.Foreground);
         DrawOverlays(context, dirtyBounds, OverlayRenderSorting.Foreground);
     }
     }