mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Bug 1671963 - Always use CTFontDrawGlyphs. r=lsalzman
CTFontDrawGlyphs has been around since 10.7 Differential Revision: https://phabricator.services.mozilla.com/D94029
This commit is contained in:
parent
678f696c20
commit
0440c26f3d
@ -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];
|
||||
|
@ -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<UnscaledFontMac*>(aUnscaledFont.get());
|
||||
bool dataFont = unscaledMac->IsDataFont();
|
||||
mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont);
|
||||
} else {
|
||||
mCTFont = nullptr;
|
||||
}
|
||||
auto unscaledMac = static_cast<UnscaledFontMac*>(aUnscaledFont.get());
|
||||
bool dataFont = unscaledMac->IsDataFont();
|
||||
mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont);
|
||||
}
|
||||
|
||||
ScaledFontMac::~ScaledFontMac() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user