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

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 1163573007: Provide tag-along for SkCreateTypefaceFromCTFont. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Comment. Created 5 years, 6 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 | « include/ports/SkTypeface_mac.h ('k') | 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 ff23b99905117c486e4c682bfbe3339aee5d4ad7..ac46dddd156d6e6b6f6ae92bd4828b8a909af404 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -429,11 +429,11 @@ class SkTypeface_Mac : public SkTypeface {
public:
SkTypeface_Mac(const SkFontStyle& fs, bool isFixedPitch,
CTFontRef fontRef, const char requestedName[], bool isLocalStream,
- CGFontRef originatingCGFontRef = NULL)
+ CFTypeRef resourceRef = NULL)
reed1 2015/06/08 19:01:40 remove default argness?
bungeman-skia 2015/06/08 19:14:40 Done.
: SkTypeface(fs, SkTypefaceCache::NewFontID(), isFixedPitch)
, fRequestedName(requestedName)
, fFontRef(fontRef) // caller has already called CFRetain for us
- , fOriginatingCGFontRef(originatingCGFontRef)
+ , fOriginatingCFTypeRef(resourceRef) // caller has already called CFRetain for us
, fHasColorGlyphs(SkToBool(CTFontGetSymbolicTraits(fFontRef) & SkCTFontColorGlyphsTrait))
, fIsLocalStream(isLocalStream)
{
@@ -442,7 +442,7 @@ public:
SkString fRequestedName;
AutoCFRelease<CTFontRef> fFontRef;
- AutoCFRelease<CGFontRef> fOriginatingCGFontRef;
+ AutoCFRelease<CFTypeRef> fOriginatingCFTypeRef;
const bool fHasColorGlyphs;
protected:
@@ -472,14 +472,13 @@ private:
/** Creates a typeface without searching the cache. Takes ownership of the CTFontRef. */
static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isLocalStream,
- CGFontRef originatingCGFontRef = NULL)
+ CFTypeRef resourceRef = NULL)
reed1 2015/06/08 19:01:40 since its internal, lets remove the defaultness of
bungeman-skia 2015/06/08 19:14:40 Done.
{
SkASSERT(fontRef);
bool isFixedPitch;
SkFontStyle style = SkFontStyle(computeStyleBits(fontRef, &isFixedPitch));
- return new SkTypeface_Mac(style, isFixedPitch, fontRef, name, isLocalStream,
- originatingCGFontRef);
+ return new SkTypeface_Mac(style, isFixedPitch, fontRef, name, isLocalStream, resourceRef);
}
static bool find_by_CTFontRef(SkTypeface* cached, const SkFontStyle&, void* context) {
@@ -569,11 +568,14 @@ CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face) {
/* This function is visible on the outside. It first searches the cache, and if
* not found, returns a new entry (after adding it to the cache).
*/
-SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef) {
+SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef, CFTypeRef resourceRef) {
SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_by_CTFontRef, (void*)fontRef);
if (!face) {
CFRetain(fontRef);
- face = NewFromFontRef(fontRef, NULL, false);
+ if (resourceRef) {
+ CFRetain(resourceRef);
+ }
+ face = NewFromFontRef(fontRef, NULL, false, resourceRef);
SkTypefaceCache::Add(face, face->fontStyle());
}
return face;
« no previous file with comments | « include/ports/SkTypeface_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698