From 345d489b70a8e057587512524e69bd5692e2e14b Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 30 Nov 2016 15:10:55 -0800 Subject: Convert loose FX_Create* functions into static methods Also remove a bool that is always false. Review-Url: https://codereview.chromium.org/2539203002 --- xfa/fgas/crt/fgas_stream.cpp | 6 ++---- xfa/fgas/crt/fgas_stream.h | 5 +++-- xfa/fgas/font/cfgas_fontmgr.cpp | 2 +- xfa/fgas/font/cfgas_gefont.cpp | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'xfa/fgas') diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp index c3850c00bb..73d3d0b661 100644 --- a/xfa/fgas/crt/fgas_stream.cpp +++ b/xfa/fgas/crt/fgas_stream.cpp @@ -1452,10 +1452,8 @@ IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess, return pShared; } -IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream, - bool bReleaseStream) { - ASSERT(pBaseStream); - return new CFGAS_FileRead(pBaseStream, bReleaseStream); +IFX_SeekableReadStream* IFX_Stream::MakeSeekableReadStream() { + return new CFGAS_FileRead(this, false); } CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, bool bReleaseStream) diff --git a/xfa/fgas/crt/fgas_stream.h b/xfa/fgas/crt/fgas_stream.h index 674007e935..413927d22f 100644 --- a/xfa/fgas/crt/fgas_stream.h +++ b/xfa/fgas/crt/fgas_stream.h @@ -37,6 +37,7 @@ class IFX_Stream { uint32_t dwAccess); static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream, bool bDeleteOnRelease); + virtual ~IFX_Stream() {} virtual void Release() = 0; virtual IFX_Stream* Retain() = 0; @@ -61,9 +62,9 @@ class IFX_Stream { virtual int32_t GetBOM(uint8_t bom[4]) const = 0; virtual uint16_t GetCodePage() const = 0; virtual uint16_t SetCodePage(uint16_t wCodePage) = 0; + + IFX_SeekableReadStream* MakeSeekableReadStream(); }; -IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream, - bool bReleaseStream); #endif // XFA_FGAS_CRT_FGAS_STREAM_H_ diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 9b95318bd0..219e67dbc6 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -909,7 +909,7 @@ IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream( uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); - return FX_CreateMemoryStream(pBuffer, dwFileSize, true); + return IFX_MemoryStream::Create(pBuffer, dwFileSize, true); } IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream( diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index ffe791aab5..c1dfa2b5b9 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -209,7 +209,7 @@ bool CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream) { if (bSaveStream) m_pStream.reset(pFontStream); - m_pFileRead.reset(FX_CreateFileRead(pFontStream, false)); + m_pFileRead.reset(pFontStream->MakeSeekableReadStream()); m_pFont = new CFX_Font; if (m_pFont->LoadFile(m_pFileRead.get())) return InitFont(); -- cgit v1.2.3