From ad2441ef675866eb84c7392eeda03391a5a5d474 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 24 Oct 2016 10:19:11 -0700 Subject: Rename IFX_ stream names It's been troubling for some time that an IFX_FileStream might actually be an in-memory buffer with no backing file. Review-Url: https://codereview.chromium.org/2443723002 --- xfa/fgas/crt/fgas_stream.cpp | 36 +++++++++++++++++++----------------- xfa/fgas/crt/fgas_stream.h | 10 ++++++---- xfa/fgas/font/fgas_gefont.h | 4 +++- xfa/fgas/font/fgas_stdfontmgr.cpp | 27 +++++++++++++++------------ xfa/fgas/font/fgas_stdfontmgr.h | 14 +++++++------- 5 files changed, 50 insertions(+), 41 deletions(-) (limited to 'xfa/fgas') diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp index 74c19eab32..f0a2a88100 100644 --- a/xfa/fgas/crt/fgas_stream.cpp +++ b/xfa/fgas/crt/fgas_stream.cpp @@ -104,7 +104,7 @@ class CFX_FileReadStreamImp : public IFX_StreamImp { CFX_FileReadStreamImp(); ~CFX_FileReadStreamImp() override {} - FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, uint32_t dwAccess); + FX_BOOL LoadFileRead(IFX_SeekableReadStream* pFileRead, uint32_t dwAccess); // IFX_StreamImp: int32_t GetLength() const override; @@ -125,7 +125,7 @@ class CFX_FileReadStreamImp : public IFX_StreamImp { FX_BOOL SetLength(int32_t iLength) override { return FALSE; } protected: - IFX_FileRead* m_pFileRead; + IFX_SeekableReadStream* m_pFileRead; int32_t m_iPosition; int32_t m_iLength; }; @@ -170,7 +170,7 @@ class CFX_FileWriteStreamImp : public IFX_StreamImp { CFX_FileWriteStreamImp(); ~CFX_FileWriteStreamImp() override {} - FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, uint32_t dwAccess); + FX_BOOL LoadFileWrite(IFX_SeekableWriteStream* pFileWrite, uint32_t dwAccess); // IFX_StreamImp: int32_t GetLength() const override; @@ -189,7 +189,7 @@ class CFX_FileWriteStreamImp : public IFX_StreamImp { FX_BOOL SetLength(int32_t iLength) override { return FALSE; } protected: - IFX_FileWrite* m_pFileWrite; + IFX_SeekableWriteStream* m_pFileWrite; int32_t m_iPosition; }; @@ -208,8 +208,8 @@ class CFX_Stream : public IFX_Stream { FX_BOOL LoadFile(const FX_WCHAR* pszSrcFileName, uint32_t dwAccess); FX_BOOL LoadBuffer(uint8_t* pData, int32_t iTotalSize, uint32_t dwAccess); - FX_BOOL LoadFileRead(IFX_FileRead* pFileRead, uint32_t dwAccess); - FX_BOOL LoadFileWrite(IFX_FileWrite* pFileWrite, uint32_t dwAccess); + FX_BOOL LoadFileRead(IFX_SeekableReadStream* pFileRead, uint32_t dwAccess); + FX_BOOL LoadFileWrite(IFX_SeekableWriteStream* pFileWrite, uint32_t dwAccess); FX_BOOL LoadBufferRead(IFX_BufferRead* pBufferRead, int32_t iFileSize, uint32_t dwAccess, @@ -289,12 +289,12 @@ class CFX_TextStream : public IFX_Stream { void InitStream(); }; -class CFGAS_FileRead : public IFX_FileRead { +class CFGAS_FileRead : public IFX_SeekableReadStream { public: CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream); ~CFGAS_FileRead() override; - // IFX_FileRead + // IFX_SeekableReadStream void Release() override; FX_FILESIZE GetSize() override; FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; @@ -336,7 +336,7 @@ FX_BOOL FileSetSize(FXSYS_FILE* file, int32_t size) { } // namespace // static -IFX_Stream* IFX_Stream::CreateStream(IFX_FileRead* pFileRead, +IFX_Stream* IFX_Stream::CreateStream(IFX_SeekableReadStream* pFileRead, uint32_t dwAccess) { CFX_Stream* pSR = new CFX_Stream; if (!pSR->LoadFileRead(pFileRead, dwAccess)) { @@ -350,7 +350,7 @@ IFX_Stream* IFX_Stream::CreateStream(IFX_FileRead* pFileRead, } // static -IFX_Stream* IFX_Stream::CreateStream(IFX_FileWrite* pFileWrite, +IFX_Stream* IFX_Stream::CreateStream(IFX_SeekableWriteStream* pFileWrite, uint32_t dwAccess) { CFX_Stream* pSR = new CFX_Stream; if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) { @@ -549,7 +549,7 @@ FX_BOOL CFX_FileStreamImp::SetLength(int32_t iLength) { } CFX_FileReadStreamImp::CFX_FileReadStreamImp() : m_pFileRead(nullptr), m_iPosition(0), m_iLength(0) {} -FX_BOOL CFX_FileReadStreamImp::LoadFileRead(IFX_FileRead* pFileRead, +FX_BOOL CFX_FileReadStreamImp::LoadFileRead(IFX_SeekableReadStream* pFileRead, uint32_t dwAccess) { ASSERT(!m_pFileRead && pFileRead); if (dwAccess & FX_STREAMACCESS_Write) { @@ -744,8 +744,9 @@ int32_t CFX_BufferReadStreamImp::ReadString(FX_WCHAR* pStr, } CFX_FileWriteStreamImp::CFX_FileWriteStreamImp() : m_pFileWrite(nullptr), m_iPosition(0) {} -FX_BOOL CFX_FileWriteStreamImp::LoadFileWrite(IFX_FileWrite* pFileWrite, - uint32_t dwAccess) { +FX_BOOL CFX_FileWriteStreamImp::LoadFileWrite( + IFX_SeekableWriteStream* pFileWrite, + uint32_t dwAccess) { ASSERT(!m_pFileWrite && pFileWrite); if (dwAccess & FX_STREAMACCESS_Read) { return FALSE; @@ -1152,7 +1153,8 @@ FX_BOOL CFX_Stream::LoadFile(const FX_WCHAR* pszSrcFileName, return TRUE; } -FX_BOOL CFX_Stream::LoadFileRead(IFX_FileRead* pFileRead, uint32_t dwAccess) { +FX_BOOL CFX_Stream::LoadFileRead(IFX_SeekableReadStream* pFileRead, + uint32_t dwAccess) { if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp) return FALSE; @@ -1170,7 +1172,7 @@ FX_BOOL CFX_Stream::LoadFileRead(IFX_FileRead* pFileRead, uint32_t dwAccess) { return TRUE; } -FX_BOOL CFX_Stream::LoadFileWrite(IFX_FileWrite* pFileWrite, +FX_BOOL CFX_Stream::LoadFileWrite(IFX_SeekableWriteStream* pFileWrite, uint32_t dwAccess) { if (m_eStreamType != FX_SREAMTYPE_Unknown || m_pStreamImp) return FALSE; @@ -1467,8 +1469,8 @@ IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess, } return pShared; } -IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, - FX_BOOL bReleaseStream) { +IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream) { ASSERT(pBaseStream); return new CFGAS_FileRead(pBaseStream, bReleaseStream); } diff --git a/xfa/fgas/crt/fgas_stream.h b/xfa/fgas/crt/fgas_stream.h index 637402f1f5..c61688d7a7 100644 --- a/xfa/fgas/crt/fgas_stream.h +++ b/xfa/fgas/crt/fgas_stream.h @@ -12,8 +12,8 @@ class IFX_Stream; -IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, - FX_BOOL bReleaseStream); +IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream, + FX_BOOL bReleaseStream); enum FX_STREAMACCESS { FX_STREAMACCESS_Binary = 0x00, @@ -33,8 +33,10 @@ enum FX_STREAMSEEK { class IFX_Stream { public: - static IFX_Stream* CreateStream(IFX_FileRead* pFileRead, uint32_t dwAccess); - static IFX_Stream* CreateStream(IFX_FileWrite* pFileWrite, uint32_t dwAccess); + static IFX_Stream* CreateStream(IFX_SeekableReadStream* pFileRead, + uint32_t dwAccess); + static IFX_Stream* CreateStream(IFX_SeekableWriteStream* pFileWrite, + uint32_t dwAccess); static IFX_Stream* CreateStream(uint8_t* pData, int32_t length, uint32_t dwAccess); diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h index 5a13aec372..7245e836a1 100644 --- a/xfa/fgas/font/fgas_gefont.h +++ b/xfa/fgas/font/fgas_gefont.h @@ -101,7 +101,9 @@ class CFGAS_GEFont { int32_t m_iRefCount; bool m_bExternalFont; std::unique_ptr> m_pStream; - std::unique_ptr> m_pFileRead; + std::unique_ptr> + m_pFileRead; std::unique_ptr m_pFontEncoding; std::unique_ptr> m_pCharWidthMap; std::unique_ptr> m_pRectArray; diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index 59bd272a93..646eb94696 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -591,7 +591,7 @@ CFGAS_FontMgrImp::~CFGAS_FontMgrImp() { pos = m_IFXFont2FileRead.GetStartPosition(); while (pos) { CFGAS_GEFont* pFont; - IFX_FileRead* pFileRead; + IFX_SeekableReadStream* pFileRead; m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); pFileRead->Release(); } @@ -609,7 +609,7 @@ FX_BOOL CFGAS_FontMgrImp::EnumFontsFromFontMapper() { pSystemFontInfo->EnumFontList(pFontMapper); for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { - IFX_FileRead* pFontStream = + IFX_SeekableReadStream* pFontStream = CreateFontStream(pFontMapper, pSystemFontInfo, i); if (!pFontStream) continue; @@ -629,7 +629,7 @@ FX_BOOL CFGAS_FontMgrImp::EnumFontsFromFiles() { CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); FX_POSITION pos = m_pFontSource->GetStartPosition(); IFX_FileAccess* pFontSource = nullptr; - IFX_FileRead* pFontStream = nullptr; + IFX_SeekableReadStream* pFontStream = nullptr; while (pos) { pFontSource = m_pFontSource->GetNext(pos); pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); @@ -783,7 +783,8 @@ CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode( FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode) { - IFX_FileRead* pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); + IFX_SeekableReadStream* pFileRead = + CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); if (!pFileRead) return FALSE; FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); @@ -835,7 +836,8 @@ CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName, if (!pSystemFontInfo) return nullptr; - IFX_FileRead* pFontStream = CreateFontStream(wsFaceName.UTF8Encode()); + IFX_SeekableReadStream* pFontStream = + CreateFontStream(wsFaceName.UTF8Encode()); if (!pFontStream) return nullptr; @@ -867,7 +869,8 @@ unsigned long _ftStreamRead(FXFT_Stream stream, if (count == 0) return 0; - IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; + IFX_SeekableReadStream* pFile = + (IFX_SeekableReadStream*)stream->descriptor.pointer; int res = pFile->ReadBlock(buffer, offset, count); if (res) return count; @@ -878,7 +881,7 @@ void _ftStreamClose(FXFT_Stream stream) {} }; // extern "C" -FXFT_Face CFGAS_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, +FXFT_Face CFGAS_FontMgrImp::LoadFace(IFX_SeekableReadStream* pFontStream, int32_t iFaceIndex) { if (!pFontStream) return nullptr; @@ -913,7 +916,7 @@ FXFT_Face CFGAS_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, return pFace; } -IFX_FileRead* CFGAS_FontMgrImp::CreateFontStream( +IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream( CFX_FontMapper* pFontMapper, IFX_SystemFontInfo* pSystemFontInfo, uint32_t index) { @@ -934,7 +937,7 @@ IFX_FileRead* CFGAS_FontMgrImp::CreateFontStream( return FX_CreateMemoryStream(pBuffer, dwFileSize, TRUE); } -IFX_FileRead* CFGAS_FontMgrImp::CreateFontStream( +IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream( const CFX_ByteString& bsFaceName) { CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); @@ -1111,7 +1114,7 @@ void CFGAS_FontMgrImp::ClearFontCache() { pos = m_IFXFont2FileRead.GetStartPosition(); while (pos) { CFGAS_GEFont* pFont; - IFX_FileRead* pFileRead; + IFX_SeekableReadStream* pFileRead; m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); pFileRead->Release(); } @@ -1121,7 +1124,7 @@ void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) { if (!pEFont) { return; } - IFX_FileRead* pFileRead; + IFX_SeekableReadStream* pFileRead; if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { pFileRead->Release(); m_IFXFont2FileRead.RemoveKey(pEFont); @@ -1179,7 +1182,7 @@ void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace, m_InstalledFonts.Add(pFont.release()); } -void CFGAS_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream, +void CFGAS_FontMgrImp::RegisterFaces(IFX_SeekableReadStream* pFontStream, const CFX_WideString* pFaceName) { int32_t index = 0; int32_t num_faces = 0; diff --git a/xfa/fgas/font/fgas_stdfontmgr.h b/xfa/fgas/font/fgas_stdfontmgr.h index 785a47f854..fd7f9cd318 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.h +++ b/xfa/fgas/font/fgas_stdfontmgr.h @@ -185,7 +185,7 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr { protected: void RegisterFace(FXFT_Face pFace, const CFX_WideString* pFaceName); - void RegisterFaces(IFX_FileRead* pFontStream, + void RegisterFaces(IFX_SeekableReadStream* pFontStream, const CFX_WideString* pFaceName); void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); std::vector GetCharsets(FXFT_Face pFace) const; @@ -204,16 +204,16 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr { uint32_t dwFontStyles, const CFX_WideString& FontName, FX_WCHAR wcUnicode = 0xFFFE); - FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); - IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, - IFX_SystemFontInfo* pSystemFontInfo, - uint32_t index); - IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); + FXFT_Face LoadFace(IFX_SeekableReadStream* pFontStream, int32_t iFaceIndex); + IFX_SeekableReadStream* CreateFontStream(CFX_FontMapper* pFontMapper, + IFX_SystemFontInfo* pSystemFontInfo, + uint32_t index); + IFX_SeekableReadStream* CreateFontStream(const CFX_ByteString& bsFaceName); CFX_FontDescriptors m_InstalledFonts; CFX_MapPtrTemplate m_Hash2CandidateList; CFX_MapPtrTemplate*> m_Hash2Fonts; - CFX_MapPtrTemplate m_IFXFont2FileRead; + CFX_MapPtrTemplate m_IFXFont2FileRead; CFX_MapPtrTemplate m_FailedUnicodes2Nullptr; CFX_FontSourceEnum_File* const m_pFontSource; }; -- cgit v1.2.3