Add copy of .ttf font with .eot extension for testing
[wine-gecko.git] / gfx / public / nsTransform2D.h
blobdc03406ceabaa6e3b7f34e2650aa1237f1c1fafa
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * michaelp 09-25-97 1:56pm
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsTransform2D_h___
40 #define nsTransform2D_h___
42 #include "gfxCore.h"
43 #include "nsCoord.h"
45 class NS_GFX nsTransform2D
47 private:
48 /**
49 * This represents the following matrix (note that the order of row/column
50 * indices is opposite to usual notation)
52 * / m00 0 m20 \
53 * M = | 0 m11 m21 |
54 * \ 0 0 1 /
56 * Transformation of a coordinate (x, y) is obtained by setting
57 * v = (x, y, 1)^T and evaluating M . v
58 **/
60 float m00, m11, m20, m21;
62 public:
63 nsTransform2D(void) { m20 = m21 = 0.0f; m00 = m11 = 1.0f; }
64 nsTransform2D(nsTransform2D *aTransform2D) {
65 m00 = aTransform2D->m00;
66 m11 = aTransform2D->m11;
67 m20 = aTransform2D->m20;
68 m21 = aTransform2D->m21;
71 ~nsTransform2D(void) { }
73 /**
74 * set this transform to a translation
76 * @param tx, x translation
77 * @param ty, y translation
78 **/
80 void SetToTranslate(float tx, float ty) { m00 = m11 = 1.0f; m20 = tx; m21 = ty; }
82 /**
83 * get the translation portion of this transform
85 * @param pt, Point to return translation values in
86 **/
88 void GetTranslationCoord(nscoord *ptX, nscoord *ptY) const { *ptX = NSToCoordRound(m20); *ptY = NSToCoordRound(m21); }
90 /**
91 * apply matrix to vector
93 * @param pt Point to transform
94 **/
96 void TransformCoord(nscoord *ptX, nscoord *ptY) const;
98 /**
99 * apply matrix to rect
101 * @param rect Rect to transform
104 void TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, nscoord *aHeight) const;
107 * add a scale to a Transform via x, y pair
109 * @param ptX x value to add as x scale
110 * @param ptY y value to add as y scale
113 void AddScale(float ptX, float ptY) { m00 *= ptX; m11 *= ptY; }
116 #endif