Chromium Code Reviews| Index: src/core/SkAdvancedTypefaceMetrics.h |
| diff --git a/src/core/SkAdvancedTypefaceMetrics.h b/src/core/SkAdvancedTypefaceMetrics.h |
| index 1b490e0199300d6671dd428835900172a9f31a6b..2ec5cfe60bfdb3c574da7c5b64d292d79cb934c0 100644 |
| --- a/src/core/SkAdvancedTypefaceMetrics.h |
| +++ b/src/core/SkAdvancedTypefaceMetrics.h |
| @@ -23,15 +23,29 @@ |
| SkTypeface::getAdvancedTypefaceMetrics. |
| */ |
| +#define SK_DEFINE_FLAG_OPERATORS(ENUM_T, UNDERLYING_T) \ |
|
bungeman-skia
2016/08/15 20:17:03
Why force the user to specify UNDERLYING_T, skstd:
hal.canary
2016/08/15 21:14:42
Acknowledged.
|
| + friend ENUM_T operator&(ENUM_T u, ENUM_T v) { \ |
|
bungeman-skia
2016/08/15 20:17:03
Ah, yes, friend definitions. I had almost forgotte
hal.canary
2016/08/15 21:14:42
Acknowledged.
|
| + return (ENUM_T)((UNDERLYING_T)u & (UNDERLYING_T)v); \ |
|
bungeman-skia
2016/08/15 20:17:03
I would much prefer
return static_cast<EN
hal.canary
2016/08/15 21:14:42
Acknowledged.
|
| + } \ |
| + friend ENUM_T operator|(ENUM_T u, ENUM_T v) { \ |
| + return (ENUM_T)((UNDERLYING_T)u | (UNDERLYING_T)v); \ |
| + } \ |
| + friend ENUM_T& operator|=(ENUM_T& u, ENUM_T v) { \ |
| + return u = u | v; \ |
| + } \ |
| + friend ENUM_T& operator&=(ENUM_T& u, ENUM_T v) { \ |
| + return u = u & v; \ |
| + } |
| + |
| class SkAdvancedTypefaceMetrics : public SkRefCnt { |
| public: |
| SkAdvancedTypefaceMetrics() |
| : fType(SkAdvancedTypefaceMetrics::kOther_Font) |
| - , fFlags(SkAdvancedTypefaceMetrics::kEmpty_FontFlag) |
| + , fFlags((FontFlags)0) |
|
bungeman-skia
2016/08/15 20:17:03
why not kEmpty_FontFlag since it exists. Or remove
hal.canary
2016/08/15 21:14:42
I'll just do away with it.
|
| , fLastGlyphID(0) |
| , fEmSize(0) |
| - , fStyle(0) |
| + , fStyle((StyleFlags)0) |
| , fItalicAngle(0) |
| , fAscent(0) |
| , fDescent(0) |
| @@ -43,7 +57,7 @@ public: |
| SkString fFontName; |
| - enum FontType { |
| + enum FontType : uint8_t { |
| kType1_Font, |
| kType1CID_Font, |
| kCFF_Font, |
| @@ -55,12 +69,14 @@ public: |
| // information will never be populated. |
| FontType fType; |
| - enum FontFlags { |
| - kEmpty_FontFlag = 0x0, //!<No flags set |
| - kMultiMaster_FontFlag = 0x1, //!<May be true for Type1, CFF, or TrueType fonts. |
| - kNotEmbeddable_FontFlag = 0x2, //!<May not be embedded. |
| - kNotSubsettable_FontFlag = 0x4, //!<May not be subset. |
| + enum FontFlags : uint8_t { |
| + kEmpty_FontFlag = 0x00, //!<No flags set |
| + kMultiMaster_FontFlag = 0x01, //!<May be true for Type1, CFF, or TrueType fonts. |
| + kNotEmbeddable_FontFlag = 0x02, //!<May not be embedded. |
| + kNotSubsettable_FontFlag = 0x04, //!<May not be subset. |
| }; |
| + SK_DEFINE_FLAG_OPERATORS(FontFlags, uint8_t) |
| + |
| // Global font flags. |
| FontFlags fFlags; |
| @@ -68,16 +84,17 @@ public: |
| uint16_t fEmSize; // The size of the em box (defines font units). |
| // These enum values match the values used in the PDF file format. |
| - enum StyleFlags { |
| - kFixedPitch_Style = 0x00001, |
| - kSerif_Style = 0x00002, |
| - kScript_Style = 0x00008, |
| - kItalic_Style = 0x00040, |
| - kAllCaps_Style = 0x10000, |
| - kSmallCaps_Style = 0x20000, |
| - kForceBold_Style = 0x40000 |
| + enum StyleFlags : uint32_t { |
| + kFixedPitch_Style = 0x00000001, |
| + kSerif_Style = 0x00000002, |
| + kScript_Style = 0x00000008, |
| + kItalic_Style = 0x00000040, |
| + kAllCaps_Style = 0x00010000, |
| + kSmallCaps_Style = 0x00020000, |
| + kForceBold_Style = 0x00040000 |
| }; |
| - uint16_t fStyle; // Font style characteristics. |
| + SK_DEFINE_FLAG_OPERATORS(StyleFlags, uint32_t) |
| + StyleFlags fStyle; // Font style characteristics. |
| int16_t fItalicAngle; // Counterclockwise degrees from vertical of the |
| // dominant vertical stroke for an Italic face. |
| // The following fields are all in font units. |