gfx/thebes/gfxPoint.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial