diff --git a/src/System.Drawing.Common/src/System/Drawing/TextureBrush.cs b/src/System.Drawing.Common/src/System/Drawing/TextureBrush.cs index c39f329afc10..1710dfb4dc43 100644 --- a/src/System.Drawing.Common/src/System/Drawing/TextureBrush.cs +++ b/src/System.Drawing.Common/src/System/Drawing/TextureBrush.cs @@ -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)); @@ -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); diff --git a/src/System.Drawing.Common/tests/TextureBrushTests.cs b/src/System.Drawing.Common/tests/TextureBrushTests.cs index bb93324f0d0a..02e3e4cc3916 100644 --- a/src/System.Drawing.Common/tests/TextureBrushTests.cs +++ b/src/System.Drawing.Common/tests/TextureBrushTests.cs @@ -294,7 +294,6 @@ public void Ctor_DisposedImage_ThrowsArgumentException() AssertExtensions.Throws(null, () => new TextureBrush(image, WrapMode.Tile, Rectangle.Empty)); } - [ActiveIssue(20884, TestPlatforms.AnyUnix)] [ConditionalTheory(Helpers.GdiplusIsAvailable)] [InlineData(WrapMode.Tile - 1)] [InlineData(WrapMode.Clamp + 1)] @@ -431,7 +430,6 @@ public void MultiplyTransform_NotInvertibleMatrix_ThrowsArgumentException() } } - [ActiveIssue(20884, TestPlatforms.AnyUnix)] [ConditionalFact(Helpers.GdiplusIsAvailable)] public void MultiplyTransform_DisposedMatrix_Nop() { @@ -662,7 +660,6 @@ public void Transform_SetValid_GetReturnsExpected() } } - [ActiveIssue(20884, TestPlatforms.AnyUnix)] [ConditionalFact(Helpers.GdiplusIsAvailable)] public void Transform_SetNull_ThrowsArgumentNullException() { @@ -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)]