Bug 1885602 - Part 4: Implement navigating to the settings from the menu header for...
[gecko.git] / gfx / 2d / Triangle.h
blob2e6fa2f54ca619007fe31858c3c765eb0627b1d6
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/. */
7 #ifndef MOZILLA_GFX_TRIANGLE_H
8 #define MOZILLA_GFX_TRIANGLE_H
10 #include <algorithm>
11 #include <utility>
13 #include "Point.h"
14 #include "Rect.h"
16 namespace mozilla {
17 namespace gfx {
19 /**
20 * A simple triangle data structure.
22 template <class Units, class F = Float>
23 struct TriangleTyped {
24 PointTyped<Units, F> p1, p2, p3;
26 TriangleTyped() : p1(), p2(), p3() {}
28 TriangleTyped(PointTyped<Units, F> aP1, PointTyped<Units, F> aP2,
29 PointTyped<Units, F> aP3)
30 : p1(aP1), p2(aP2), p3(aP3) {}
32 RectTyped<Units, F> BoundingBox() const {
33 F minX = std::min(std::min(p1.x, p2.x), p3.x);
34 F maxX = std::max(std::max(p1.x, p2.x), p3.x);
36 F minY = std::min(std::min(p1.y, p2.y), p3.y);
37 F maxY = std::max(std::max(p1.y, p2.y), p3.y);
39 return RectTyped<Units, F>(minX, minY, maxX - minX, maxY - minY);
43 typedef TriangleTyped<UnknownUnits, Float> Triangle;
45 template <class Units, class F = Float>
46 struct TexturedTriangleTyped : public TriangleTyped<Units, F> {
47 explicit TexturedTriangleTyped(const TriangleTyped<Units, F>& aTriangle)
48 : TriangleTyped<Units, F>(aTriangle) {}
50 explicit TexturedTriangleTyped(TriangleTyped<Units, F>&& aTriangle)
51 : TriangleTyped<Units, F>(std::move(aTriangle)) {}
53 TriangleTyped<Units, F> textureCoords;
56 typedef TexturedTriangleTyped<UnknownUnits, Float> TexturedTriangle;
58 } // namespace gfx
59 } // namespace mozilla
61 #endif /* MOZILLA_GFX_TRIANGLE_H */