~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gdiplus/tests/matrix.c

Version: ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit test suite for matrices
  3  *
  4  * Copyright (C) 2007 Google (Evan Stade)
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include <math.h>
 22 
 23 #include "windows.h"
 24 #include <stdio.h>
 25 #include "gdiplus.h"
 26 #include "wine/test.h"
 27 
 28 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 29 
 30 static void test_constructor_destructor(void)
 31 {
 32     GpStatus status;
 33     GpMatrix *matrix = NULL;
 34 
 35     status = GdipCreateMatrix2(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &matrix);
 36     expect(Ok, status);
 37     ok(matrix != NULL, "Expected matrix to be initialized\n");
 38 
 39     status = GdipDeleteMatrix(NULL);
 40     expect(InvalidParameter, status);
 41 
 42     status = GdipDeleteMatrix(matrix);
 43     expect(Ok, status);
 44 }
 45 
 46 typedef struct{
 47     REAL X;
 48     REAL Y;
 49 } real_point;
 50 
 51 static real_point transform_points[] = {
 52     {1000.00, 2600.00}, /**/
 53     {855.00, 2390.00}, /*1*/
 54     {700.00, 2200.00}, /*2*/
 55     {565.00, 1970.00}, /*3*/
 56     {400.00, 1800.00}, /*4*/
 57     {275.00, 1550.00}, /*5*/
 58     {100.00, 1400.00}, /*6*/
 59     {-15.00, 1130.00}, /*7*/
 60     {-200.00, 1000.00}, /*8*/
 61     {-305.00, 710.00} /*9*/
 62     };
 63 
 64 static void test_transform(void)
 65 {
 66     GpStatus status;
 67     GpMatrix *matrix = NULL;
 68     GpPointF pts[10];
 69     INT i;
 70     BOOL match;
 71 
 72     for(i = 0; i < 10; i ++){
 73         pts[i].X = i * 5.0 * (REAL)(i % 2);
 74         pts[i].Y = 50.0 - i * 5.0;
 75     }
 76 
 77     GdipCreateMatrix2(1.0, -2.0, 30.0, 40.0, -500.0, 600.0, &matrix);
 78 
 79     status = GdipTransformMatrixPoints(matrix, pts, 10);
 80     expect(Ok, status);
 81 
 82     for(i = 0; i < 10; i ++){
 83         match = fabs(transform_points[i].X - pts[i].X) < 2.0
 84             && fabs(transform_points[i].Y -  pts[i].Y) < 2.0;
 85 
 86         ok(match, "Expected #%d to be (%.2f, %.2f) but got (%.2f, %.2f)\n", i,
 87            transform_points[i].X, transform_points[i].Y, pts[i].X, pts[i].Y);
 88     }
 89 
 90     GdipDeleteMatrix(matrix);
 91 }
 92 
 93 static void test_isinvertible(void)
 94 {
 95     GpStatus status;
 96     GpMatrix *matrix = NULL;
 97     BOOL result;
 98 
 99     /* NULL arguments */
100     status = GdipIsMatrixInvertible(NULL, &result);
101     expect(InvalidParameter, status);
102     status = GdipIsMatrixInvertible((GpMatrix*)0xdeadbeef, NULL);
103     expect(InvalidParameter, status);
104     status = GdipIsMatrixInvertible(NULL, NULL);
105     expect(InvalidParameter, status);
106 
107     /* invertible */
108     GdipCreateMatrix2(1.0, 1.2, 2.3, -1.0, 2.0, 3.0, &matrix);
109     status = GdipIsMatrixInvertible(matrix, &result);
110     expect(Ok, status);
111     expect(TRUE, result);
112     GdipDeleteMatrix(matrix);
113 
114     /* noninvertible */
115     GdipCreateMatrix2(2.0, -1.0, 6.0, -3.0, 2.2, 3.0, &matrix);
116     status = GdipIsMatrixInvertible(matrix, &result);
117     expect(Ok, status);
118     expect(FALSE, result);
119     GdipDeleteMatrix(matrix);
120 }
121 
122 static void test_invert(void)
123 {
124     GpStatus status;
125     GpMatrix *matrix = NULL;
126     GpMatrix *inverted = NULL;
127     BOOL equal = FALSE;
128 
129     /* NULL */
130     status = GdipInvertMatrix(NULL);
131     expect(InvalidParameter, status);
132 
133     /* noninvertible */
134     GdipCreateMatrix2(2.0, -1.0, 6.0, -3.0, 2.2, 3.0, &matrix);
135     status = GdipInvertMatrix(matrix);
136     expect(InvalidParameter, status);
137     GdipDeleteMatrix(matrix);
138 
139     /* invertible */
140     GdipCreateMatrix2(3.0, -2.0, 5.0, 2.0, 6.0, 3.0, &matrix);
141     status = GdipInvertMatrix(matrix);
142     expect(Ok, status);
143     GdipCreateMatrix2(2.0/16.0, 2.0/16.0, -5.0/16.0, 3.0/16.0, 3.0/16.0, -21.0/16.0, &inverted);
144     GdipIsMatrixEqual(matrix, inverted, &equal);
145     expect(TRUE, equal);
146 
147     GdipDeleteMatrix(inverted);
148     GdipDeleteMatrix(matrix);
149 }
150 
151 static void test_shear(void)
152 {
153     GpStatus status;
154     GpMatrix *matrix  = NULL;
155     GpMatrix *sheared = NULL;
156     BOOL equal;
157 
158     /* NULL */
159     status = GdipShearMatrix(NULL, 0.0, 0.0, MatrixOrderPrepend);
160     expect(InvalidParameter, status);
161 
162     /* X only shearing, MatrixOrderPrepend */
163     GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
164     status = GdipShearMatrix(matrix, 1.5, 0.0, MatrixOrderPrepend);
165     expect(Ok, status);
166     GdipCreateMatrix2(1.0, 2.0, 5.5, 2.0, 6.0, 3.0, &sheared);
167     GdipIsMatrixEqual(matrix, sheared, &equal);
168     expect(TRUE, equal);
169     GdipDeleteMatrix(sheared);
170     GdipDeleteMatrix(matrix);
171 
172     /* X only shearing, MatrixOrderAppend */
173     GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
174     status = GdipShearMatrix(matrix, 1.5, 0.0, MatrixOrderAppend);
175     expect(Ok, status);
176     GdipCreateMatrix2(4.0, 2.0, 2.5, -1.0, 10.5, 3.0, &sheared);
177     GdipIsMatrixEqual(matrix, sheared, &equal);
178     expect(TRUE, equal);
179     GdipDeleteMatrix(sheared);
180     GdipDeleteMatrix(matrix);
181 
182     /* Y only shearing, MatrixOrderPrepend */
183     GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
184     status = GdipShearMatrix(matrix, 0.0, 1.5, MatrixOrderPrepend);
185     expect(Ok, status);
186     GdipCreateMatrix2(7.0, 0.5, 4.0, -1.0, 6.0, 3.0, &sheared);
187     GdipIsMatrixEqual(matrix, sheared, &equal);
188     expect(TRUE, equal);
189     GdipDeleteMatrix(sheared);
190     GdipDeleteMatrix(matrix);
191 
192     /* Y only shearing, MatrixOrderAppend */
193     GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
194     status = GdipShearMatrix(matrix, 0.0, 1.5, MatrixOrderAppend);
195     expect(Ok, status);
196     GdipCreateMatrix2(1.0, 3.5, 4.0, 5.0, 6.0, 12.0, &sheared);
197     GdipIsMatrixEqual(matrix, sheared, &equal);
198     expect(TRUE, equal);
199     GdipDeleteMatrix(sheared);
200     GdipDeleteMatrix(matrix);
201 
202     /* X,Y shearing, MatrixOrderPrepend */
203     GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
204     status = GdipShearMatrix(matrix, 4.0, 1.5, MatrixOrderPrepend);
205     expect(Ok, status);
206     GdipCreateMatrix2(7.0, 0.5, 8.0, 7.0, 6.0, 3.0, &sheared);
207     GdipIsMatrixEqual(matrix, sheared, &equal);
208     expect(TRUE, equal);
209     GdipDeleteMatrix(sheared);
210     GdipDeleteMatrix(matrix);
211 
212     /* X,Y shearing, MatrixOrderAppend */
213     GdipCreateMatrix2(1.0, 2.0, 4.0, -1.0, 6.0, 3.0, &matrix);
214     status = GdipShearMatrix(matrix, 4.0, 1.5, MatrixOrderAppend);
215     expect(Ok, status);
216     GdipCreateMatrix2(9.0, 3.5, 0.0, 5.0, 18.0, 12.0, &sheared);
217     GdipIsMatrixEqual(matrix, sheared, &equal);
218     expect(TRUE, equal);
219     GdipDeleteMatrix(sheared);
220     GdipDeleteMatrix(matrix);
221 }
222 
223 START_TEST(matrix)
224 {
225     struct GdiplusStartupInput gdiplusStartupInput;
226     ULONG_PTR gdiplusToken;
227 
228     gdiplusStartupInput.GdiplusVersion              = 1;
229     gdiplusStartupInput.DebugEventCallback          = NULL;
230     gdiplusStartupInput.SuppressBackgroundThread    = 0;
231     gdiplusStartupInput.SuppressExternalCodecs      = 0;
232 
233     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
234 
235     test_constructor_destructor();
236     test_transform();
237     test_isinvertible();
238     test_invert();
239     test_shear();
240 
241     GdiplusShutdown(gdiplusToken);
242 }
243 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.