Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 1061123002: Attempted mitigation of font tables released early. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SkToBool Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_mac.cpp
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 5be7cc1f9781ea301b21bc529f5b50a50627f157..836576bc2a2adc7e067080817f49df02141fe925 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -453,14 +453,15 @@ public:
: SkTypeface(fs, fontID, isFixedPitch)
, fRequestedName(requestedName)
, fFontRef(fontRef) // caller has already called CFRetain for us
+ , fHasColorGlyphs(SkToBool(CTFontGetSymbolicTraits(fFontRef) & SkCTFontColorGlyphsTrait))
, fIsLocalStream(isLocalStream)
- , fHasColorGlyphs(CTFontGetSymbolicTraits(fFontRef) & SkCTFontColorGlyphsTrait)
{
SkASSERT(fontRef);
}
SkString fRequestedName;
AutoCFRelease<CTFontRef> fFontRef;
+ const bool fHasColorGlyphs;
protected:
int onGetUPEM() const override;
@@ -482,7 +483,6 @@ protected:
private:
bool fIsLocalStream;
- bool fHasColorGlyphs;
typedef SkTypeface INHERITED;
};
@@ -907,6 +907,13 @@ CGRGBPixel* Offscreen::getCG(const SkScalerContext_Mac& context, const SkGlyph&
// So always make the font transform identity and place the transform on the context.
point = CGPointApplyAffineTransform(point, context.fInvTransform);
+ // Attempt to keep on the stack a hard reference to the font tables.
+ // This is an experiment to see if this affects crbug.com/413332 .
+ // When 10.6 headers are no longer supported, 'sbix' can be replaced with kCTFontTableSbix.
+ AutoCFRelease<CFDataRef> sbix;
+ if (static_cast<SkTypeface_Mac*>(context.getTypeface())->fHasColorGlyphs) {
+ sbix.reset(CGFontCopyTableForTag(context.fCGFont, 'sbix'));
+ }
ctFontDrawGlyphs(context.fCTUnrotatedFont, &glyphID, &point, 1, fCG);
SkASSERT(rowBytesPtr);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698