Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/gfx/Point.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 MOZILLA_GFX_POINT_H_
8
#define MOZILLA_GFX_POINT_H_
9
10
#include "mozilla/Attributes.h"
11
#include "Types.h"
12
#include "Coord.h"
13
#include "BaseCoord.h"
14
#include "BasePoint.h"
15
#include "BasePoint3D.h"
16
#include "BasePoint4D.h"
17
#include "BaseSize.h"
18
#include "mozilla/Maybe.h"
19
#include "mozilla/TypeTraits.h"
20
21
#include <cmath>
22
23
namespace mozilla {
24
25
template <typename> struct IsPixel;
26
27
namespace gfx {
28
29
// This should only be used by the typedefs below.
30
struct UnknownUnits {};
31
32
} // namespace gfx
33
34
template<> struct IsPixel<gfx::UnknownUnits> : TrueType {};
35
36
namespace gfx {
37
38
/// Use this for parameters of functions to allow implicit conversions to
39
/// integer types but not floating point types.
40
/// We use this wrapper to prevent IntSize and IntPoint's constructors to
41
/// take foating point values as parameters, and not require their constructors
42
/// to have implementations for each permutation of integer types.
43
template<typename T>
44
struct IntParam {
45
  constexpr MOZ_IMPLICIT IntParam(char val) : value(val) {}
46
0
  constexpr MOZ_IMPLICIT IntParam(unsigned char val) : value(val) {}
47
0
  constexpr MOZ_IMPLICIT IntParam(short val) : value(val) {}
48
0
  constexpr MOZ_IMPLICIT IntParam(unsigned short val) : value(val) {}
49
42
  constexpr MOZ_IMPLICIT IntParam(int val) : value(val) {}
50
  constexpr MOZ_IMPLICIT IntParam(unsigned int val) : value(val) {}
51
  constexpr MOZ_IMPLICIT IntParam(long val) : value(val) {}
52
0
  constexpr MOZ_IMPLICIT IntParam(unsigned long val) : value(val) {}
53
  constexpr MOZ_IMPLICIT IntParam(long long val) : value(val) {}
54
  constexpr MOZ_IMPLICIT IntParam(unsigned long long val) : value(val) {}
55
  template<typename Unit>
56
0
  constexpr MOZ_IMPLICIT IntParam(IntCoordTyped<Unit> val) : value(val) {}
57
58
  // Disable the evil ones!
59
  MOZ_IMPLICIT IntParam(float val) = delete;
60
  MOZ_IMPLICIT IntParam(double val) = delete;
61
62
  T value;
63
};
64
65
template<class units, class> struct PointTyped;
66
template<class units, class> struct SizeTyped;
67
68
template<class units>
69
struct IntPointTyped :
70
  public BasePoint< int32_t, IntPointTyped<units>, IntCoordTyped<units> >,
71
  public units {
72
  static_assert(IsPixel<units>::value,
73
                "'units' must be a coordinate system tag");
74
75
  typedef IntParam<int32_t> ToInt;
76
  typedef IntCoordTyped<units> Coord;
77
  typedef BasePoint< int32_t, IntPointTyped<units>, IntCoordTyped<units> > Super;
78
79
0
  constexpr IntPointTyped() : Super() {}
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits>::IntPointTyped()
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::IntPointTyped()
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayerPixel>::IntPointTyped()
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ScreenPixel>::IntPointTyped()
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ParentLayerPixel>::IntPointTyped()
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::TileCoordUnit>::IntPointTyped()
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::CSSPixel>::IntPointTyped()
80
15
  constexpr IntPointTyped(ToInt aX, ToInt aY) : Super(Coord(aX.value), Coord(aY.value)) {}
mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Line
Count
Source
80
9
  constexpr IntPointTyped(ToInt aX, ToInt aY) : Super(Coord(aX.value), Coord(aY.value)) {}
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::RenderTargetPixel>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::TileCoordUnit>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayerPixel>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ScreenPixel>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ParentLayerPixel>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
mozilla::gfx::IntPointTyped<mozilla::CSSPixel>::IntPointTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Line
Count
Source
80
6
  constexpr IntPointTyped(ToInt aX, ToInt aY) : Super(Coord(aX.value), Coord(aY.value)) {}
81
82
0
  static IntPointTyped<units> Round(float aX, float aY) {
83
0
    return IntPointTyped(int32_t(floorf(aX + 0.5)), int32_t(floorf(aY + 0.5)));
84
0
  }
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits>::Round(float, float)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::Round(float, float)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ScreenPixel>::Round(float, float)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ParentLayerPixel>::Round(float, float)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayerPixel>::Round(float, float)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::CSSPixel>::Round(float, float)
85
86
  static IntPointTyped<units> Ceil(float aX, float aY) {
87
    return IntPointTyped(int32_t(ceil(aX)), int32_t(ceil(aY)));
88
  }
89
90
0
  static IntPointTyped<units> Floor(float aX, float aY) {
91
0
    return IntPointTyped(int32_t(floorf(aX)), int32_t(floorf(aY)));
92
0
  }
93
94
0
  static IntPointTyped<units> Truncate(float aX, float aY) {
95
0
    return IntPointTyped(int32_t(aX), int32_t(aY));
96
0
  }
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::Truncate(float, float)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::CSSPixel>::Truncate(float, float)
97
98
  static IntPointTyped<units> Round(const PointTyped<units, float>& aPoint);
99
  static IntPointTyped<units> Ceil(const PointTyped<units, float>& aPoint);
100
  static IntPointTyped<units> Floor(const PointTyped<units, float>& aPoint);
101
  static IntPointTyped<units> Truncate(const PointTyped<units, float>& aPoint);
102
103
  // XXX When all of the code is ported, the following functions to convert to and from
104
  // unknown types should be removed.
105
106
0
  static IntPointTyped<units> FromUnknownPoint(const IntPointTyped<UnknownUnits>& aPoint) {
107
0
    return IntPointTyped<units>(aPoint.x, aPoint.y);
108
0
  }
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::FromUnknownPoint(mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayerPixel>::FromUnknownPoint(mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits> const&)
109
110
0
  IntPointTyped<UnknownUnits> ToUnknownPoint() const {
111
0
    return IntPointTyped<UnknownUnits>(this->x, this->y);
112
0
  }
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits>::ToUnknownPoint() const
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayerPixel>::ToUnknownPoint() const
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::ToUnknownPoint() const
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::RenderTargetPixel>::ToUnknownPoint() const
113
};
114
typedef IntPointTyped<UnknownUnits> IntPoint;
115
116
template<class units, class F = Float>
117
struct PointTyped :
118
  public BasePoint< F, PointTyped<units, F>, CoordTyped<units, F> >,
119
  public units {
120
  static_assert(IsPixel<units>::value,
121
                "'units' must be a coordinate system tag");
122
123
  typedef CoordTyped<units, F> Coord;
124
  typedef BasePoint< F, PointTyped<units, F>, CoordTyped<units, F> > Super;
125
126
0
  constexpr PointTyped() : Super() {}
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float>::PointTyped()
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ScreenPixel, float>::PointTyped()
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float>::PointTyped()
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::CSSPixel, float>::PointTyped()
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayerPixel, float>::PointTyped()
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ParentLayerPixel, float>::PointTyped()
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::RenderTargetPixel, float>::PointTyped()
127
0
  constexpr PointTyped(F aX, F aY) : Super(Coord(aX), Coord(aY)) {}
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::CSSPixel, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayerPixel, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ScreenPixel, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ParentLayerPixel, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::RenderTargetPixel, float>::PointTyped(float, float)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::DesktopPixel, float>::PointTyped(float, float)
128
  // The mixed-type constructors (Float, Coord) and (Coord, Float) are needed to
129
  // avoid ambiguities because Coord is implicitly convertible to Float.
130
0
  constexpr PointTyped(F aX, Coord aY) : Super(Coord(aX), aY) {}
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ParentLayerPixel, float>::PointTyped(float, mozilla::gfx::CoordTyped<mozilla::ParentLayerPixel, float>)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ScreenPixel, float>::PointTyped(float, mozilla::gfx::CoordTyped<mozilla::ScreenPixel, float>)
131
0
  constexpr PointTyped(Coord aX, F aY) : Super(aX, Coord(aY)) {}
132
0
  constexpr PointTyped(Coord aX, Coord aY) : Super(aX.value, aY.value) {}
133
0
  constexpr MOZ_IMPLICIT PointTyped(const IntPointTyped<units>& point) : Super(F(point.x), F(point.y)) {}
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float>::PointTyped(mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits> const&)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayerPixel, float>::PointTyped(mozilla::gfx::IntPointTyped<mozilla::LayerPixel> const&)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float>::PointTyped(mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel> const&)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ScreenPixel, float>::PointTyped(mozilla::gfx::IntPointTyped<mozilla::ScreenPixel> const&)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::CSSPixel, float>::PointTyped(mozilla::gfx::IntPointTyped<mozilla::CSSPixel> const&)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ParentLayerPixel, float>::PointTyped(mozilla::gfx::IntPointTyped<mozilla::ParentLayerPixel> const&)
134
135
0
  bool WithinEpsilonOf(const PointTyped<units, F>& aPoint, F aEpsilon) {
136
0
    return fabs(aPoint.x - this->x) < aEpsilon && fabs(aPoint.y - this->y) < aEpsilon;
137
0
  }
138
139
  // XXX When all of the code is ported, the following functions to convert to and from
140
  // unknown types should be removed.
141
142
0
  static PointTyped<units, F> FromUnknownPoint(const PointTyped<UnknownUnits, F>& aPoint) {
143
0
    return PointTyped<units, F>(aPoint.x, aPoint.y);
144
0
  }
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::CSSPixel, float>::FromUnknownPoint(mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float> const&)
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float>::FromUnknownPoint(mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float> const&)
145
146
0
  PointTyped<UnknownUnits, F> ToUnknownPoint() const {
147
0
    return PointTyped<UnknownUnits, F>(this->x, this->y);
148
0
  }
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::ParentLayerPixel, float>::ToUnknownPoint() const
Unexecuted instantiation: mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float>::ToUnknownPoint() const
149
};
150
typedef PointTyped<UnknownUnits> Point;
151
typedef PointTyped<UnknownUnits, double> PointDouble;
152
153
template<class units>
154
0
IntPointTyped<units> RoundedToInt(const PointTyped<units>& aPoint) {
155
0
  return IntPointTyped<units>::Round(aPoint.x, aPoint.y);
156
0
}
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel> mozilla::gfx::RoundedToInt<mozilla::LayoutDevicePixel>(mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ScreenPixel> mozilla::gfx::RoundedToInt<mozilla::ScreenPixel>(mozilla::gfx::PointTyped<mozilla::ScreenPixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::ParentLayerPixel> mozilla::gfx::RoundedToInt<mozilla::ParentLayerPixel>(mozilla::gfx::PointTyped<mozilla::ParentLayerPixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits> mozilla::gfx::RoundedToInt<mozilla::gfx::UnknownUnits>(mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::CSSPixel> mozilla::gfx::RoundedToInt<mozilla::CSSPixel>(mozilla::gfx::PointTyped<mozilla::CSSPixel, float> const&)
157
158
template<class units>
159
0
IntPointTyped<units> TruncatedToInt(const PointTyped<units>& aPoint) {
160
0
  return IntPointTyped<units>::Truncate(aPoint.x, aPoint.y);
161
0
}
162
163
template<class units, class F = Float>
164
struct Point3DTyped :
165
  public BasePoint3D< F, Point3DTyped<units, F> > {
166
  static_assert(IsPixel<units>::value,
167
                "'units' must be a coordinate system tag");
168
169
  typedef BasePoint3D< F, Point3DTyped<units, F> > Super;
170
171
0
  Point3DTyped() : Super() {}
172
  Point3DTyped(F aX, F aY, F aZ) : Super(aX, aY, aZ) {}
173
174
  // XXX When all of the code is ported, the following functions to convert to and from
175
  // unknown types should be removed.
176
177
  static Point3DTyped<units, F> FromUnknownPoint(const Point3DTyped<UnknownUnits, F>& aPoint) {
178
    return Point3DTyped<units, F>(aPoint.x, aPoint.y, aPoint.z);
179
  }
180
181
  Point3DTyped<UnknownUnits, F> ToUnknownPoint() const {
182
    return Point3DTyped<UnknownUnits, F>(this->x, this->y, this->z);
183
  }
184
};
185
typedef Point3DTyped<UnknownUnits> Point3D;
186
typedef Point3DTyped<UnknownUnits, double> PointDouble3D;
187
188
template<typename units>
189
IntPointTyped<units>
190
IntPointTyped<units>::Round(const PointTyped<units, float>& aPoint)
191
0
{
192
0
  return IntPointTyped::Round(aPoint.x, aPoint.y);
193
0
}
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::gfx::UnknownUnits>::Round(mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayerPixel>::Round(mozilla::gfx::PointTyped<mozilla::LayerPixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntPointTyped<mozilla::LayoutDevicePixel>::Round(mozilla::gfx::PointTyped<mozilla::LayoutDevicePixel, float> const&)
194
195
template<typename units>
196
IntPointTyped<units>
197
IntPointTyped<units>::Ceil(const PointTyped<units, float>& aPoint)
198
{
199
  return IntPointTyped::Ceil(aPoint.x, aPoint.y);
200
}
201
202
template<typename units>
203
IntPointTyped<units>
204
IntPointTyped<units>::Floor(const PointTyped<units, float>& aPoint)
205
0
{
206
0
  return IntPointTyped::Floor(aPoint.x, aPoint.y);
207
0
}
208
209
template<typename units>
210
IntPointTyped<units>
211
IntPointTyped<units>::Truncate(const PointTyped<units, float>& aPoint)
212
0
{
213
0
  return IntPointTyped::Truncate(aPoint.x, aPoint.y);
214
0
}
215
216
template<class units, class F = Float>
217
struct Point4DTyped :
218
  public BasePoint4D< F, Point4DTyped<units, F> > {
219
  static_assert(IsPixel<units>::value,
220
                "'units' must be a coordinate system tag");
221
222
  typedef BasePoint4D< F, Point4DTyped<units, F> > Super;
223
224
0
  Point4DTyped() : Super() {}
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float>::Point4DTyped()
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double>::Point4DTyped()
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::ScreenPixel, float>::Point4DTyped()
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::ParentLayerPixel, float>::Point4DTyped()
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float>::Point4DTyped()
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::RenderTargetPixel, float>::Point4DTyped()
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::LayoutDevicePixel, float>::Point4DTyped()
225
0
  Point4DTyped(F aX, F aY, F aZ, F aW) : Super(aX, aY, aZ, aW) {}
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float>::Point4DTyped(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double>::Point4DTyped(double, double, double, double)
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::ParentLayerPixel, float>::Point4DTyped(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::ScreenPixel, float>::Point4DTyped(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float>::Point4DTyped(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::LayoutDevicePixel, float>::Point4DTyped(float, float, float, float)
226
227
  explicit Point4DTyped(const Point3DTyped<units, F>& aPoint)
228
    : Super(aPoint.x, aPoint.y, aPoint.z, 1) {}
229
230
  // XXX When all of the code is ported, the following functions to convert to and from
231
  // unknown types should be removed.
232
233
  static Point4DTyped<units, F> FromUnknownPoint(const Point4DTyped<UnknownUnits, F>& aPoint) {
234
    return Point4DTyped<units, F>(aPoint.x, aPoint.y, aPoint.z, aPoint.w);
235
  }
236
237
  Point4DTyped<UnknownUnits, F> ToUnknownPoint() const {
238
    return Point4DTyped<UnknownUnits, F>(this->x, this->y, this->z, this->w);
239
  }
240
241
0
  PointTyped<units, F> As2DPoint() const {
242
0
    return PointTyped<units, F>(this->x / this->w,
243
0
                                this->y / this->w);
244
0
  }
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float>::As2DPoint() const
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double>::As2DPoint() const
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::ScreenPixel, float>::As2DPoint() const
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::ParentLayerPixel, float>::As2DPoint() const
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float>::As2DPoint() const
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::RenderTargetPixel, float>::As2DPoint() const
Unexecuted instantiation: mozilla::gfx::Point4DTyped<mozilla::LayoutDevicePixel, float>::As2DPoint() const
245
246
  Point3DTyped<units, F> As3DPoint() const {
247
    return Point3DTyped<units, F>(this->x / this->w,
248
                                  this->y / this->w,
249
                                  this->z / this->w);
250
  }
251
};
252
typedef Point4DTyped<UnknownUnits> Point4D;
253
typedef Point4DTyped<UnknownUnits, double> PointDouble4D;
254
255
template<class units>
256
struct IntSizeTyped :
257
  public BaseSize< int32_t, IntSizeTyped<units> >,
258
  public units {
259
  static_assert(IsPixel<units>::value,
260
                "'units' must be a coordinate system tag");
261
262
  typedef IntParam<int32_t> ToInt;
263
  typedef BaseSize< int32_t, IntSizeTyped<units> > Super;
264
265
0
  constexpr IntSizeTyped() : Super() {}
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits>::IntSizeTyped()
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayoutDevicePixel>::IntSizeTyped()
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::ScreenPixel>::IntSizeTyped()
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::TileCoordUnit>::IntSizeTyped()
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::CSSPixel>::IntSizeTyped()
266
0
  constexpr IntSizeTyped(ToInt aWidth, ToInt aHeight) : Super(aWidth.value, aHeight.value) {}
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayoutDevicePixel>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::RenderTargetPixel>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayerPixel>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::TileCoordUnit>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::CSSPixel>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::ScreenPixel>::IntSizeTyped(mozilla::gfx::IntParam<int>, mozilla::gfx::IntParam<int>)
267
268
0
  static IntSizeTyped<units> Round(float aWidth, float aHeight) {
269
0
    return IntSizeTyped(int32_t(floorf(aWidth + 0.5)), int32_t(floorf(aHeight + 0.5)));
270
0
  }
271
272
0
  static IntSizeTyped<units> Truncate(float aWidth, float aHeight) {
273
0
    return IntSizeTyped(int32_t(aWidth), int32_t(aHeight));
274
0
  }
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayoutDevicePixel>::Truncate(float, float)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::CSSPixel>::Truncate(float, float)
275
276
0
  static IntSizeTyped<units> Ceil(float aWidth, float aHeight) {
277
0
    return IntSizeTyped(int32_t(ceil(aWidth)), int32_t(ceil(aHeight)));
278
0
  }
279
280
  static IntSizeTyped<units> Floor(float aWidth, float aHeight) {
281
    return IntSizeTyped(int32_t(floorf(aWidth)), int32_t(floorf(aHeight)));
282
  }
283
284
  static IntSizeTyped<units> Round(const SizeTyped<units, float>& aSize);
285
  static IntSizeTyped<units> Ceil(const SizeTyped<units, float>& aSize);
286
  static IntSizeTyped<units> Floor(const SizeTyped<units, float>& aSize);
287
  static IntSizeTyped<units> Truncate(const SizeTyped<units, float>& aSize);
288
289
  // XXX When all of the code is ported, the following functions to convert to and from
290
  // unknown types should be removed.
291
292
  static IntSizeTyped<units> FromUnknownSize(const IntSizeTyped<UnknownUnits>& aSize) {
293
    return IntSizeTyped<units>(aSize.width, aSize.height);
294
  }
295
296
0
  IntSizeTyped<UnknownUnits> ToUnknownSize() const {
297
0
    return IntSizeTyped<UnknownUnits>(this->width, this->height);
298
0
  }
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayerPixel>::ToUnknownSize() const
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayoutDevicePixel>::ToUnknownSize() const
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::RenderTargetPixel>::ToUnknownSize() const
299
};
300
typedef IntSizeTyped<UnknownUnits> IntSize;
301
typedef Maybe<IntSize> MaybeIntSize;
302
303
template<class units, class F = Float>
304
struct SizeTyped :
305
  public BaseSize< F, SizeTyped<units, F> >,
306
  public units {
307
  static_assert(IsPixel<units>::value,
308
                "'units' must be a coordinate system tag");
309
310
  typedef BaseSize< F, SizeTyped<units, F> > Super;
311
312
0
  constexpr SizeTyped() : Super() {}
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::CSSPixel, float>::SizeTyped()
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::ParentLayerPixel, float>::SizeTyped()
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::gfx::UnknownUnits, double>::SizeTyped()
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::ScreenPixel, float>::SizeTyped()
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::LayoutDevicePixel, float>::SizeTyped()
313
0
  constexpr SizeTyped(F aWidth, F aHeight) : Super(aWidth, aHeight) {}
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::CSSPixel, float>::SizeTyped(float, float)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::gfx::UnknownUnits, float>::SizeTyped(float, float)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::ParentLayerPixel, float>::SizeTyped(float, float)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::gfx::UnknownUnits, double>::SizeTyped(double, double)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::LayerPixel, float>::SizeTyped(float, float)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::LayoutDevicePixel, float>::SizeTyped(float, float)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::ScreenPixel, float>::SizeTyped(float, float)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::DesktopPixel, float>::SizeTyped(float, float)
314
  explicit SizeTyped(const IntSizeTyped<units>& size) :
315
0
    Super(F(size.width), F(size.height)) {}
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::gfx::UnknownUnits, float>::SizeTyped(mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits> const&)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::gfx::UnknownUnits, double>::SizeTyped(mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits> const&)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::LayoutDevicePixel, float>::SizeTyped(mozilla::gfx::IntSizeTyped<mozilla::LayoutDevicePixel> const&)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::LayerPixel, float>::SizeTyped(mozilla::gfx::IntSizeTyped<mozilla::LayerPixel> const&)
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::ScreenPixel, float>::SizeTyped(mozilla::gfx::IntSizeTyped<mozilla::ScreenPixel> const&)
316
317
  // XXX When all of the code is ported, the following functions to convert to and from
318
  // unknown types should be removed.
319
320
0
  static SizeTyped<units, F> FromUnknownSize(const SizeTyped<UnknownUnits, F>& aSize) {
321
0
    return SizeTyped<units, F>(aSize.width, aSize.height);
322
0
  }
323
324
0
  SizeTyped<UnknownUnits, F> ToUnknownSize() const {
325
0
    return SizeTyped<UnknownUnits, F>(this->width, this->height);
326
0
  }
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::DesktopPixel, float>::ToUnknownSize() const
Unexecuted instantiation: mozilla::gfx::SizeTyped<mozilla::LayoutDevicePixel, float>::ToUnknownSize() const
327
};
328
typedef SizeTyped<UnknownUnits> Size;
329
typedef SizeTyped<UnknownUnits, double> SizeDouble;
330
331
template<class units>
332
0
IntSizeTyped<units> RoundedToInt(const SizeTyped<units>& aSize) {
333
0
  return IntSizeTyped<units>(int32_t(floorf(aSize.width + 0.5f)),
334
0
                             int32_t(floorf(aSize.height + 0.5f)));
335
0
}
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayerPixel> mozilla::gfx::RoundedToInt<mozilla::LayerPixel>(mozilla::gfx::SizeTyped<mozilla::LayerPixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::CSSPixel> mozilla::gfx::RoundedToInt<mozilla::CSSPixel>(mozilla::gfx::SizeTyped<mozilla::CSSPixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::ScreenPixel> mozilla::gfx::RoundedToInt<mozilla::ScreenPixel>(mozilla::gfx::SizeTyped<mozilla::ScreenPixel, float> const&)
Unexecuted instantiation: mozilla::gfx::IntSizeTyped<mozilla::LayoutDevicePixel> mozilla::gfx::RoundedToInt<mozilla::LayoutDevicePixel>(mozilla::gfx::SizeTyped<mozilla::LayoutDevicePixel, float> const&)
336
337
template<typename units> IntSizeTyped<units>
338
0
IntSizeTyped<units>::Round(const SizeTyped<units, float>& aSize) {
339
0
  return IntSizeTyped::Round(aSize.width, aSize.height);
340
0
}
341
342
template<typename units> IntSizeTyped<units>
343
0
IntSizeTyped<units>::Ceil(const SizeTyped<units, float>& aSize) {
344
0
  return IntSizeTyped::Ceil(aSize.width, aSize.height);
345
0
}
346
347
template<typename units> IntSizeTyped<units>
348
IntSizeTyped<units>::Floor(const SizeTyped<units, float>& aSize) {
349
  return IntSizeTyped::Floor(aSize.width, aSize.height);
350
}
351
352
template<typename units> IntSizeTyped<units>
353
0
IntSizeTyped<units>::Truncate(const SizeTyped<units, float>& aSize) {
354
0
  return IntSizeTyped::Truncate(aSize.width, aSize.height);
355
0
}
356
357
} // namespace gfx
358
} // namespace mozilla
359
360
#endif /* MOZILLA_GFX_POINT_H_ */