Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix multiplying TextureBrush with a disposed matrix on Unix #24109

Merged
merged 3 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/System.Drawing.Common/src/System/Drawing/TextureBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public Matrix Transform
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
}

int status = SafeNativeMethods.Gdip.GdipSetTextureTransform(new HandleRef(this, NativeBrush), new HandleRef(value, value.nativeMatrix));
Expand Down Expand Up @@ -225,6 +225,13 @@ public void MultiplyTransform(Matrix matrix, MatrixOrder order)
throw new ArgumentNullException(nameof(matrix));
}

// Multiplying the transform by a disposed matrix is a nop in GDI+, but throws
// with the libgdiplus backend. Simulate a nop for compatability with GDI+.
if (matrix.nativeMatrix == IntPtr.Zero)
{
return;
}

int status = SafeNativeMethods.Gdip.GdipMultiplyTextureTransform(new HandleRef(this, NativeBrush),
new HandleRef(matrix, matrix.nativeMatrix),
order);
Expand Down
4 changes: 0 additions & 4 deletions src/System.Drawing.Common/tests/TextureBrushTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ public void Ctor_DisposedImage_ThrowsArgumentException()
AssertExtensions.Throws<ArgumentException>(null, () => new TextureBrush(image, WrapMode.Tile, Rectangle.Empty));
}

[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.GdiplusIsAvailable)]
[InlineData(WrapMode.Tile - 1)]
[InlineData(WrapMode.Clamp + 1)]
Expand Down Expand Up @@ -431,7 +430,6 @@ public void MultiplyTransform_NotInvertibleMatrix_ThrowsArgumentException()
}
}

[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void MultiplyTransform_DisposedMatrix_Nop()
{
Expand Down Expand Up @@ -662,7 +660,6 @@ public void Transform_SetValid_GetReturnsExpected()
}
}

[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void Transform_SetNull_ThrowsArgumentNullException()
{
Expand Down Expand Up @@ -786,7 +783,6 @@ public void WrapMode_SetValid_GetReturnsExpected(WrapMode wrapMode)
}
}

[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.GdiplusIsAvailable)]
[InlineData(WrapMode.Tile - 1)]
[InlineData(WrapMode.Clamp + 1)]
Expand Down