Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsTransform2D.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef nsTransform2D_h___
8
#define nsTransform2D_h___
9
10
#include "nsCoord.h"
11
12
class nsTransform2D
13
{
14
private:
15
 /**
16
  * This represents the following matrix (note that the order of row/column
17
  * indices is opposite to usual notation)
18
  *
19
  *      / m00   0   m20  \
20
  * M =  |  0   m11  m21  |
21
  *      \  0    0    1   /
22
  *
23
  * Transformation of a coordinate (x, y) is obtained by setting
24
  * v = (x, y, 1)^T and evaluating  M . v
25
  **/
26
27
  float     m00, m11, m20, m21;
28
29
public:
30
0
  nsTransform2D(void)                         { m20 = m21 = 0.0f; m00 = m11 = 1.0f; }
31
32
0
  ~nsTransform2D(void)                        { }
33
34
 /**
35
  * set this transform to a translation
36
  *
37
  * @param      tx, x translation
38
  * @param      ty, y translation
39
  **/
40
41
0
  void SetToTranslate(float tx, float ty)    { m00 = m11 = 1.0f; m20 = tx; m21 = ty; }
42
  
43
 /**
44
  * get the translation portion of this transform
45
  *
46
  * @param      pt, Point to return translation values in
47
  **/
48
49
  void GetTranslationCoord(nscoord *ptX, nscoord *ptY) const { *ptX = NSToCoordRound(m20); *ptY = NSToCoordRound(m21); }
50
51
 /**
52
  * apply matrix to vector
53
  *
54
  * @param    pt Point to transform
55
  **/
56
57
  void TransformCoord(nscoord *ptX, nscoord *ptY) const;
58
59
 /**
60
  * apply matrix to rect
61
  *
62
  * @param    rect Rect to transform
63
  **/
64
65
  void TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, nscoord *aHeight) const;
66
67
 /**
68
  * add a scale to a Transform via x, y pair
69
  *
70
  * @param    ptX x value to add as x scale
71
  * @param    ptY y value to add as y scale
72
  **/
73
74
  void AddScale(float ptX, float ptY) { m00 *= ptX; m11 *= ptY; }
75
76
 /**
77
  * Set the scale (overriding any previous calls to AddScale, but leaving
78
  * any existing translation).
79
  *
80
  * @param    ptX x value to add as x scale
81
  * @param    ptY y value to add as y scale
82
  **/
83
84
0
  void SetScale(float ptX, float ptY) { m00 = ptX; m11 = ptY; }
85
};
86
87
#endif