Bug 1456820 - patch 2 - Reorder fields in gfxFontStyle for better packing. r=lsalzman
authorJonathan Kew <jkew@mozilla.com>
Wed, 25 Apr 2018 18:54:03 +0100
changeset 469183 a021bec0b4d26269ed1a45a88a75b841a5922ee0
parent 469182 d870719ab035c58ee9bb561cdd93c8862e2b1d8e
child 469184 2758feefd02f0a08a98d25b0a157f8c8cbd18b97
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1456820
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456820 - patch 2 - Reorder fields in gfxFontStyle for better packing. r=lsalzman
gfx/thebes/gfxFont.h
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -136,30 +136,36 @@ struct gfxFontStyle {
     // use font-language-override to request the Serbian option in the font
     // in order to get correct glyph shapes.)
     uint32_t languageOverride;
 
     // The estimated background color behind the text. Enables a special
     // rendering mode when NS_GET_A(.) > 0. Only used for text in the chrome.
     nscolor fontSmoothingBackgroundColor;
 
+    // The Font{Weight,Stretch,SlantStyle} fields are each a 16-bit type.
+
     // The weight of the font: 100, 200, ... 900.
     FontWeight weight;
 
     // The stretch of the font
     FontStretch stretch;
 
     // The style of font
     FontSlantStyle style;
 
+    // We pack these two small-integer fields into a single byte to avoid
+    // overflowing an 8-byte boundary [in a 64-bit build] and ending up with
+    // 7 bytes of padding at the end of the struct.
+
     // caps variant (small-caps, petite-caps, etc.)
-    uint8_t variantCaps;
+    uint8_t variantCaps : 4; // uses range 0..6
 
     // sub/superscript variant
-    uint8_t variantSubSuper;
+    uint8_t variantSubSuper : 4; // uses range 0..2
 
     // Say that this font is a system font and therefore does not
     // require certain fixup that we do for fonts from untrusted
     // sources.
     bool systemFont : 1;
 
     // Say that this font is used for print or print preview.
     bool printerFont : 1;