aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/ports
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-09-26 09:46:08 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-26 14:05:18 +0000
commit592273965a7fc7fc403252e420d15f6555b8f25d (patch)
tree9d5f6fa74228b81278bc97af1dc78d9587d63c08 /include/ports
parentf6f7cf60985d8e109cc136f25e2a3c3383ca05ea (diff)
Revert "Revert "migrate to sk_sp for SkFontMgr API""
This reverts commit f40ae1a4b5365620463bd63b5140bd3fc78894a1. Bug: skia: Change-Id: I752606de92ea405d6e50219c98030409b00a2841 Reviewed-on: https://skia-review.googlesource.com/51160 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include/ports')
-rw-r--r--include/ports/SkFontMgr.h59
-rw-r--r--include/ports/SkFontMgr_indirect.h9
2 files changed, 51 insertions, 17 deletions
diff --git a/include/ports/SkFontMgr.h b/include/ports/SkFontMgr.h
index b13e113a2e..08e406a97d 100644
--- a/include/ports/SkFontMgr.h
+++ b/include/ports/SkFontMgr.h
@@ -95,26 +95,28 @@ public:
* or NULL if the data is not recognized. The caller must call unref() on
* the returned object if it is not null.
*/
- SkTypeface* createFromData(SkData*, int ttcIndex = 0) const;
+ sk_sp<SkTypeface> makeFromData(sk_sp<SkData>, int ttcIndex = 0) const;
/**
* Create a typeface for the specified stream and TTC index
* (pass 0 for none) or NULL if the stream is not recognized. The caller
* must call unref() on the returned object if it is not null.
*/
- SkTypeface* createFromStream(SkStreamAsset*, int ttcIndex = 0) const;
+ sk_sp<SkTypeface> makeFromStream(std::unique_ptr<SkStreamAsset>, int ttcIndex = 0) const;
- // deprecated, use SkFontArguments instead.
+#ifdef SK_SUPPORT_LEGACY_FONTMGR_API
using FontParameters = SkFontArguments;
+#endif
+
/* Experimental, API subject to change. */
- SkTypeface* createFromStream(SkStreamAsset*, const SkFontArguments&) const;
+ sk_sp<SkTypeface> makeFromStream(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const;
/**
* Create a typeface from the specified font data.
* Will return NULL if the typeface could not be created.
* The caller must call unref() on the returned object if it is not null.
*/
- SkTypeface* createFromFontData(std::unique_ptr<SkFontData>) const;
+ sk_sp<SkTypeface> makeFromFontData(std::unique_ptr<SkFontData>) const;
/**
* Create a typeface for the specified fileName and TTC index
@@ -122,9 +124,18 @@ public:
* not recognized. The caller must call unref() on the returned object
* if it is not null.
*/
- SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const;
+ sk_sp<SkTypeface> makeFromFile(const char path[], int ttcIndex = 0) const;
+
+ sk_sp<SkTypeface> legacyMakeTypeface(const char familyName[], SkFontStyle style) const;
+#ifdef SK_SUPPORT_LEGACY_FONTMGR_API
+ SkTypeface* createFromData(SkData* data, int ttcIndex = 0) const;
+ SkTypeface* createFromStream(SkStreamAsset* strm, int ttcIndex = 0) const;
+ SkTypeface* createFromStream(SkStreamAsset* strm, const SkFontArguments& args) const;
+ SkTypeface* createFromFontData(std::unique_ptr<SkFontData> fd) const;
+ SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const;
SkTypeface* legacyCreateTypeface(const char familyName[], SkFontStyle style) const;
+#endif
/** Return the default fontmgr. */
static sk_sp<SkFontMgr> RefDefault();
@@ -145,14 +156,38 @@ protected:
virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
const SkFontStyle&) const = 0;
- virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0;
- virtual SkTypeface* onCreateFromStream(SkStreamAsset*, int ttcIndex) const = 0;
- // TODO: make pure virtual.
+#ifdef SK_SUPPORT_LEGACY_FONTMGR_API
+ // legacy virtuals
+ virtual SkTypeface* onCreateFromData(SkData*, int) const { return nullptr; }
+ virtual SkTypeface* onCreateFromStream(SkStreamAsset*, int) const { return nullptr; }
virtual SkTypeface* onCreateFromStream(SkStreamAsset*, const SkFontArguments&) const;
virtual SkTypeface* onCreateFromFontData(std::unique_ptr<SkFontData>) const;
- virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const = 0;
-
- virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle) const = 0;
+ virtual SkTypeface* onCreateFromFile(const char[], int) const { return nullptr; }
+ virtual SkTypeface* onLegacyCreateTypeface(const char[], SkFontStyle) const {
+ return nullptr;
+ }
+
+ // new virtuals express as calling legacy versions
+
+ virtual sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData> data, int ttcIndex) const;
+ virtual sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset> strm,
+ int ttcIndex) const;
+ virtual sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset> strm,
+ const SkFontArguments& args) const;
+ virtual sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> fd) const;
+ virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const;
+ virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const;
+#else
+ virtual sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const = 0;
+ virtual sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>,
+ int ttcIndex) const = 0;
+ virtual sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
+ const SkFontArguments&) const;
+ virtual sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const;
+ virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const = 0;
+
+ virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const = 0;
+#endif
private:
diff --git a/include/ports/SkFontMgr_indirect.h b/include/ports/SkFontMgr_indirect.h
index 251d74a83a..04e903ed14 100644
--- a/include/ports/SkFontMgr_indirect.h
+++ b/include/ports/SkFontMgr_indirect.h
@@ -50,11 +50,10 @@ protected:
SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
const SkFontStyle& fontStyle) const override;
- SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const override;
- SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override;
- SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override;
-
- SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle) const override;
+ sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>, int ttcIndex) const override;
+ sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;
+ sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const override;
+ sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const override;
private:
SkTypeface* createTypefaceFromFontId(const SkFontIdentity& fontId) const;