Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/gfx/Triangle.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_TRIANGLE_H
8
#define MOZILLA_GFX_TRIANGLE_H
9
10
#include <algorithm>
11
12
#include "mozilla/Move.h"
13
#include "Point.h"
14
#include "Rect.h"
15
16
namespace mozilla {
17
namespace gfx {
18
19
/**
20
 * A simple triangle data structure.
21
 */
22
template<class Units, class F = Float>
23
struct TriangleTyped
24
{
25
  PointTyped<Units, F> p1, p2, p3;
26
27
  TriangleTyped()
28
0
    : p1(), p2(), p3() {}
29
30
  TriangleTyped(PointTyped<Units, F> aP1,
31
                PointTyped<Units, F> aP2,
32
                PointTyped<Units, F> aP3)
33
0
    : p1(aP1), p2(aP2), p3(aP3) {}
34
35
  RectTyped<Units, F> BoundingBox() const
36
0
  {
37
0
    F minX = std::min(std::min(p1.x, p2.x), p3.x);
38
0
    F maxX = std::max(std::max(p1.x, p2.x), p3.x);
39
0
40
0
    F minY = std::min(std::min(p1.y, p2.y), p3.y);
41
0
    F maxY = std::max(std::max(p1.y, p2.y), p3.y);
42
0
43
0
    return RectTyped<Units, F>(minX, minY, maxX - minX, maxY - minY);
44
0
  }
45
};
46
47
typedef TriangleTyped<UnknownUnits, Float> Triangle;
48
49
template<class Units, class F = Float>
50
struct TexturedTriangleTyped : public TriangleTyped<Units, F>
51
{
52
  explicit TexturedTriangleTyped(const TriangleTyped<Units, F>& aTriangle)
53
0
    : TriangleTyped<Units, F>(aTriangle) {}
54
55
  explicit TexturedTriangleTyped(TriangleTyped<Units, F>&& aTriangle)
56
    : TriangleTyped<Units, F>(std::move(aTriangle)) {}
57
58
  TriangleTyped<Units, F> textureCoords;
59
};
60
61
typedef TexturedTriangleTyped<UnknownUnits, Float> TexturedTriangle;
62
63
} // namespace gfx
64
} // namespace mozilla
65
66
#endif /* MOZILLA_GFX_TRIANGLE_H */