aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-04 19:07:02 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-04 19:07:02 +0000
commitd66045ec7d37720309dae4879efc01793c3e746a (patch)
tree7f191a3e86945bd16286e7924fc1a50e14cd3c0d
parent86a44b89c5bd6345790c03fba63969cd1c19e66b (diff)
export getter for global instance of fontconfiginterfacedirect
git-svn-id: http://skia.googlecode.com/svn/trunk@7963 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/ports/SkFontConfigInterface.h6
-rw-r--r--src/ports/SkFontConfigInterface_direct.cpp9
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp4
3 files changed, 14 insertions, 5 deletions
diff --git a/include/ports/SkFontConfigInterface.h b/include/ports/SkFontConfigInterface.h
index c2be8c817b..1e20438a08 100644
--- a/include/ports/SkFontConfigInterface.h
+++ b/include/ports/SkFontConfigInterface.h
@@ -66,6 +66,12 @@ public:
* calling stream->unref() when it is done accessing the data.
*/
virtual SkStream* openStream(const FontIdentity&) = 0;
+
+ /**
+ * Return a singleton instance of a direct subclass that calls into
+ * libfontconfig. This does not affect the refcnt of the returned instance.
+ */
+ static SkFontConfigInterface* GetSingletonDirectInterface();
};
#endif
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp
index a9e1f5ea02..83e01c1f1a 100644
--- a/src/ports/SkFontConfigInterface_direct.cpp
+++ b/src/ports/SkFontConfigInterface_direct.cpp
@@ -32,9 +32,12 @@ private:
SkMutex mutex_;
};
-SkFontConfigInterface* SkCreateDirectFontConfigInterface();
-SkFontConfigInterface* SkCreateDirectFontConfigInterface() {
- return SkNEW(SkFontConfigInterfaceDirect);
+SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() {
+ static SkFontConfigInterface* gDirect;
+ if (NULL == gDirect) {
+ gDirect = new SkFontConfigInterfaceDirect;
+ }
+ return gDirect;
}
namespace {
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index a254d360bd..28a938e7f6 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -41,8 +41,8 @@ static SkFontConfigInterface* RefFCI() {
if (fci) {
return fci;
}
- fci = SkCreateDirectFontConfigInterface();
- SkFontConfigInterface::SetGlobal(fci)->unref();
+ fci = SkFontConfigInterface::GetSingletonDirectInterface();
+ SkFontConfigInterface::SetGlobal(fci);
}
}