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