2005-04-06 01:54:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-04-06 01:54:26 +00:00
|
|
|
|
2005-04-11 04:36:18 +00:00
|
|
|
#ifndef GFX_POINT_H
|
|
|
|
#define GFX_POINT_H
|
2005-04-08 05:44:32 +00:00
|
|
|
|
2008-01-07 07:00:49 +00:00
|
|
|
#include "nsMathUtils.h"
|
2011-06-24 17:41:16 +00:00
|
|
|
#include "mozilla/gfx/BaseSize.h"
|
|
|
|
#include "mozilla/gfx/BasePoint.h"
|
2011-04-19 03:07:21 +00:00
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsPoint.h"
|
2005-06-28 09:18:55 +00:00
|
|
|
|
2005-04-08 05:44:32 +00:00
|
|
|
#include "gfxTypes.h"
|
2005-04-06 01:54:26 +00:00
|
|
|
|
2013-05-29 21:59:24 +00:00
|
|
|
struct gfxSize : public mozilla::gfx::BaseSize<gfxFloat, gfxSize> {
|
2011-06-24 17:41:16 +00:00
|
|
|
typedef mozilla::gfx::BaseSize<gfxFloat, gfxSize> Super;
|
2007-02-08 20:47:48 +00:00
|
|
|
|
2011-04-19 03:07:21 +00:00
|
|
|
gfxSize() : Super() {}
|
|
|
|
gfxSize(gfxFloat aWidth, gfxFloat aHeight) : Super(aWidth, aHeight) {}
|
2014-07-29 12:07:24 +00:00
|
|
|
MOZ_IMPLICIT gfxSize(const nsIntSize& aSize) : Super(aSize.width, aSize.height) {}
|
2005-04-06 01:54:26 +00:00
|
|
|
};
|
|
|
|
|
2013-05-29 21:59:24 +00:00
|
|
|
struct gfxPoint : public mozilla::gfx::BasePoint<gfxFloat, gfxPoint> {
|
2011-06-24 17:41:16 +00:00
|
|
|
typedef mozilla::gfx::BasePoint<gfxFloat, gfxPoint> Super;
|
2007-02-08 20:47:48 +00:00
|
|
|
|
2011-04-19 03:07:21 +00:00
|
|
|
gfxPoint() : Super() {}
|
|
|
|
gfxPoint(gfxFloat aX, gfxFloat aY) : Super(aX, aY) {}
|
2014-07-29 12:07:24 +00:00
|
|
|
MOZ_IMPLICIT gfxPoint(const nsIntPoint& aPoint) : Super(aPoint.x, aPoint.y) {}
|
2007-02-08 20:47:48 +00:00
|
|
|
|
2012-08-16 23:38:59 +00:00
|
|
|
bool WithinEpsilonOf(const gfxPoint& aPoint, gfxFloat aEpsilon) {
|
|
|
|
return fabs(aPoint.x - x) < aEpsilon && fabs(aPoint.y - y) < aEpsilon;
|
|
|
|
}
|
2005-04-06 01:54:26 +00:00
|
|
|
};
|
|
|
|
|
2012-12-23 15:50:30 +00:00
|
|
|
inline gfxPoint
|
|
|
|
operator*(const gfxPoint& aPoint, const gfxSize& aSize)
|
|
|
|
{
|
|
|
|
return gfxPoint(aPoint.x * aSize.width, aPoint.y * aSize.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline gfxPoint
|
|
|
|
operator/(const gfxPoint& aPoint, const gfxSize& aSize)
|
|
|
|
{
|
|
|
|
return gfxPoint(aPoint.x / aSize.width, aPoint.y / aSize.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline gfxSize
|
|
|
|
operator/(gfxFloat aValue, const gfxSize& aSize)
|
|
|
|
{
|
|
|
|
return gfxSize(aValue / aSize.width, aValue / aSize.height);
|
|
|
|
}
|
|
|
|
|
2005-04-11 04:36:18 +00:00
|
|
|
#endif /* GFX_POINT_H */
|