Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_POINT_H
7 #define GFX_POINT_H
9 #include "nsMathUtils.h"
10 #include "mozilla/gfx/BaseSize.h"
11 #include "mozilla/gfx/BasePoint.h"
12 #include "nsSize.h"
13 #include "nsPoint.h"
15 #include "gfxTypes.h"
17 struct gfxSize : public mozilla::gfx::BaseSize<gfxFloat, gfxSize> {
18 typedef mozilla::gfx::BaseSize<gfxFloat, gfxSize> Super;
20 gfxSize() : Super() {}
21 gfxSize(gfxFloat aWidth, gfxFloat aHeight) : Super(aWidth, aHeight) {}
22 gfxSize(const nsIntSize& aSize) : Super(aSize.width, aSize.height) {}
23 };
25 struct gfxPoint : public mozilla::gfx::BasePoint<gfxFloat, gfxPoint> {
26 typedef mozilla::gfx::BasePoint<gfxFloat, gfxPoint> Super;
28 gfxPoint() : Super() {}
29 gfxPoint(gfxFloat aX, gfxFloat aY) : Super(aX, aY) {}
30 gfxPoint(const nsIntPoint& aPoint) : Super(aPoint.x, aPoint.y) {}
32 bool WithinEpsilonOf(const gfxPoint& aPoint, gfxFloat aEpsilon) {
33 return fabs(aPoint.x - x) < aEpsilon && fabs(aPoint.y - y) < aEpsilon;
34 }
35 };
37 inline gfxPoint
38 operator*(const gfxPoint& aPoint, const gfxSize& aSize)
39 {
40 return gfxPoint(aPoint.x * aSize.width, aPoint.y * aSize.height);
41 }
43 inline gfxPoint
44 operator/(const gfxPoint& aPoint, const gfxSize& aSize)
45 {
46 return gfxPoint(aPoint.x / aSize.width, aPoint.y / aSize.height);
47 }
49 inline gfxSize
50 operator/(gfxFloat aValue, const gfxSize& aSize)
51 {
52 return gfxSize(aValue / aSize.width, aValue / aSize.height);
53 }
55 #endif /* GFX_POINT_H */