| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkRemotableFontMgr.h" | 8 #include "SkRemotableFontMgr.h" |
| 9 | 9 |
| 10 #include "SkLazyPtr.h" | 10 #include "SkOnce.h" |
| 11 | 11 |
| 12 SkRemotableFontIdentitySet::SkRemotableFontIdentitySet(int count, SkFontIdentity
** data) | 12 SkRemotableFontIdentitySet::SkRemotableFontIdentitySet(int count, SkFontIdentity
** data) |
| 13 : fCount(count), fData(count) | 13 : fCount(count), fData(count) |
| 14 { | 14 { |
| 15 SkASSERT(data); | 15 SkASSERT(data); |
| 16 *data = fData; | 16 *data = fData; |
| 17 } | 17 } |
| 18 | 18 |
| 19 SkRemotableFontIdentitySet* SkRemotableFontIdentitySet::NewEmptyImpl() { | 19 static SkRemotableFontIdentitySet* gEmptyRemotableFontIdentitySet = NULL; |
| 20 return SkNEW(SkRemotableFontIdentitySet); | 20 static void cleanup_gEmptyRemotableFontIdentitySet() { gEmptyRemotableFontIdenti
tySet->unref(); } |
| 21 |
| 22 void SkRemotableFontIdentitySet::NewEmptyImpl(int) { |
| 23 gEmptyRemotableFontIdentitySet = new SkRemotableFontIdentitySet(); |
| 21 } | 24 } |
| 22 | 25 |
| 23 SkRemotableFontIdentitySet* SkRemotableFontIdentitySet::NewEmpty() { | 26 SkRemotableFontIdentitySet* SkRemotableFontIdentitySet::NewEmpty() { |
| 24 SK_DECLARE_STATIC_LAZY_PTR(SkRemotableFontIdentitySet, empty, NewEmptyImpl); | 27 SK_DECLARE_STATIC_ONCE(once); |
| 25 return SkRef(empty.get()); | 28 SkOnce(&once, SkRemotableFontIdentitySet::NewEmptyImpl, 0, |
| 29 cleanup_gEmptyRemotableFontIdentitySet); |
| 30 gEmptyRemotableFontIdentitySet->ref(); |
| 31 return gEmptyRemotableFontIdentitySet; |
| 26 } | 32 } |
| OLD | NEW |