src/hb-open-type-private.hh | 75 +++++++++++++++++++++++++++++++++++--------- src/hb-private.hh | 41 ------------------------ src/hb-uniscribe.cc | 6 +++ 3 files changed, 66 insertions(+), 56 deletions(-)
New commits: commit 5a5640d8506ccfc99fd119e89e829170d1fea421 Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 14 21:26:13 2014 -0700 Move code around diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 9807569..a58e790 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -552,57 +552,57 @@ struct BEInt<Type, 2> private: uint8_t v[2]; }; template <typename Type> -struct BEInt<Type, 4> +struct BEInt<Type, 3> { public: inline void set (Type V) { - v[0] = (V >> 24) & 0xFF; - v[1] = (V >> 16) & 0xFF; - v[2] = (V >> 8) & 0xFF; - v[3] = (V ) & 0xFF; + v[0] = (V >> 16) & 0xFF; + v[1] = (V >> 8) & 0xFF; + v[2] = (V ) & 0xFF; } inline operator Type (void) const { - return (v[0] << 24) - + (v[1] << 16) - + (v[2] << 8) - + (v[3] ); + return (v[0] << 16) + + (v[1] << 8) + + (v[2] ); } - inline bool operator == (const BEInt<Type, 4>& o) const + inline bool operator == (const BEInt<Type, 3>& o) const { return v[0] == o.v[0] && v[1] == o.v[1] - && v[2] == o.v[2] - && v[3] == o.v[3]; + && v[2] == o.v[2]; } - inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); } - private: uint8_t v[4]; + inline bool operator != (const BEInt<Type, 3>& o) const { return !(*this == o); } + private: uint8_t v[3]; }; template <typename Type> -struct BEInt<Type, 3> +struct BEInt<Type, 4> { public: inline void set (Type V) { - v[0] = (V >> 16) & 0xFF; - v[1] = (V >> 8) & 0xFF; - v[2] = (V ) & 0xFF; + v[0] = (V >> 24) & 0xFF; + v[1] = (V >> 16) & 0xFF; + v[2] = (V >> 8) & 0xFF; + v[3] = (V ) & 0xFF; } inline operator Type (void) const { - return (v[0] << 16) - + (v[1] << 8) - + (v[2] ); + return (v[0] << 24) + + (v[1] << 16) + + (v[2] << 8) + + (v[3] ); } - inline bool operator == (const BEInt<Type, 3>& o) const + inline bool operator == (const BEInt<Type, 4>& o) const { return v[0] == o.v[0] && v[1] == o.v[1] - && v[2] == o.v[2]; + && v[2] == o.v[2] + && v[3] == o.v[3]; } - inline bool operator != (const BEInt<Type, 3>& o) const { return !(*this == o); } - private: uint8_t v[3]; + inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); } + private: uint8_t v[4]; }; /* Integer types in big-endian order and no alignment requirement */ commit 666b42f73bd1f516657b206ef738108825bf239f Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 14 21:24:59 2014 -0700 Move macros around Fixes https://bugs.freedesktop.org/show_bug.cgi?id=84491 diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 475187b..9807569 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -533,9 +533,21 @@ template <typename Type> struct BEInt<Type, 2> { public: - inline void set (Type i) { hb_be_uint16_put (v,i); } - inline operator Type (void) const { return hb_be_uint16_get (v); } - inline bool operator == (const BEInt<Type, 2>& o) const { return hb_be_uint16_eq (v, o.v); } + inline void set (Type V) + { + v[0] = (V >> 8) & 0xFF; + v[1] = (V ) & 0xFF; + } + inline operator Type (void) const + { + return (v[0] << 8) + + (v[1] ); + } + inline bool operator == (const BEInt<Type, 2>& o) const + { + return v[0] == o.v[0] + && v[1] == o.v[1]; + } inline bool operator != (const BEInt<Type, 2>& o) const { return !(*this == o); } private: uint8_t v[2]; }; @@ -543,9 +555,27 @@ template <typename Type> struct BEInt<Type, 4> { public: - inline void set (Type i) { hb_be_uint32_put (v,i); } - inline operator Type (void) const { return hb_be_uint32_get (v); } - inline bool operator == (const BEInt<Type, 4>& o) const { return hb_be_uint32_eq (v, o.v); } + inline void set (Type V) + { + v[0] = (V >> 24) & 0xFF; + v[1] = (V >> 16) & 0xFF; + v[2] = (V >> 8) & 0xFF; + v[3] = (V ) & 0xFF; + } + inline operator Type (void) const + { + return (v[0] << 24) + + (v[1] << 16) + + (v[2] << 8) + + (v[3] ); + } + inline bool operator == (const BEInt<Type, 4>& o) const + { + return v[0] == o.v[0] + && v[1] == o.v[1] + && v[2] == o.v[2] + && v[3] == o.v[3]; + } inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); } private: uint8_t v[4]; }; @@ -553,9 +583,24 @@ template <typename Type> struct BEInt<Type, 3> { public: - inline void set (Type i) { hb_be_uint24_put (v,i); } - inline operator Type (void) const { return hb_be_uint24_get (v); } - inline bool operator == (const BEInt<Type, 3>& o) const { return hb_be_uint24_eq (v, o.v); } + inline void set (Type V) + { + v[0] = (V >> 16) & 0xFF; + v[1] = (V >> 8) & 0xFF; + v[2] = (V ) & 0xFF; + } + inline operator Type (void) const + { + return (v[0] << 16) + + (v[1] << 8) + + (v[2] ); + } + inline bool operator == (const BEInt<Type, 3>& o) const + { + return v[0] == o.v[0] + && v[1] == o.v[1] + && v[2] == o.v[2]; + } inline bool operator != (const BEInt<Type, 3>& o) const { return !(*this == o); } private: uint8_t v[3]; }; diff --git a/src/hb-private.hh b/src/hb-private.hh index 40d02ea..cd02e2b 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -539,47 +539,6 @@ struct hb_lockable_set_t }; - - -/* Big-endian handling */ - -static inline uint16_t hb_be_uint16 (const uint16_t v) -{ - const uint8_t *V = (const uint8_t *) &v; - return (V[0] << 8) | V[1]; -} - -static inline uint16_t hb_uint16_swap (const uint16_t v) -{ - return (v >> 8) | (v << 8); -} - -static inline uint32_t hb_uint32_swap (const uint32_t v) -{ - return (hb_uint16_swap (v) << 16) | hb_uint16_swap (v >> 16); -} - -/* Note, of the following macros, uint16_get is the one called many many times. - * If there is any optimizations to be done, it's in that macro. However, I - * already confirmed that on my T400 ThinkPad at least, using bswap_16(), which - * results in a single ror instruction, does NOT speed this up. In fact, it - * resulted in a minor slowdown. At any rate, note that v may not be correctly - * aligned, so I think the current implementation is optimal. - */ - -#define hb_be_uint16_put(v,V) HB_STMT_START { v[0] = (V>>8); v[1] = (V); } HB_STMT_END -#define hb_be_uint16_get(v) (uint16_t) ((v[0] << 8) + v[1]) -#define hb_be_uint16_eq(a,b) (a[0] == b[0] && a[1] == b[1]) - -#define hb_be_uint32_put(v,V) HB_STMT_START { v[0] = (V>>24); v[1] = (V>>16); v[2] = (V>>8); v[3] = (V); } HB_STMT_END -#define hb_be_uint32_get(v) (uint32_t) ((v[0] << 24) + (v[1] << 16) + (v[2] << 8) + v[3]) -#define hb_be_uint32_eq(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3]) - -#define hb_be_uint24_put(v,V) HB_STMT_START { v[0] = (V>>16); v[1] = (V>>8); v[2] = (V); } HB_STMT_END -#define hb_be_uint24_get(v) (uint32_t) ((v[0] << 16) + (v[1] << 8) + v[2]) -#define hb_be_uint24_eq(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]) - - /* ASCII tag/character handling */ static inline bool ISALPHA (unsigned char c) diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc index 74ae3a3..e7bcad2 100644 --- a/src/hb-uniscribe.cc +++ b/src/hb-uniscribe.cc @@ -43,6 +43,12 @@ #endif +static inline uint16_t hb_uint16_swap (const uint16_t v) +{ return (v >> 8) | (v << 8); } +static inline uint32_t hb_uint32_swap (const uint32_t v) +{ return (hb_uint16_swap (v) << 16) | hb_uint16_swap (v >> 16); } + + typedef HRESULT (WINAPI *SIOT) /*ScriptItemizeOpenType*/( const WCHAR *pwcInChars, int cInChars, _______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
