From 0440c26f3dfe5e2bb7db2763221da00ae6d6df56 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Mon, 19 Oct 2020 15:59:02 +0000 Subject: [PATCH] Bug 1671963 - Always use CTFontDrawGlyphs. r=lsalzman CTFontDrawGlyphs has been around since 10.7 Differential Revision: https://phabricator.services.mozilla.com/D94029 --- gfx/2d/DrawTargetSkia.cpp | 13 +++---------- gfx/2d/ScaledFontMac.cpp | 21 +++------------------ gfx/2d/ScaledFontMac.h | 11 ----------- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp index 14aa9aed0664..64618e2a899c 100644 --- a/gfx/2d/DrawTargetSkia.cpp +++ b/gfx/2d/DrawTargetSkia.cpp @@ -1237,16 +1237,9 @@ bool DrawTargetSkia::FillGlyphsWithCG(ScaledFont* aFont, macFont->FontSmoothingBackgroundColor()); SetFontColor(cgContext, mColorSpace, aPattern); - if (ScaledFontMac::CTFontDrawGlyphsPtr != nullptr) { - ScaledFontMac::CTFontDrawGlyphsPtr(macFont->mCTFont, glyphs.begin(), - positions.begin(), aBuffer.mNumGlyphs, - cgContext); - } else { - CGContextSetFont(cgContext, macFont->mFont); - CGContextSetFontSize(cgContext, macFont->mSize); - CGContextShowGlyphsAtPositions(cgContext, glyphs.begin(), positions.begin(), - aBuffer.mNumGlyphs); - } + CTFontDrawGlyphs(macFont->mCTFont, glyphs.begin(), + positions.begin(), aBuffer.mNumGlyphs, + cgContext); // Calculate the area of the text we just drew auto* bboxes = new CGRect[aBuffer.mNumGlyphs]; diff --git a/gfx/2d/ScaledFontMac.cpp b/gfx/2d/ScaledFontMac.cpp index 920275baf4cb..1708d5450aba 100644 --- a/gfx/2d/ScaledFontMac.cpp +++ b/gfx/2d/ScaledFontMac.cpp @@ -62,10 +62,6 @@ class AutoRelease final { T mObject; }; -ScaledFontMac::CTFontDrawGlyphsFuncT* ScaledFontMac::CTFontDrawGlyphsPtr = - nullptr; -bool ScaledFontMac::sSymbolLookupDone = false; - // Helper to create a CTFont from a CGFont, copying any variations that were // set on the original CGFont. static CTFontRef CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, @@ -132,25 +128,14 @@ ScaledFontMac::ScaledFontMac(CGFontRef aFont, mFontSmoothingBackgroundColor(aFontSmoothingBackgroundColor), mUseFontSmoothing(aUseFontSmoothing), mApplySyntheticBold(aApplySyntheticBold) { - if (!sSymbolLookupDone) { - CTFontDrawGlyphsPtr = - (CTFontDrawGlyphsFuncT*)dlsym(RTLD_DEFAULT, "CTFontDrawGlyphs"); - sSymbolLookupDone = true; - } - if (!aOwnsFont) { // XXX: should we be taking a reference CGFontRetain(aFont); } - if (CTFontDrawGlyphsPtr != nullptr) { - // only create mCTFont if we're going to be using the CTFontDrawGlyphs API - auto unscaledMac = static_cast(aUnscaledFont.get()); - bool dataFont = unscaledMac->IsDataFont(); - mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont); - } else { - mCTFont = nullptr; - } + auto unscaledMac = static_cast(aUnscaledFont.get()); + bool dataFont = unscaledMac->IsDataFont(); + mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont); } ScaledFontMac::~ScaledFontMac() { diff --git a/gfx/2d/ScaledFontMac.h b/gfx/2d/ScaledFontMac.h index d7a6318c0b3d..664363a1c49b 100644 --- a/gfx/2d/ScaledFontMac.h +++ b/gfx/2d/ScaledFontMac.h @@ -78,17 +78,6 @@ class ScaledFontMac : public ScaledFontBase { bool mUseFontSmoothing; bool mApplySyntheticBold; }; - - typedef void(CTFontDrawGlyphsFuncT)(CTFontRef, const CGGlyph[], const CGPoint[], size_t, - CGContextRef); - - static bool sSymbolLookupDone; - - public: - // function pointer for CTFontDrawGlyphs, if available; - // initialized the first time a ScaledFontMac is created, - // so it will be valid by the time DrawTargetCG wants to use it - static CTFontDrawGlyphsFuncT* CTFontDrawGlyphsPtr; }; } // namespace gfx