Skip to content

Commit

Permalink
Fix multiplying TextureBrush with a disposed matrix on Unix (dotnet/c…
Browse files Browse the repository at this point in the history
…orefx#24109)

* Fix multiplying TextureBrush with a disposed matrix on Unix

* Enable another passing test

* Fix accidentally committed file


Commit migrated from dotnet/corefx@15f9a31
  • Loading branch information
hughbe authored and mellinoe committed Sep 19, 2017
1 parent 27d1056 commit b857b2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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
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

0 comments on commit b857b2a

Please sign in to comment.