Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/gfx/BasePoint4D.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_BASEPOINT4D_H_
8
#define MOZILLA_BASEPOINT4D_H_
9
10
#include "mozilla/Assertions.h"
11
12
namespace mozilla {
13
namespace gfx {
14
15
/**
16
 * Do not use this class directly. Subclass it, pass that subclass as the
17
 * Sub parameter, and only use that subclass. This allows methods to safely
18
 * cast 'this' to 'Sub*'.
19
 */
20
template <class T, class Sub>
21
struct BasePoint4D {
22
  union {
23
    struct {
24
      T x, y, z, w;
25
    };
26
    T components[4];
27
  };
28
29
  // Constructors
30
0
  BasePoint4D() : x(0), y(0), z(0), w(0) {}
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::BasePoint4D()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::ScreenPixel, float> >::BasePoint4D()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::ParentLayerPixel, float> >::BasePoint4D()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> >::BasePoint4D()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::RenderTargetPixel, float> >::BasePoint4D()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, gfxQuaternion>::BasePoint4D()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayoutDevicePixel, float> >::BasePoint4D()
31
0
  BasePoint4D(T aX, T aY, T aZ, T aW) : x(aX), y(aY), z(aZ), w(aW) {}
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::BasePoint4D(double, double, double, double)
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::ParentLayerPixel, float> >::BasePoint4D(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::ScreenPixel, float> >::BasePoint4D(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> >::BasePoint4D(float, float, float, float)
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, gfxQuaternion>::BasePoint4D(double, double, double, double)
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayoutDevicePixel, float> >::BasePoint4D(float, float, float, float)
32
33
  void MoveTo(T aX, T aY, T aZ, T aW) { x = aX; y = aY; z = aZ; w = aW; }
34
  void MoveBy(T aDx, T aDy, T aDz, T aDw) { x += aDx; y += aDy; z += aDz; w += aDw; }
35
36
  // Note that '=' isn't defined so we'll get the
37
  // compiler generated default assignment operator
38
39
  bool operator==(const Sub& aPoint) const {
40
    return x == aPoint.x && y == aPoint.y && 
41
           z == aPoint.z && w == aPoint.w;
42
  }
43
  bool operator!=(const Sub& aPoint) const {
44
    return x != aPoint.x || y != aPoint.y || 
45
           z != aPoint.z || w != aPoint.w;
46
  }
47
48
0
  Sub operator+(const Sub& aPoint) const {
49
0
    return Sub(x + aPoint.x, y + aPoint.y, z + aPoint.z, w + aPoint.w);
50
0
  }
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::operator+(mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> const&) const
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> >::operator+(mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> const&) const
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, gfxQuaternion>::operator+(gfxQuaternion const&) const
51
0
  Sub operator-(const Sub& aPoint) const {
52
0
    return Sub(x - aPoint.x, y - aPoint.y, z - aPoint.z, w - aPoint.w);
53
0
  }
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float> >::operator-(mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float> const&) const
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> >::operator-(mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> const&) const
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::operator-(mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> const&) const
54
0
  Sub& operator+=(const Sub& aPoint) {
55
0
    x += aPoint.x;
56
0
    y += aPoint.y;
57
0
    z += aPoint.z;
58
0
    w += aPoint.w;
59
0
    return *static_cast<Sub*>(this);
60
0
  }
61
0
  Sub& operator-=(const Sub& aPoint) {
62
0
    x -= aPoint.x;
63
0
    y -= aPoint.y;
64
0
    z -= aPoint.z;
65
0
    w -= aPoint.w;
66
0
    return *static_cast<Sub*>(this);
67
0
  }
68
69
0
  Sub operator*(T aScale) const {
70
0
    return Sub(x * aScale, y * aScale, z * aScale, w * aScale);
71
0
  }
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::operator*(double) const
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> >::operator*(float) const
72
0
  Sub operator/(T aScale) const {
73
0
    return Sub(x / aScale, y / aScale, z / aScale, w / aScale);
74
0
  }
75
76
0
  Sub& operator*=(T aScale) {
77
0
    x *= aScale;
78
0
    y *= aScale;
79
0
    z *= aScale;
80
0
    w *= aScale;
81
0
    return *static_cast<Sub*>(this);
82
0
  }
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, gfxQuaternion>::operator*=(double)
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float> >::operator*=(float)
83
84
0
  Sub& operator/=(T aScale) {
85
0
    x /= aScale;
86
0
    y /= aScale;
87
0
    z /= aScale;
88
0
    w /= aScale;
89
0
    return *static_cast<Sub*>(this);
90
0
  }
91
92
  Sub operator-() const {
93
    return Sub(-x, -y, -z, -w);
94
  }
95
96
0
  T& operator[](int aIndex) {
97
0
    MOZ_ASSERT(aIndex >= 0 && aIndex <= 3, "Invalid array index");
98
0
    return *((&x)+aIndex);
99
0
  }
100
101
0
  const T& operator[](int aIndex) const {
102
0
    MOZ_ASSERT(aIndex >= 0 && aIndex <= 3, "Invalid array index");
103
0
    return *((&x)+aIndex);
104
0
  }
105
106
0
  T DotProduct(const Sub& aPoint) const {
107
0
    return x * aPoint.x + y * aPoint.y + z * aPoint.z + w * aPoint.w;
108
0
  }
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::DotProduct(mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> const&) const
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, gfxQuaternion>::DotProduct(gfxQuaternion const&) const
109
110
  // Ignores the 4th component!
111
0
  Sub CrossProduct(const Sub& aPoint) const {
112
0
      return Sub(y * aPoint.z - aPoint.y * z,
113
0
          z * aPoint.x - aPoint.z * x,
114
0
          x * aPoint.y - aPoint.x * y, 
115
0
          0);
116
0
  }
117
118
0
  T Length() const {
119
0
    return sqrt(x*x + y*y + z*z + w*w);
120
0
  }
121
122
0
  void Normalize() {
123
0
    *this /= Length();
124
0
  }
125
126
0
  bool HasPositiveWCoord() { return w > 0; }
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::ParentLayerPixel, float> >::HasPositiveWCoord()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::ScreenPixel, float> >::HasPositiveWCoord()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::LayerPixel, float> >::HasPositiveWCoord()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<float, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, float> >::HasPositiveWCoord()
Unexecuted instantiation: mozilla::gfx::BasePoint4D<double, mozilla::gfx::Point4DTyped<mozilla::gfx::UnknownUnits, double> >::HasPositiveWCoord()
127
};
128
129
} // namespace gfx
130
} // namespace mozilla
131
132
#endif /* MOZILLA_BASEPOINT4D_H_ */