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

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-11-04 04:18:19 +03:00 committed by Alexandre Julliard
parent da2021e46f
commit f7187ecbd6
2 changed files with 44 additions and 14 deletions

View file

@ -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);
}

View file

@ -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);
}