Coverage Report

Created: 2025-08-26 06:51

/src/dng_sdk/source/dng_point.h
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************/
2
// Copyright 2006 Adobe Systems Incorporated
3
// All Rights Reserved.
4
//
5
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
6
// accordance with the terms of the Adobe license agreement accompanying it.
7
/*****************************************************************************/
8
9
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_point.h#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
/*****************************************************************************/
15
16
#ifndef __dng_point__
17
#define __dng_point__
18
19
/*****************************************************************************/
20
21
#include "dng_safe_arithmetic.h"
22
#include "dng_types.h"
23
#include "dng_utils.h"
24
25
/*****************************************************************************/
26
27
class dng_point
28
  {
29
  
30
  public:
31
  
32
    int32 v;
33
    int32 h;
34
  
35
  public:
36
  
37
    dng_point ()
38
10.1M
      : v (0)
39
10.1M
      , h (0)
40
10.1M
      {
41
10.1M
      }
42
      
43
    dng_point (int32 vv, int32 hh)
44
6.35M
      : v (vv)
45
6.35M
      , h (hh)
46
6.35M
      {
47
6.35M
      }
48
      
49
    bool operator== (const dng_point &pt) const
50
245k
      {
51
245k
      return (v == pt.v) &&
52
245k
           (h == pt.h);
53
245k
      }
54
      
55
    bool operator!= (const dng_point &pt) const
56
137k
      {
57
137k
      return !(*this == pt);
58
137k
      }
59
      
60
  };
61
62
/*****************************************************************************/
63
64
class dng_point_real64
65
  {
66
  
67
  public:
68
  
69
    real64 v;
70
    real64 h;
71
  
72
  public:
73
  
74
    dng_point_real64 ()
75
222M
      : v (0.0)
76
222M
      , h (0.0)
77
222M
      {
78
222M
      }
79
      
80
    dng_point_real64 (real64 vv, real64 hh)
81
1.33k
      : v (vv)
82
1.33k
      , h (hh)
83
1.33k
      {
84
1.33k
      }
85
      
86
    dng_point_real64 (const dng_point &pt)
87
      : v ((real64) pt.v)
88
      , h ((real64) pt.h)
89
0
      {
90
0
      }
91
      
92
    bool operator== (const dng_point_real64 &pt) const
93
17.7M
      {
94
17.7M
      return (v == pt.v) &&
95
17.7M
           (h == pt.h);
96
17.7M
      }
97
      
98
    bool operator!= (const dng_point_real64 &pt) const
99
0
      {
100
0
      return !(*this == pt);
101
0
      }
102
      
103
    dng_point Round () const
104
0
      {
105
0
      return dng_point (Round_int32 (v),
106
0
                Round_int32 (h));
107
0
      }
108
      
109
  };
110
111
/*****************************************************************************/
112
113
inline dng_point operator+ (const dng_point &a,
114
                const dng_point &b)
115
          
116
          
117
31
  {
118
  
119
31
  return dng_point (SafeInt32Add(a.v, b.v),
120
31
            SafeInt32Add(a.h, b.h));
121
            
122
31
  }
123
124
/*****************************************************************************/
125
126
inline dng_point_real64 operator+ (const dng_point_real64 &a,
127
                     const dng_point_real64 &b)
128
          
129
          
130
0
  {
131
  
132
0
  return dng_point_real64 (a.v + b.v,
133
0
                 a.h + b.h);
134
            
135
0
  }
136
137
/*****************************************************************************/
138
139
inline dng_point operator- (const dng_point &a,
140
                const dng_point &b)
141
          
142
          
143
62
  {
144
  
145
62
  return dng_point (SafeInt32Sub(a.v, b.v),
146
62
            SafeInt32Sub(a.h, b.h));
147
            
148
62
  }
149
150
/*****************************************************************************/
151
152
inline dng_point_real64 operator- (const dng_point_real64 &a,
153
                     const dng_point_real64 &b)
154
          
155
          
156
0
  {
157
  
158
0
  return dng_point_real64 (a.v - b.v,
159
0
                   a.h - b.h);
160
            
161
0
  }
162
163
/*****************************************************************************/
164
165
inline real64 DistanceSquared (const dng_point_real64 &a,
166
                 const dng_point_real64 &b)
167
          
168
          
169
0
  {
170
171
0
  dng_point_real64 diff = a - b;
172
173
0
  return (diff.v * diff.v) + (diff.h * diff.h);
174
            
175
0
  }
176
177
/*****************************************************************************/
178
179
inline dng_point Transpose (const dng_point &a)
180
0
  {
181
0
  
182
0
  return dng_point (a.h, a.v);
183
0
  
184
0
  }
185
186
/*****************************************************************************/
187
188
inline dng_point_real64 Transpose (const dng_point_real64 &a)
189
0
  {
190
0
  
191
0
  return dng_point_real64 (a.h, a.v);
192
0
  
193
0
  }
194
195
/*****************************************************************************/
196
197
#endif
198
  
199
/*****************************************************************************/