Chromium Code Reviews| Index: include/core/SkTypeface.h |
| diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h |
| index 0fbf6a3e0ad337395c66f513e73eb6a37f61e8f2..44933a7b7561bdfcfd0b3d68841450858400c5c5 100644 |
| --- a/include/core/SkTypeface.h |
| +++ b/include/core/SkTypeface.h |
| @@ -96,7 +96,12 @@ public: |
| * Returns a ref() to the default typeface. The caller must call unref() |
|
tomhudson
2016/04/29 21:10:36
If we don't update these comments now, we'll need
bungeman-skia
2016/04/29 22:03:23
Yeah, these static methods are legacy as far as I'
|
| * when they are done referencing the object. Never returns NULL. |
| */ |
| - static SkTypeface* RefDefault(Style style = SkTypeface::kNormal); |
| + static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* RefDefault(Style style = SkTypeface::kNormal) { |
| + return MakeDefault(style).release(); |
| + } |
| +#endif |
| /** Return a new reference to the typeface that most closely matches the |
| requested familyName and style. Pass null as the familyName to return |
| @@ -107,7 +112,12 @@ public: |
| @return reference to the closest-matching typeface. Call must call |
| unref() when they are done. |
| */ |
| - static SkTypeface* CreateFromName(const char familyName[], Style style); |
| + static sk_sp<SkTypeface> MakeFromName(const char familyName[], Style style); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* CreateFromName(const char familyName[], Style style) { |
| + return MakeFromName(familyName, style).release(); |
| + } |
| +#endif |
| /** Return a new reference to the typeface that most closely matches the |
| requested typeface and specified Style. Use this call if you want to |
| @@ -119,24 +129,44 @@ public: |
| @return reference to the closest-matching typeface. Call must call |
| unref() when they are done. |
| */ |
| - static SkTypeface* CreateFromTypeface(const SkTypeface* family, Style s); |
| + static sk_sp<SkTypeface> MakeFromTypeface(SkTypeface* family, Style); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* CreateFromTypeface(const SkTypeface* family, Style style) { |
| + return MakeFromTypeface(const_cast<SkTypeface*>(family), style).release(); |
| + } |
| +#endif |
| /** Return a new typeface given a file. If the file does not exist, or is |
| not a valid font file, returns null. |
| */ |
| - static SkTypeface* CreateFromFile(const char path[], int index = 0); |
| + static sk_sp<SkTypeface> MakeFromFile(const char path[], int index = 0); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* CreateFromFile(const char path[], int index = 0) { |
| + return MakeFromFile(path, index).release(); |
| + } |
| +#endif |
| /** Return a new typeface given a stream. If the stream is |
| not a valid font file, returns null. Ownership of the stream is |
| transferred, so the caller must not reference it again. |
| */ |
| - static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0); |
| + static sk_sp<SkTypeface> MakeFromStream(SkStreamAsset* stream, int index = 0); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0) { |
| + return MakeFromStream(stream, index).release(); |
| + } |
| +#endif |
| /** Return a new typeface given font data and configuration. If the data |
| is not valid font data, returns null. Ownership of the font data is |
| transferred, so the caller must not reference it again. |
| */ |
| - static SkTypeface* CreateFromFontData(SkFontData*); |
| + static sk_sp<SkTypeface> MakeFromFontData(SkFontData*); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* CreateFromFontData(SkFontData* fd) { |
| + return MakeFromFontData(fd).release(); |
| + } |
| +#endif |
| /** Write a unique signature to a stream, sufficient to reconstruct a |
| typeface referencing the same font when Deserialize is called. |
| @@ -149,7 +179,12 @@ public: |
| calling unref() when they are done with it. |
| Does not affect ownership of SkStream. |
| */ |
| - static SkTypeface* Deserialize(SkStream*); |
| + static sk_sp<SkTypeface> MakeDeserialize(SkStream*); |
| +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| + static SkTypeface* Deserialize(SkStream* stream) { |
| + return MakeDeserialize(stream).release(); |
| + } |
| +#endif |
| enum Encoding { |
| kUTF8_Encoding, |
| @@ -395,9 +430,6 @@ private: |
| uint32_t glyphIDsCount = 0) const; |
| private: |
| - static SkTypeface* CreateDefault(int style); // SkLazyPtr requires an int, not a Style. |
| - static void DeleteDefault(SkTypeface*); |
| - |
| SkOncePtr<SkRect> fLazyBounds; |
| SkFontID fUniqueID; |
| SkFontStyle fStyle; |