Stage SkFontMgr factories to return smart pointers.
authorBen Wagner <bungeman@google.com>
Tue, 3 Jan 2017 18:32:36 +0000 (13:32 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 4 Jan 2017 14:51:09 +0000 (14:51 +0000)
All the SkFontMgr factories currently return bare pointers and sometimes
even document the ownership rules. Since such factories can be
implemented by external ports, the ownership rules should be explicit in
order to prevent simple reference counting issues.

Change-Id: I25b598ce0954cd473a3fb1f8adc0cb86331583ca
Reviewed-on: https://skia-review.googlesource.com/6533
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>

24 files changed:
gm/fontmgr.cpp
include/ports/SkFontMgr.h
include/ports/SkFontMgr_FontConfigInterface.h
include/ports/SkFontMgr_android.h
include/ports/SkFontMgr_custom.h
include/ports/SkFontMgr_fontconfig.h
include/ports/SkTypeface_win.h
src/core/SkFontMgr.cpp
src/ports/SkFontHost_mac.cpp
src/ports/SkFontHost_win.cpp
src/ports/SkFontMgr_FontConfigInterface.cpp
src/ports/SkFontMgr_FontConfigInterface_factory.cpp
src/ports/SkFontMgr_android.cpp
src/ports/SkFontMgr_android_factory.cpp
src/ports/SkFontMgr_custom.cpp
src/ports/SkFontMgr_custom_directory_factory.cpp
src/ports/SkFontMgr_custom_embedded_factory.cpp
src/ports/SkFontMgr_custom_empty_factory.cpp
src/ports/SkFontMgr_empty_factory.cpp
src/ports/SkFontMgr_fontconfig.cpp
src/ports/SkFontMgr_fontconfig_factory.cpp
src/ports/SkFontMgr_win_dw.cpp
src/ports/SkFontMgr_win_dw_factory.cpp
src/ports/SkFontMgr_win_gdi_factory.cpp

index 216fdd8249f7144016e9e6157f4c583db5a4019b..18fc1d9250f69654c566528d72b3e3c8fdef6d3b 100644 (file)
@@ -55,6 +55,7 @@ static const char* ja = "ja";
 
 class FontMgrGM : public skiagm::GM {
 public:
+#ifdef SK_LEGACY_FONTMGR_FACTORY
     FontMgrGM(SkFontMgr* fontMgr = nullptr) {
         SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
 
@@ -68,6 +69,21 @@ public:
         fName.append(sk_tool_utils::platform_os_name());
         fName.append(sk_tool_utils::platform_extra_config("GDI"));
     }
+#else
+    FontMgrGM(sk_sp<SkFontMgr> fontMgr = nullptr) {
+        SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
+
+        fName.set("fontmgr_iter");
+        if (fontMgr) {
+            fName.append("_factory");
+            fFM = std::move(fontMgr);
+        } else {
+            fFM = SkFontMgr::RefDefault();
+        }
+        fName.append(sk_tool_utils::platform_os_name());
+        fName.append(sk_tool_utils::platform_extra_config("GDI"));
+    }
+#endif
 
 protected:
     SkString onShortName() override {
@@ -225,7 +241,11 @@ public:
         }
         fName.append(sk_tool_utils::platform_os_name());
         fName.append(sk_tool_utils::platform_extra_config("GDI"));
+#ifdef SK_LEGACY_FONTMGR_FACTORY
         fFM.reset(SkFontMgr::RefDefault());
+#else
+        fFM = SkFontMgr::RefDefault();
+#endif
     }
 
     static void show_bounds(SkCanvas* canvas, const SkPaint& paint, SkScalar x, SkScalar y,
index afadeaaa9785fe55f4f7ce686878d5487aed8c0f..a9317d31e4a9cf2d8780083ab97229fd9c45dafa 100644 (file)
@@ -165,11 +165,12 @@ public:
 
     SkTypeface* legacyCreateTypeface(const char familyName[], SkFontStyle style) const;
 
-    /**
-     *  Return a ref to the default fontmgr. The caller must call unref() on
-     *  the returned object.
-     */
+    /** Return the default fontmgr. */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
     static SkFontMgr* RefDefault();
+#else
+    static sk_sp<SkFontMgr> RefDefault();
+#endif
 
 protected:
     virtual int onCountFamilies() const = 0;
@@ -197,7 +198,13 @@ protected:
     virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle) const = 0;
 
 private:
-    static SkFontMgr* Factory();    // implemented by porting layer
+
+    /** Implemented by porting layer to return the default factory. */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
+    static SkFontMgr* Factory();
+#else
+    static sk_sp<SkFontMgr> Factory();
+#endif
 
     typedef SkRefCnt INHERITED;
 };
index 356e54c87d0b6202035b76884c0b11de71083e76..6cf34d013c19f1ee7339f7fff643e863668b9da8 100644 (file)
@@ -15,6 +15,10 @@ class SkFontMgr;
 class SkFontConfigInterface;
 
 /** Creates a SkFontMgr which wraps a SkFontConfigInterface. */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_FCI(sk_sp<SkFontConfigInterface> fci);
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_FCI(sk_sp<SkFontConfigInterface> fci);
+#endif
 
 #endif // #ifndef SkFontMgr_FontConfigInterface_DEFINED
index f12f51f36afccfe69db0c5a6de12285c6b314a33..9ed435dc0d47eef0eab11868cfb133ae79c2bf8a 100644 (file)
@@ -47,6 +47,10 @@ struct SkFontMgr_Android_CustomFonts {
 };
 
 /** Create a font manager for Android. If 'custom' is NULL, use only system fonts. */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom);
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom);
+#endif
 
 #endif // SkFontMgr_android_DEFINED
index 53be63db1b4d0294482ef95ea15330caafaccd1c..9d3986d161b147de95948b52f471d5e49ef5de94 100644 (file)
 class SkFontMgr;
 
 /** Create a custom font manager which scans a given directory for font files. */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_Custom_Directory(const char* dir);
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_Custom_Directory(const char* dir);
+#endif
 
 /** Create a custom font manager that contains no built-in fonts. */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_Custom_Empty();
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_Custom_Empty();
+#endif
 
 #endif // SkFontMgr_custom_DEFINED
index 7a59ff0c469e7ceeb5266f905ed6f68febd9d944..ed479828eab60195c20c242f128da01d782ae283 100644 (file)
@@ -17,6 +17,10 @@ class SkFontMgr;
  *  If 'fc' is NULL, will use a new default config.
  *  Takes ownership of 'fc' and will call FcConfigDestroy on it.
  */
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc);
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_FontConfig(FcConfig* fc);
+#endif
 
 #endif // #ifndef SkFontMgr_fontconfig_DEFINED
index f3a881f3cc36463d4eb0dd4d94411f99dd439bb6..e332f00b7204ecdd83139b34cae5bb717a10b4eb 100644 (file)
@@ -44,6 +44,7 @@ struct IDWriteFactory;
 struct IDWriteFontCollection;
 struct IDWriteFontFallback;
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_GDI();
 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
                                             IDWriteFontCollection* collection = NULL);
@@ -66,6 +67,30 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr>);
  *  If DirectWrite could not be initialized, will return NULL.
  */
 SK_API SkRemotableFontMgr* SkRemotableFontMgr_New_DirectWrite();
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_GDI();
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
+                                                  IDWriteFontCollection* collection = NULL);
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
+                                                  IDWriteFontCollection* collection,
+                                                  IDWriteFontFallback* fallback);
+
+/**
+ *  Creates an SkFontMgr which renders using DirectWrite and obtains its data
+ *  from the SkRemotableFontMgr.
+ *
+ *  If DirectWrite could not be initialized, will return NULL.
+ */
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr>);
+
+/**
+ *  Creates an SkRemotableFontMgr backed by DirectWrite using the default
+ *  system font collection in the current locale.
+ *
+ *  If DirectWrite could not be initialized, will return NULL.
+ */
+SK_API sk_sp<SkRemotableFontMgr> SkRemotableFontMgr_New_DirectWrite();
+#endif
 
 #endif  // SK_BUILD_FOR_WIN
 #endif  // SkTypeface_win_DEFINED
index 57f82b03ba28201a21959f67ace59c7787191bc7..b9865a2597151a4d51d63e81423ef5b1192571e5 100644 (file)
@@ -167,6 +167,7 @@ SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], SkFontStyle
     return this->onLegacyCreateTypeface(familyName, style);
 }
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::RefDefault() {
     static SkOnce once;
     static SkFontMgr* singleton;
@@ -177,6 +178,18 @@ SkFontMgr* SkFontMgr::RefDefault() {
     });
     return SkRef(singleton);
 }
+#else
+sk_sp<SkFontMgr> SkFontMgr::RefDefault() {
+    static SkOnce once;
+    static sk_sp<SkFontMgr> singleton;
+
+    once([]{
+        sk_sp<SkFontMgr> fm = SkFontMgr::Factory();
+        singleton = fm ? std::move(fm) : sk_make_sp<SkEmptyFontMgr>();
+    });
+    return singleton;
+}
+#endif
 
 /**
 * Width has the greatest priority.
index 2c2f373db59b3dc5551ea6df93245aa82fe363b5..274c9253a90b56d7ec8600e87a70d4c21364cbb2 100644 (file)
@@ -2379,6 +2379,10 @@ protected:
 
 ///////////////////////////////////////////////////////////////////////////////
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; }
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() { return sk_make_sp<SkFontMgr_Mac>(); }
+#endif
 
 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
index 9229be6d301b0dd95f9d86818df0c4fff3e2fc82..9caff02b5457cc14914369819a8d60205e192889 100644 (file)
@@ -2487,6 +2487,10 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////////
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; }
+#else
+sk_sp<SkFontMgr> SkFontMgr_New_GDI() { return sk_make_sp<SkFontMgrGDI>(); }
+#endif
 
 #endif//defined(SK_BUILD_FOR_WIN32)
index a8838046c55d9f497c18c34ddc61f225116d76df..201306c805192d28a509f5dd9ff2b003616d876e 100644 (file)
@@ -296,7 +296,14 @@ protected:
     }
 };
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_FCI(sk_sp<SkFontConfigInterface> fci) {
     SkASSERT(fci);
     return new SkFontMgr_FCI(std::move(fci));
 }
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_FCI(sk_sp<SkFontConfigInterface> fci) {
+    SkASSERT(fci);
+    return sk_make_sp<SkFontMgr_FCI>(std::move(fci));
+}
+#endif
index b2bb74ee1d6255413a1e6094380bb622202d7db0..2aa617c75714a1ab33906676da3ac11c98820d88 100644 (file)
@@ -9,7 +9,11 @@
 #include "SkFontMgr.h"
 #include "SkFontMgr_FontConfigInterface.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     sk_sp<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal());
     if (!fci) {
         return nullptr;
index 116bc01549732e68edf0f21112073b7b3994af92..fe4a82d9643a338e28f0c27e8c572f7891418785 100644 (file)
@@ -535,7 +535,11 @@ static char const * const gSystemFontUseStrings[] = {
     "OnlyCustom", "PreferCustom", "PreferSystem"
 };
 #endif
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom) {
+#else
+sk_sp<SkFontMgr> SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom) {
+#endif
     if (custom) {
         SkASSERT(0 <= custom->fSystemFontUse);
         SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings));
@@ -545,6 +549,9 @@ SkFontMgr* SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom) {
                   custom->fFontsXml,
                   custom->fFallbackFontsXml));
     }
-
+#ifdef SK_LEGACY_FONTMGR_FACTORY
     return new SkFontMgr_Android(custom);
+#else
+    return sk_make_sp<SkFontMgr_Android>(custom);
+#endif
 }
index ce39b2cf97df5d89b4bf5fee137d5d0e4880af18..74bcef2de5db5ccdea11a553457373651819c2e7 100644 (file)
@@ -28,7 +28,11 @@ void SkUseTestFontConfigFile(const char* fontsXml, const char* fallbackFontsXml,
               gTestBasePath, gTestFontsXml, gTestFallbackFontsXml));
 }
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     // These globals exist so that Chromium can override the environment.
     // TODO: these globals need to be removed, and Chromium use SkFontMgr_New_Android instead.
     if ((gTestFontsXml || gTestFallbackFontsXml) && gTestBasePath) {
index ada7d0b190060c360c1148112abd4858f22fd525..5cfdb081d6ce4fc0f0c1d44da1e2d345af285258 100644 (file)
@@ -420,9 +420,15 @@ private:
     SkString fBaseDirectory;
 };
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_Custom_Directory(const char* dir) {
     return new SkFontMgr_Custom(DirectorySystemFontLoader(dir));
 }
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_Custom_Directory(const char* dir) {
+    return sk_make_sp<SkFontMgr_Custom>(DirectorySystemFontLoader(dir));
+}
+#endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -498,9 +504,15 @@ private:
     const SkEmbeddedResourceHeader* fHeader;
 };
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header) {
     return new SkFontMgr_Custom(EmbeddedSystemFontLoader(header));
 }
+#else
+sk_sp<SkFontMgr> SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header) {
+    return sk_make_sp<SkFontMgr_Custom>(EmbeddedSystemFontLoader(header));
+}
+#endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -518,6 +530,12 @@ public:
 
 };
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_Custom_Empty() {
     return new SkFontMgr_Custom(EmptyFontLoader());
 }
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_Custom_Empty() {
+    return sk_make_sp<SkFontMgr_Custom>(EmptyFontLoader());
+}
+#endif
index 0ca6f4b3b4b6968232437381278f13239ab3a3c9..5cf6d3cb044f4fbcd1d160e487ec385009d134bc 100644 (file)
 #    define SK_FONT_FILE_PREFIX "/usr/share/fonts/"
 #endif
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     return SkFontMgr_New_Custom_Directory(SK_FONT_FILE_PREFIX);
 }
index 6ea6a2d2af22cbdeaa51a6de58e8d70d00997c42..79d5500648d8f2e09e4d2db1c88c4c489a4e6ea5 100644 (file)
@@ -9,9 +9,17 @@
 
 struct SkEmbeddedResource { const uint8_t* data; size_t size; };
 struct SkEmbeddedResourceHeader { const SkEmbeddedResource* entries; int count; };
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header);
+#else
+sk_sp<SkFontMgr> SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header);
+#endif
 
 extern "C" const SkEmbeddedResourceHeader SK_EMBEDDED_FONTS;
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     return SkFontMgr_New_Custom_Embedded(&SK_EMBEDDED_FONTS);
 }
index c9487cdcc717823ee22dbfa29e0abbec207dc815..c95647ef24e03d7a6c2aa30d77de2cc66bf9b6ed 100644 (file)
@@ -8,6 +8,10 @@
 #include "SkFontMgr.h"
 #include "SkFontMgr_custom.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     return SkFontMgr_New_Custom_Empty();
 }
index b4232cde1270870bd6cb40e82b710e52377dfa1f..b01811a33543ac0542d6a03bb91cfba41052430e 100644 (file)
@@ -7,7 +7,11 @@
 
 #include "SkFontMgr.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     // Always return nullptr, an empty SkFontMgr will be used.
     return nullptr;
 }
index 3592feccfb9e66b995f2dbb662070099d6d8ba20..28edcf790b9697c146f24e7ec0514e5fd2b331a8 100644 (file)
@@ -953,6 +953,12 @@ protected:
     }
 };
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) {
     return new SkFontMgr_fontconfig(fc);
 }
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_FontConfig(FcConfig* fc) {
+    return sk_make_sp<SkFontMgr_fontconfig>(fc);
+}
+#endif
index cdf055608d5477d2e4762dae1dbeacef6490850b..1a86ed5323bc33b4fe5851d31c2504e7c8c189c3 100644 (file)
@@ -9,6 +9,10 @@
 #include "SkFontMgr_fontconfig.h"
 #include "SkTypes.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     return SkFontMgr_New_FontConfig(nullptr);
 }
index 547cbe36394e63c44e4923d7c2e4e037b979bb35..29069f069e86b3f8110c669748ccac20b3bb6251 100644 (file)
@@ -1043,12 +1043,20 @@ SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
 ////////////////////////////////////////////////////////////////////////////////
 #include "SkTypeface_win.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
+#endif
                                             IDWriteFontCollection* collection) {
     return SkFontMgr_New_DirectWrite(factory, collection, nullptr);
 }
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
+#endif
                                             IDWriteFontCollection* collection,
                                             IDWriteFontFallback* fallback) {
     if (nullptr == factory) {
@@ -1081,15 +1089,28 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
         };
     }
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
     return new SkFontMgr_DirectWrite(factory, collection, fallback, localeName, localeNameLen);
+#else
+    return sk_make_sp<SkFontMgr_DirectWrite>(factory, collection, fallback,
+                                             localeName, localeNameLen);
+#endif
 }
 
 #include "SkFontMgr_indirect.h"
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr> proxy) {
+#else
+SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr> proxy) {
+#endif
     sk_sp<SkFontMgr> impl(SkFontMgr_New_DirectWrite());
     if (!impl) {
         return nullptr;
     }
+#ifdef SK_LEGACY_FONTMGR_FACTORY
     return new SkFontMgr_Indirect(std::move(impl), std::move(proxy));
+#else
+    return sk_make_sp<SkFontMgr_Indirect>(std::move(impl), std::move(proxy));
+#endif
 }
 #endif//defined(SK_BUILD_FOR_WIN32)
index 52e22aec52682ac6aefb82ebd3afe1f5437db24e..01a0e0be8a1f698b03764d426d50f5862ee9efad 100644 (file)
 #include "SkFontMgr.h"
 #include "SkTypeface_win.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     return SkFontMgr_New_DirectWrite();
 }
 
index c1ca822c28f6a689bf08fbaa936b5bd621cace97..040778e17487103b5b2b26fde7b5dd6072c630b8 100644 (file)
 #include "SkFontMgr.h"
 #include "SkTypeface_win.h"
 
+#ifdef SK_LEGACY_FONTMGR_FACTORY
 SkFontMgr* SkFontMgr::Factory() {
+#else
+sk_sp<SkFontMgr> SkFontMgr::Factory() {
+#endif
     return SkFontMgr_New_GDI();
 }