Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkFontStyle_DEFINED | 8 #ifndef SkFontStyle_DEFINED |
| 9 #define SkFontStyle_DEFINED | 9 #define SkFontStyle_DEFINED |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 kUltaExpanded_Width = 9 | 36 kUltaExpanded_Width = 9 |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 enum Slant { | 39 enum Slant { |
| 40 kUpright_Slant, | 40 kUpright_Slant, |
| 41 kItalic_Slant, | 41 kItalic_Slant, |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 SkFontStyle(); | 44 SkFontStyle(); |
| 45 SkFontStyle(int weight, int width, Slant); | 45 SkFontStyle(int weight, int width, Slant); |
| 46 /** oldStyle means the style-bits in SkTypeface::Style: bold=1, italic=2 */ | 46 |
| 47 explicit SkFontStyle(unsigned oldStyle); | 47 static SkFontStyle FromOldStyle(unsigned oldStyle); |
| 48 | |
| 49 explicit SkFontStyle(uint32_t d) | |
|
dogben
2016/04/11 20:28:58
I don't see anywhere you use the uint32_t construc
bungeman-skia
2016/04/11 21:55:52
This was done to make the Chromium side IPC change
| |
| 50 : SkFontStyle(Data{d}.fR.fWeight, Data{d}.fR.fWidth, static_cast<Slant>( Data{d}.fR.fSlant)) | |
| 51 {} | |
| 52 explicit operator uint32_t() { return fUnion.fU32; } | |
| 48 | 53 |
| 49 bool operator==(const SkFontStyle& rhs) const { | 54 bool operator==(const SkFontStyle& rhs) const { |
| 50 return fUnion.fU32 == rhs.fUnion.fU32; | 55 return fUnion.fU32 == rhs.fUnion.fU32; |
| 51 } | 56 } |
| 52 | 57 |
| 53 int weight() const { return fUnion.fR.fWeight; } | 58 int weight() const { return fUnion.fR.fWeight; } |
| 54 int width() const { return fUnion.fR.fWidth; } | 59 int width() const { return fUnion.fR.fWidth; } |
| 55 Slant slant() const { return (Slant)fUnion.fR.fSlant; } | 60 Slant slant() const { return (Slant)fUnion.fR.fSlant; } |
| 56 | 61 |
| 57 bool isItalic() const { | 62 bool isItalic() const { |
| 58 return kItalic_Slant == fUnion.fR.fSlant; | 63 return kItalic_Slant == fUnion.fR.fSlant; |
| 59 } | 64 } |
| 60 | 65 |
| 61 private: | 66 private: |
| 62 union { | 67 union Data { |
| 68 uint32_t fU32; | |
| 63 struct { | 69 struct { |
| 64 uint16_t fWeight; // 100 .. 900 | 70 uint16_t fWeight; // 100 .. 900 |
| 65 uint8_t fWidth; // 1 .. 9 | 71 uint8_t fWidth; // 1 .. 9 |
| 66 uint8_t fSlant; // 0 .. 2 | 72 uint8_t fSlant; // 0 .. 2 |
| 67 } fR; | 73 } fR; |
| 68 uint32_t fU32; | |
| 69 } fUnion; | 74 } fUnion; |
| 70 }; | 75 }; |
| 71 | 76 |
| 72 #endif | 77 #endif |
| OLD | NEW |