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

Unified Diff: src/utils/win/SkDWrite.cpp

Issue 302083003: Clean up SkOnce: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unused 1 == Created 6 years, 7 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 | « src/utils/SkEventTracer.cpp ('k') | tests/OnceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/win/SkDWrite.cpp
diff --git a/src/utils/win/SkDWrite.cpp b/src/utils/win/SkDWrite.cpp
index 16e8ddc4d0d93c4103283616199df0ed5df9aa18..87826b5194e4e52a8a540efb3df10ced65a7c009 100644
--- a/src/utils/win/SkDWrite.cpp
+++ b/src/utils/win/SkDWrite.cpp
@@ -14,6 +14,12 @@
static IDWriteFactory* gDWriteFactory = NULL;
+static void release_dwrite_factory() {
+ if (gDWriteFactory) {
+ gDWriteFactory->Release();
+ }
+}
+
static void create_dwrite_factory(IDWriteFactory** factory) {
typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
DWriteCreateFactoryProc dWriteCreateFactoryProc = reinterpret_cast<DWriteCreateFactoryProc>(
@@ -31,17 +37,13 @@ static void create_dwrite_factory(IDWriteFactory** factory) {
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(factory)),
"Could not create DirectWrite factory.");
+ atexit(release_dwrite_factory);
}
-static void release_dwrite_factory() {
- if (gDWriteFactory) {
- gDWriteFactory->Release();
- }
-}
IDWriteFactory* sk_get_dwrite_factory() {
SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, create_dwrite_factory, &gDWriteFactory, release_dwrite_factory);
+ SkOnce(&once, create_dwrite_factory, &gDWriteFactory);
return gDWriteFactory;
}
« no previous file with comments | « src/utils/SkEventTracer.cpp ('k') | tests/OnceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698