Browse Source

Fixed chunk resolution wrong rasterization

flabbet 11 months ago
parent
commit
39c0d231ec

+ 4 - 4
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/Data/EllipseVectorData.cs

@@ -24,7 +24,7 @@ public class EllipseVectorData : ShapeVectorData
         Radius = radius;
     }
 
-    public override void Rasterize(DrawingSurface drawingSurface)
+    public override void Rasterize(DrawingSurface drawingSurface, ChunkResolution resolution)
     {
         var imageSize = (VecI)(Radius * 2);
         
@@ -43,12 +43,12 @@ public class EllipseVectorData : ShapeVectorData
         
         RectI region = new(VecI.Zero, (VecI)GeometryAABB.Size);
 
-        drawingSurface.Canvas.Save();
+        int num = drawingSurface.Canvas.Save();
         drawingSurface.Canvas.SetMatrix(TransformationMatrix);
 
-        img.DrawMostUpToDateRegionOn(region, ChunkResolution.Full, drawingSurface, topLeft);
+        img.DrawMostUpToDateRegionOn(region, resolution, drawingSurface, topLeft);
         
-        drawingSurface.Canvas.Restore();
+        drawingSurface.Canvas.RestoreToCount(num);
     }
 
     public override bool IsValid()

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/Data/PointsVectorData.cs

@@ -18,7 +18,7 @@ public class PointsVectorData : ShapeVectorData
     public override ShapeCorners TransformationCorners => new ShapeCorners(
         GeometryAABB).WithMatrix(TransformationMatrix); 
 
-    public override void Rasterize(DrawingSurface drawingSurface)
+    public override void Rasterize(DrawingSurface drawingSurface, ChunkResolution resolution)
     {
         using Paint paint = new Paint();
         paint.Color = FillColor;

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/Data/ShapeVectorData.cs

@@ -17,7 +17,7 @@ public abstract class ShapeVectorData : ICacheable, ICloneable
     public RectD TransformedAABB => new ShapeCorners(GeometryAABB).WithMatrix(TransformationMatrix).AABBBounds;
     public abstract ShapeCorners TransformationCorners { get; } 
 
-    public abstract void Rasterize(DrawingSurface drawingSurface);
+    public abstract void Rasterize(DrawingSurface drawingSurface, ChunkResolution resolution);
     public abstract bool IsValid();
     public abstract int GetCacheHash();
     public abstract int CalculateHash();

+ 4 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/RasterizeShapeNode.cs

@@ -16,6 +16,9 @@ public class RasterizeShapeNode : Node
     public InputProperty<ShapeVectorData> Data { get; }
 
 
+    protected override bool AffectedByChunkResolution => true;
+
+
     public RasterizeShapeNode()
     {
         Image = CreateOutput<Texture>("Image", "IMAGE", null);
@@ -32,7 +35,7 @@ public class RasterizeShapeNode : Node
         var size = context.DocumentSize;
         var image = RequestTexture(0, size);
         
-        shape.Rasterize(image.DrawingSurface);
+        shape.Rasterize(image.DrawingSurface, context.ChunkResolution);
 
         Image.Value = image;
         

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

@@ -33,7 +33,7 @@ public abstract class ShapeNode<T> : Node where T : ShapeVectorData
     {
         Texture texture = RequestTexture(0, size);
         
-        vectorData.Rasterize(texture.DrawingSurface);
+        vectorData.Rasterize(texture.DrawingSurface, ChunkResolution.Full);
         
         return texture;
     }

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

@@ -19,13 +19,16 @@ public class VectorLayerNode : LayerNode, ITransformableObject
     }
     
     public ShapeVectorData ShapeData { get; } = new EllipseVectorData(new VecI(32), new VecI(32));
-    
+
+    protected override bool AffectedByChunkResolution => true;
+
     private int lastCacheHash;
     
     protected override Texture? OnExecute(RenderingContext context)
     {
-        Texture texture = RequestTexture(0, context.DocumentSize);
-        ShapeData.Rasterize(texture.DrawingSurface);
+        Texture texture = RequestTexture(0, (VecI)(context.DocumentSize /** context.ChunkResolution.Multiplier()*/));
+
+        ShapeData.Rasterize(texture.DrawingSurface, context.ChunkResolution);
         
         Output.Value = texture;