summaryrefslogtreecommitdiff
path: root/core/fxge/cttfontdesc.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-30 21:02:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-30 21:02:03 +0000
commitda65a8ea74d2748c93015fb5521da678e29e6548 (patch)
treec9455640dd3e89a43ab4cf7e3bf17ed475033b5d /core/fxge/cttfontdesc.h
parentf213df4a87ede709db1f311bbad3c68fbccf159c (diff)
downloadpdfium-da65a8ea74d2748c93015fb5521da678e29e6548.tar.xz
Saner memory managment in cttfontdesc, part 1.
A subsequent patch will tackle the ad-hoc ref counting, but we can tidy this before going down that hole. Decouple CTTFontDesc creation from face setting. Remove union and treat single-entry case as vector's first element. Pass unique_ptr to prove memory ownership. Change-Id: Ic427798da04f3afbb65a56ee10045b9f22457a73 Reviewed-on: https://pdfium-review.googlesource.com/31730 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge/cttfontdesc.h')
-rw-r--r--core/fxge/cttfontdesc.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/core/fxge/cttfontdesc.h b/core/fxge/cttfontdesc.h
index bc0ea1737f..e73b03f6ec 100644
--- a/core/fxge/cttfontdesc.h
+++ b/core/fxge/cttfontdesc.h
@@ -7,6 +7,9 @@
#ifndef CORE_FXGE_CTTFONTDESC_H_
#define CORE_FXGE_CTTFONTDESC_H_
+#include <memory>
+
+#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/fx_font.h"
@@ -18,34 +21,23 @@ class CTTFontDesc {
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);
-
+ explicit CTTFontDesc(std::unique_ptr<uint8_t, FxFreeDeleter> pData);
~CTTFontDesc();
- void SetTTCFace(size_t index, FXFT_Face face);
+ void SetFace(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;
+ uint8_t* FontData() const { return m_pFontData.get(); }
+ FXFT_Face GetFace(size_t index) const;
private:
- const bool m_bIsTTC;
int m_RefCount = 1;
- uint8_t* const m_pFontData;
- union {
- const FXFT_Face m_SingleFace;
- FXFT_Face m_TTCFaces[16];
- };
+ std::unique_ptr<uint8_t, FxFreeDeleter> const m_pFontData;
+ FXFT_Face m_TTCFaces[16];
};
#endif // CORE_FXGE_CTTFONTDESC_H_