Chromium Code Reviews| Index: src/core/SkFontDescriptor.h |
| diff --git a/src/core/SkFontDescriptor.h b/src/core/SkFontDescriptor.h |
| index 66707ddd3c5e10819ecd87e4d2352ed603c85817..8a837ae46fbf0efa274e349f05e759f04e079f06 100644 |
| --- a/src/core/SkFontDescriptor.h |
| +++ b/src/core/SkFontDescriptor.h |
| @@ -12,6 +12,29 @@ |
| #include "SkString.h" |
| #include "SkTypeface.h" |
| +class SkFontData { |
| +public: |
| + /** This takes ownership of 'stream'. Makes a copy of the data in 'axis'. */ |
| + SkFontData(SkStreamAsset* stream, int index, int axisCount, const SkFixed axis[]) |
| + : fStream(stream), fIndex(index), fAxisCount(axisCount), fAxis(axisCount) |
| + { |
| + for (int i = 0; i < axisCount; ++i) { |
| + fAxis[i] = axis[i]; |
| + } |
| + } |
| + bool hasStream() const { return fStream.get() != NULL; } |
| + SkStreamAsset* transferStream() { return fStream.detach(); } |
| + int getIndex() const { return fIndex; } |
| + int getAxisCount() const { return fAxisCount; } |
| + const SkFixed* getAxis() const { return fAxis.get(); } |
| + |
| +private: |
| + SkAutoTDelete<SkStreamAsset> fStream; |
| + int fIndex; |
| + int fAxisCount; |
| + SkAutoSTMalloc<4, SkFixed> fAxis; |
|
bungeman-skia
2015/04/23 21:16:34
Is this the right way to serialize the axes (as a
|
| +}; |
| + |
| class SkFontDescriptor { |
| public: |
| SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal); |
| @@ -28,24 +51,20 @@ public: |
| const char* getPostscriptName() const { return fPostscriptName.c_str(); } |
| bool hasFontData() const { return fFontData.get() != NULL; } |
| // Transfers ownership to the caller. |
| - SkStreamAsset* transferFontData() { return fFontData.detach(); } |
| - int getFontIndex() const { return fFontIndex; } |
| + SkFontData* getFontData() { return fFontData.get(); } |
| void setFamilyName(const char* name) { fFamilyName.set(name); } |
| void setFullName(const char* name) { fFullName.set(name); } |
| void setPostscriptName(const char* name) { fPostscriptName.set(name); } |
| /** Set the font data only if it is necessary for serialization. |
| - * This method takes ownership of the stream (both reference and cursor). |
| - */ |
| - void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); } |
| - void setFontIndex(int index) { fFontIndex = index; } |
| + * This method takes ownership of the font data. */ |
| + void setFontData(SkFontData* data) { fFontData.reset(data); } |
| private: |
| SkString fFamilyName; |
| SkString fFullName; |
| SkString fPostscriptName; |
| - SkAutoTDelete<SkStreamAsset> fFontData; |
| - int fFontIndex; |
| + SkAutoTDelete<SkFontData> fFontData; |
| SkTypeface::Style fStyle; |
| }; |