summaryrefslogtreecommitdiff
path: root/xfa/fgas/font
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-07 12:10:20 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-07 12:10:20 -0800
commit7cda31ac2f2884166f044937619478a6103198cf (patch)
tree640f14ab5c81696cfffdedf0644eac4b1f2bc47f /xfa/fgas/font
parentab5a20d9de8c801b8376bfe2d6f7cf9ac7d26028 (diff)
downloadpdfium-7cda31ac2f2884166f044937619478a6103198cf.tar.xz
Refcount IFGAS_ streams all the time, too
IFGAS_Streams are not part of the IFX_Stream hierarchy, but can be made from such. Review-Url: https://codereview.chromium.org/2559763002
Diffstat (limited to 'xfa/fgas/font')
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp14
-rw-r--r--xfa/fgas/font/cfgas_gefont.h7
2 files changed, 12 insertions, 9 deletions
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 3bca4dc09f..bc971f6294 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -72,9 +72,10 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer,
}
// static
-CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFGAS_Stream* pFontStream,
- CFGAS_FontMgr* pFontMgr,
- bool bSaveStream) {
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(
+ const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ CFGAS_FontMgr* pFontMgr,
+ bool bSaveStream) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) {
pFont->Release();
@@ -203,12 +204,13 @@ bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
return InitFont();
}
-bool CFGAS_GEFont::LoadFontInternal(IFGAS_Stream* pFontStream,
- bool bSaveStream) {
+bool CFGAS_GEFont::LoadFontInternal(
+ const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ bool bSaveStream) {
if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1)
return false;
if (bSaveStream)
- m_pStream.reset(pFontStream);
+ m_pStream = pFontStream;
m_pFileRead = pFontStream->MakeSeekableReadStream();
m_pFont = new CFX_Font;
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index b4fcf25ae1..86e5e4c955 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -33,7 +33,7 @@ class CFGAS_GEFont {
static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
int32_t iLength,
CFGAS_FontMgr* pFontMgr);
- static CFGAS_GEFont* LoadFont(IFGAS_Stream* pFontStream,
+ static CFGAS_GEFont* LoadFont(const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
CFGAS_FontMgr* pFontMgr,
bool bSaveStream);
#endif
@@ -69,7 +69,8 @@ class CFGAS_GEFont {
uint32_t dwFontStyles,
uint16_t wCodePage);
bool LoadFontInternal(const uint8_t* pBuffer, int32_t length);
- bool LoadFontInternal(IFGAS_Stream* pFontStream, bool bSaveStream);
+ bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ bool bSaveStream);
#endif
bool LoadFontInternal(CFX_Font* pExternalFont);
bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont);
@@ -97,7 +98,7 @@ class CFGAS_GEFont {
CFGAS_FontMgr* const m_pFontMgr;
int32_t m_iRefCount;
bool m_bExternalFont;
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;