Minor code tweaks to the built-in transform mappers
このコミットが含まれているのは:
1 親
a152f9322e
コミット
fe11643c57
4ファイル変更
+17
-15
検索条件に一致するファイルはありません
+1
@@ -10,6 +10,7 @@
|
||||
internal abstract class D2D1TransformMapperFactory<T, TSelf, TParameters, TTransformMapper> : ID2D1TransformMapperFactory<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
where TSelf : D2D1TransformMapperFactory<T, TSelf, TParameters, TTransformMapper>, new()
|
||||
where TParameters : unmanaged
|
||||
where TTransformMapper : D2D1TransformMapper<T, TParameters>, new()
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
+9
-8
@@ -12,11 +12,12 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
/// <typeparam name="TParameters">The type of parameters that the transform mapper will use.</typeparam>
|
||||
internal abstract class D2D1TransformMapper<T, TParameters> : ID2D1TransformMapper<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
where TParameters : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// The current pixel shader value, which can be used to extract parameters from.
|
||||
/// The parameters to use in this transform mapper.
|
||||
/// </summary>
|
||||
private T shader;
|
||||
private TParameters parameters;
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperFactory{T, TSelf, TParameters, TTransformMapper}.Parameters"/>
|
||||
public D2D1TransformMapperParametersAccessor<T, TParameters>? Parameters { get; init; }
|
||||
@@ -26,19 +27,19 @@ internal abstract class D2D1TransformMapper<T, TParameters> : ID2D1TransformMapp
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parameters to be used to inform the transformation.</param>
|
||||
/// <param name="rectangle">The input rectangle to transform to output.</param>
|
||||
protected abstract void TransformInputToOutput(TParameters parameters, ref Rectangle64 rectangle);
|
||||
protected abstract void TransformInputToOutput(in TParameters parameters, ref Rectangle64 rectangle);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms an output rectangle to an input rectangle.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parameters to be used to inform the transformation.</param>
|
||||
/// <param name="rectangle">The output rectangle to transform to input.</param>
|
||||
protected abstract void TransformOutputToInput(TParameters parameters, ref Rectangle64 rectangle);
|
||||
protected abstract void TransformOutputToInput(in TParameters parameters, ref Rectangle64 rectangle);
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapper<T>.MapInputsToOutput(in T shader, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
|
||||
{
|
||||
this.shader = shader;
|
||||
this.parameters = Parameters!.Get(in shader);
|
||||
|
||||
if (inputs.IsEmpty)
|
||||
{
|
||||
@@ -56,7 +57,7 @@ internal abstract class D2D1TransformMapper<T, TParameters> : ID2D1TransformMapp
|
||||
output64.Union(Rectangle64.FromRectangle(input));
|
||||
}
|
||||
|
||||
TransformInputToOutput(Parameters!.Get(in shader), ref output64);
|
||||
TransformInputToOutput(in this.parameters, ref output64);
|
||||
|
||||
output = output64.ToRectangleWithD2D1LogicallyInfiniteClamping();
|
||||
opaqueOutput = Rectangle.Empty;
|
||||
@@ -68,7 +69,7 @@ internal abstract class D2D1TransformMapper<T, TParameters> : ID2D1TransformMapp
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.FromRectangle(invalidInput);
|
||||
|
||||
TransformInputToOutput(Parameters!.Get(in shader), ref output64);
|
||||
TransformInputToOutput(in this.parameters, ref output64);
|
||||
|
||||
invalidOutput = output64.ToRectangleWithD2D1LogicallyInfiniteClamping();
|
||||
}
|
||||
@@ -78,7 +79,7 @@ internal abstract class D2D1TransformMapper<T, TParameters> : ID2D1TransformMapp
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.FromRectangle(output);
|
||||
|
||||
TransformOutputToInput(Parameters!.Get(in shader), ref output64);
|
||||
TransformOutputToInput(in this.parameters, ref output64);
|
||||
|
||||
inputs.Fill(output64.ToRectangleWithD2D1LogicallyInfiniteClamping());
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ internal sealed class D2D1AffineTransformMapperFactory<T> : D2D1TransformMapperF
|
||||
public sealed class TransformMapper : D2D1TransformMapper<T, Matrix3x2>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformInputToOutput(Matrix3x2 parameters, ref Rectangle64 rectangle)
|
||||
protected override void TransformInputToOutput(in Matrix3x2 parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
Transform(parameters, ref rectangle);
|
||||
Transform(in parameters, ref rectangle);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformOutputToInput(Matrix3x2 parameters, ref Rectangle64 rectangle)
|
||||
protected override void TransformOutputToInput(in Matrix3x2 parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
if (!Matrix3x2.Invert(parameters, out Matrix3x2 matrix))
|
||||
{
|
||||
@@ -71,7 +71,7 @@ internal sealed class D2D1AffineTransformMapperFactory<T> : D2D1TransformMapperF
|
||||
Throw();
|
||||
}
|
||||
|
||||
Transform(matrix, ref rectangle);
|
||||
Transform(in matrix, ref rectangle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,7 +79,7 @@ internal sealed class D2D1AffineTransformMapperFactory<T> : D2D1TransformMapperF
|
||||
/// </summary>
|
||||
/// <param name="matrix">The transform matrix to use.</param>
|
||||
/// <param name="rectangle">The rectangle to transform.</param>
|
||||
private static void Transform(Matrix3x2 matrix, ref Rectangle64 rectangle)
|
||||
private static void Transform(in Matrix3x2 matrix, ref Rectangle64 rectangle)
|
||||
{
|
||||
// Get the rectangle corners
|
||||
Point64 topLeft = new(rectangle.Left, rectangle.Top);
|
||||
|
||||
@@ -102,13 +102,13 @@ internal sealed class D2D1InflateTransformMapperFactory<T> : D2D1TransformMapper
|
||||
public sealed class TransformMapper : D2D1TransformMapper<T, (int Left, int Top, int Right, int Bottom)>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformInputToOutput((int Left, int Top, int Right, int Bottom) parameters, ref Rectangle64 rectangle)
|
||||
protected override void TransformInputToOutput(in (int Left, int Top, int Right, int Bottom) parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
rectangle.Inflate(parameters.Left, parameters.Top, parameters.Right, parameters.Bottom);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformOutputToInput((int Left, int Top, int Right, int Bottom) parameters, ref Rectangle64 rectangle)
|
||||
protected override void TransformOutputToInput(in (int Left, int Top, int Right, int Bottom) parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
rectangle.Inflate(parameters.Left, parameters.Top, parameters.Right, parameters.Bottom);
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする