From 2dcef755ed44eefc84a361190824be35bdd2efb7 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Sun, 17 Sep 2017 22:27:05 +0100 Subject: [PATCH 1/3] Fix multiplying TextureBrush with a disposed matrix on Unix --- .../src/System/Drawing/TextureBrush.cs | 9 ++++++++- src/System.Drawing.Common/tests/TextureBrushTests.cs | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) 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..b861e6920141 100644 --- a/src/System.Drawing.Common/tests/TextureBrushTests.cs +++ b/src/System.Drawing.Common/tests/TextureBrushTests.cs @@ -431,7 +431,6 @@ public void MultiplyTransform_NotInvertibleMatrix_ThrowsArgumentException() } } - [ActiveIssue(20884, TestPlatforms.AnyUnix)] [ConditionalFact(Helpers.GdiplusIsAvailable)] public void MultiplyTransform_DisposedMatrix_Nop() { @@ -662,7 +661,6 @@ public void Transform_SetValid_GetReturnsExpected() } } - [ActiveIssue(20884, TestPlatforms.AnyUnix)] [ConditionalFact(Helpers.GdiplusIsAvailable)] public void Transform_SetNull_ThrowsArgumentNullException() { From 3cadee4bb70fa09087785daaa4502f2f2879236f Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Mon, 18 Sep 2017 09:08:22 +0100 Subject: [PATCH 2/3] Enable another passing test --- src/System.Drawing.Common/tests/Helpers.cs | 3 ++- src/System.Drawing.Common/tests/TextureBrushTests.cs | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/System.Drawing.Common/tests/Helpers.cs b/src/System.Drawing.Common/tests/Helpers.cs index 75067647affb..ca7bfdec4e3c 100644 --- a/src/System.Drawing.Common/tests/Helpers.cs +++ b/src/System.Drawing.Common/tests/Helpers.cs @@ -23,13 +23,14 @@ public static bool GetGdiplusIsAvailable() } else { + return true;/* IntPtr nativeLib = dlopen("libgdiplus.so", RTLD_NOW); if (nativeLib == IntPtr.Zero) { nativeLib = dlopen("libgdiplus.so.0", RTLD_NOW); } - return nativeLib != IntPtr.Zero; + return nativeLib != IntPtr.Zero; */ } } diff --git a/src/System.Drawing.Common/tests/TextureBrushTests.cs b/src/System.Drawing.Common/tests/TextureBrushTests.cs index b861e6920141..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)] @@ -784,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)] From e7015c7a34f42f912e5bf35c81186f9f3bb32574 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Tue, 19 Sep 2017 20:54:37 +0100 Subject: [PATCH 3/3] Fix accidentally committed file --- src/System.Drawing.Common/tests/Helpers.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/System.Drawing.Common/tests/Helpers.cs b/src/System.Drawing.Common/tests/Helpers.cs index ca7bfdec4e3c..75067647affb 100644 --- a/src/System.Drawing.Common/tests/Helpers.cs +++ b/src/System.Drawing.Common/tests/Helpers.cs @@ -23,14 +23,13 @@ public static bool GetGdiplusIsAvailable() } else { - return true;/* IntPtr nativeLib = dlopen("libgdiplus.so", RTLD_NOW); if (nativeLib == IntPtr.Zero) { nativeLib = dlopen("libgdiplus.so.0", RTLD_NOW); } - return nativeLib != IntPtr.Zero; */ + return nativeLib != IntPtr.Zero; } }