Nikolay Sivov : gdiplus: Use static data for identity check in GdipIsMatrixIdentity().
Module: wine Branch: master Commit: f7187ecbd62f778649e055af61cd2c6786ead7f1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f7187ecbd62f778649e055af61... Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Fri Nov 4 04:18:19 2016 +0300 gdiplus: Use static data for identity check in GdipIsMatrixIdentity(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/matrix.c | 20 +++++++------------- dlls/gdiplus/tests/matrix.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/dlls/gdiplus/matrix.c b/dlls/gdiplus/matrix.c index fc2d3f5..3cd8d82 100644 --- a/dlls/gdiplus/matrix.c +++ b/dlls/gdiplus/matrix.c @@ -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); } diff --git a/dlls/gdiplus/tests/matrix.c b/dlls/gdiplus/tests/matrix.c index 83b57ef..a2e0595 100644 --- a/dlls/gdiplus/tests/matrix.c +++ b/dlls/gdiplus/tests/matrix.c @@ -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); }
participants (1)
-
Alexandre Julliard