|
@@ -14,8 +14,9 @@ internal class PixelOperation : IMirroredDrawOperation
|
|
|
private readonly Color color;
|
|
|
private readonly BlendMode blendMode;
|
|
|
private readonly Paint paint;
|
|
|
+ private readonly Func<VecI, Color>? getCommitedPixelFunc = null;
|
|
|
|
|
|
- private readonly PixelProcessor? _colorProcessor = null;
|
|
|
+ private readonly PixelProcessor? colorProcessor = null;
|
|
|
|
|
|
public PixelOperation(VecI pixel, Color color, BlendMode blendMode)
|
|
|
{
|
|
@@ -25,18 +26,19 @@ internal class PixelOperation : IMirroredDrawOperation
|
|
|
paint = new Paint() { BlendMode = blendMode };
|
|
|
}
|
|
|
|
|
|
- public PixelOperation(VecI pixel, PixelProcessor colorProcessor, BlendMode blendMode)
|
|
|
+ public PixelOperation(VecI pixel, PixelProcessor colorProcessor, Func<VecI, Color> getCommitedPixelFunc, BlendMode blendMode)
|
|
|
{
|
|
|
this.pixel = pixel;
|
|
|
- this._colorProcessor = colorProcessor;
|
|
|
+ this.colorProcessor = colorProcessor;
|
|
|
this.blendMode = blendMode;
|
|
|
+ this.getCommitedPixelFunc = getCommitedPixelFunc;
|
|
|
paint = new Paint() { BlendMode = blendMode };
|
|
|
}
|
|
|
|
|
|
- public void DrawOnChunk(Chunk targetChunk, VecI chunkPos, ChunkyImage caller)
|
|
|
+ public void DrawOnChunk(Chunk targetChunk, VecI chunkPos)
|
|
|
{
|
|
|
// a hacky way to make the lines look slightly better on non full res chunks
|
|
|
- paint.Color = GetColor(targetChunk, chunkPos, caller);
|
|
|
+ paint.Color = GetColor(targetChunk, chunkPos);
|
|
|
|
|
|
DrawingSurface surf = targetChunk.Surface.DrawingSurface;
|
|
|
surf.Canvas.Save();
|
|
@@ -46,13 +48,13 @@ internal class PixelOperation : IMirroredDrawOperation
|
|
|
surf.Canvas.Restore();
|
|
|
}
|
|
|
|
|
|
- private Color GetColor(Chunk chunk, VecI chunkPos, ChunkyImage chunkyImage)
|
|
|
+ private Color GetColor(Chunk chunk, VecI chunkPos)
|
|
|
{
|
|
|
Color pixelColor = color;
|
|
|
- if (_colorProcessor != null)
|
|
|
+ if (colorProcessor != null && getCommitedPixelFunc != null)
|
|
|
{
|
|
|
var pos = pixel - chunkPos * ChunkyImage.FullChunkSize;
|
|
|
- pixelColor = _colorProcessor(chunkyImage.GetCommittedPixel(pos), chunk.Surface.GetSRGBPixel(pos));
|
|
|
+ pixelColor = colorProcessor(getCommitedPixelFunc(pos), chunk.Surface.GetSRGBPixel(pos));
|
|
|
}
|
|
|
|
|
|
return new Color(pixelColor.R, pixelColor.G, pixelColor.B, (byte)(pixelColor.A * chunk.Resolution.Multiplier()));
|
|
@@ -70,9 +72,9 @@ internal class PixelOperation : IMirroredDrawOperation
|
|
|
pixelRect = (RectI)pixelRect.ReflectX((double)verAxisX).Round();
|
|
|
if (horAxisY is not null)
|
|
|
pixelRect = (RectI)pixelRect.ReflectY((double)horAxisY);
|
|
|
- if (_colorProcessor != null)
|
|
|
+ if (colorProcessor != null && getCommitedPixelFunc != null)
|
|
|
{
|
|
|
- return new PixelOperation(pixelRect.Pos, _colorProcessor, blendMode);
|
|
|
+ return new PixelOperation(pixelRect.Pos, colorProcessor, getCommitedPixelFunc, blendMode);
|
|
|
}
|
|
|
|
|
|
return new PixelOperation(pixelRect.Pos, color, blendMode);
|