Commit 4ea173ef authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Implemented GdipShearMatrix with tests.

parent ca12410f
...@@ -598,7 +598,7 @@ ...@@ -598,7 +598,7 @@
@ stdcall GdipSetTextureTransform(ptr ptr) @ stdcall GdipSetTextureTransform(ptr ptr)
@ stub GdipSetTextureWrapMode @ stub GdipSetTextureWrapMode
@ stdcall GdipSetWorldTransform(ptr ptr) @ stdcall GdipSetWorldTransform(ptr ptr)
@ stub GdipShearMatrix @ stdcall GdipShearMatrix(ptr long long long)
@ stdcall GdipStartPathFigure(ptr) @ stdcall GdipStartPathFigure(ptr)
@ stub GdipStringFormatGetGenericDefault @ stub GdipStringFormatGetGenericDefault
@ stub GdipStringFormatGetGenericTypographic @ stub GdipStringFormatGetGenericTypographic
......
...@@ -280,6 +280,30 @@ GpStatus WINGDIPAPI GdipSetMatrixElements(GpMatrix *matrix, REAL m11, REAL m12, ...@@ -280,6 +280,30 @@ GpStatus WINGDIPAPI GdipSetMatrixElements(GpMatrix *matrix, REAL m11, REAL m12,
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipShearMatrix(GpMatrix *matrix, REAL shearX, REAL shearY,
GpMatrixOrder order)
{
REAL shear[6];
if(!matrix)
return InvalidParameter;
/* prepare transformation matrix */
shear[0] = 1.0;
shear[1] = shearY;
shear[2] = shearX;
shear[3] = 1.0;
shear[4] = 0.0;
shear[5] = 0.0;
if(order == MatrixOrderAppend)
matrix_multiply(matrix->matrix, shear, matrix->matrix);
else
matrix_multiply(shear, matrix->matrix, matrix->matrix);
return Ok;
}
GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts, GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts,
INT count) INT count)
{ {
......
...@@ -149,6 +149,78 @@ static void test_invert(void) ...@@ -149,6 +149,78 @@ static void test_invert(void)
GdipDeleteMatrix(matrix); GdipDeleteMatrix(matrix);
} }
static void test_shear(void)
{
GpStatus status;
GpMatrix *matrix = NULL;
GpMatrix *sheared = NULL;
BOOL equal;
/* NULL */
status = GdipShearMatrix(NULL, 0.0, 0.0, MatrixOrderPrepend);
expect(InvalidParameter, status);
/* X only shearing, MatrixOrderPrepend */
GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
status = GdipShearMatrix(matrix, 1.5, 0.0, MatrixOrderPrepend);
expect(Ok, status);
GdipCreateMatrix2(1.0, 2.0, 5.5, 2.0, 6.0, 3.0, &sheared);
GdipIsMatrixEqual(matrix, sheared, &equal);
expect(TRUE, equal);
GdipDeleteMatrix(sheared);
GdipDeleteMatrix(matrix);
/* X only shearing, MatrixOrderAppend */
GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
status = GdipShearMatrix(matrix, 1.5, 0.0, MatrixOrderAppend);
expect(Ok, status);
GdipCreateMatrix2(4.0, 2.0, 2.5, -1.0, 10.5, 3.0, &sheared);
GdipIsMatrixEqual(matrix, sheared, &equal);
expect(TRUE, equal);
GdipDeleteMatrix(sheared);
GdipDeleteMatrix(matrix);
/* Y only shearing, MatrixOrderPrepend */
GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
status = GdipShearMatrix(matrix, 0.0, 1.5, MatrixOrderPrepend);
expect(Ok, status);
GdipCreateMatrix2(7.0, 0.5, 4.0, -1.0, 6.0, 3.0, &sheared);
GdipIsMatrixEqual(matrix, sheared, &equal);
expect(TRUE, equal);
GdipDeleteMatrix(sheared);
GdipDeleteMatrix(matrix);
/* Y only shearing, MatrixOrderAppend */
GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
status = GdipShearMatrix(matrix, 0.0, 1.5, MatrixOrderAppend);
expect(Ok, status);
GdipCreateMatrix2(1.0, 3.5, 4.0, 5.0, 6.0, 12.0, &sheared);
GdipIsMatrixEqual(matrix, sheared, &equal);
expect(TRUE, equal);
GdipDeleteMatrix(sheared);
GdipDeleteMatrix(matrix);
/* X,Y shearing, MatrixOrderPrepend */
GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
status = GdipShearMatrix(matrix, 4.0, 1.5, MatrixOrderPrepend);
expect(Ok, status);
GdipCreateMatrix2(7.0, 0.5, 8.0, 7.0, 6.0, 3.0, &sheared);
GdipIsMatrixEqual(matrix, sheared, &equal);
expect(TRUE, equal);
GdipDeleteMatrix(sheared);
GdipDeleteMatrix(matrix);
/* X,Y shearing, MatrixOrderAppend */
GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
status = GdipShearMatrix(matrix, 4.0, 1.5, MatrixOrderAppend);
expect(Ok, status);
GdipCreateMatrix2(9.0, 3.5, 0.0, 5.0, 18.0, 12.0, &sheared);
GdipIsMatrixEqual(matrix, sheared, &equal);
expect(TRUE, equal);
GdipDeleteMatrix(sheared);
GdipDeleteMatrix(matrix);
}
START_TEST(matrix) START_TEST(matrix)
{ {
struct GdiplusStartupInput gdiplusStartupInput; struct GdiplusStartupInput gdiplusStartupInput;
...@@ -165,6 +237,7 @@ START_TEST(matrix) ...@@ -165,6 +237,7 @@ START_TEST(matrix)
test_transform(); test_transform();
test_isinvertible(); test_isinvertible();
test_invert(); test_invert();
test_shear();
GdiplusShutdown(gdiplusToken); GdiplusShutdown(gdiplusToken);
} }
...@@ -263,6 +263,7 @@ GpStatus WINGDIPAPI GdipCreateMatrix2(REAL,REAL,REAL,REAL,REAL,REAL,GpMatrix**); ...@@ -263,6 +263,7 @@ GpStatus WINGDIPAPI GdipCreateMatrix2(REAL,REAL,REAL,REAL,REAL,REAL,GpMatrix**);
GpStatus WINGDIPAPI GdipCreateMatrix3(GDIPCONST GpRectF *,GDIPCONST GpPointF*,GpMatrix**); GpStatus WINGDIPAPI GdipCreateMatrix3(GDIPCONST GpRectF *,GDIPCONST GpPointF*,GpMatrix**);
GpStatus WINGDIPAPI GdipCreateMatrix3I(GDIPCONST GpRect*,GDIPCONST GpPoint*,GpMatrix**); GpStatus WINGDIPAPI GdipCreateMatrix3I(GDIPCONST GpRect*,GDIPCONST GpPoint*,GpMatrix**);
GpStatus WINGDIPAPI GdipInvertMatrix(GpMatrix*); GpStatus WINGDIPAPI GdipInvertMatrix(GpMatrix*);
GpStatus WINGDIPAPI GdipShearMatrix(GpMatrix*,REAL,REAL,GpMatrixOrder);
GpStatus WINGDIPAPI GdipIsMatrixEqual(GDIPCONST GpMatrix*, GDIPCONST GpMatrix*, BOOL*); GpStatus WINGDIPAPI GdipIsMatrixEqual(GDIPCONST GpMatrix*, GDIPCONST GpMatrix*, BOOL*);
GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix*, BOOL*); GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix*, BOOL*);
GpStatus WINGDIPAPI GdipIsMatrixInvertible(GDIPCONST GpMatrix*, BOOL*); GpStatus WINGDIPAPI GdipIsMatrixInvertible(GDIPCONST GpMatrix*, BOOL*);
......
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