File tree 3 files changed +17
-11
lines changed
3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 8
8
#define MOZILLA_GFX_FONTVARIATION_H_
9
9
10
10
#include < stdint.h>
11
+ #include " mozilla/FloatingPoint.h"
11
12
12
- namespace mozilla {
13
- namespace gfx {
13
+ namespace mozilla ::gfx {
14
14
15
15
// An OpenType variation tag and value pair
16
16
struct FontVariation {
17
17
uint32_t mTag ;
18
18
float mValue ;
19
19
20
20
bool operator ==(const FontVariation& aOther) const {
21
- return mTag == aOther.mTag && mValue == aOther.mValue ;
21
+ return mTag == aOther.mTag &&
22
+ NumbersAreBitwiseIdentical (mValue , aOther.mValue );
22
23
}
23
24
};
24
25
25
- } // namespace gfx
26
- } // namespace mozilla
26
+ } // namespace mozilla::gfx
27
27
28
28
#endif /* MOZILLA_GFX_FONTVARIATION_H_ */
Original file line number Diff line number Diff line change @@ -219,8 +219,7 @@ struct gfxFontStyle {
219
219
}
220
220
221
221
bool Equals (const gfxFontStyle& other) const {
222
- return (*reinterpret_cast <const uint64_t *>(&size) ==
223
- *reinterpret_cast <const uint64_t *>(&other.size )) &&
222
+ return mozilla::NumbersAreBitwiseIdentical (size, other.size ) &&
224
223
(style == other.style ) && (weight == other.weight ) &&
225
224
(stretch == other.stretch ) && (variantCaps == other.variantCaps ) &&
226
225
(variantSubSuper == other.variantSubSuper ) &&
@@ -230,8 +229,7 @@ struct gfxFontStyle {
230
229
(printerFont == other.printerFont ) &&
231
230
(useGrayscaleAntialiasing == other.useGrayscaleAntialiasing ) &&
232
231
(baselineOffset == other.baselineOffset ) &&
233
- (*reinterpret_cast <const uint32_t *>(&sizeAdjust) ==
234
- *reinterpret_cast <const uint32_t *>(&other.sizeAdjust )) &&
232
+ mozilla::NumbersAreBitwiseIdentical (sizeAdjust, other.sizeAdjust ) &&
235
233
(featureSettings == other.featureSettings ) &&
236
234
(variantAlternates == other.variantAlternates ) &&
237
235
(featureValueLookup == other.featureValueLookup ) &&
Original file line number Diff line number Diff line change @@ -524,14 +524,22 @@ static MOZ_ALWAYS_INLINE T UnspecifiedNaN() {
524
524
*/
525
525
template <typename T>
526
526
static inline bool NumbersAreIdentical (T aValue1, T aValue2) {
527
- typedef FloatingPoint<T> Traits;
528
- typedef typename Traits::Bits Bits;
527
+ using Bits = typename FloatingPoint<T>::Bits;
529
528
if (IsNaN (aValue1)) {
530
529
return IsNaN (aValue2);
531
530
}
532
531
return BitwiseCast<Bits>(aValue1) == BitwiseCast<Bits>(aValue2);
533
532
}
534
533
534
+ /* *
535
+ * Compare two floating point values for bit-wise equality.
536
+ */
537
+ template <typename T>
538
+ static inline bool NumbersAreBitwiseIdentical (T aValue1, T aValue2) {
539
+ using Bits = typename FloatingPoint<T>::Bits;
540
+ return BitwiseCast<Bits>(aValue1) == BitwiseCast<Bits>(aValue2);
541
+ }
542
+
535
543
/* *
536
544
* Return true iff |aValue| and |aValue2| are equal (ignoring sign if both are
537
545
* zero) or both NaN.
You can’t perform that action at this time.
0 commit comments