Bug 1516677. Remove unused drawtarget parameter. r=jfkthame
authorJeff Muizelaar <jrmuizel@gmail.com>
Mon, 31 Dec 2018 11:43:27 +0000
changeset 452194 19828a8dd8ae5ce8d7aa37d57ed607ee3043e49b
parent 452193 aa9b106b15d93573e5125356667f3a1f474d2e5a
child 452195 cc4bb8c7fa92e8a4f44377c253160cea4ab66c97
push id35292
push userdvarga@mozilla.com
push dateMon, 31 Dec 2018 21:26:28 +0000
treeherdermozilla-central@d96e39ed615b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1516677, 1509358
milestone66.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 1516677. Remove unused drawtarget parameter. r=jfkthame With bug 1509358 having landed we don't need a draw target in a bunch of places. This removes it from those places. Differential Revision: https://phabricator.services.mozilla.com/D15481
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxDWriteFonts.h
gfx/thebes/gfxFT2FontBase.cpp
gfx/thebes/gfxFT2FontBase.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxGDIFont.cpp
gfx/thebes/gfxGDIFont.h
gfx/thebes/gfxGraphiteShaper.cpp
gfx/thebes/gfxGraphiteShaper.h
gfx/thebes/gfxHarfBuzzShaper.cpp
gfx/thebes/gfxHarfBuzzShaper.h
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxMacFont.h
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -541,17 +541,17 @@ gfxFont::RunMetrics gfxDWriteFont::Measu
 
 bool gfxDWriteFont::ProvidesGlyphWidths() const {
   return !mUseSubpixelPositions ||
          (mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD) ||
          (((gfxDWriteFontEntry*)(GetFontEntry()))->HasVariations() &&
           !mStyle.variationSettings.IsEmpty());
 }
 
-int32_t gfxDWriteFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID) {
+int32_t gfxDWriteFont::GetGlyphWidth(uint16_t aGID) {
   if (!mGlyphWidths) {
     mGlyphWidths = MakeUnique<nsDataHashtable<nsUint32HashKey, int32_t>>(128);
   }
 
   int32_t width = -1;
   if (mGlyphWidths->Get(aGID, &width)) {
     return width;
   }
--- a/gfx/thebes/gfxDWriteFonts.h
+++ b/gfx/thebes/gfxDWriteFonts.h
@@ -52,18 +52,17 @@ class gfxDWriteFont : public gfxFont {
   virtual RunMetrics Measure(
       const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
       BoundingBoxType aBoundingBoxType,
       DrawTarget *aDrawTargetForTightBoundingBox, Spacing *aSpacing,
       mozilla::gfx::ShapedTextFlags aOrientation) override;
 
   virtual bool ProvidesGlyphWidths() const override;
 
-  virtual int32_t GetGlyphWidth(DrawTarget &aDrawTarget,
-                                uint16_t aGID) override;
+  virtual int32_t GetGlyphWidth(uint16_t aGID) override;
 
   virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                       FontCacheSizes *aSizes) const override;
   virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                       FontCacheSizes *aSizes) const override;
 
   virtual FontType GetType() const override { return FONT_TYPE_DWRITE; }
 
--- a/gfx/thebes/gfxFT2FontBase.cpp
+++ b/gfx/thebes/gfxFT2FontBase.cpp
@@ -539,17 +539,17 @@ bool gfxFT2FontBase::GetFTGlyphAdvance(u
 
   // Round the 16.16 fixed-point value to whole pixels for better consistency
   // with how cairo renders the glyphs.
   *aAdvance = (advance + 0x8000) & 0xffff0000u;
 
   return true;
 }
 
-int32_t gfxFT2FontBase::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID) {
+int32_t gfxFT2FontBase::GetGlyphWidth(uint16_t aGID) {
   if (!mGlyphWidths) {
     mGlyphWidths =
         mozilla::MakeUnique<nsDataHashtable<nsUint32HashKey, int32_t>>(128);
   }
 
   int32_t width;
   if (mGlyphWidths->Get(aGID, &width)) {
     return width;
--- a/gfx/thebes/gfxFT2FontBase.h
+++ b/gfx/thebes/gfxFT2FontBase.h
@@ -24,18 +24,17 @@ class gfxFT2FontBase : public gfxFont {
 
   uint32_t GetGlyph(uint32_t aCharCode);
   void GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents);
   virtual uint32_t GetSpaceGlyph() override;
   virtual bool ProvidesGetGlyph() const override { return true; }
   virtual uint32_t GetGlyph(uint32_t unicode,
                             uint32_t variation_selector) override;
   virtual bool ProvidesGlyphWidths() const override { return true; }
-  virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget,
-                                uint16_t aGID) override;
+  virtual int32_t GetGlyphWidth(uint16_t aGID) override;
 
   virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
 
   virtual FontType GetType() const override { return FONT_TYPE_FT2; }
 
   static void SetupVarCoords(FT_MM_Var* aMMVar,
                              const nsTArray<gfxFontVariation>& aVariations,
                              nsTArray<FT_Fixed>* aCoords);
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -880,17 +880,17 @@ gfxFont::RoundingFlags gfxFont::GetRound
   return result;
 }
 
 gfxFloat gfxFont::GetGlyphHAdvance(DrawTarget* aDrawTarget, uint16_t aGID) {
   if (!SetupCairoFont(aDrawTarget)) {
     return 0;
   }
   if (ProvidesGlyphWidths()) {
-    return GetGlyphWidth(*aDrawTarget, aGID) / 65536.0;
+    return GetGlyphWidth(aGID) / 65536.0;
   }
   if (mFUnitsConvFactor < 0.0f) {
     GetMetrics(eHorizontal);
   }
   NS_ASSERTION(mFUnitsConvFactor >= 0.0f,
                "missing font unit conversion factor");
   if (!mHarfBuzzShaper) {
     mHarfBuzzShaper = MakeUnique<gfxHarfBuzzShaper>(this);
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -1935,17 +1935,17 @@ class gfxFont {
 
   // subclasses may provide (possibly hinted) glyph widths (in font units);
   // if they do not override this, harfbuzz will use unhinted widths
   // derived from the font tables
   virtual bool ProvidesGlyphWidths() const { return false; }
 
   // The return value is interpreted as a horizontal advance in 16.16 fixed
   // point format.
-  virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID) {
+  virtual int32_t GetGlyphWidth(uint16_t aGID) {
     return -1;
   }
 
   bool IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget,
                              const gfxTextRun* aTextRun);
 
   void AddGlyphChangeObserver(GlyphChangeObserver* aObserver);
   void RemoveGlyphChangeObserver(GlyphChangeObserver* aObserver);
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -478,17 +478,17 @@ uint32_t gfxGDIFont::GetGlyph(uint32_t a
       }
     }
   }
 
   mGlyphIDs->Put(aUnicode, glyph);
   return glyph;
 }
 
-int32_t gfxGDIFont::GetGlyphWidth(DrawTarget &aDrawTarget, uint16_t aGID) {
+int32_t gfxGDIFont::GetGlyphWidth(uint16_t aGID) {
   if (!mGlyphWidths) {
     mGlyphWidths = MakeUnique<nsDataHashtable<nsUint32HashKey, int32_t>>(128);
   }
 
   int32_t width;
   if (mGlyphWidths->Get(aGID, &width)) {
     return width;
   }
--- a/gfx/thebes/gfxGDIFont.h
+++ b/gfx/thebes/gfxGDIFont.h
@@ -52,18 +52,17 @@ class gfxGDIFont : public gfxFont {
     return !mFontEntry->HasCmapTable();
   }
 
   virtual uint32_t GetGlyph(uint32_t aUnicode, uint32_t aVarSelector) override;
 
   virtual bool ProvidesGlyphWidths() const override { return true; }
 
   // get hinted glyph width in pixels as 16.16 fixed-point value
-  virtual int32_t GetGlyphWidth(DrawTarget &aDrawTarget,
-                                uint16_t aGID) override;
+  virtual int32_t GetGlyphWidth(uint16_t aGID) override;
 
   virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                       FontCacheSizes *aSizes) const;
   virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                       FontCacheSizes *aSizes) const;
 
   virtual FontType GetType() const override { return FONT_TYPE_GDI; }
 
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -28,31 +28,30 @@ using namespace mozilla;  // for AutoSwa
  * Creation and destruction; on deletion, release any font tables we're holding
  */
 
 gfxGraphiteShaper::gfxGraphiteShaper(gfxFont *aFont)
     : gfxFontShaper(aFont),
       mGrFace(mFont->GetFontEntry()->GetGrFace()),
       mGrFont(nullptr),
       mFallbackToSmallCaps(false) {
-  mCallbackData.mDrawTarget = nullptr;
   mCallbackData.mFont = aFont;
 }
 
 gfxGraphiteShaper::~gfxGraphiteShaper() {
   if (mGrFont) {
     gr_font_destroy(mGrFont);
   }
   mFont->GetFontEntry()->ReleaseGrFace(mGrFace);
 }
 
 /*static*/ float gfxGraphiteShaper::GrGetAdvance(const void *appFontHandle,
                                                  uint16_t glyphid) {
   const CallbackData *cb = static_cast<const CallbackData *>(appFontHandle);
-  return FixedToFloat(cb->mFont->GetGlyphWidth(*cb->mDrawTarget, glyphid));
+  return FixedToFloat(cb->mFont->GetGlyphWidth(glyphid));
 }
 
 static inline uint32_t MakeGraphiteLangTag(uint32_t aTag) {
   uint32_t grLangTag = aTag;
   // replace trailing space-padding with NULs for graphite
   uint32_t mask = 0x000000FF;
   while ((grLangTag & mask) == ' ') {
     grLangTag &= ~mask;
@@ -80,18 +79,16 @@ bool gfxGraphiteShaper::ShapeText(DrawTa
                                   uint32_t aLength, Script aScript,
                                   bool aVertical, RoundingFlags aRounding,
                                   gfxShapedText *aShapedText) {
   // some font back-ends require this in order to get proper hinted metrics
   if (!mFont->SetupCairoFont(aDrawTarget)) {
     return false;
   }
 
-  mCallbackData.mDrawTarget = aDrawTarget;
-
   const gfxFontStyle *style = mFont->GetStyle();
 
   if (!mGrFont) {
     if (!mGrFace) {
       return false;
     }
 
     if (mFont->ProvidesGlyphWidths()) {
--- a/gfx/thebes/gfxGraphiteShaper.h
+++ b/gfx/thebes/gfxGraphiteShaper.h
@@ -36,19 +36,16 @@ class gfxGraphiteShaper : public gfxFont
   gr_face *mGrFace;  // owned by the font entry; shaper must call
                      // gfxFontEntry::ReleaseGrFace when finished with it
   gr_font *mGrFont;  // owned by the shaper itself
 
   struct CallbackData {
     // mFont is a pointer to the font that owns this shaper, so it will
     // remain valid throughout our lifetime
     gfxFont *MOZ_NON_OWNING_REF mFont;
-    // initialized to a DrawTarget owned by our caller on every call to
-    // ShapeText
-    mozilla::gfx::DrawTarget *MOZ_NON_OWNING_REF mDrawTarget;
   };
 
   CallbackData mCallbackData;
   bool mFallbackToSmallCaps;  // special fallback for the petite-caps case
 
   // Convert HTML 'lang' (BCP47) to Graphite language code
   static uint32_t GetGraphiteTagForLang(const nsCString &aLang);
   static nsTHashtable<nsUint32HashKey> *sLanguageTags;
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -352,17 +352,17 @@ hb_position_t gfxHarfBuzzShaper::GetGlyp
 hb_position_t gfxHarfBuzzShaper::HBGetGlyphHAdvance(hb_font_t *font,
                                                     void *font_data,
                                                     hb_codepoint_t glyph,
                                                     void *user_data) {
   const gfxHarfBuzzShaper::FontCallbackData *fcd =
       static_cast<const gfxHarfBuzzShaper::FontCallbackData *>(font_data);
   const gfxHarfBuzzShaper *shaper = fcd->mShaper;
   if (shaper->mUseFontGlyphWidths) {
-    return shaper->GetFont()->GetGlyphWidth(*fcd->mDrawTarget, glyph);
+    return shaper->GetFont()->GetGlyphWidth(glyph);
   }
   return shaper->GetGlyphHAdvance(glyph);
 }
 
 /* static */
 hb_position_t gfxHarfBuzzShaper::HBGetGlyphVAdvance(hb_font_t *font,
                                                     void *font_data,
                                                     hb_codepoint_t glyph,
@@ -395,24 +395,24 @@ struct VORGrec {
 /* static */
 hb_bool_t gfxHarfBuzzShaper::HBGetGlyphVOrigin(hb_font_t *font, void *font_data,
                                                hb_codepoint_t glyph,
                                                hb_position_t *x,
                                                hb_position_t *y,
                                                void *user_data) {
   const gfxHarfBuzzShaper::FontCallbackData *fcd =
       static_cast<const gfxHarfBuzzShaper::FontCallbackData *>(font_data);
-  fcd->mShaper->GetGlyphVOrigin(*fcd->mDrawTarget, glyph, x, y);
+  fcd->mShaper->GetGlyphVOrigin(glyph, x, y);
   return true;
 }
 
-void gfxHarfBuzzShaper::GetGlyphVOrigin(DrawTarget &aDT, hb_codepoint_t aGlyph,
+void gfxHarfBuzzShaper::GetGlyphVOrigin(hb_codepoint_t aGlyph,
                                         hb_position_t *aX,
                                         hb_position_t *aY) const {
-  *aX = 0.5 * (mUseFontGlyphWidths ? mFont->GetGlyphWidth(aDT, aGlyph)
+  *aX = 0.5 * (mUseFontGlyphWidths ? mFont->GetGlyphWidth(aGlyph)
                                    : GetGlyphHAdvance(aGlyph));
 
   if (mVORGTable) {
     // We checked in Initialize() that the VORG table is safely readable,
     // so no length/bounds-check needed here.
     const VORG *vorg =
         reinterpret_cast<const VORG *>(hb_blob_get_data(mVORGTable, nullptr));
 
@@ -1334,17 +1334,16 @@ bool gfxHarfBuzzShaper::ShapeText(DrawTa
                                   uint32_t aLength, Script aScript,
                                   bool aVertical, RoundingFlags aRounding,
                                   gfxShapedText *aShapedText) {
   // some font back-ends require this in order to get proper hinted metrics
   if (!mFont->SetupCairoFont(aDrawTarget)) {
     return false;
   }
 
-  mCallbackData.mDrawTarget = aDrawTarget;
   mUseVerticalPresentationForms = false;
 
   if (!Initialize()) {
     return false;
   }
 
   if (aVertical) {
     InitializeVertical();
--- a/gfx/thebes/gfxHarfBuzzShaper.h
+++ b/gfx/thebes/gfxHarfBuzzShaper.h
@@ -18,19 +18,16 @@ class gfxHarfBuzzShaper : public gfxFont
   virtual ~gfxHarfBuzzShaper();
 
   /*
    * For HarfBuzz font callback functions, font_data is a ptr to a
    * FontCallbackData struct
    */
   struct FontCallbackData {
     gfxHarfBuzzShaper *mShaper;
-    // initialized to a DrawTarget owned by our caller on every call to
-    // ShapeText
-    mozilla::gfx::DrawTarget *MOZ_NON_OWNING_REF mDrawTarget;
   };
 
   bool Initialize();
 
   bool ShapeText(DrawTarget *aDrawTarget, const char16_t *aText,
                  uint32_t aOffset, uint32_t aLength, Script aScript,
                  bool aVertical, RoundingFlags aRounding,
                  gfxShapedText *aShapedText) override;
@@ -43,18 +40,18 @@ class gfxHarfBuzzShaper : public gfxFont
   hb_codepoint_t GetVariationGlyph(hb_codepoint_t unicode,
                                    hb_codepoint_t variation_selector) const;
 
   // get harfbuzz glyph advance, in font design units
   hb_position_t GetGlyphHAdvance(hb_codepoint_t glyph) const;
 
   hb_position_t GetGlyphVAdvance(hb_codepoint_t glyph) const;
 
-  void GetGlyphVOrigin(mozilla::gfx::DrawTarget &aDT, hb_codepoint_t aGlyph,
-                       hb_position_t *aX, hb_position_t *aY) const;
+  void GetGlyphVOrigin(hb_codepoint_t aGlyph, hb_position_t *aX,
+                       hb_position_t *aY) const;
 
   // get harfbuzz horizontal advance in 16.16 fixed point format.
   static hb_position_t HBGetGlyphHAdvance(hb_font_t *font, void *font_data,
                                           hb_codepoint_t glyph,
                                           void *user_data);
 
   // get harfbuzz vertical advance in 16.16 fixed point format.
   static hb_position_t HBGetGlyphVAdvance(hb_font_t *font, void *font_data,
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -491,17 +491,17 @@ CTFontRef gfxMacFont::CreateCTFontFromCG
     }
   } else {
     ctFont = ::CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, aFontDesc);
   }
 
   return ctFont;
 }
 
-int32_t gfxMacFont::GetGlyphWidth(DrawTarget &aDrawTarget, uint16_t aGID) {
+int32_t gfxMacFont::GetGlyphWidth(uint16_t aGID) {
   if (mVariationFont) {
     // Avoid a potential Core Text crash (bug 1450209) by using
     // CoreGraphics glyph advance API. This is inferior for 'sbix'
     // fonts, but those won't have variations, so it's OK.
     int cgAdvance;
     if (::CGFontGetGlyphAdvances(mCGFont, &aGID, 1, &cgAdvance)) {
       return cgAdvance * mFUnitsConvFactor * 0x10000;
     }
--- a/gfx/thebes/gfxMacFont.h
+++ b/gfx/thebes/gfxMacFont.h
@@ -36,17 +36,17 @@ class gfxMacFont : public gfxFont {
 
   // We need to provide hinted (non-linear) glyph widths if using a font
   // with embedded color bitmaps (Apple Color Emoji), as Core Text renders
   // the glyphs with non-linear scaling at small pixel sizes.
   bool ProvidesGlyphWidths() const override {
     return mVariationFont || mFontEntry->HasFontTable(TRUETYPE_TAG('s', 'b', 'i', 'x'));
   }
 
-  int32_t GetGlyphWidth(DrawTarget &aDrawTarget, uint16_t aGID) override;
+  int32_t GetGlyphWidth(uint16_t aGID) override;
 
   already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(
       mozilla::gfx::DrawTarget *aTarget) override;
 
   void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                               FontCacheSizes *aSizes) const override;
   void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                               FontCacheSizes *aSizes) const override;