diff options
author | 2014-05-30 21:00:52 +0000 | |
---|---|---|
committer | 2014-05-30 21:00:52 +0000 | |
commit | f6351a071810b3a848a5002a0c0ba7e1490fd0db (patch) | |
tree | 07dcff256e7ba4b7a1a7b2cb5b6fdca8c42938c5 /src/fonts | |
parent | 97f5fc651956287e78e35934cf62b9e1b45b4f6c (diff) |
Revert of Port most uses of SkOnce to SkLazyPtr. (https://codereview.chromium.org/304383005/)
Reason for revert:
Leaking refs on SkTypeface on Macs.
Original issue's description:
> Port most uses of SkOnce to SkLazyPtr.
>
> BUG=skia:
>
> Committed: http://code.google.com/p/skia/source/detail?r=15006
R=reed@google.com, mtklein@chromium.org
TBR=mtklein@chromium.org, reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/304283007
git-svn-id: http://skia.googlecode.com/svn/trunk@15009 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/fonts')
-rw-r--r-- | src/fonts/SkRemotableFontMgr.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/fonts/SkRemotableFontMgr.cpp b/src/fonts/SkRemotableFontMgr.cpp index 633e91458b..1139972848 100644 --- a/src/fonts/SkRemotableFontMgr.cpp +++ b/src/fonts/SkRemotableFontMgr.cpp @@ -7,7 +7,7 @@ #include "SkRemotableFontMgr.h" -#include "SkLazyPtr.h" +#include "SkOnce.h" SkRemotableFontIdentitySet::SkRemotableFontIdentitySet(int count, SkFontIdentity** data) : fCount(count), fData(count) @@ -16,11 +16,17 @@ SkRemotableFontIdentitySet::SkRemotableFontIdentitySet(int count, SkFontIdentity *data = fData; } -SkRemotableFontIdentitySet* SkRemotableFontIdentitySet::NewEmptyImpl() { - return SkNEW(SkRemotableFontIdentitySet); +static SkRemotableFontIdentitySet* gEmptyRemotableFontIdentitySet = NULL; +static void cleanup_gEmptyRemotableFontIdentitySet() { gEmptyRemotableFontIdentitySet->unref(); } + +void SkRemotableFontIdentitySet::NewEmptyImpl(int) { + gEmptyRemotableFontIdentitySet = new SkRemotableFontIdentitySet(); } SkRemotableFontIdentitySet* SkRemotableFontIdentitySet::NewEmpty() { - SK_DECLARE_STATIC_LAZY_PTR(SkRemotableFontIdentitySet, empty, NewEmptyImpl); - return SkRef(empty.get()); + SK_DECLARE_STATIC_ONCE(once); + SkOnce(&once, SkRemotableFontIdentitySet::NewEmptyImpl, 0, + cleanup_gEmptyRemotableFontIdentitySet); + gEmptyRemotableFontIdentitySet->ref(); + return gEmptyRemotableFontIdentitySet; } |