Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / sfnt / SkOTTableTypes.h
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7
8 #ifndef SkOTTableTypes_DEFINED
9 #define SkOTTableTypes_DEFINED
10
11 #include "SkTemplates.h"
12 #include "SkTypes.h"
13 #include "SkEndian.h"
14
15 //All SK_OT_ prefixed types should be considered as big endian.
16 typedef uint8_t SK_OT_BYTE;
17 #if CHAR_BIT == 8
18 typedef signed char SK_OT_CHAR; //easier to debug
19 #else
20 typedef int8_t SK_OT_CHAR;
21 #endif
22 typedef uint16_t SK_OT_SHORT;
23 typedef uint16_t SK_OT_USHORT;
24 typedef uint32_t SK_OT_ULONG;
25 typedef uint32_t SK_OT_LONG;
26 //16.16 Signed fixed point representation.
27 typedef int32_t SK_OT_Fixed;
28 //2.14 Signed fixed point representation.
29 typedef uint16_t SK_OT_F2DOT14;
30 //F units are the units of measurement in em space.
31 typedef uint16_t SK_OT_FWORD;
32 typedef uint16_t SK_OT_UFWORD;
33 //Number of seconds since 12:00 midnight, January 1, 1904.
34 typedef uint64_t SK_OT_LONGDATETIME;
35
36 #define SK_OT_BYTE_BITFIELD SK_UINT8_BITFIELD
37
38 template<typename T> class SkOTTableTAG {
39 public:
40     /**
41      * SkOTTableTAG<T>::value is the big endian value of an OpenType table tag.
42      * It may be directly compared with raw big endian table data.
43      */
44     static const SK_OT_ULONG value = SkTEndian_SwapBE32(
45         SkSetFourByteTag(T::TAG0, T::TAG1, T::TAG2, T::TAG3)
46     );
47 };
48
49 /** SkOTSetUSHORTBit<N>::value is an SK_OT_USHORT with the Nth BE bit set. */
50 template <unsigned N> struct SkOTSetUSHORTBit {
51     SK_COMPILE_ASSERT(N < 16, NTooBig);
52     static const uint16_t bit = 1u << N;
53     static const SK_OT_USHORT value = SkTEndian_SwapBE16(bit);
54 };
55
56 /** SkOTSetULONGBit<N>::value is an SK_OT_ULONG with the Nth BE bit set. */
57 template <unsigned N> struct SkOTSetULONGBit {
58     SK_COMPILE_ASSERT(N < 32, NTooBig);
59     static const uint32_t bit = 1u << N;
60     static const SK_OT_ULONG value = SkTEndian_SwapBE32(bit);
61 };
62
63 #endif