aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontMgr_win_dw.cpp
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2017-01-03 13:32:36 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-04 14:51:09 +0000
commit3546ff10c2e1e91f5afe1efaab4e5e14f71689d1 (patch)
treecbcf83ae724df22c6cc5704a75be9095a28058db /src/ports/SkFontMgr_win_dw.cpp
parent8bc9f7b32867cb46fd7b56c11bf9dfa79a7d246e (diff)
Stage SkFontMgr factories to return smart pointers.
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>
Diffstat (limited to 'src/ports/SkFontMgr_win_dw.cpp')
-rw-r--r--src/ports/SkFontMgr_win_dw.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index 547cbe3639..29069f069e 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -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)