diff options
author | 2013-03-14 15:04:57 +0000 | |
---|---|---|
committer | 2013-03-14 15:04:57 +0000 | |
commit | fed86bdb8b9f037439bbfa7cdbd53a581dbc5985 (patch) | |
tree | b03a35f11ee303aed8cd9c3c6210b22ba463c2dc /src/core/SkTypefacePriv.h | |
parent | a936e37cc76614868f5b489395bceeb340cc04cd (diff) |
move most of SkFontHost to private (preceeding making it all private)
In this change, have to accomodate PDF wanting to call openStream and advancedMetrics
Review URL: https://codereview.chromium.org/12739006
git-svn-id: http://skia.googlecode.com/svn/trunk@8156 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkTypefacePriv.h')
-rw-r--r-- | src/core/SkTypefacePriv.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/core/SkTypefacePriv.h b/src/core/SkTypefacePriv.h new file mode 100644 index 0000000000..2f48372b0e --- /dev/null +++ b/src/core/SkTypefacePriv.h @@ -0,0 +1,38 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkTypefacePriv_DEFINED +#define SkTypefacePriv_DEFINED + +#include "SkTypeface.h" + +/** + * Return a ref'd typeface, which must later be unref'd + * + * If the parameter is non-null, it will be ref'd and returned, otherwise + * it will be the default typeface. + */ +static inline SkTypeface* ref_or_default(SkTypeface* face) { + return face ? SkRef(face) : SkTypeface::RefDefault(); +} + +/** + * Always resolves to a non-null typeface, either the value passed to its + * constructor, or the default typeface if null was passed. + */ +class SkAutoResolveDefaultTypeface : public SkAutoTUnref<SkTypeface> { +public: + SkAutoResolveDefaultTypeface() : INHERITED(SkTypeface::RefDefault()) {} + + SkAutoResolveDefaultTypeface(SkTypeface* face) + : INHERITED(ref_or_default(face)) {} + +private: + typedef SkAutoTUnref<SkTypeface> INHERITED; +}; + +#endif |