Commit d4554ad5 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: GdipIsMatrixInvertible implementation with tests.

parent 9fbec615
......@@ -420,7 +420,7 @@
@ stdcall GdipIsInfiniteRegion(ptr ptr ptr)
@ stdcall GdipIsMatrixEqual(ptr ptr ptr)
@ stdcall GdipIsMatrixIdentity(ptr ptr)
@ stub GdipIsMatrixInvertible
@ stdcall GdipIsMatrixInvertible(ptr ptr)
@ stub GdipIsOutlineVisiblePathPoint
@ stdcall GdipIsOutlineVisiblePathPointI(ptr long long ptr ptr ptr)
@ stub GdipIsStyleAvailable
......
......@@ -158,6 +158,20 @@ GpStatus WINGDIPAPI GdipGetMatrixElements(GDIPCONST GpMatrix *matrix,
return Ok;
}
GpStatus WINGDIPAPI GdipIsMatrixInvertible(GDIPCONST GpMatrix *matrix, BOOL *result)
{
REAL det;
if(!matrix || !result)
return InvalidParameter;
det = matrix->matrix[0]*matrix->matrix[3] - matrix->matrix[1]*matrix->matrix[2];
*result = (fabs(det) >= 1e-5);
return Ok;
}
GpStatus WINGDIPAPI GdipMultiplyMatrix(GpMatrix *matrix, GpMatrix* matrix2,
GpMatrixOrder order)
{
......
......@@ -89,6 +89,35 @@ static void test_transform(void)
GdipDeleteMatrix(matrix);
}
static void test_isinvertible(void)
{
GpStatus status;
GpMatrix *matrix = NULL;
BOOL result;
/* NULL arguments */
status = GdipIsMatrixInvertible(NULL, &result);
expect(InvalidParameter, status);
status = GdipIsMatrixInvertible((GpMatrix*)0xdeadbeef, NULL);
expect(InvalidParameter, status);
status = GdipIsMatrixInvertible(NULL, NULL);
expect(InvalidParameter, status);
/* invertible */
GdipCreateMatrix2(1.0, 1.2, 2.3, -1.0, 2.0, 3.0, &matrix);
status = GdipIsMatrixInvertible(matrix, &result);
expect(Ok, status);
expect(TRUE, result);
GdipDeleteMatrix(matrix);
/* noninvertible */
GdipCreateMatrix2(2.0, -1.0, 6.0, -3.0, 2.2, 3.0, &matrix);
status = GdipIsMatrixInvertible(matrix, &result);
expect(Ok, status);
expect(FALSE, result);
GdipDeleteMatrix(matrix);
}
START_TEST(matrix)
{
struct GdiplusStartupInput gdiplusStartupInput;
......@@ -103,6 +132,7 @@ START_TEST(matrix)
test_constructor_destructor();
test_transform();
test_isinvertible();
GdiplusShutdown(gdiplusToken);
}
......@@ -264,6 +264,7 @@ GpStatus WINGDIPAPI GdipCreateMatrix3(GDIPCONST GpRectF *,GDIPCONST GpPointF*,Gp
GpStatus WINGDIPAPI GdipCreateMatrix3I(GDIPCONST GpRect*,GDIPCONST GpPoint*,GpMatrix**);
GpStatus WINGDIPAPI GdipIsMatrixEqual(GDIPCONST GpMatrix*, GDIPCONST GpMatrix*, BOOL*);
GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix*, BOOL*);
GpStatus WINGDIPAPI GdipIsMatrixInvertible(GDIPCONST GpMatrix*, BOOL*);
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix*);
GpStatus WINGDIPAPI GdipGetMatrixElements(GDIPCONST GpMatrix*,REAL*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment