Bug 1330710 - make gfxFontconfigFont keep track of its actual adjusted size. r=jfkthame
authorLee Salzman <lsalzman@mozilla.com>
Thu, 12 Jan 2017 17:37:07 -0500
changeset 374211 456f50aee1e10562e5f08c57c14e7eb667155902
parent 374210 c246033325458c04e30e27d27f23e5da836fb0eb
child 374212 2815d3833df6436abf2f466a96204261135b6a81
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1330710
milestone53.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 1330710 - make gfxFontconfigFont keep track of its actual adjusted size. r=jfkthame MozReview-Commit-ID: 1EqZvtppDXK
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFcPlatformFontList.h
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -639,16 +639,17 @@ PrepareFontOptions(FcPattern* aPattern,
     } else {
         antialias = CAIRO_ANTIALIAS_SUBPIXEL;
     }
     cairo_font_options_set_antialias(aFontOptions, antialias);
 }
 
 cairo_scaled_font_t*
 gfxFontconfigFontEntry::CreateScaledFont(FcPattern* aRenderPattern,
+                                         gfxFloat aAdjustedSize,
                                          const gfxFontStyle *aStyle,
                                          bool aNeedsBold)
 {
     if (aNeedsBold) {
         FcPatternAddBool(aRenderPattern, FC_EMBOLDEN, FcTrue);
     }
 
     // synthetic oblique by skewing via the font matrix
@@ -676,21 +677,17 @@ gfxFontconfigFontEntry::CreateScaledFont
                                       FTUserFontDataRef::Destroy);
     }
 
     cairo_scaled_font_t *scaledFont = nullptr;
 
     cairo_matrix_t sizeMatrix;
     cairo_matrix_t identityMatrix;
 
-    double adjustedSize = aStyle->size;
-    if (aStyle->sizeAdjust >= 0.0) {
-        adjustedSize = aStyle->GetAdjustedSize(GetAspect());
-    }
-    cairo_matrix_init_scale(&sizeMatrix, adjustedSize, adjustedSize);
+    cairo_matrix_init_scale(&sizeMatrix, aAdjustedSize, aAdjustedSize);
     cairo_matrix_init_identity(&identityMatrix);
 
     if (needsOblique) {
         const double kSkewFactor = OBLIQUE_SKEW_FACTOR;
 
         cairo_matrix_t style;
         cairo_matrix_init(&style,
                           1,                //xx
@@ -804,20 +801,26 @@ gfxFontconfigFontEntry::CreateFontInstan
     PreparePattern(pattern, aFontStyle->printerFont);
     nsAutoRef<FcPattern> renderPattern
         (FcFontRenderPrepare(nullptr, pattern, mFontPattern));
     if (!renderPattern) {
         NS_WARNING("Failed to prepare Fontconfig pattern for font instance");
         return nullptr;
     }
 
+    double adjustedSize = aFontStyle->size;
+    if (aFontStyle->sizeAdjust >= 0.0) {
+        adjustedSize = aFontStyle->GetAdjustedSize(GetAspect());
+    }
+
     cairo_scaled_font_t* scaledFont =
-        CreateScaledFont(renderPattern, aFontStyle, aNeedsBold);
+        CreateScaledFont(renderPattern, adjustedSize, aFontStyle, aNeedsBold);
     gfxFont* newFont =
-        new gfxFontconfigFont(scaledFont, renderPattern, this, aFontStyle, aNeedsBold);
+        new gfxFontconfigFont(scaledFont, renderPattern, adjustedSize,
+                              this, aFontStyle, aNeedsBold);
     cairo_scaled_font_destroy(scaledFont);
 
     return newFont;
 }
 
 nsresult
 gfxFontconfigFontEntry::CopyFontTable(uint32_t aTableTag,
                                       nsTArray<uint8_t>& aBuffer)
@@ -920,21 +923,23 @@ gfxFontconfigFontFamily::AddFontPattern(
                  "font patterns must not be added to already enumerated families");
 
     nsCountedRef<FcPattern> pattern(aFontPattern);
     mFontPatterns.AppendElement(pattern);
 }
 
 gfxFontconfigFont::gfxFontconfigFont(cairo_scaled_font_t *aScaledFont,
                                      FcPattern *aPattern,
+                                     gfxFloat aAdjustedSize,
                                      gfxFontEntry *aFontEntry,
                                      const gfxFontStyle *aFontStyle,
                                      bool aNeedsBold) :
     gfxFontconfigFontBase(aScaledFont, aPattern, aFontEntry, aFontStyle)
 {
+    mAdjustedSize = aAdjustedSize;
 }
 
 gfxFontconfigFont::~gfxFontconfigFont()
 {
 }
 
 gfxFcPlatformFontList::gfxFcPlatformFontList()
     : mLocalNames(64)
--- a/gfx/thebes/gfxFcPlatformFontList.h
+++ b/gfx/thebes/gfxFcPlatformFontList.h
@@ -128,16 +128,17 @@ protected:
     virtual ~gfxFontconfigFontEntry();
 
     gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
                                 bool aNeedsBold) override;
 
     // helper method for creating cairo font from pattern
     cairo_scaled_font_t*
     CreateScaledFont(FcPattern* aRenderPattern,
+                     gfxFloat aAdjustedSize,
                      const gfxFontStyle *aStyle,
                      bool aNeedsBold);
 
     // override to pull data from FTFace
     virtual nsresult
     CopyFontTable(uint32_t aTableTag,
                   nsTArray<uint8_t>& aBuffer) override;
 
@@ -194,16 +195,17 @@ protected:
 
     bool      mContainsAppFonts;
 };
 
 class gfxFontconfigFont : public gfxFontconfigFontBase {
 public:
     gfxFontconfigFont(cairo_scaled_font_t *aScaledFont,
                       FcPattern *aPattern,
+                      gfxFloat aAdjustedSize,
                       gfxFontEntry *aFontEntry,
                       const gfxFontStyle *aFontStyle,
                       bool aNeedsBold);
 
 protected:
     virtual ~gfxFontconfigFont();
 };