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

gdiplus: Use static data for identity check in GdipIsMatrixIdentity().

parent da2021e4
......@@ -497,23 +497,17 @@ GpStatus WINGDIPAPI GdipIsMatrixEqual(GDIPCONST GpMatrix *matrix, GDIPCONST GpMa
GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix *matrix, BOOL *result)
{
GpMatrix *e;
GpStatus ret;
BOOL isIdentity;
static const GpMatrix identity =
{
{ 1.0, 0.0,
0.0, 1.0,
0.0, 0.0 }
};
TRACE("(%p, %p)\n", matrix, result);
if(!matrix || !result)
return InvalidParameter;
ret = GdipCreateMatrix(&e);
if(ret != Ok) return ret;
ret = GdipIsMatrixEqual(matrix, e, &isIdentity);
if(ret == Ok)
*result = isIdentity;
heap_free(e);
return ret;
return GdipIsMatrixEqual(matrix, &identity, result);
}
......@@ -302,7 +302,42 @@ static void test_constructor3(void)
expectf(0.0, values[4]);
expectf(0.0, values[5]);
GdipDeleteMatrix(matrix);}
GdipDeleteMatrix(matrix);
}
static void test_isidentity(void)
{
GpMatrix *matrix;
GpStatus stat;
BOOL result;
stat = GdipIsMatrixIdentity(NULL, NULL);
expect(InvalidParameter, stat);
stat = GdipIsMatrixIdentity(NULL, &result);
expect(InvalidParameter, stat);
stat = GdipCreateMatrix2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, &matrix);
expect(Ok, stat);
stat = GdipIsMatrixIdentity(matrix, NULL);
expect(InvalidParameter, stat);
result = FALSE;
stat = GdipIsMatrixIdentity(matrix, &result);
expect(Ok, stat);
ok(!!result, "got %d\n", result);
stat = GdipSetMatrixElements(matrix, 1.0, 0.0, 0.0, 1.0, 0.1, 0.0);
expect(Ok, stat);
result = TRUE;
stat = GdipIsMatrixIdentity(matrix, &result);
expect(Ok, stat);
ok(!result, "got %d\n", result);
GdipDeleteMatrix(matrix);
}
START_TEST(matrix)
{
......@@ -322,6 +357,7 @@ START_TEST(matrix)
test_invert();
test_shear();
test_constructor3();
test_isidentity();
GdiplusShutdown(gdiplusToken);
}
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