|
@@ -1,10 +1,13 @@
|
|
|
-using System.Diagnostics;
|
|
|
-using System.Runtime.CompilerServices;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
using ChunkyImageLib.DataHolders;
|
|
|
using ChunkyImageLib.Operations;
|
|
|
using OneOf;
|
|
|
using OneOf.Types;
|
|
|
-using SkiaSharp;
|
|
|
+using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
|
+using PixiEditor.DrawingApi.Core.Numerics;
|
|
|
+using PixiEditor.DrawingApi.Core.Surface;
|
|
|
+using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
|
|
|
+using PixiEditor.DrawingApi.Core.Surface.Vector;
|
|
|
|
|
|
[assembly: InternalsVisibleTo("ChunkyImageLibTest")]
|
|
|
|
|
@@ -30,7 +33,7 @@ namespace ChunkyImageLib;
|
|
|
/// You can check the current state via queuedOperations.Count == 0
|
|
|
///
|
|
|
/// Depending on the chosen blend mode the latest chunks contain different things:
|
|
|
-/// - SKBlendMode.Src: default mode, the latest chunks are the same as committed ones but with some or all queued operations applied.
|
|
|
+/// - BlendMode.Src: default mode, the latest chunks are the same as committed ones but with some or all queued operations applied.
|
|
|
/// This means that operations can work with the existing pixels.
|
|
|
/// - Any other blend mode: the latest chunks contain only the things drawn by the queued operations.
|
|
|
/// They need to be drawn over the committed chunks to obtain the final image. In this case, operations won't have access to the existing pixels.
|
|
@@ -54,12 +57,12 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
private int commitCounter = 0;
|
|
|
|
|
|
public const int FullChunkSize = ChunkPool.FullChunkSize;
|
|
|
- private static SKPaint ClippingPaint { get; } = new SKPaint() { BlendMode = SKBlendMode.DstIn };
|
|
|
- private static SKPaint InverseClippingPaint { get; } = new SKPaint() { BlendMode = SKBlendMode.DstOut };
|
|
|
- private static SKPaint ReplacingPaint { get; } = new SKPaint() { BlendMode = SKBlendMode.Src };
|
|
|
- private static SKPaint SmoothReplacingPaint { get; } = new SKPaint() { BlendMode = SKBlendMode.Src, FilterQuality = SKFilterQuality.Medium };
|
|
|
- private static SKPaint AddingPaint { get; } = new SKPaint() { BlendMode = SKBlendMode.Plus };
|
|
|
- private readonly SKPaint blendModePaint = new SKPaint() { BlendMode = SKBlendMode.Src };
|
|
|
+ private static Paint ClippingPaint { get; } = new Paint() { BlendMode = BlendMode.DstIn };
|
|
|
+ private static Paint InverseClippingPaint { get; } = new Paint() { BlendMode = BlendMode.DstOut };
|
|
|
+ private static Paint ReplacingPaint { get; } = new Paint() { BlendMode = BlendMode.Src };
|
|
|
+ private static Paint SmoothReplacingPaint { get; } = new Paint() { BlendMode = BlendMode.Src, FilterQuality = FilterQuality.Medium };
|
|
|
+ private static Paint AddingPaint { get; } = new Paint() { BlendMode = BlendMode.Plus };
|
|
|
+ private readonly Paint blendModePaint = new Paint() { BlendMode = BlendMode.Src };
|
|
|
|
|
|
public VecI CommittedSize { get; private set; }
|
|
|
public VecI LatestSize { get; private set; }
|
|
@@ -75,9 +78,9 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
|
|
|
private readonly List<(IOperation operation, HashSet<VecI> affectedChunks)> queuedOperations = new();
|
|
|
private readonly List<ChunkyImage> activeClips = new();
|
|
|
- private SKBlendMode blendMode = SKBlendMode.Src;
|
|
|
+ private BlendMode blendMode = BlendMode.Src;
|
|
|
private bool lockTransparency = false;
|
|
|
- private SKPath? clippingPath;
|
|
|
+ private VectorPath? clippingPath;
|
|
|
private int? horizontalSymmetryAxis = null;
|
|
|
private int? verticalSymmetryAxis = null;
|
|
|
|
|
@@ -157,7 +160,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public SKColor GetCommittedPixel(VecI posOnImage)
|
|
|
+ public Color GetCommittedPixel(VecI posOnImage)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -166,14 +169,14 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
var posInChunk = posOnImage - chunkPos * FullChunkSize;
|
|
|
return MaybeGetCommittedChunk(chunkPos, ChunkResolution.Full) switch
|
|
|
{
|
|
|
- null => SKColors.Transparent,
|
|
|
+ null => Colors.Transparent,
|
|
|
var chunk => chunk.Surface.GetSRGBPixel(posInChunk)
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public SKColor GetMostUpToDatePixel(VecI posOnImage)
|
|
|
+ public Color GetMostUpToDatePixel(VecI posOnImage)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -187,18 +190,18 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
Chunk? committedChunk = MaybeGetCommittedChunk(chunkPos, ChunkResolution.Full);
|
|
|
return committedChunk switch
|
|
|
{
|
|
|
- null => SKColors.Transparent,
|
|
|
+ null => Colors.Transparent,
|
|
|
_ => committedChunk.Surface.GetSRGBPixel(posInChunk)
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// something is queued, blend mode is Src so no merging needed
|
|
|
- if (blendMode == SKBlendMode.Src)
|
|
|
+ if (blendMode == BlendMode.Src)
|
|
|
{
|
|
|
Chunk? latestChunk = GetLatestChunk(chunkPos, ChunkResolution.Full);
|
|
|
return latestChunk switch
|
|
|
{
|
|
|
- null => SKColors.Transparent,
|
|
|
+ null => Colors.Transparent,
|
|
|
_ => latestChunk.Surface.GetSRGBPixel(posInChunk)
|
|
|
};
|
|
|
}
|
|
@@ -207,19 +210,19 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
{
|
|
|
Chunk? committedChunk = MaybeGetCommittedChunk(chunkPos, ChunkResolution.Full);
|
|
|
Chunk? latestChunk = GetLatestChunk(chunkPos, ChunkResolution.Full);
|
|
|
- SKColor committedColor = committedChunk is null ?
|
|
|
- SKColors.Transparent :
|
|
|
+ Color committedColor = committedChunk is null ?
|
|
|
+ Colors.Transparent :
|
|
|
committedChunk.Surface.GetSRGBPixel(posInChunk);
|
|
|
- SKColor latestColor = latestChunk is null ?
|
|
|
- SKColors.Transparent :
|
|
|
+ Color latestColor = latestChunk is null ?
|
|
|
+ Colors.Transparent :
|
|
|
latestChunk.Surface.GetSRGBPixel(posInChunk);
|
|
|
// using a whole chunk just to draw 1 pixel is kinda dumb,
|
|
|
// but this should be faster than any approach that requires allocations
|
|
|
using Chunk tempChunk = Chunk.Create(ChunkResolution.Eighth);
|
|
|
- using SKPaint committedPaint = new SKPaint() { Color = committedColor, BlendMode = SKBlendMode.Src };
|
|
|
- using SKPaint latestPaint = new SKPaint() { Color = latestColor, BlendMode = this.blendMode };
|
|
|
- tempChunk.Surface.SkiaSurface.Canvas.DrawPoint(VecI.Zero, committedPaint);
|
|
|
- tempChunk.Surface.SkiaSurface.Canvas.DrawPoint(VecI.Zero, latestPaint);
|
|
|
+ using Paint committedPaint = new Paint() { Color = committedColor, BlendMode = BlendMode.Src };
|
|
|
+ using Paint latestPaint = new Paint() { Color = latestColor, BlendMode = this.blendMode };
|
|
|
+ tempChunk.Surface.DrawingSurface.Canvas.DrawPixel(VecI.Zero, committedPaint);
|
|
|
+ tempChunk.Surface.DrawingSurface.Canvas.DrawPixel(VecI.Zero, latestPaint);
|
|
|
return tempChunk.Surface.GetSRGBPixel(VecI.Zero);
|
|
|
}
|
|
|
}
|
|
@@ -229,7 +232,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
/// True if the chunk existed and was drawn, otherwise false
|
|
|
/// </returns>
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public bool DrawMostUpToDateChunkOn(VecI chunkPos, ChunkResolution resolution, SKSurface surface, VecI pos, SKPaint? paint = null)
|
|
|
+ public bool DrawMostUpToDateChunkOn(VecI chunkPos, ChunkResolution resolution, DrawingSurface surface, VecI pos, Paint? paint = null)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -250,7 +253,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
var committedChunk = GetCommittedChunk(chunkPos, resolution);
|
|
|
|
|
|
// draw committed directly
|
|
|
- if (latestChunk.IsT0 || latestChunk.IsT1 && committedChunk is not null && blendMode != SKBlendMode.Src)
|
|
|
+ if (latestChunk.IsT0 || latestChunk.IsT1 && committedChunk is not null && blendMode != BlendMode.Src)
|
|
|
{
|
|
|
if (committedChunk is null)
|
|
|
return false;
|
|
@@ -259,7 +262,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
// no need to combine with committed, draw directly
|
|
|
- if (blendMode == SKBlendMode.Src || committedChunk is null)
|
|
|
+ if (blendMode == BlendMode.Src || committedChunk is null)
|
|
|
{
|
|
|
if (latestChunk.IsT2)
|
|
|
{
|
|
@@ -272,11 +275,11 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
|
|
|
// combine with committed and then draw
|
|
|
using var tempChunk = Chunk.Create(resolution);
|
|
|
- tempChunk.Surface.SkiaSurface.Canvas.DrawSurface(committedChunk.Surface.SkiaSurface, 0, 0, ReplacingPaint);
|
|
|
+ tempChunk.Surface.DrawingSurface.Canvas.DrawSurface(committedChunk.Surface.DrawingSurface, 0, 0, ReplacingPaint);
|
|
|
blendModePaint.BlendMode = blendMode;
|
|
|
- tempChunk.Surface.SkiaSurface.Canvas.DrawSurface(latestChunk.AsT2.Surface.SkiaSurface, 0, 0, blendModePaint);
|
|
|
+ tempChunk.Surface.DrawingSurface.Canvas.DrawSurface(latestChunk.AsT2.Surface.DrawingSurface, 0, 0, blendModePaint);
|
|
|
if (lockTransparency)
|
|
|
- OperationHelper.ClampAlpha(tempChunk.Surface.SkiaSurface, committedChunk.Surface.SkiaSurface);
|
|
|
+ OperationHelper.ClampAlpha(tempChunk.Surface.DrawingSurface, committedChunk.Surface.DrawingSurface);
|
|
|
tempChunk.DrawOnSurface(surface, pos, paint);
|
|
|
|
|
|
return true;
|
|
@@ -303,7 +306,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- internal bool DrawCommittedChunkOn(VecI chunkPos, ChunkResolution resolution, SKSurface surface, VecI pos, SKPaint? paint = null)
|
|
|
+ internal bool DrawCommittedChunkOn(VecI chunkPos, ChunkResolution resolution, DrawingSurface surface, VecI pos, Paint? paint = null)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -374,7 +377,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void SetClippingPath(SKPath clippingPath)
|
|
|
+ public void SetClippingPath(VectorPath clippingPath)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -389,7 +392,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
/// Porter duff compositing operators (apart from SrcOver) likely won't have the intended effect.
|
|
|
/// </summary>
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void SetBlendMode(SKBlendMode mode)
|
|
|
+ public void SetBlendMode(BlendMode mode)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -435,7 +438,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueReplaceColor(SKColor oldColor, SKColor newColor)
|
|
|
+ public void EnqueueReplaceColor(Color oldColor, Color newColor)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -457,7 +460,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawEllipse(RectI location, SKColor strokeColor, SKColor fillColor, int strokeWidth, SKPaint? paint = null)
|
|
|
+ public void EnqueueDrawEllipse(RectI location, Color strokeColor, Color fillColor, int strokeWidth, Paint? paint = null)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -474,7 +477,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
/// Surface is NOT THREAD SAFE, so if you pass a Surface here with copyImage == false you must not do anything with that surface anywhere (not even read) until CommitChanges/CancelChanges is called.
|
|
|
/// </summary>
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawImage(SKMatrix transformMatrix, Surface image, SKPaint? paint = null, bool copyImage = true)
|
|
|
+ public void EnqueueDrawImage(Matrix3X3 transformMatrix, Surface image, Paint? paint = null, bool copyImage = true)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -488,7 +491,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
/// Be careful about the copyImage argument, see other overload for details
|
|
|
/// </summary>
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawImage(ShapeCorners corners, Surface image, SKPaint? paint = null, bool copyImage = true)
|
|
|
+ public void EnqueueDrawImage(ShapeCorners corners, Surface image, Paint? paint = null, bool copyImage = true)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -502,7 +505,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
/// Be careful about the copyImage argument, see other overload for details
|
|
|
/// </summary>
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawImage(VecI pos, Surface image, SKPaint? paint = null, bool copyImage = true)
|
|
|
+ public void EnqueueDrawImage(VecI pos, Surface image, Paint? paint = null, bool copyImage = true)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -514,7 +517,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
|
|
|
/// <param name="customBounds">Bounds used for affected chunks, will be computed from path in O(n) if null is passed</param>
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawPath(SKPath path, SKColor color, float strokeWidth, SKStrokeCap strokeCap, SKBlendMode blendMode, RectI? customBounds = null)
|
|
|
+ public void EnqueueDrawPath(VectorPath path, Color color, float strokeWidth, StrokeCap strokeCap, BlendMode blendMode, RectI? customBounds = null)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -525,7 +528,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawBresenhamLine(VecI from, VecI to, SKColor color, SKBlendMode blendMode)
|
|
|
+ public void EnqueueDrawBresenhamLine(VecI from, VecI to, Color color, BlendMode blendMode)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -536,18 +539,18 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawSkiaLine(VecI from, VecI to, SKStrokeCap strokeCap, float strokeWidth, SKColor color, SKBlendMode blendMode)
|
|
|
+ public void EnqueueDrawSkiaLine(VecI from, VecI to, StrokeCap strokeCap, float strokeWidth, Color color, BlendMode blendMode)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
|
ThrowIfDisposed();
|
|
|
- SkiaLineOperation operation = new(from, to, strokeCap, strokeWidth, color, blendMode);
|
|
|
+ DrawingSurfaceLineOperation operation = new(from, to, strokeCap, strokeWidth, color, blendMode);
|
|
|
EnqueueOperation(operation);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawPixels(IEnumerable<VecI> pixels, SKColor color, SKBlendMode blendMode)
|
|
|
+ public void EnqueueDrawPixels(IEnumerable<VecI> pixels, Color color, BlendMode blendMode)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -558,7 +561,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueDrawPixel(VecI pos, SKColor color, SKBlendMode blendMode)
|
|
|
+ public void EnqueueDrawPixel(VecI pos, Color color, BlendMode blendMode)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -591,7 +594,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
/// <exception cref="ObjectDisposedException">This image is disposed</exception>
|
|
|
- public void EnqueueClearPath(SKPath path, RectI? pathTightBounds = null)
|
|
|
+ public void EnqueueClearPath(VectorPath path, RectI? pathTightBounds = null)
|
|
|
{
|
|
|
lock (lockObject)
|
|
|
{
|
|
@@ -663,7 +666,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
|
|
|
//clear additional state
|
|
|
activeClips.Clear();
|
|
|
- blendMode = SKBlendMode.Src;
|
|
|
+ blendMode = BlendMode.Src;
|
|
|
lockTransparency = false;
|
|
|
horizontalSymmetryAxis = null;
|
|
|
verticalSymmetryAxis = null;
|
|
@@ -709,7 +712,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
CommittedSize = LatestSize;
|
|
|
queuedOperations.Clear();
|
|
|
activeClips.Clear();
|
|
|
- blendMode = SKBlendMode.Src;
|
|
|
+ blendMode = BlendMode.Src;
|
|
|
lockTransparency = false;
|
|
|
horizontalSymmetryAxis = null;
|
|
|
verticalSymmetryAxis = null;
|
|
@@ -747,7 +750,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
// do a swap
|
|
|
- if (blendMode == SKBlendMode.Src)
|
|
|
+ if (blendMode == BlendMode.Src)
|
|
|
{
|
|
|
// delete committed version
|
|
|
if (committedChunks[resolution].ContainsKey(pos))
|
|
@@ -786,13 +789,13 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
if (lockTransparency)
|
|
|
{
|
|
|
using Chunk tempChunk = Chunk.Create(resolution);
|
|
|
- tempChunk.Surface.SkiaSurface.Canvas.DrawSurface(maybeCommitted.Surface.SkiaSurface, 0, 0, ReplacingPaint);
|
|
|
- maybeCommitted.Surface.SkiaSurface.Canvas.DrawSurface(chunk.Surface.SkiaSurface, 0, 0, blendModePaint);
|
|
|
- OperationHelper.ClampAlpha(maybeCommitted.Surface.SkiaSurface, tempChunk.Surface.SkiaSurface);
|
|
|
+ tempChunk.Surface.DrawingSurface.Canvas.DrawSurface(maybeCommitted.Surface.DrawingSurface, 0, 0, ReplacingPaint);
|
|
|
+ maybeCommitted.Surface.DrawingSurface.Canvas.DrawSurface(chunk.Surface.DrawingSurface, 0, 0, blendModePaint);
|
|
|
+ OperationHelper.ClampAlpha(maybeCommitted.Surface.DrawingSurface, tempChunk.Surface.DrawingSurface);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- maybeCommitted.Surface.SkiaSurface.Canvas.DrawSurface(chunk.Surface.SkiaSurface, 0, 0, blendModePaint);
|
|
|
+ maybeCommitted.Surface.DrawingSurface.Canvas.DrawSurface(chunk.Surface.DrawingSurface, 0, 0, blendModePaint);
|
|
|
}
|
|
|
|
|
|
chunk.Dispose();
|
|
@@ -912,7 +915,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
if (lockTransparency && !chunkData.IsDeleted && MaybeGetCommittedChunk(chunkPos, ChunkResolution.Full) is not null)
|
|
|
{
|
|
|
var committed = GetCommittedChunk(chunkPos, resolution);
|
|
|
- OperationHelper.ClampAlpha(targetChunk!.Surface.SkiaSurface, committed!.Surface.SkiaSurface);
|
|
|
+ OperationHelper.ClampAlpha(targetChunk!.Surface.DrawingSurface, committed!.Surface.DrawingSurface);
|
|
|
}
|
|
|
|
|
|
chunkData.QueueProgress = queuedOperations.Count;
|
|
@@ -936,13 +939,13 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
}
|
|
|
|
|
|
var intersection = Chunk.Create(resolution);
|
|
|
- intersection.Surface.SkiaSurface.Canvas.Clear(SKColors.White);
|
|
|
+ intersection.Surface.DrawingSurface.Canvas.Clear(Colors.White);
|
|
|
|
|
|
foreach (var mask in activeClips)
|
|
|
{
|
|
|
if (mask.CommittedChunkExists(chunkPos))
|
|
|
{
|
|
|
- mask.DrawCommittedChunkOn(chunkPos, resolution, intersection.Surface.SkiaSurface, VecI.Zero, ClippingPaint);
|
|
|
+ mask.DrawCommittedChunkOn(chunkPos, resolution, intersection.Surface.DrawingSurface, VecI.Zero, ClippingPaint);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -974,7 +977,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
return chunkData.IsDeleted;
|
|
|
|
|
|
if (chunkData.IsDeleted)
|
|
|
- targetChunk.Surface.SkiaSurface.Canvas.Clear();
|
|
|
+ targetChunk.Surface.DrawingSurface.Canvas.Clear();
|
|
|
|
|
|
// just regular drawing
|
|
|
if (combinedRasterClips.IsT0) //Everything is visible as far as raster clips are concerned
|
|
@@ -987,14 +990,14 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
var clip = combinedRasterClips.AsT2;
|
|
|
|
|
|
using var tempChunk = Chunk.Create(targetChunk.Resolution);
|
|
|
- targetChunk.DrawOnSurface(tempChunk.Surface.SkiaSurface, VecI.Zero, ReplacingPaint);
|
|
|
+ targetChunk.DrawOnSurface(tempChunk.Surface.DrawingSurface, VecI.Zero, ReplacingPaint);
|
|
|
|
|
|
CallDrawWithClip(chunkOperation, tempChunk, resolution, chunkPos);
|
|
|
|
|
|
- clip.DrawOnSurface(tempChunk.Surface.SkiaSurface, VecI.Zero, ClippingPaint);
|
|
|
- clip.DrawOnSurface(targetChunk.Surface.SkiaSurface, VecI.Zero, InverseClippingPaint);
|
|
|
+ clip.DrawOnSurface(tempChunk.Surface.DrawingSurface, VecI.Zero, ClippingPaint);
|
|
|
+ clip.DrawOnSurface(targetChunk.Surface.DrawingSurface, VecI.Zero, InverseClippingPaint);
|
|
|
|
|
|
- tempChunk.DrawOnSurface(targetChunk.Surface.SkiaSurface, VecI.Zero, AddingPaint);
|
|
|
+ tempChunk.DrawOnSurface(targetChunk.Surface.DrawingSurface, VecI.Zero, AddingPaint);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -1010,15 +1013,15 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
{
|
|
|
if (clippingPath is not null && !clippingPath.IsEmpty)
|
|
|
{
|
|
|
- int count = targetChunk.Surface.SkiaSurface.Canvas.Save();
|
|
|
+ int count = targetChunk.Surface.DrawingSurface.Canvas.Save();
|
|
|
|
|
|
- using SKPath transformedPath = new(clippingPath);
|
|
|
+ using VectorPath transformedPath = new(clippingPath);
|
|
|
float scale = (float)resolution.Multiplier();
|
|
|
VecD trans = -chunkPos * FullChunkSize * scale;
|
|
|
- transformedPath.Transform(SKMatrix.CreateScaleTranslation(scale, scale, (float)trans.X, (float)trans.Y));
|
|
|
- targetChunk.Surface.SkiaSurface.Canvas.ClipPath(transformedPath);
|
|
|
+ transformedPath.Transform(Matrix3X3.CreateScaleTranslation(scale, scale, (float)trans.X, (float)trans.Y));
|
|
|
+ targetChunk.Surface.DrawingSurface.Canvas.ClipPath(transformedPath);
|
|
|
operation.DrawOnChunk(targetChunk, chunkPos);
|
|
|
- targetChunk.Surface.SkiaSurface.Canvas.RestoreToCount(count);
|
|
|
+ targetChunk.Surface.DrawingSurface.Canvas.RestoreToCount(count);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1101,11 +1104,11 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
if (existingFullResChunk is not null)
|
|
|
{
|
|
|
var newChunk = Chunk.Create(resolution);
|
|
|
- newChunk.Surface.SkiaSurface.Canvas.Save();
|
|
|
- newChunk.Surface.SkiaSurface.Canvas.Scale((float)resolution.Multiplier());
|
|
|
+ newChunk.Surface.DrawingSurface.Canvas.Save();
|
|
|
+ newChunk.Surface.DrawingSurface.Canvas.Scale((float)resolution.Multiplier());
|
|
|
|
|
|
- newChunk.Surface.SkiaSurface.Canvas.DrawSurface(existingFullResChunk.Surface.SkiaSurface, 0, 0, SmoothReplacingPaint);
|
|
|
- newChunk.Surface.SkiaSurface.Canvas.Restore();
|
|
|
+ newChunk.Surface.DrawingSurface.Canvas.DrawSurface(existingFullResChunk.Surface.DrawingSurface, 0, 0, SmoothReplacingPaint);
|
|
|
+ newChunk.Surface.DrawingSurface.Canvas.Restore();
|
|
|
committedChunks[resolution][chunkPos] = newChunk;
|
|
|
return newChunk;
|
|
|
}
|
|
@@ -1134,10 +1137,10 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
if (maybeCommittedAnyRes is not null)
|
|
|
{
|
|
|
Chunk newChunk = Chunk.Create(resolution);
|
|
|
- if (blendMode == SKBlendMode.Src)
|
|
|
+ if (blendMode == BlendMode.Src)
|
|
|
maybeCommittedAnyRes.Surface.CopyTo(newChunk.Surface);
|
|
|
else
|
|
|
- newChunk.Surface.SkiaSurface.Canvas.Clear();
|
|
|
+ newChunk.Surface.DrawingSurface.Canvas.Clear();
|
|
|
latestChunks[resolution][chunkPos] = newChunk;
|
|
|
return newChunk;
|
|
|
}
|
|
@@ -1157,7 +1160,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable
|
|
|
|
|
|
// no previous chunks exist
|
|
|
var newLatestChunk = Chunk.Create(resolution);
|
|
|
- newLatestChunk.Surface.SkiaSurface.Canvas.Clear();
|
|
|
+ newLatestChunk.Surface.DrawingSurface.Canvas.Clear();
|
|
|
latestChunks[resolution][chunkPos] = newLatestChunk;
|
|
|
return newLatestChunk;
|
|
|
}
|