summaryrefslogtreecommitdiff
path: root/core/fxge/cttfontdesc.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-01-10 21:24:46 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 21:24:46 +0000
commit962760426dcb1801683e6fd91c4f3650eea51155 (patch)
tree9cc0755abaeb324498b9655f0763502e6872c9b6 /core/fxge/cttfontdesc.h
parenta0157f4b46e6b6253a9185f3b70a5fd22b19c3dd (diff)
downloadpdfium-962760426dcb1801683e6fd91c4f3650eea51155.tar.xz
Encapsulate CTTFontDesc.
Change-Id: I602890527dae9e2e2de16e70bccfa1793e31e0f8 Reviewed-on: https://pdfium-review.googlesource.com/22530 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fxge/cttfontdesc.h')
-rw-r--r--core/fxge/cttfontdesc.h38
1 files changed, 29 insertions, 9 deletions
diff --git a/core/fxge/cttfontdesc.h b/core/fxge/cttfontdesc.h
index ee1e0b0102..b48e78c6b6 100644
--- a/core/fxge/cttfontdesc.h
+++ b/core/fxge/cttfontdesc.h
@@ -12,21 +12,41 @@
class CTTFontDesc {
public:
- CTTFontDesc() : m_Type(0), m_pFontData(nullptr), m_RefCount(0) {}
+ enum ReleaseStatus {
+ kNotAppropriate, // ReleaseFace() not appropriate for given object.
+ kReleased,
+ kNotReleased // Object still alive.
+ };
+
+ // Single face ctor.
+ CTTFontDesc(uint8_t* pData, FXFT_Face face);
+
+ // TTC face ctor.
+ CTTFontDesc(uint8_t* pData, size_t index, FXFT_Face face);
+
~CTTFontDesc();
- // ret < 0, releaseface not appropriate for this object.
- // ret == 0, object released
- // ret > 0, object still alive, other referrers.
- int ReleaseFace(FXFT_Face face);
- int m_Type;
+ void SetTTCFace(size_t index, FXFT_Face face);
+
+ void AddRef();
+
+ // May not decrement refcount, depending on the value of |face|.
+ ReleaseStatus ReleaseFace(FXFT_Face face);
+
+ uint8_t* FontData() const { return m_pFontData; }
+
+ FXFT_Face SingleFace() const;
+ FXFT_Face TTCFace(size_t index) const;
+
+ private:
+ const bool m_bIsTTC;
union {
- FXFT_Face m_SingleFace;
+ const FXFT_Face m_SingleFace;
FXFT_Face m_TTCFaces[16];
};
- uint8_t* m_pFontData;
- int m_RefCount;
+ uint8_t* const m_pFontData;
+ int m_RefCount = 1;
};
#endif // CORE_FXGE_CTTFONTDESC_H_