From 0b95042db2e6dab5876abd12ce485fff0a8e08fe Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 21 Sep 2017 15:49:49 -0400 Subject: Rename CFX_RetainPtr to RetainPtr This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fpdfapi/edit/cpdf_creator.cpp | 11 +- core/fpdfapi/edit/cpdf_creator.h | 6 +- core/fpdfapi/edit/cpdf_flateencoder.h | 4 +- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 2 +- core/fpdfapi/font/cpdf_cidfont.h | 6 +- core/fpdfapi/font/cpdf_cmap.h | 6 +- core/fpdfapi/font/cpdf_cmapmanager.cpp | 9 +- core/fpdfapi/font/cpdf_cmapmanager.h | 12 +- core/fpdfapi/font/cpdf_font.h | 2 +- core/fpdfapi/font/cpdf_type3char.cpp | 2 +- core/fpdfapi/font/cpdf_type3char.h | 4 +- core/fpdfapi/page/cpdf_colorspace.cpp | 2 +- core/fpdfapi/page/cpdf_contentparser.h | 4 +- core/fpdfapi/page/cpdf_docpagedata.cpp | 6 +- core/fpdfapi/page/cpdf_docpagedata.h | 12 +- core/fpdfapi/page/cpdf_generalstate.cpp | 4 +- core/fpdfapi/page/cpdf_generalstate.h | 6 +- core/fpdfapi/page/cpdf_iccprofile.h | 6 +- core/fpdfapi/page/cpdf_image.cpp | 21 +- core/fpdfapi/page/cpdf_image.h | 25 +- core/fpdfapi/page/cpdf_imageobject.cpp | 2 +- core/fpdfapi/page/cpdf_imageobject.h | 6 +- core/fpdfapi/page/cpdf_meshstream.h | 2 +- core/fpdfapi/page/cpdf_sampledfunc.h | 8 +- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 +- core/fpdfapi/page/cpdf_streamcontentparser.h | 4 +- core/fpdfapi/parser/cfdf_document.cpp | 4 +- core/fpdfapi/parser/cfdf_document.h | 6 +- core/fpdfapi/parser/cpdf_crypto_handler.h | 6 +- core/fpdfapi/parser/cpdf_data_avail.cpp | 6 +- core/fpdfapi/parser/cpdf_data_avail.h | 8 +- core/fpdfapi/parser/cpdf_document.cpp | 8 +- core/fpdfapi/parser/cpdf_document.h | 6 +- core/fpdfapi/parser/cpdf_object_avail_unittest.cpp | 8 +- .../parser/cpdf_page_object_avail_unittest.cpp | 8 +- core/fpdfapi/parser/cpdf_parser.cpp | 18 +- core/fpdfapi/parser/cpdf_parser.h | 19 +- core/fpdfapi/parser/cpdf_parser_unittest.cpp | 6 +- core/fpdfapi/parser/cpdf_read_validator.cpp | 2 +- core/fpdfapi/parser/cpdf_read_validator.h | 6 +- .../parser/cpdf_read_validator_unittest.cpp | 2 +- core/fpdfapi/parser/cpdf_stream.cpp | 2 +- core/fpdfapi/parser/cpdf_stream.h | 4 +- core/fpdfapi/parser/cpdf_stream_acc.h | 6 +- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 8 +- core/fpdfapi/parser/cpdf_syntax_parser.h | 17 +- core/fpdfapi/parser/fpdf_parser_utility.cpp | 2 +- core/fpdfapi/parser/fpdf_parser_utility.h | 4 +- core/fpdfapi/render/cpdf_devicebuffer.h | 6 +- core/fpdfapi/render/cpdf_dibsource.cpp | 2 +- core/fpdfapi/render/cpdf_dibsource.h | 14 +- core/fpdfapi/render/cpdf_dibtransferfunc.cpp | 2 +- core/fpdfapi/render/cpdf_dibtransferfunc.h | 6 +- core/fpdfapi/render/cpdf_docrenderdata.cpp | 4 +- core/fpdfapi/render/cpdf_docrenderdata.h | 8 +- core/fpdfapi/render/cpdf_imagecacheentry.cpp | 13 +- core/fpdfapi/render/cpdf_imagecacheentry.h | 20 +- core/fpdfapi/render/cpdf_imageloader.cpp | 2 +- core/fpdfapi/render/cpdf_imageloader.h | 6 +- core/fpdfapi/render/cpdf_imagerenderer.cpp | 14 +- core/fpdfapi/render/cpdf_imagerenderer.h | 8 +- core/fpdfapi/render/cpdf_pagerendercache.cpp | 7 +- core/fpdfapi/render/cpdf_pagerendercache.h | 8 +- core/fpdfapi/render/cpdf_rendercontext.cpp | 9 +- core/fpdfapi/render/cpdf_rendercontext.h | 4 +- core/fpdfapi/render/cpdf_renderoptions.h | 4 +- core/fpdfapi/render/cpdf_renderstatus.cpp | 60 ++--- core/fpdfapi/render/cpdf_renderstatus.h | 22 +- core/fpdfapi/render/cpdf_transferfunc.cpp | 6 +- core/fpdfapi/render/cpdf_transferfunc.h | 9 +- core/fpdfapi/render/cpdf_type3cache.cpp | 7 +- core/fpdfapi/render/cpdf_type3cache.h | 6 +- core/fpdfdoc/cpdf_annotlist.cpp | 2 +- core/fpdfdoc/cpdf_occontext.h | 6 +- core/fpdfdoc/cpdf_structelement.h | 8 +- core/fpdfdoc/cpdf_structtree.cpp | 10 +- core/fpdfdoc/cpdf_structtree.h | 10 +- core/fxcodec/codec/ccodec_jbig2module.h | 10 +- core/fxcodec/codec/ccodec_jpegmodule.h | 4 +- core/fxcodec/codec/ccodec_progressivedecoder.h | 41 ++- core/fxcodec/codec/ccodec_tiffmodule.cpp | 39 ++- core/fxcodec/codec/ccodec_tiffmodule.h | 6 +- core/fxcodec/codec/fx_codec_jbig.cpp | 4 +- core/fxcodec/codec/fx_codec_jpeg.cpp | 2 +- core/fxcodec/codec/fx_codec_progress.cpp | 32 +-- core/fxcodec/jbig2/JBig2_BitStream.cpp | 3 +- core/fxcodec/jbig2/JBig2_BitStream.h | 4 +- core/fxcodec/jbig2/JBig2_Context.cpp | 9 +- core/fxcodec/jbig2/JBig2_Context.h | 4 +- core/fxcrt/bytestring.cpp | 10 +- core/fxcrt/bytestring.h | 4 +- core/fxcrt/cfx_char.h | 2 +- core/fxcrt/cfx_checksumcontext.cpp | 2 +- core/fxcrt/cfx_checksumcontext.h | 2 +- core/fxcrt/cfx_crtfileaccess.cpp | 2 +- core/fxcrt/cfx_crtfileaccess.h | 8 +- core/fxcrt/cfx_memorystream.h | 4 +- core/fxcrt/cfx_retain_ptr.h | 124 --------- core/fxcrt/cfx_retain_ptr_unittest.cpp | 300 --------------------- core/fxcrt/cfx_seekablestreamproxy.cpp | 2 +- core/fxcrt/cfx_seekablestreamproxy.h | 10 +- core/fxcrt/cfx_shared_copy_on_write.h | 4 +- core/fxcrt/cfx_weak_ptr.h | 4 +- core/fxcrt/css/cfx_csscomputedstyle.h | 6 +- core/fxcrt/css/cfx_cssdeclaration.cpp | 46 ++-- core/fxcrt/css/cfx_cssdeclaration.h | 25 +- core/fxcrt/css/cfx_csspropertyholder.h | 4 +- core/fxcrt/css/cfx_cssstyleselector.cpp | 21 +- core/fxcrt/css/cfx_cssstyleselector.h | 8 +- core/fxcrt/css/cfx_cssstylesheet_unittest.cpp | 8 +- core/fxcrt/css/cfx_cssvalue.h | 2 +- core/fxcrt/css/cfx_cssvaluelist.cpp | 5 +- core/fxcrt/css/cfx_cssvaluelist.h | 6 +- core/fxcrt/fx_stream.cpp | 10 +- core/fxcrt/fx_stream.h | 15 +- core/fxcrt/fx_unicode.h | 2 +- core/fxcrt/retain_ptr.h | 130 +++++++++ core/fxcrt/retain_ptr_unittest.cpp | 300 +++++++++++++++++++++ core/fxcrt/widestring.cpp | 10 +- core/fxcrt/widestring.h | 4 +- core/fxcrt/xml/cfx_saxreader.cpp | 4 +- core/fxcrt/xml/cfx_saxreader.h | 8 +- core/fxcrt/xml/cfx_xmldoc.cpp | 2 +- core/fxcrt/xml/cfx_xmldoc.h | 6 +- core/fxcrt/xml/cfx_xmlnode.cpp | 2 +- core/fxcrt/xml/cfx_xmlnode.h | 4 +- core/fxcrt/xml/cfx_xmlparser.cpp | 5 +- core/fxcrt/xml/cfx_xmlparser.h | 6 +- core/fxcrt/xml/cfx_xmlsyntaxparser.cpp | 2 +- core/fxcrt/xml/cfx_xmlsyntaxparser.h | 6 +- core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp | 30 +-- core/fxge/agg/fx_agg_driver.cpp | 72 +++-- core/fxge/agg/fx_agg_driver.h | 18 +- core/fxge/android/cfpf_skiafilefont.h | 4 +- core/fxge/android/cfpf_skiafontmgr.cpp | 2 +- core/fxge/android/cfpf_skiafontmgr.h | 2 +- core/fxge/apple/apple_int.h | 2 +- core/fxge/apple/fx_apple_platform.cpp | 2 +- core/fxge/apple/fx_quartz_device.cpp | 2 +- core/fxge/cfx_cliprgn.cpp | 6 +- core/fxge/cfx_cliprgn.h | 12 +- core/fxge/cfx_defaultrenderdevice.h | 10 +- core/fxge/cfx_font.cpp | 4 +- core/fxge/cfx_renderdevice.cpp | 50 ++-- core/fxge/cfx_renderdevice.h | 49 ++-- core/fxge/dib/cfx_bitmapcomposer.cpp | 2 +- core/fxge/dib/cfx_bitmapcomposer.h | 8 +- core/fxge/dib/cfx_bitmapstorer.cpp | 4 +- core/fxge/dib/cfx_bitmapstorer.h | 10 +- core/fxge/dib/cfx_dibextractor.cpp | 4 +- core/fxge/dib/cfx_dibextractor.h | 8 +- core/fxge/dib/cfx_dibitmap.cpp | 67 +++-- core/fxge/dib/cfx_dibitmap.h | 18 +- core/fxge/dib/cfx_dibsource.cpp | 124 ++++----- core/fxge/dib/cfx_dibsource.h | 34 +-- core/fxge/dib/cfx_filtereddib.cpp | 2 +- core/fxge/dib/cfx_filtereddib.h | 8 +- core/fxge/dib/cfx_imagerenderer.cpp | 19 +- core/fxge/dib/cfx_imagerenderer.h | 8 +- core/fxge/dib/cfx_imagestretcher.cpp | 13 +- core/fxge/dib/cfx_imagestretcher.h | 8 +- core/fxge/dib/cfx_imagetransformer.cpp | 13 +- core/fxge/dib/cfx_imagetransformer.h | 8 +- core/fxge/dib/cstretchengine.cpp | 2 +- core/fxge/dib/cstretchengine.h | 6 +- core/fxge/fx_font.h | 5 +- core/fxge/ifx_renderdevicedriver.cpp | 15 +- core/fxge/ifx_renderdevicedriver.h | 16 +- core/fxge/skia/fx_skia_device.cpp | 62 +++-- core/fxge/skia/fx_skia_device.h | 28 +- core/fxge/skia/fx_skia_device_unittest.cpp | 2 +- core/fxge/win32/cfx_psrenderer.cpp | 10 +- core/fxge/win32/cfx_psrenderer.h | 12 +- core/fxge/win32/cfx_windowsdib.h | 15 +- core/fxge/win32/dwrite_int.h | 2 +- core/fxge/win32/fx_win32_device.cpp | 60 ++--- core/fxge/win32/fx_win32_dib.cpp | 22 +- core/fxge/win32/fx_win32_dwrite.cpp | 11 +- core/fxge/win32/fx_win32_gdipext.cpp | 28 +- core/fxge/win32/fx_win32_print.cpp | 75 +++--- core/fxge/win32/win32_int.h | 45 ++-- 181 files changed, 1438 insertions(+), 1497 deletions(-) delete mode 100644 core/fxcrt/cfx_retain_ptr.h delete mode 100644 core/fxcrt/cfx_retain_ptr_unittest.cpp create mode 100644 core/fxcrt/retain_ptr.h create mode 100644 core/fxcrt/retain_ptr_unittest.cpp (limited to 'core') diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp index c3143b5322..7c567779ff 100644 --- a/core/fpdfapi/edit/cpdf_creator.cpp +++ b/core/fpdfapi/edit/cpdf_creator.cpp @@ -27,7 +27,7 @@ const size_t kArchiveBufferSize = 32768; class CFX_FileBufferArchive : public IFX_ArchiveStream { public: - explicit CFX_FileBufferArchive(const CFX_RetainPtr& archive); + explicit CFX_FileBufferArchive(const RetainPtr& archive); ~CFX_FileBufferArchive() override; bool WriteBlock(const void* pBuf, size_t size) override; @@ -43,11 +43,11 @@ class CFX_FileBufferArchive : public IFX_ArchiveStream { FX_FILESIZE offset_; size_t current_length_; std::vector buffer_; - CFX_RetainPtr backing_file_; + RetainPtr backing_file_; }; CFX_FileBufferArchive::CFX_FileBufferArchive( - const CFX_RetainPtr& file) + const RetainPtr& file) : offset_(0), current_length_(0), buffer_(kArchiveBufferSize), @@ -139,7 +139,7 @@ int32_t OutputIndex(IFX_ArchiveStream* archive, FX_FILESIZE offset) { } // namespace CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc, - const CFX_RetainPtr& archive) + const RetainPtr& archive) : m_pDocument(pDoc), m_pParser(pDoc->GetParser()), m_bSecurityChanged(false), @@ -437,8 +437,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1() { } if (m_iStage == 15) { if (IsOriginal() && m_SavedOffset > 0) { - CFX_RetainPtr pSrcFile = - m_pParser->GetFileAccess(); + RetainPtr pSrcFile = m_pParser->GetFileAccess(); std::vector buffer(4096); FX_FILESIZE src_size = m_SavedOffset; while (src_size) { diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h index d97ee01d73..3ea5da85b7 100644 --- a/core/fpdfapi/edit/cpdf_creator.h +++ b/core/fpdfapi/edit/cpdf_creator.h @@ -11,9 +11,9 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Array; class CPDF_CryptoHandler; @@ -28,7 +28,7 @@ class CPDF_Parser; class CPDF_Creator { public: explicit CPDF_Creator(CPDF_Document* pDoc, - const CFX_RetainPtr& archive); + const RetainPtr& archive); ~CPDF_Creator(); void RemoveSecurity(); @@ -85,7 +85,7 @@ class CPDF_Creator { bool m_bSecurityChanged; CFX_UnownedPtr m_pEncryptDict; uint32_t m_dwEncryptObjNum; - CFX_RetainPtr m_pCryptoHandler; + RetainPtr m_pCryptoHandler; CFX_UnownedPtr m_pMetadata; uint32_t m_dwLastObjNum; std::unique_ptr m_Archive; diff --git a/core/fpdfapi/edit/cpdf_flateencoder.h b/core/fpdfapi/edit/cpdf_flateencoder.h index 3698414fd2..887816c1a1 100644 --- a/core/fpdfapi/edit/cpdf_flateencoder.h +++ b/core/fpdfapi/edit/cpdf_flateencoder.h @@ -9,9 +9,9 @@ #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/maybe_owned.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Stream; @@ -31,7 +31,7 @@ class CPDF_FlateEncoder { uint32_t m_dwSize; MaybeOwned m_pData; MaybeOwned m_pDict; - CFX_RetainPtr m_pAcc; + RetainPtr m_pAcc; }; #endif // CORE_FPDFAPI_EDIT_CPDF_FLATEENCODER_H_ diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index c0c6604671..fc7e97fc79 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -175,7 +175,7 @@ void CPDF_PageContentGenerator::ProcessImage(std::ostringstream* buf, } *buf << "q " << pImageObj->matrix() << " cm "; - CFX_RetainPtr pImage = pImageObj->GetImage(); + RetainPtr pImage = pImageObj->GetImage(); if (pImage->IsInline()) return; diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h index f4ddcfd577..653cc5f98e 100644 --- a/core/fpdfapi/font/cpdf_cidfont.h +++ b/core/fpdfapi/font/cpdf_cidfont.h @@ -11,10 +11,10 @@ #include #include "core/fpdfapi/font/cpdf_font.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" enum CIDSet : uint8_t { CIDSET_UNKNOWN, @@ -73,13 +73,13 @@ class CPDF_CIDFont : public CPDF_Font { void LoadSubstFont(); wchar_t GetUnicodeFromCharCode(uint32_t charcode) const; - CFX_RetainPtr m_pCMap; + RetainPtr m_pCMap; CFX_UnownedPtr m_pCID2UnicodeMap; CIDSet m_Charset; bool m_bType1; bool m_bCIDIsGID; uint16_t m_DefaultWidth; - CFX_RetainPtr m_pStreamAcc; + RetainPtr m_pStreamAcc; bool m_bAnsiWidthsFixed; FX_RECT m_CharBBox[256]; std::vector m_WidthList; diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h index 3e23d03a01..6e90c3936b 100644 --- a/core/fpdfapi/font/cpdf_cmap.h +++ b/core/fpdfapi/font/cpdf_cmap.h @@ -10,7 +10,7 @@ #include #include "core/fpdfapi/font/cpdf_cidfont.h" -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_CMapManager; struct FXCMAP_CMap; @@ -26,7 +26,7 @@ enum CIDCoding : uint8_t { CIDCODING_UTF16, }; -class CPDF_CMap : public CFX_Retainable { +class CPDF_CMap : public Retainable { public: enum CodingScheme : uint8_t { OneByte, @@ -48,7 +48,7 @@ class CPDF_CMap : public CFX_Retainable { }; template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); void LoadPredefined(CPDF_CMapManager* pMgr, const ByteString& name, diff --git a/core/fpdfapi/font/cpdf_cmapmanager.cpp b/core/fpdfapi/font/cpdf_cmapmanager.cpp index a449db6a45..53183af340 100644 --- a/core/fpdfapi/font/cpdf_cmapmanager.cpp +++ b/core/fpdfapi/font/cpdf_cmapmanager.cpp @@ -16,21 +16,20 @@ CPDF_CMapManager::CPDF_CMapManager() {} CPDF_CMapManager::~CPDF_CMapManager() {} -CFX_RetainPtr CPDF_CMapManager::GetPredefinedCMap( - const ByteString& name, - bool bPromptCJK) { +RetainPtr CPDF_CMapManager::GetPredefinedCMap(const ByteString& name, + bool bPromptCJK) { auto it = m_CMaps.find(name); if (it != m_CMaps.end()) return it->second; - CFX_RetainPtr pCMap = LoadPredefinedCMap(name, bPromptCJK); + RetainPtr pCMap = LoadPredefinedCMap(name, bPromptCJK); if (!name.IsEmpty()) m_CMaps[name] = pCMap; return pCMap; } -CFX_RetainPtr CPDF_CMapManager::LoadPredefinedCMap( +RetainPtr CPDF_CMapManager::LoadPredefinedCMap( const ByteString& name, bool bPromptCJK) { const char* pname = name.c_str(); diff --git a/core/fpdfapi/font/cpdf_cmapmanager.h b/core/fpdfapi/font/cpdf_cmapmanager.h index 6a860e6859..089eb3d705 100644 --- a/core/fpdfapi/font/cpdf_cmapmanager.h +++ b/core/fpdfapi/font/cpdf_cmapmanager.h @@ -12,24 +12,24 @@ #include "core/fpdfapi/font/cpdf_cidfont.h" #include "core/fxcrt/bytestring.h" -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_CMapManager { public: CPDF_CMapManager(); ~CPDF_CMapManager(); - CFX_RetainPtr GetPredefinedCMap(const ByteString& name, - bool bPromptCJK); + RetainPtr GetPredefinedCMap(const ByteString& name, + bool bPromptCJK); CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, bool bPromptCJK); private: - CFX_RetainPtr LoadPredefinedCMap(const ByteString& name, - bool bPromptCJK); + RetainPtr LoadPredefinedCMap(const ByteString& name, + bool bPromptCJK); std::unique_ptr LoadCID2UnicodeMap(CIDSet charset, bool bPromptCJK); - std::map> m_CMaps; + std::map> m_CMaps; std::unique_ptr m_CID2UnicodeMaps[6]; }; diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h index e92e2f24e5..570d5d5a11 100644 --- a/core/fpdfapi/font/cpdf_font.h +++ b/core/fpdfapi/font/cpdf_font.h @@ -111,7 +111,7 @@ class CPDF_Font { CFX_Font m_Font; std::vector> m_FontFallbacks; ByteString m_BaseFont; - CFX_RetainPtr m_pFontFile; + RetainPtr m_pFontFile; CPDF_Dictionary* m_pFontDict; mutable std::unique_ptr m_pToUnicodeMap; mutable bool m_bToUnicodeLoaded; diff --git a/core/fpdfapi/font/cpdf_type3char.cpp b/core/fpdfapi/font/cpdf_type3char.cpp index e11193fdaa..c0ed88d4db 100644 --- a/core/fpdfapi/font/cpdf_type3char.cpp +++ b/core/fpdfapi/font/cpdf_type3char.cpp @@ -35,7 +35,7 @@ bool CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) { // |pSource| actually gets assigned a CPDF_DIBSource, which has pointers // into objects owned by |m_pForm|. Make sure it is out of scope before // clearing the form. - CFX_RetainPtr pSource = + RetainPtr pSource = pPageObj->AsImage()->GetImage()->LoadDIBSource(); // Clone() is non-virtual, and can't be overloaded by CPDF_DIBSource to diff --git a/core/fpdfapi/font/cpdf_type3char.h b/core/fpdfapi/font/cpdf_type3char.h index 9f2f94f603..444c9930e1 100644 --- a/core/fpdfapi/font/cpdf_type3char.h +++ b/core/fpdfapi/font/cpdf_type3char.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBitmap; class CPDF_Form; @@ -25,7 +25,7 @@ class CPDF_Type3Char { bool LoadBitmap(CPDF_RenderContext* pContext); std::unique_ptr m_pForm; - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; bool m_bColored; int m_Width; CFX_Matrix m_ImageMatrix; diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index 5455d4dbba..f4980fbb99 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -177,7 +177,7 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace { void PopulateRanges(CPDF_Dictionary* pDict); MaybeOwned m_pAlterCS; - CFX_RetainPtr m_pProfile; + RetainPtr m_pProfile; uint8_t* m_pCache; float* m_pRanges; }; diff --git a/core/fpdfapi/page/cpdf_contentparser.h b/core/fpdfapi/page/cpdf_contentparser.h index b201f95df8..c14f451209 100644 --- a/core/fpdfapi/page/cpdf_contentparser.h +++ b/core/fpdfapi/page/cpdf_contentparser.h @@ -54,8 +54,8 @@ class CPDF_ContentParser { bool m_bForm; CFX_UnownedPtr m_pType3Char; uint32_t m_nStreams; - CFX_RetainPtr m_pSingleStream; - std::vector> m_StreamArray; + RetainPtr m_pSingleStream; + std::vector> m_StreamArray; uint8_t* m_pData; uint32_t m_Size; uint32_t m_CurrentOffset; diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index 08345dac78..31d6bae63f 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -389,7 +389,7 @@ void CPDF_DocPageData::ReleasePattern(const CPDF_Object* pPatternObj) { pPattern->clear(); } -CFX_RetainPtr CPDF_DocPageData::GetImage(uint32_t dwStreamObjNum) { +RetainPtr CPDF_DocPageData::GetImage(uint32_t dwStreamObjNum) { ASSERT(dwStreamObjNum); auto it = m_ImageMap.find(dwStreamObjNum); if (it != m_ImageMap.end()) @@ -407,7 +407,7 @@ void CPDF_DocPageData::MaybePurgeImage(uint32_t dwStreamObjNum) { m_ImageMap.erase(it); } -CFX_RetainPtr CPDF_DocPageData::GetIccProfile( +RetainPtr CPDF_DocPageData::GetIccProfile( CPDF_Stream* pProfileStream) { if (!pProfileStream) return nullptr; @@ -443,7 +443,7 @@ void CPDF_DocPageData::MaybePurgeIccProfile(CPDF_Stream* pProfileStream) { m_IccProfileMap.erase(it); } -CFX_RetainPtr CPDF_DocPageData::GetFontFileStreamAcc( +RetainPtr CPDF_DocPageData::GetFontFileStreamAcc( CPDF_Stream* pFontStream) { ASSERT(pFontStream); auto it = m_FontFileMap.find(pFontStream); diff --git a/core/fpdfapi/page/cpdf_docpagedata.h b/core/fpdfapi/page/cpdf_docpagedata.h index 3f1d392262..175bee21eb 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.h +++ b/core/fpdfapi/page/cpdf_docpagedata.h @@ -53,13 +53,13 @@ class CPDF_DocPageData { const CFX_Matrix& matrix); void ReleasePattern(const CPDF_Object* pPatternObj); - CFX_RetainPtr GetImage(uint32_t dwStreamObjNum); + RetainPtr GetImage(uint32_t dwStreamObjNum); void MaybePurgeImage(uint32_t dwStreamObjNum); - CFX_RetainPtr GetIccProfile(CPDF_Stream* pProfileStream); + RetainPtr GetIccProfile(CPDF_Stream* pProfileStream); void MaybePurgeIccProfile(CPDF_Stream* pProfileStream); - CFX_RetainPtr GetFontFileStreamAcc(CPDF_Stream* pFontStream); + RetainPtr GetFontFileStreamAcc(CPDF_Stream* pFontStream); void MaybePurgeFontFileStreamAcc(const CPDF_Stream* pFontStream); CPDF_CountedColorSpace* FindColorSpacePtr(CPDF_Object* pCSObj) const; @@ -72,10 +72,10 @@ class CPDF_DocPageData { CFX_UnownedPtr const m_pPDFDoc; std::map m_HashProfileMap; std::map m_ColorSpaceMap; - std::map> m_FontFileMap; + std::map> m_FontFileMap; std::map m_FontMap; - std::map> m_IccProfileMap; - std::map> m_ImageMap; + std::map> m_IccProfileMap; + std::map> m_ImageMap; std::map m_PatternMap; }; diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp index c5c259f051..6f4062fb65 100644 --- a/core/fpdfapi/page/cpdf_generalstate.cpp +++ b/core/fpdfapi/page/cpdf_generalstate.cpp @@ -161,13 +161,13 @@ void CPDF_GeneralState::SetTR(CPDF_Object* pObject) { m_Ref.GetPrivateCopy()->m_pTR = pObject; } -CFX_RetainPtr CPDF_GeneralState::GetTransferFunc() const { +RetainPtr CPDF_GeneralState::GetTransferFunc() const { const StateData* pData = m_Ref.GetObject(); return pData ? pData->m_pTransferFunc : nullptr; } void CPDF_GeneralState::SetTransferFunc( - const CFX_RetainPtr& pFunc) { + const RetainPtr& pFunc) { m_Ref.GetPrivateCopy()->m_pTransferFunc = pFunc; } diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h index 95f59784f2..a55f1a7b33 100644 --- a/core/fpdfapi/page/cpdf_generalstate.h +++ b/core/fpdfapi/page/cpdf_generalstate.h @@ -43,8 +43,8 @@ class CPDF_GeneralState { CPDF_Object* GetTR() const; void SetTR(CPDF_Object* pObject); - CFX_RetainPtr GetTransferFunc() const; - void SetTransferFunc(const CFX_RetainPtr& pFunc); + RetainPtr GetTransferFunc() const; + void SetTransferFunc(const RetainPtr& pFunc); void SetBlendMode(const ByteString& mode); @@ -90,7 +90,7 @@ class CPDF_GeneralState { float m_StrokeAlpha; float m_FillAlpha; CFX_UnownedPtr m_pTR; - CFX_RetainPtr m_pTransferFunc; + RetainPtr m_pTransferFunc; CFX_Matrix m_Matrix; int m_RenderIntent; bool m_StrokeAdjust; diff --git a/core/fpdfapi/page/cpdf_iccprofile.h b/core/fpdfapi/page/cpdf_iccprofile.h index 0226a5678d..57d7c3eb79 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.h +++ b/core/fpdfapi/page/cpdf_iccprofile.h @@ -9,16 +9,16 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CLcmsCmm; class CPDF_Stream; -class CPDF_IccProfile : public CFX_Retainable { +class CPDF_IccProfile : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); CPDF_Stream* GetStream() const { return m_pStream.Get(); } bool IsValid() const { return IsSRGB() || IsSupported(); } diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index f748b6950d..4c08336e3a 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -117,8 +117,7 @@ std::unique_ptr CPDF_Image::InitJPEG(uint8_t* pData, return pDict; } -void CPDF_Image::SetJpegImage( - const CFX_RetainPtr& pFile) { +void CPDF_Image::SetJpegImage(const RetainPtr& pFile) { uint32_t size = pdfium::base::checked_cast(pFile->GetSize()); if (!size) return; @@ -142,7 +141,7 @@ void CPDF_Image::SetJpegImage( } void CPDF_Image::SetJpegImageInline( - const CFX_RetainPtr& pFile) { + const RetainPtr& pFile) { uint32_t size = pdfium::base::checked_cast(pFile->GetSize()); if (!size) return; @@ -158,7 +157,7 @@ void CPDF_Image::SetJpegImageInline( m_pStream->InitStream(&(data[0]), size, std::move(pDict)); } -void CPDF_Image::SetImage(const CFX_RetainPtr& pBitmap) { +void CPDF_Image::SetImage(const RetainPtr& pBitmap) { int32_t BitmapWidth = pBitmap->GetWidth(); int32_t BitmapHeight = pBitmap->GetHeight(); if (BitmapWidth < 1 || BitmapHeight < 1) @@ -250,7 +249,7 @@ void CPDF_Image::SetImage(const CFX_RetainPtr& pBitmap) { bCopyWithoutAlpha = false; } - CFX_RetainPtr pMaskBitmap; + RetainPtr pMaskBitmap; if (pBitmap->HasAlpha()) pMaskBitmap = pBitmap->CloneAlphaMask(); @@ -323,12 +322,12 @@ void CPDF_Image::SetImage(const CFX_RetainPtr& pBitmap) { } void CPDF_Image::ResetCache(CPDF_Page* pPage, - const CFX_RetainPtr& pBitmap) { - CFX_RetainPtr pHolder(this); + const RetainPtr& pBitmap) { + RetainPtr pHolder(this); pPage->GetRenderCache()->ResetBitmap(pHolder, pBitmap); } -CFX_RetainPtr CPDF_Image::LoadDIBSource() const { +RetainPtr CPDF_Image::LoadDIBSource() const { auto source = pdfium::MakeRetain(); if (!source->Load(m_pDocument.Get(), m_pStream.Get())) return nullptr; @@ -336,11 +335,11 @@ CFX_RetainPtr CPDF_Image::LoadDIBSource() const { return source; } -CFX_RetainPtr CPDF_Image::DetachBitmap() { +RetainPtr CPDF_Image::DetachBitmap() { return std::move(m_pDIBSource); } -CFX_RetainPtr CPDF_Image::DetachMask() { +RetainPtr CPDF_Image::DetachMask() { return std::move(m_pMask); } @@ -367,7 +366,7 @@ bool CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource, } bool CPDF_Image::Continue(IFX_PauseIndicator* pPause) { - CFX_RetainPtr pSource = m_pDIBSource.As(); + RetainPtr pSource = m_pDIBSource.As(); int ret = pSource->ContinueLoadDIBSource(pPause); if (!ret) { m_pDIBSource.Reset(); diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index ddfd95ccf3..51f342f4aa 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -10,10 +10,10 @@ #include #include "core/fpdfapi/parser/cpdf_stream.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/maybe_owned.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBSource; class CFX_DIBitmap; @@ -22,10 +22,10 @@ class CPDF_Page; class IFX_PauseIndicator; class IFX_SeekableReadStream; -class CPDF_Image : public CFX_Retainable { +class CPDF_Image : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); void ConvertStreamToIndirectObject(); @@ -44,25 +44,24 @@ class CPDF_Image : public CFX_Retainable { bool IsMask() const { return m_bIsMask; } bool IsInterpol() const { return m_bInterpolate; } - CFX_RetainPtr LoadDIBSource() const; + RetainPtr LoadDIBSource() const; - void SetImage(const CFX_RetainPtr& pDIBitmap); - void SetJpegImage(const CFX_RetainPtr& pFile); - void SetJpegImageInline(const CFX_RetainPtr& pFile); + void SetImage(const RetainPtr& pDIBitmap); + void SetJpegImage(const RetainPtr& pFile); + void SetJpegImageInline(const RetainPtr& pFile); - void ResetCache(CPDF_Page* pPage, - const CFX_RetainPtr& pDIBitmap); + void ResetCache(CPDF_Page* pPage, const RetainPtr& pDIBitmap); bool StartLoadDIBSource(CPDF_Dictionary* pFormResource, CPDF_Dictionary* pPageResource, bool bStdCS = false, uint32_t GroupFamily = 0, bool bLoadMask = false); bool Continue(IFX_PauseIndicator* pPause); - CFX_RetainPtr DetachBitmap(); - CFX_RetainPtr DetachMask(); + RetainPtr DetachBitmap(); + RetainPtr DetachMask(); - CFX_RetainPtr m_pDIBSource; - CFX_RetainPtr m_pMask; + RetainPtr m_pDIBSource; + RetainPtr m_pMask; uint32_t m_MatteColor = 0; private: diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp index dd07385db4..3b5a740155 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -45,7 +45,7 @@ void CPDF_ImageObject::CalcBoundingBox() { m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f); } -void CPDF_ImageObject::SetImage(const CFX_RetainPtr& pImage) { +void CPDF_ImageObject::SetImage(const RetainPtr& pImage) { MaybePurgeCache(); m_pImage = pImage; } diff --git a/core/fpdfapi/page/cpdf_imageobject.h b/core/fpdfapi/page/cpdf_imageobject.h index 484fb7baa6..16a506e537 100644 --- a/core/fpdfapi/page/cpdf_imageobject.h +++ b/core/fpdfapi/page/cpdf_imageobject.h @@ -27,8 +27,8 @@ class CPDF_ImageObject : public CPDF_PageObject { const CPDF_ImageObject* AsImage() const override; void CalcBoundingBox(); - CFX_RetainPtr GetImage() const { return m_pImage; } - void SetImage(const CFX_RetainPtr& pImage); + RetainPtr GetImage() const { return m_pImage; } + void SetImage(const RetainPtr& pImage); void set_matrix(const CFX_Matrix& matrix) { m_Matrix = matrix; } const CFX_Matrix& matrix() const { return m_Matrix; } @@ -36,7 +36,7 @@ class CPDF_ImageObject : public CPDF_PageObject { void MaybePurgeCache(); CFX_Matrix m_Matrix; - CFX_RetainPtr m_pImage; + RetainPtr m_pImage; }; #endif // CORE_FPDFAPI_PAGE_CPDF_IMAGEOBJECT_H_ diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h index 0a06381c68..ddbe31fe07 100644 --- a/core/fpdfapi/page/cpdf_meshstream.h +++ b/core/fpdfapi/page/cpdf_meshstream.h @@ -80,7 +80,7 @@ class CPDF_MeshStream { float m_ymax; float m_ColorMin[kMaxComponents]; float m_ColorMax[kMaxComponents]; - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; std::unique_ptr m_BitStream; }; diff --git a/core/fpdfapi/page/cpdf_sampledfunc.h b/core/fpdfapi/page/cpdf_sampledfunc.h index 59fe1ef141..d6dfed575f 100644 --- a/core/fpdfapi/page/cpdf_sampledfunc.h +++ b/core/fpdfapi/page/cpdf_sampledfunc.h @@ -11,7 +11,7 @@ #include "core/fpdfapi/page/cpdf_function.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_SampledFunc : public CPDF_Function { public: @@ -37,16 +37,14 @@ class CPDF_SampledFunc : public CPDF_Function { return m_EncodeInfo; } uint32_t GetBitsPerSample() const { return m_nBitsPerSample; } - CFX_RetainPtr GetSampleStream() const { - return m_pSampleStream; - } + RetainPtr GetSampleStream() const { return m_pSampleStream; } private: std::vector m_EncodeInfo; std::vector m_DecodeInfo; uint32_t m_nBitsPerSample; uint32_t m_SampleMax; - CFX_RetainPtr m_pSampleStream; + RetainPtr m_pSampleStream; }; #endif // CORE_FPDFAPI_PAGE_CPDF_SAMPLEDFUNC_H_ diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index c58e456238..47aa20938a 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -806,7 +806,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(uint32_t streamObjNum) { } CPDF_ImageObject* CPDF_StreamContentParser::AddImage( - const CFX_RetainPtr& pImage) { + const RetainPtr& pImage) { if (!pImage) return nullptr; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index c30c6b7d3c..59bd7bdc37 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -106,7 +106,7 @@ class CPDF_StreamContentParser { void AddPathObject(int FillType, bool bStroke); CPDF_ImageObject* AddImage(std::unique_ptr pStream); CPDF_ImageObject* AddImage(uint32_t streamObjNum); - CPDF_ImageObject* AddImage(const CFX_RetainPtr& pImage); + CPDF_ImageObject* AddImage(const RetainPtr& pImage); void AddForm(CPDF_Stream* pStream); void SetGraphicStates(CPDF_PageObject* pObj, @@ -217,7 +217,7 @@ class CPDF_StreamContentParser { float m_PathCurrentY; uint8_t m_PathClipType; ByteString m_LastImageName; - CFX_RetainPtr m_pLastImage; + RetainPtr m_pLastImage; bool m_bColored; float m_Type3Data[6]; bool m_bResourceMissing; diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp index 1f84f56547..1d5cf8ade7 100644 --- a/core/fpdfapi/parser/cfdf_document.cpp +++ b/core/fpdfapi/parser/cfdf_document.cpp @@ -30,7 +30,7 @@ std::unique_ptr CFDF_Document::CreateNewDoc() { } std::unique_ptr CFDF_Document::ParseFile( - const CFX_RetainPtr& pFile) { + const RetainPtr& pFile) { if (!pFile) return nullptr; @@ -46,7 +46,7 @@ std::unique_ptr CFDF_Document::ParseMemory(uint8_t* pData, } void CFDF_Document::ParseStream( - const CFX_RetainPtr& pFile) { + const RetainPtr& pFile) { m_pFile = pFile; CPDF_SyntaxParser parser; parser.InitParser(m_pFile, 0); diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h index a24415b099..9065621ea7 100644 --- a/core/fpdfapi/parser/cfdf_document.h +++ b/core/fpdfapi/parser/cfdf_document.h @@ -20,7 +20,7 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { public: static std::unique_ptr CreateNewDoc(); static std::unique_ptr ParseFile( - const CFX_RetainPtr& pFile); + const RetainPtr& pFile); static std::unique_ptr ParseMemory(uint8_t* pData, uint32_t size); @@ -31,10 +31,10 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); } protected: - void ParseStream(const CFX_RetainPtr& pFile); + void ParseStream(const RetainPtr& pFile); CFX_UnownedPtr m_pRootDict; - CFX_RetainPtr m_pFile; + RetainPtr m_pFile; }; #endif // CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_ diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h index 252f41c333..d815e786f6 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -11,18 +11,18 @@ #include "core/fdrm/crypto/fx_crypt.h" #include "core/fxcrt/cfx_binarybuf.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Dictionary; class CPDF_SecurityHandler; -class CPDF_CryptoHandler : public CFX_Retainable { +class CPDF_CryptoHandler : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); bool Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler); diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index bbd61dda00..5dd6285526 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -76,7 +76,7 @@ CPDF_DataAvail::DownloadHints::~DownloadHints() {} CPDF_DataAvail::CPDF_DataAvail( FileAvail* pFileAvail, - const CFX_RetainPtr& pFileRead, + const RetainPtr& pFileRead, bool bSupportHintTable) : m_pFileAvail(pFileAvail) { ASSERT(pFileRead); @@ -1422,11 +1422,11 @@ bool CPDF_DataAvail::CheckResources() { return true; } -CFX_RetainPtr CPDF_DataAvail::GetFileRead() const { +RetainPtr CPDF_DataAvail::GetFileRead() const { return m_pFileRead; } -CFX_RetainPtr CPDF_DataAvail::GetValidator() const { +RetainPtr CPDF_DataAvail::GetValidator() const { return m_pFileRead; } diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index befb84f833..f48abb5be0 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -94,7 +94,7 @@ class CPDF_DataAvail final { }; CPDF_DataAvail(FileAvail* pFileAvail, - const CFX_RetainPtr& pFileRead, + const RetainPtr& pFileRead, bool bSupportHintTable); ~CPDF_DataAvail(); @@ -105,10 +105,10 @@ class CPDF_DataAvail final { DocFormStatus IsFormAvail(DownloadHints* pHints); DocLinearizationStatus IsLinearizedPDF(); bool IsLinearized(); - CFX_RetainPtr GetFileRead() const; + RetainPtr GetFileRead() const; int GetPageCount() const; CPDF_Dictionary* GetPage(int index); - CFX_RetainPtr GetValidator() const; + RetainPtr GetValidator() const; protected: class PageNode { @@ -178,7 +178,7 @@ class CPDF_DataAvail final { bool ValidateForm(); FileAvail* const m_pFileAvail; - CFX_RetainPtr m_pFileRead; + RetainPtr m_pFileRead; CPDF_Parser m_parser; CPDF_SyntaxParser m_syntaxParser; std::unique_ptr m_pRoot; diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index f47551f82b..fef031119f 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -625,8 +625,7 @@ CPDF_Font* CPDF_Document::LoadFont(CPDF_Dictionary* pFontDict) { return m_pDocPage->GetFont(pFontDict); } -CFX_RetainPtr CPDF_Document::LoadFontFile( - CPDF_Stream* pStream) { +RetainPtr CPDF_Document::LoadFontFile(CPDF_Stream* pStream) { return m_pDocPage->GetFontFileStreamAcc(pStream); } @@ -641,12 +640,11 @@ CPDF_Pattern* CPDF_Document::LoadPattern(CPDF_Object* pPatternObj, return m_pDocPage->GetPattern(pPatternObj, bShading, matrix); } -CFX_RetainPtr CPDF_Document::LoadIccProfile( - CPDF_Stream* pStream) { +RetainPtr CPDF_Document::LoadIccProfile(CPDF_Stream* pStream) { return m_pDocPage->GetIccProfile(pStream); } -CFX_RetainPtr CPDF_Document::LoadImageFromPageData( +RetainPtr CPDF_Document::LoadImageFromPageData( uint32_t dwStreamObjNum) { ASSERT(dwStreamObjNum); return m_pDocPage->GetImage(dwStreamObjNum); diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h index ff80fa85c3..1b985dd7e1 100644 --- a/core/fpdfapi/parser/cpdf_document.h +++ b/core/fpdfapi/parser/cpdf_document.h @@ -81,9 +81,9 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { bool bShading, const CFX_Matrix& matrix); - CFX_RetainPtr LoadImageFromPageData(uint32_t dwStreamObjNum); - CFX_RetainPtr LoadFontFile(CPDF_Stream* pStream); - CFX_RetainPtr LoadIccProfile(CPDF_Stream* pStream); + RetainPtr LoadImageFromPageData(uint32_t dwStreamObjNum); + RetainPtr LoadFontFile(CPDF_Stream* pStream); + RetainPtr LoadIccProfile(CPDF_Stream* pStream); void LoadDoc(); void LoadLinearizedDoc(const CPDF_LinearizedHeader* pLinearizationParams); diff --git a/core/fpdfapi/parser/cpdf_object_avail_unittest.cpp b/core/fpdfapi/parser/cpdf_object_avail_unittest.cpp index cb9ceac101..1a8c6d5d14 100644 --- a/core/fpdfapi/parser/cpdf_object_avail_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_avail_unittest.cpp @@ -22,7 +22,7 @@ namespace { class InvalidReader : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableReadStream overrides: bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { @@ -38,7 +38,7 @@ class InvalidReader : public IFX_SeekableReadStream { class TestReadValidator : public CPDF_ReadValidator { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); void SimulateReadError() { ReadBlock(nullptr, 0, 1); } @@ -71,7 +71,7 @@ class TestHolder : public CPDF_IndirectObjectHolder { return obj_data.object.get(); } - CFX_RetainPtr GetValidator() { return validator_; } + RetainPtr GetValidator() { return validator_; } void AddObject(uint32_t objnum, std::unique_ptr object, @@ -103,7 +103,7 @@ class TestHolder : public CPDF_IndirectObjectHolder { ObjectState state = ObjectState::Unavailable; }; std::map objects_data_; - CFX_RetainPtr validator_; + RetainPtr validator_; }; class CPDF_ObjectAvailFailOnExclude : public CPDF_ObjectAvail { diff --git a/core/fpdfapi/parser/cpdf_page_object_avail_unittest.cpp b/core/fpdfapi/parser/cpdf_page_object_avail_unittest.cpp index a6454cd9fe..1e83e80d32 100644 --- a/core/fpdfapi/parser/cpdf_page_object_avail_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_page_object_avail_unittest.cpp @@ -23,7 +23,7 @@ namespace { class InvalidReader : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableReadStream overrides: bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { @@ -39,7 +39,7 @@ class InvalidReader : public IFX_SeekableReadStream { class TestReadValidator : public CPDF_ReadValidator { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); void SimulateReadError() { ReadBlock(nullptr, 0, 1); } @@ -72,7 +72,7 @@ class TestHolder : public CPDF_IndirectObjectHolder { return obj_data.object.get(); } - CFX_RetainPtr GetValidator() { return validator_; } + RetainPtr GetValidator() { return validator_; } void AddObject(uint32_t objnum, std::unique_ptr object, @@ -104,7 +104,7 @@ class TestHolder : public CPDF_IndirectObjectHolder { ObjectState state = ObjectState::Unavailable; }; std::map objects_data_; - CFX_RetainPtr validator_; + RetainPtr validator_; }; } // namespace diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 9239c5f0d0..a45ac13ad5 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -43,11 +43,11 @@ uint32_t GetVarInt(const uint8_t* p, int32_t n) { return result; } -int32_t GetStreamNCount(const CFX_RetainPtr& pObjStream) { +int32_t GetStreamNCount(const RetainPtr& pObjStream) { return pObjStream->GetDict()->GetIntegerFor("N"); } -int32_t GetStreamFirst(const CFX_RetainPtr& pObjStream) { +int32_t GetStreamFirst(const RetainPtr& pObjStream) { return pObjStream->GetDict()->GetIntegerFor("First"); } @@ -164,11 +164,11 @@ void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) { m_pEncryptDict = pDict; } -CFX_RetainPtr CPDF_Parser::GetCryptoHandler() const { +RetainPtr CPDF_Parser::GetCryptoHandler() const { return m_pSyntax->m_pCryptoHandler; } -CFX_RetainPtr CPDF_Parser::GetFileAccess() const { +RetainPtr CPDF_Parser::GetFileAccess() const { return m_pSyntax->GetFileAccess(); } @@ -189,7 +189,7 @@ void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) { } bool CPDF_Parser::InitSyntaxParser( - const CFX_RetainPtr& file_access) { + const RetainPtr& file_access) { const int32_t header_offset = GetHeaderOffset(file_access); if (header_offset == kInvalidHeaderOffset) return false; @@ -218,7 +218,7 @@ bool CPDF_Parser::ParseFileVersion() { } CPDF_Parser::Error CPDF_Parser::StartParse( - const CFX_RetainPtr& pFileAccess, + const RetainPtr& pFileAccess, CPDF_Document* pDocument) { if (!InitSyntaxParser(pFileAccess)) return FORMAT_ERROR; @@ -1211,7 +1211,7 @@ std::unique_ptr CPDF_Parser::ParseIndirectObject( if (GetObjectType(objnum) != ObjectType::kCompressed) return nullptr; - CFX_RetainPtr pObjStream = + RetainPtr pObjStream = GetObjectStream(m_ObjectInfo[objnum].pos); if (!pObjStream) return nullptr; @@ -1240,7 +1240,7 @@ std::unique_ptr CPDF_Parser::ParseIndirectObject( return syntax.GetObject(pObjList, 0, 0, false); } -CFX_RetainPtr CPDF_Parser::GetObjectStream(uint32_t objnum) { +RetainPtr CPDF_Parser::GetObjectStream(uint32_t objnum) { auto it = m_ObjectStreamMap.find(objnum); if (it != m_ObjectStreamMap.end()) return it->second; @@ -1348,7 +1348,7 @@ bool CPDF_Parser::ParseLinearizedHeader() { } CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( - const CFX_RetainPtr& pFileAccess, + const RetainPtr& pFileAccess, CPDF_Document* pDocument) { ASSERT(!m_bHasParsed); m_bXRefStream = false; diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h index 5cd1301ddd..f59691fe36 100644 --- a/core/fpdfapi/parser/cpdf_parser.h +++ b/core/fpdfapi/parser/cpdf_parser.h @@ -14,10 +14,10 @@ #include #include "core/fpdfapi/parser/cpdf_syntax_parser.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Array; class CPDF_CryptoHandler; @@ -57,9 +57,9 @@ class CPDF_Parser { CPDF_Parser(); ~CPDF_Parser(); - Error StartParse(const CFX_RetainPtr& pFile, + Error StartParse(const RetainPtr& pFile, CPDF_Document* pDocument); - Error StartLinearizedParse(const CFX_RetainPtr& pFile, + Error StartLinearizedParse(const RetainPtr& pFile, CPDF_Document* pDocument); void SetPassword(const char* password) { m_Password = password; } @@ -84,8 +84,8 @@ class CPDF_Parser { ObjectType GetObjectType(uint32_t objnum) const; uint16_t GetObjectGenNum(uint32_t objnum) const; bool IsObjectFreeOrNull(uint32_t objnum) const; - CFX_RetainPtr GetCryptoHandler() const; - CFX_RetainPtr GetFileAccess() const; + RetainPtr GetCryptoHandler() const; + RetainPtr GetFileAccess() const; FX_FILESIZE GetObjectOffset(uint32_t objnum) const; @@ -164,7 +164,7 @@ class CPDF_Parser { bool LoadLinearizedCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount); bool LoadLinearizedAllCrossRefV5(FX_FILESIZE pos); Error LoadLinearizedMainXRefTable(); - CFX_RetainPtr GetObjectStream(uint32_t number); + RetainPtr GetObjectStream(uint32_t number); bool ParseLinearizedHeader(); void SetEncryptDictionary(CPDF_Dictionary* pDict); void ShrinkObjectMap(uint32_t size); @@ -188,8 +188,7 @@ class CPDF_Parser { CPDF_SyntaxParser::ParseType parse_type, FX_FILESIZE* pResultPos); - bool InitSyntaxParser( - const CFX_RetainPtr& file_access); + bool InitSyntaxParser(const RetainPtr& file_access); bool ParseFileVersion(); CFX_UnownedPtr m_pDocument; @@ -205,7 +204,7 @@ class CPDF_Parser { uint32_t m_dwLinearizedFirstPageXRefStartObjNum; // A map of object numbers to indirect streams. - std::map> m_ObjectStreamMap; + std::map> m_ObjectStreamMap; // Mapping of object numbers to offsets. The offsets are relative to the first // object in the stream. @@ -213,7 +212,7 @@ class CPDF_Parser { // Mapping of streams to their object caches. This is valid as long as the // streams in |m_ObjectStreamMap| are valid. - std::map, StreamObjectCache> m_ObjCache; + std::map, StreamObjectCache> m_ObjCache; // All indirect object numbers that are being parsed. std::set m_ParsingObjNums; diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp index d441b12cef..b3352975a9 100644 --- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp @@ -7,9 +7,9 @@ #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_syntax_parser.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/path_service.h" @@ -17,7 +17,7 @@ class CFX_TestBufferRead : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableReadStream: bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { @@ -46,7 +46,7 @@ class CPDF_TestParser : public CPDF_Parser { // Setup reading from a file and initial states. bool InitTestFromFile(const char* path) { - CFX_RetainPtr pFileAccess = + RetainPtr pFileAccess = IFX_SeekableReadStream::CreateFromFilename(path); if (!pFileAccess) return false; diff --git a/core/fpdfapi/parser/cpdf_read_validator.cpp b/core/fpdfapi/parser/cpdf_read_validator.cpp index d01b3c61e6..bf086008ca 100644 --- a/core/fpdfapi/parser/cpdf_read_validator.cpp +++ b/core/fpdfapi/parser/cpdf_read_validator.cpp @@ -40,7 +40,7 @@ CPDF_ReadValidator::Session::~Session() { } CPDF_ReadValidator::CPDF_ReadValidator( - const CFX_RetainPtr& file_read, + const RetainPtr& file_read, CPDF_DataAvail::FileAvail* file_avail) : file_read_(file_read), file_avail_(file_avail), diff --git a/core/fpdfapi/parser/cpdf_read_validator.h b/core/fpdfapi/parser/cpdf_read_validator.h index cc04a1f55e..812a5ccb1b 100644 --- a/core/fpdfapi/parser/cpdf_read_validator.h +++ b/core/fpdfapi/parser/cpdf_read_validator.h @@ -11,7 +11,7 @@ class CPDF_ReadValidator : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); class Session { public: @@ -48,14 +48,14 @@ class CPDF_ReadValidator : public IFX_SeekableReadStream { FX_FILESIZE GetSize() override; protected: - CPDF_ReadValidator(const CFX_RetainPtr& file_read, + CPDF_ReadValidator(const RetainPtr& file_read, CPDF_DataAvail::FileAvail* file_avail); ~CPDF_ReadValidator() override; private: void ScheduleDownload(FX_FILESIZE offset, size_t size); - CFX_RetainPtr file_read_; + RetainPtr file_read_; CFX_UnownedPtr file_avail_; CFX_UnownedPtr hints_; diff --git a/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp b/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp index cb6c07ecb6..c6007a6c31 100644 --- a/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp @@ -65,7 +65,7 @@ class MockDownloadHints : public CPDF_DataAvail::DownloadHints { class InvalidReader : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableReadStream overrides: bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp index c00096df8b..bf2feaed22 100644 --- a/core/fpdfapi/parser/cpdf_stream.cpp +++ b/core/fpdfapi/parser/cpdf_stream.cpp @@ -60,7 +60,7 @@ void CPDF_Stream::InitStream(const uint8_t* pData, } void CPDF_Stream::InitStreamFromFile( - const CFX_RetainPtr& pFile, + const RetainPtr& pFile, std::unique_ptr pDict) { m_pDict = std::move(pDict); m_bMemoryBased = false; diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h index be70e05e72..f8b09af7e2 100644 --- a/core/fpdfapi/parser/cpdf_stream.h +++ b/core/fpdfapi/parser/cpdf_stream.h @@ -51,7 +51,7 @@ class CPDF_Stream : public CPDF_Object { void InitStream(const uint8_t* pData, uint32_t size, std::unique_ptr pDict); - void InitStreamFromFile(const CFX_RetainPtr& pFile, + void InitStreamFromFile(const RetainPtr& pFile, std::unique_ptr pDict); bool ReadRawData(FX_FILESIZE start_pos, @@ -70,7 +70,7 @@ class CPDF_Stream : public CPDF_Object { uint32_t m_dwSize = 0; std::unique_ptr m_pDict; std::unique_ptr m_pDataBuf; - CFX_RetainPtr m_pFile; + RetainPtr m_pFile; }; inline CPDF_Stream* ToStream(CPDF_Object* obj) { diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index 2161dd1950..a6cca095a6 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -11,14 +11,14 @@ #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_stream.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" -class CPDF_StreamAcc : public CFX_Retainable { +class CPDF_StreamAcc : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); CPDF_StreamAcc(const CPDF_StreamAcc&) = delete; CPDF_StreamAcc& operator=(const CPDF_StreamAcc&) = delete; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 4556dc9627..7bea4c45fc 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -721,7 +721,7 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( } void CPDF_SyntaxParser::InitParser( - const CFX_RetainPtr& pFileAccess, + const RetainPtr& pFileAccess, uint32_t HeaderOffset) { ASSERT(pFileAccess); return InitParserWithValidator( @@ -730,7 +730,7 @@ void CPDF_SyntaxParser::InitParser( } void CPDF_SyntaxParser::InitParserWithValidator( - const CFX_RetainPtr& validator, + const RetainPtr& validator, uint32_t HeaderOffset) { ASSERT(validator); FX_Free(m_pFileBuf); @@ -843,10 +843,10 @@ FX_FILESIZE CPDF_SyntaxParser::FindTag(const ByteStringView& tag, } void CPDF_SyntaxParser::SetEncrypt( - const CFX_RetainPtr& pCryptoHandler) { + const RetainPtr& pCryptoHandler) { m_pCryptoHandler = pCryptoHandler; } -CFX_RetainPtr CPDF_SyntaxParser::GetFileAccess() const { +RetainPtr CPDF_SyntaxParser::GetFileAccess() const { return m_pFileAccess; } diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 4e28c2fb92..78d5345001 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -29,12 +29,11 @@ class CPDF_SyntaxParser { explicit CPDF_SyntaxParser(const CFX_WeakPtr& pPool); ~CPDF_SyntaxParser(); - void InitParser(const CFX_RetainPtr& pFileAccess, + void InitParser(const RetainPtr& pFileAccess, uint32_t HeaderOffset); - void InitParserWithValidator( - const CFX_RetainPtr& pValidator, - uint32_t HeaderOffset); + void InitParserWithValidator(const RetainPtr& pValidator, + uint32_t HeaderOffset); FX_FILESIZE GetPos() const { return m_Pos; } void SetPos(FX_FILESIZE pos) { m_Pos = std::min(pos, m_FileLen); } @@ -61,15 +60,15 @@ class CPDF_SyntaxParser { void ToNextWord(); bool BackwardsSearchToWord(const ByteStringView& word, FX_FILESIZE limit); FX_FILESIZE FindTag(const ByteStringView& tag, FX_FILESIZE limit); - void SetEncrypt(const CFX_RetainPtr& pCryptoHandler); + void SetEncrypt(const RetainPtr& pCryptoHandler); bool ReadBlock(uint8_t* pBuf, uint32_t size); bool GetCharAt(FX_FILESIZE pos, uint8_t& ch); ByteString GetNextWord(bool* bIsNumber); ByteString PeekNextWord(bool* bIsNumber); - CFX_RetainPtr GetFileAccess() const; + RetainPtr GetFileAccess() const; - const CFX_RetainPtr& GetValidator() const { + const RetainPtr& GetValidator() const { return m_pFileAccess; } @@ -113,13 +112,13 @@ class CPDF_SyntaxParser { FX_FILESIZE m_Pos; uint32_t m_MetadataObjnum; - CFX_RetainPtr m_pFileAccess; + RetainPtr m_pFileAccess; FX_FILESIZE m_HeaderOffset; FX_FILESIZE m_FileLen; uint8_t* m_pFileBuf; uint32_t m_BufSize; FX_FILESIZE m_BufOffset; - CFX_RetainPtr m_pCryptoHandler; + RetainPtr m_pCryptoHandler; uint8_t m_WordBuffer[257]; uint32_t m_WordSize; CFX_WeakPtr m_pPool; diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 82804528ab..e57f834cee 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -71,7 +71,7 @@ const char PDF_CharType[256] = { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'}; -int32_t GetHeaderOffset(const CFX_RetainPtr& pFile) { +int32_t GetHeaderOffset(const RetainPtr& pFile) { const size_t kBufSize = 4; uint8_t buf[kBufSize]; for (int32_t offset = 0; offset <= 1024; ++offset) { diff --git a/core/fpdfapi/parser/fpdf_parser_utility.h b/core/fpdfapi/parser/fpdf_parser_utility.h index 5f85551a53..e4b922cad2 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.h +++ b/core/fpdfapi/parser/fpdf_parser_utility.h @@ -7,8 +7,8 @@ #ifndef CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_ #define CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" class IFX_SeekableReadStream; class CPDF_Dictionary; @@ -39,7 +39,7 @@ constexpr int32_t kInvalidHeaderOffset = -1; // On success, return a positive offset value to the PDF header.. If the header // cannot be found, or if there is an error reading from |pFile|, then return // |kInvalidHeaderOffset|. -int32_t GetHeaderOffset(const CFX_RetainPtr& pFile); +int32_t GetHeaderOffset(const RetainPtr& pFile); int32_t GetDirectInteger(CPDF_Dictionary* pDict, const ByteString& key); diff --git a/core/fpdfapi/render/cpdf_devicebuffer.h b/core/fpdfapi/render/cpdf_devicebuffer.h index bfab27503b..2146c9761f 100644 --- a/core/fpdfapi/render/cpdf_devicebuffer.h +++ b/core/fpdfapi/render/cpdf_devicebuffer.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBitmap; class CFX_RenderDevice; @@ -29,14 +29,14 @@ class CPDF_DeviceBuffer { const CPDF_PageObject* pObj, int max_dpi); void OutputToDevice(); - CFX_RetainPtr GetBitmap() const { return m_pBitmap; } + RetainPtr GetBitmap() const { return m_pBitmap; } const CFX_Matrix* GetMatrix() const { return &m_Matrix; } private: CFX_UnownedPtr m_pDevice; CFX_UnownedPtr m_pContext; CFX_UnownedPtr m_pObject; - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; FX_RECT m_Rect; CFX_Matrix m_Matrix; }; diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index c6a5632055..5104f7b618 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -752,7 +752,7 @@ int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_PauseIndicator* pPause) { return 1; } -CFX_RetainPtr CPDF_DIBSource::DetachMask() { +RetainPtr CPDF_DIBSource::DetachMask() { return std::move(m_pMask); } diff --git a/core/fpdfapi/render/cpdf_dibsource.h b/core/fpdfapi/render/cpdf_dibsource.h index f6883ed263..08c4afe862 100644 --- a/core/fpdfapi/render/cpdf_dibsource.h +++ b/core/fpdfapi/render/cpdf_dibsource.h @@ -18,8 +18,8 @@ #include "core/fpdfapi/render/cpdf_imageloader.h" #include "core/fpdfapi/render/cpdf_rendercontext.h" #include "core/fpdfapi/render/cpdf_renderoptions.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_defaultrenderdevice.h" #include "core/fxge/cfx_renderdevice.h" @@ -42,7 +42,7 @@ typedef struct { class CPDF_DIBSource : public CFX_DIBSource { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CPDF_DIBSource() override; @@ -76,7 +76,7 @@ class CPDF_DIBSource : public CFX_DIBSource { int StartLoadMaskDIB(); int ContinueLoadMaskDIB(IFX_PauseIndicator* pPause); int ContinueToLoadMask(); - CFX_RetainPtr DetachMask(); + RetainPtr DetachMask(); private: CPDF_DIBSource(); @@ -125,7 +125,7 @@ class CPDF_DIBSource : public CFX_DIBSource { CFX_UnownedPtr m_pDocument; CFX_UnownedPtr m_pStream; CFX_UnownedPtr m_pDict; - CFX_RetainPtr m_pStreamAcc; + RetainPtr m_pStreamAcc; CPDF_ColorSpace* m_pColorSpace; uint32_t m_Family; uint32_t m_bpc; @@ -143,9 +143,9 @@ class CPDF_DIBSource : public CFX_DIBSource { DIB_COMP_DATA* m_pCompData; uint8_t* m_pLineBuf; uint8_t* m_pMaskedLine; - CFX_RetainPtr m_pCachedBitmap; - CFX_RetainPtr m_pMask; - CFX_RetainPtr m_pGlobalStream; + RetainPtr m_pCachedBitmap; + RetainPtr m_pMask; + RetainPtr m_pGlobalStream; std::unique_ptr m_pDecoder; std::unique_ptr m_pJbig2Context; CFX_UnownedPtr m_pMaskStream; diff --git a/core/fpdfapi/render/cpdf_dibtransferfunc.cpp b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp index 6ba148e15c..be2c9f30bb 100644 --- a/core/fpdfapi/render/cpdf_dibtransferfunc.cpp +++ b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp @@ -12,7 +12,7 @@ #include "core/fpdfapi/render/cpdf_transferfunc.h" CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( - const CFX_RetainPtr& pTransferFunc) + const RetainPtr& pTransferFunc) : m_pTransferFunc(pTransferFunc) { m_RampR = pTransferFunc->m_Samples; m_RampG = &pTransferFunc->m_Samples[256]; diff --git a/core/fpdfapi/render/cpdf_dibtransferfunc.h b/core/fpdfapi/render/cpdf_dibtransferfunc.h index b22ae9c775..442811b97e 100644 --- a/core/fpdfapi/render/cpdf_dibtransferfunc.h +++ b/core/fpdfapi/render/cpdf_dibtransferfunc.h @@ -17,7 +17,7 @@ class CPDF_TransferFunc; class CPDF_DIBTransferFunc : public CFX_FilteredDIB { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CPDF_DIBTransferFunc() override; @@ -33,12 +33,12 @@ class CPDF_DIBTransferFunc : public CFX_FilteredDIB { private: explicit CPDF_DIBTransferFunc( - const CFX_RetainPtr& pTransferFunc); + const RetainPtr& pTransferFunc); const uint8_t* m_RampR; const uint8_t* m_RampG; const uint8_t* m_RampB; - CFX_RetainPtr m_pTransferFunc; + RetainPtr m_pTransferFunc; }; #endif // CORE_FPDFAPI_RENDER_CPDF_DIBTRANSFERFUNC_H_ diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp index bf277f03f8..3b16013bc5 100644 --- a/core/fpdfapi/render/cpdf_docrenderdata.cpp +++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp @@ -44,7 +44,7 @@ void CPDF_DocRenderData::Clear(bool bRelease) { } } -CFX_RetainPtr CPDF_DocRenderData::GetCachedType3( +RetainPtr CPDF_DocRenderData::GetCachedType3( CPDF_Type3Font* pFont) { auto it = m_Type3FaceMap.find(pFont); if (it != m_Type3FaceMap.end()) @@ -61,7 +61,7 @@ void CPDF_DocRenderData::MaybePurgeCachedType3(CPDF_Type3Font* pFont) { m_Type3FaceMap.erase(it); } -CFX_RetainPtr CPDF_DocRenderData::GetTransferFunc( +RetainPtr CPDF_DocRenderData::GetTransferFunc( CPDF_Object* pObj) { if (!pObj) return nullptr; diff --git a/core/fpdfapi/render/cpdf_docrenderdata.h b/core/fpdfapi/render/cpdf_docrenderdata.h index 949a079126..efc4741e5e 100644 --- a/core/fpdfapi/render/cpdf_docrenderdata.h +++ b/core/fpdfapi/render/cpdf_docrenderdata.h @@ -25,18 +25,18 @@ class CPDF_DocRenderData { explicit CPDF_DocRenderData(CPDF_Document* pPDFDoc); ~CPDF_DocRenderData(); - CFX_RetainPtr GetCachedType3(CPDF_Type3Font* pFont); + RetainPtr GetCachedType3(CPDF_Type3Font* pFont); void MaybePurgeCachedType3(CPDF_Type3Font* pFont); - CFX_RetainPtr GetTransferFunc(CPDF_Object* pObj); + RetainPtr GetTransferFunc(CPDF_Object* pObj); void MaybePurgeTransferFunc(CPDF_Object* pOb); void Clear(bool bRelease); private: CFX_UnownedPtr m_pPDFDoc; - std::map> m_Type3FaceMap; - std::map> m_TransferFuncMap; + std::map> m_Type3FaceMap; + std::map> m_TransferFuncMap; }; #endif // CORE_FPDFAPI_RENDER_CPDF_DOCRENDERDATA_H_ diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.cpp b/core/fpdfapi/render/cpdf_imagecacheentry.cpp index 4f98b96726..666839b0f2 100644 --- a/core/fpdfapi/render/cpdf_imagecacheentry.cpp +++ b/core/fpdfapi/render/cpdf_imagecacheentry.cpp @@ -18,9 +18,8 @@ #include "core/fpdfapi/render/cpdf_rendercontext.h" #include "core/fpdfapi/render/cpdf_renderstatus.h" -CPDF_ImageCacheEntry::CPDF_ImageCacheEntry( - CPDF_Document* pDoc, - const CFX_RetainPtr& pImage) +CPDF_ImageCacheEntry::CPDF_ImageCacheEntry(CPDF_Document* pDoc, + const RetainPtr& pImage) : m_dwTimeCount(0), m_MatteColor(0), m_pDocument(pDoc), @@ -29,7 +28,7 @@ CPDF_ImageCacheEntry::CPDF_ImageCacheEntry( CPDF_ImageCacheEntry::~CPDF_ImageCacheEntry() {} -void CPDF_ImageCacheEntry::Reset(const CFX_RetainPtr& pBitmap) { +void CPDF_ImageCacheEntry::Reset(const RetainPtr& pBitmap) { m_pCachedBitmap.Reset(); if (pBitmap) m_pCachedBitmap = pBitmap->Clone(nullptr); @@ -37,18 +36,18 @@ void CPDF_ImageCacheEntry::Reset(const CFX_RetainPtr& pBitmap) { } static uint32_t FPDF_ImageCache_EstimateImageSize( - const CFX_RetainPtr& pDIB) { + const RetainPtr& pDIB) { return pDIB && pDIB->GetBuffer() ? (uint32_t)pDIB->GetHeight() * pDIB->GetPitch() + (uint32_t)pDIB->GetPaletteSize() * 4 : 0; } -CFX_RetainPtr CPDF_ImageCacheEntry::DetachBitmap() { +RetainPtr CPDF_ImageCacheEntry::DetachBitmap() { return std::move(m_pCurBitmap); } -CFX_RetainPtr CPDF_ImageCacheEntry::DetachMask() { +RetainPtr CPDF_ImageCacheEntry::DetachMask() { return std::move(m_pCurMask); } diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.h b/core/fpdfapi/render/cpdf_imagecacheentry.h index 176b2818d9..111050f60c 100644 --- a/core/fpdfapi/render/cpdf_imagecacheentry.h +++ b/core/fpdfapi/render/cpdf_imagecacheentry.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBSource; class CFX_DIBitmap; @@ -24,10 +24,10 @@ class IFX_PauseIndicator; class CPDF_ImageCacheEntry { public: CPDF_ImageCacheEntry(CPDF_Document* pDoc, - const CFX_RetainPtr& pImage); + const RetainPtr& pImage); ~CPDF_ImageCacheEntry(); - void Reset(const CFX_RetainPtr& pBitmap); + void Reset(const RetainPtr& pBitmap); uint32_t EstimateSize() const { return m_dwCacheSize; } uint32_t GetTimeCount() const { return m_dwTimeCount; } CPDF_Image* GetImage() const { return m_pImage.Get(); } @@ -38,8 +38,8 @@ class CPDF_ImageCacheEntry { bool bLoadMask, CPDF_RenderStatus* pRenderStatus); int Continue(IFX_PauseIndicator* pPause, CPDF_RenderStatus* pRenderStatus); - CFX_RetainPtr DetachBitmap(); - CFX_RetainPtr DetachMask(); + RetainPtr DetachBitmap(); + RetainPtr DetachMask(); int m_dwTimeCount; uint32_t m_MatteColor; @@ -49,11 +49,11 @@ class CPDF_ImageCacheEntry { void CalcSize(); CFX_UnownedPtr const m_pDocument; - CFX_RetainPtr const m_pImage; - CFX_RetainPtr m_pCurBitmap; - CFX_RetainPtr m_pCurMask; - CFX_RetainPtr m_pCachedBitmap; - CFX_RetainPtr m_pCachedMask; + RetainPtr const m_pImage; + RetainPtr m_pCurBitmap; + RetainPtr m_pCurMask; + RetainPtr m_pCachedBitmap; + RetainPtr m_pCachedMask; uint32_t m_dwCacheSize; }; diff --git a/core/fpdfapi/render/cpdf_imageloader.cpp b/core/fpdfapi/render/cpdf_imageloader.cpp index f195b89dfc..19eb875946 100644 --- a/core/fpdfapi/render/cpdf_imageloader.cpp +++ b/core/fpdfapi/render/cpdf_imageloader.cpp @@ -61,7 +61,7 @@ void CPDF_ImageLoader::HandleFailure() { m_MatteColor = entry->m_MatteColor; return; } - CFX_RetainPtr pImage = m_pImageObject->GetImage(); + RetainPtr pImage = m_pImageObject->GetImage(); m_bCached = false; m_pBitmap = pImage->DetachBitmap(); m_pMask = pImage->DetachMask(); diff --git a/core/fpdfapi/render/cpdf_imageloader.h b/core/fpdfapi/render/cpdf_imageloader.h index 69577c3a18..2fc0670dff 100644 --- a/core/fpdfapi/render/cpdf_imageloader.h +++ b/core/fpdfapi/render/cpdf_imageloader.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" class CPDF_ImageObject; @@ -31,8 +31,8 @@ class CPDF_ImageLoader { CPDF_RenderStatus* pRenderStatus); bool Continue(IFX_PauseIndicator* pPause, CPDF_RenderStatus* pRenderStatus); - CFX_RetainPtr m_pBitmap; - CFX_RetainPtr m_pMask; + RetainPtr m_pBitmap; + RetainPtr m_pMask; uint32_t m_MatteColor; bool m_bCached; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index e9f1752d57..2fa0beba47 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -184,7 +184,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, } bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, - const CFX_RetainPtr& pDIBSource, + const RetainPtr& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -222,7 +222,7 @@ CFX_Matrix CPDF_ImageRenderer::GetDrawMatrix(const FX_RECT& rect) const { void CPDF_ImageRenderer::CalculateDrawImage( CFX_DefaultRenderDevice* pBitmapDevice1, CFX_DefaultRenderDevice* pBitmapDevice2, - const CFX_RetainPtr& pDIBSource, + const RetainPtr& pDIBSource, CFX_Matrix* pNewMatrix, const FX_RECT& rect) const { CPDF_RenderStatus bitmap_render; @@ -380,7 +380,7 @@ bool CPDF_ImageRenderer::StartDIBSource() { } } #ifdef _SKIA_SUPPORT_ - CFX_RetainPtr premultiplied = m_pDIBSource->Clone(nullptr); + RetainPtr premultiplied = m_pDIBSource->Clone(nullptr); if (m_pDIBSource->HasAlpha()) CFX_SkiaDeviceDriver::PreMultiply(premultiplied); if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( @@ -456,7 +456,7 @@ bool CPDF_ImageRenderer::StartDIBSource() { FX_RECT dest_clip( dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); - CFX_RetainPtr pStretched = + RetainPtr pStretched = m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip); if (pStretched) { m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left, @@ -477,7 +477,7 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() { FXFILL_WINDING); return false; } - CFX_RetainPtr pAlphaMask; + RetainPtr pAlphaMask; if (m_pDIBSource->IsAlphaMask()) pAlphaMask = m_pDIBSource; else @@ -486,7 +486,7 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() { if (fabs(m_ImageMatrix.b) >= 0.5f || fabs(m_ImageMatrix.c) >= 0.5f) { int left; int top; - CFX_RetainPtr pTransformed = + RetainPtr pTransformed = pAlphaMask->TransformTo(&m_ImageMatrix, &left, &top); if (!pTransformed) return true; @@ -515,7 +515,7 @@ bool CPDF_ImageRenderer::Continue(IFX_PauseIndicator* pPause) { if (m_pTransformer->Continue(pPause)) return true; - CFX_RetainPtr pBitmap = m_pTransformer->DetachBitmap(); + RetainPtr pBitmap = m_pTransformer->DetachBitmap(); if (!pBitmap) return false; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h index 332cbf515c..0d59a4e7cb 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.h +++ b/core/fpdfapi/render/cpdf_imagerenderer.h @@ -35,7 +35,7 @@ class CPDF_ImageRenderer { int blendType); bool Start(CPDF_RenderStatus* pStatus, - const CFX_RetainPtr& pDIBSource, + const RetainPtr& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -58,7 +58,7 @@ class CPDF_ImageRenderer { CFX_Matrix GetDrawMatrix(const FX_RECT& rect) const; void CalculateDrawImage(CFX_DefaultRenderDevice* bitmap_device1, CFX_DefaultRenderDevice* bitmap_device2, - const CFX_RetainPtr& pDIBSource, + const RetainPtr& pDIBSource, CFX_Matrix* pNewMatrix, const FX_RECT& rect) const; void HandleFilters(); @@ -69,8 +69,8 @@ class CPDF_ImageRenderer { CFX_UnownedPtr m_pObj2Device; CFX_Matrix m_ImageMatrix; CPDF_ImageLoader m_Loader; - CFX_RetainPtr m_pDIBSource; - CFX_RetainPtr m_pClone; + RetainPtr m_pDIBSource; + RetainPtr m_pClone; int m_BitmapAlpha; bool m_bPatternColor; CFX_UnownedPtr m_pPattern; diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp index ca5b620316..42205ebe63 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.cpp +++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp @@ -80,7 +80,7 @@ void CPDF_PageRenderCache::ClearImageCacheEntry(CPDF_Stream* pStream) { } bool CPDF_PageRenderCache::StartGetCachedBitmap( - const CFX_RetainPtr& pImage, + const RetainPtr& pImage, bool bStdCS, uint32_t GroupFamily, bool bLoadMask, @@ -126,9 +126,8 @@ bool CPDF_PageRenderCache::Continue(IFX_PauseIndicator* pPause, return false; } -void CPDF_PageRenderCache::ResetBitmap( - const CFX_RetainPtr& pImage, - const CFX_RetainPtr& pBitmap) { +void CPDF_PageRenderCache::ResetBitmap(const RetainPtr& pImage, + const RetainPtr& pBitmap) { CPDF_ImageCacheEntry* pEntry; CPDF_Stream* pStream = pImage->GetStream(); const auto it = m_ImageCache.find(pStream); diff --git a/core/fpdfapi/render/cpdf_pagerendercache.h b/core/fpdfapi/render/cpdf_pagerendercache.h index 0a315b74ed..76898ab258 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.h +++ b/core/fpdfapi/render/cpdf_pagerendercache.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBitmap; class CPDF_Image; @@ -28,14 +28,14 @@ class CPDF_PageRenderCache { void CacheOptimization(int32_t dwLimitCacheSize); uint32_t GetTimeCount() const { return m_nTimeCount; } - void ResetBitmap(const CFX_RetainPtr& pImage, - const CFX_RetainPtr& pBitmap); + void ResetBitmap(const RetainPtr& pImage, + const RetainPtr& pBitmap); CPDF_Page* GetPage() const { return m_pPage.Get(); } CPDF_ImageCacheEntry* GetCurImageCacheEntry() const { return m_pCurImageCacheEntry; } - bool StartGetCachedBitmap(const CFX_RetainPtr& pImage, + bool StartGetCachedBitmap(const RetainPtr& pImage, bool bStdCS, uint32_t GroupFamily, bool bLoadMask, diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp index dec513276d..3c08295480 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.cpp +++ b/core/fpdfapi/render/cpdf_rendercontext.cpp @@ -30,11 +30,10 @@ CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc, CPDF_RenderContext::~CPDF_RenderContext() {} -void CPDF_RenderContext::GetBackground( - const CFX_RetainPtr& pBuffer, - const CPDF_PageObject* pObj, - const CPDF_RenderOptions* pOptions, - CFX_Matrix* pFinalMatrix) { +void CPDF_RenderContext::GetBackground(const RetainPtr& pBuffer, + const CPDF_PageObject* pObj, + const CPDF_RenderOptions* pOptions, + CFX_Matrix* pFinalMatrix) { CFX_DefaultRenderDevice device; device.Attach(pBuffer, false, nullptr, false); diff --git a/core/fpdfapi/render/cpdf_rendercontext.h b/core/fpdfapi/render/cpdf_rendercontext.h index feb71871b1..8806a78622 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.h +++ b/core/fpdfapi/render/cpdf_rendercontext.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Dictionary; class CPDF_Document; @@ -52,7 +52,7 @@ class CPDF_RenderContext { const CPDF_RenderOptions* pOptions, const CFX_Matrix* pFinalMatrix); - void GetBackground(const CFX_RetainPtr& pBuffer, + void GetBackground(const RetainPtr& pBuffer, const CPDF_PageObject* pObj, const CPDF_RenderOptions* pOptions, CFX_Matrix* pFinalMatrix); diff --git a/core/fpdfapi/render/cpdf_renderoptions.h b/core/fpdfapi/render/cpdf_renderoptions.h index aa48b4e5dc..1f6afc30e2 100644 --- a/core/fpdfapi/render/cpdf_renderoptions.h +++ b/core/fpdfapi/render/cpdf_renderoptions.h @@ -8,8 +8,8 @@ #define CORE_FPDFAPI_RENDER_CPDF_RENDEROPTIONS_H_ #include "core/fpdfdoc/cpdf_occontext.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" #define RENDER_CLEARTYPE 0x00000001 @@ -44,7 +44,7 @@ class CPDF_RenderOptions { uint32_t m_Flags; uint32_t m_dwLimitCacheSize; bool m_bDrawAnnots; - CFX_RetainPtr m_pOCContext; + RetainPtr m_pOCContext; }; #endif // CORE_FPDFAPI_RENDER_CPDF_RENDEROPTIONS_H_ diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index ef07852e38..e94913d9aa 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -100,7 +100,7 @@ uint32_t CountOutputs( return total; } -void DrawAxialShading(const CFX_RetainPtr& pBitmap, +void DrawAxialShading(const RetainPtr& pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Dictionary* pDict, const std::vector>& funcs, @@ -185,7 +185,7 @@ void DrawAxialShading(const CFX_RetainPtr& pBitmap, } } -void DrawRadialShading(const CFX_RetainPtr& pBitmap, +void DrawRadialShading(const RetainPtr& pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Dictionary* pDict, const std::vector>& funcs, @@ -317,7 +317,7 @@ void DrawRadialShading(const CFX_RetainPtr& pBitmap, } } -void DrawFuncShading(const CFX_RetainPtr& pBitmap, +void DrawFuncShading(const RetainPtr& pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Dictionary* pDict, const std::vector>& funcs, @@ -388,7 +388,7 @@ bool GetScanlineIntersect(int y, return true; } -void DrawGouraud(const CFX_RetainPtr& pBitmap, +void DrawGouraud(const RetainPtr& pBitmap, int alpha, CPDF_MeshVertex triangle[3]) { float min_y = triangle[0].position.y; @@ -470,7 +470,7 @@ void DrawGouraud(const CFX_RetainPtr& pBitmap, } void DrawFreeGouraudShading( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Stream* pShadingStream, const std::vector>& funcs, @@ -511,7 +511,7 @@ void DrawFreeGouraudShading( } void DrawLatticeGouraudShading( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Stream* pShadingStream, const std::vector>& funcs, @@ -827,7 +827,7 @@ struct CPDF_PatchDrawer { void DrawCoonPatchMeshes( ShadingType type, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Stream* pShadingStream, const std::vector>& funcs, @@ -911,13 +911,13 @@ void DrawCoonPatchMeshes( } } -CFX_RetainPtr DrawPatternBitmap(CPDF_Document* pDoc, - CPDF_PageRenderCache* pCache, - CPDF_TilingPattern* pPattern, - const CFX_Matrix* pObject2Device, - int width, - int height, - int flags) { +RetainPtr DrawPatternBitmap(CPDF_Document* pDoc, + CPDF_PageRenderCache* pCache, + CPDF_TilingPattern* pPattern, + const CFX_Matrix* pObject2Device, + int width, + int height, + int flags) { auto pBitmap = pdfium::MakeRetain(); if (!pBitmap->Create(width, height, pPattern->colored() ? FXDIB_Argb : FXDIB_8bppMask)) { @@ -1319,7 +1319,7 @@ bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, fill_argb, stroke_argb, FillType, m_curBlend); } -CFX_RetainPtr CPDF_RenderStatus::GetTransferFunc( +RetainPtr CPDF_RenderStatus::GetTransferFunc( CPDF_Object* pObj) const { ASSERT(pObj); CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData(); @@ -1557,7 +1557,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, int width = FXSYS_round((float)rect.Width() * scaleX); int height = FXSYS_round((float)rect.Height() * scaleY); CFX_DefaultRenderDevice bitmap_device; - CFX_RetainPtr oriDevice; + RetainPtr oriDevice; if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { oriDevice = pdfium::MakeRetain(); if (!m_pDevice->CreateCompatibleBitmap(oriDevice, width, height)) @@ -1567,14 +1567,14 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice)) return true; - CFX_RetainPtr bitmap = bitmap_device.GetBitmap(); + RetainPtr bitmap = bitmap_device.GetBitmap(); bitmap->Clear(0); CFX_Matrix new_matrix = *pObj2Device; new_matrix.Translate(-rect.left, -rect.top); new_matrix.Scale(scaleX, scaleY); - CFX_RetainPtr pTextMask; + RetainPtr pTextMask; if (bTextClip) { pTextMask = pdfium::MakeRetain(); if (!pTextMask->Create(width, height, FXDIB_8bppMask)) @@ -1609,7 +1609,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, if (pSMaskDict) { CFX_Matrix smask_matrix = *pPageObj->m_GeneralState.GetSMaskMatrix(); smask_matrix.Concat(*pObj2Device); - CFX_RetainPtr pSMaskSource = + RetainPtr pSMaskSource = LoadSMask(pSMaskDict, &rect, &smask_matrix); if (pSMaskSource) bitmap->MultiplyAlpha(pSMaskSource); @@ -1638,7 +1638,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, return true; } -CFX_RetainPtr CPDF_RenderStatus::GetBackdrop( +RetainPtr CPDF_RenderStatus::GetBackdrop( const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, @@ -1815,7 +1815,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, &text_matrix, fill_argb, &m_Options); } -CFX_RetainPtr CPDF_RenderStatus::GetCachedType3( +RetainPtr CPDF_RenderStatus::GetCachedType3( CPDF_Type3Font* pFont) { CPDF_Document* pDoc = pFont->GetDocument(); if (!pDoc) @@ -1923,7 +1923,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, } } else if (pType3Char->m_pBitmap) { if (device_class == FXDC_DISPLAY) { - CFX_RetainPtr pCache = GetCachedType3(pType3Font); + RetainPtr pCache = GetCachedType3(pType3Font); refTypeCache.m_dwCount++; CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix, sa, sd); if (!pBitmap) @@ -2086,7 +2086,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, buffer.Initialize(m_pContext.Get(), m_pDevice, &clip_rect, m_pCurObj, 150); CFX_Matrix FinalMatrix = *pMatrix; FinalMatrix.Concat(*buffer.GetMatrix()); - CFX_RetainPtr pBitmap = buffer.GetBitmap(); + RetainPtr pBitmap = buffer.GetBitmap(); if (!pBitmap->GetBuffer()) return; @@ -2290,9 +2290,9 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, } float left_offset = cell_bbox.left - mtPattern2Device.e; float top_offset = cell_bbox.bottom - mtPattern2Device.f; - CFX_RetainPtr pPatternBitmap; + RetainPtr pPatternBitmap; if (width * height < 16) { - CFX_RetainPtr pEnlargedBitmap = + RetainPtr pEnlargedBitmap = DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, pObj2Device, 8, 8, m_Options.m_Flags); pPatternBitmap = pEnlargedBitmap->StretchTo(width, height, 0, nullptr); @@ -2409,7 +2409,7 @@ bool CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, } void CPDF_RenderStatus::CompositeDIBitmap( - const CFX_RetainPtr& pDIBitmap, + const RetainPtr& pDIBitmap, int left, int top, FX_ARGB mask_argb, @@ -2466,10 +2466,10 @@ void CPDF_RenderStatus::CompositeDIBitmap( FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitmap->GetHeight()); rect.Intersect(m_pDevice->GetClipBox()); - CFX_RetainPtr pClone; + RetainPtr pClone; if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { pClone = m_pDevice->GetBackDrop()->Clone(&rect); - CFX_RetainPtr pForeBitmap = m_pDevice->GetBitmap(); + RetainPtr pForeBitmap = m_pDevice->GetBitmap(); pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), pForeBitmap, rect.left, rect.top); left = left >= 0 ? 0 : left; @@ -2497,7 +2497,7 @@ void CPDF_RenderStatus::CompositeDIBitmap( int back_left, back_top; FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitmap->GetHeight()); - CFX_RetainPtr pBackdrop = + RetainPtr pBackdrop = GetBackdrop(m_pCurObj, rect, back_left, back_top, blend_mode > FXDIB_BLEND_NORMAL && bIsolated); if (!pBackdrop) @@ -2523,7 +2523,7 @@ void CPDF_RenderStatus::CompositeDIBitmap( m_pDevice->SetDIBits(pBackdrop, back_left, back_top); } -CFX_RetainPtr CPDF_RenderStatus::LoadSMask( +RetainPtr CPDF_RenderStatus::LoadSMask( CPDF_Dictionary* pSMaskDict, FX_RECT* pClipRect, const CFX_Matrix* pMatrix) { diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h index b4872f1d1e..b823834e7d 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.h +++ b/core/fpdfapi/render/cpdf_renderstatus.h @@ -107,7 +107,7 @@ class CPDF_RenderStatus { const CFX_Matrix* pObj2Device, bool bStroke); bool ProcessImage(CPDF_ImageObject* pImageObj, const CFX_Matrix* pObj2Device); - void CompositeDIBitmap(const CFX_RetainPtr& pDIBitmap, + void CompositeDIBitmap(const RetainPtr& pDIBitmap, int left, int top, FX_ARGB mask_argb, @@ -135,19 +135,19 @@ class CPDF_RenderStatus { bool bStroke); bool ProcessForm(const CPDF_FormObject* pFormObj, const CFX_Matrix* pObj2Device); - CFX_RetainPtr GetBackdrop(const CPDF_PageObject* pObj, - const FX_RECT& rect, - int& left, - int& top, - bool bBackAlphaRequired); - CFX_RetainPtr LoadSMask(CPDF_Dictionary* pSMaskDict, - FX_RECT* pClipRect, - const CFX_Matrix* pMatrix); - static CFX_RetainPtr GetCachedType3(CPDF_Type3Font* pFont); + RetainPtr GetBackdrop(const CPDF_PageObject* pObj, + const FX_RECT& rect, + int& left, + int& top, + bool bBackAlphaRequired); + RetainPtr LoadSMask(CPDF_Dictionary* pSMaskDict, + FX_RECT* pClipRect, + const CFX_Matrix* pMatrix); + static RetainPtr GetCachedType3(CPDF_Type3Font* pFont); static std::unique_ptr CloneObjStates( const CPDF_GraphicStates* pPathObj, bool bStroke); - CFX_RetainPtr GetTransferFunc(CPDF_Object* pObject) const; + RetainPtr GetTransferFunc(CPDF_Object* pObject) const; FX_ARGB GetFillArgb(CPDF_PageObject* pObj, bool bType3 = false) const; FX_ARGB GetStrokeArgb(CPDF_PageObject* pObj) const; bool GetObjectClippedRect(const CPDF_PageObject* pObj, diff --git a/core/fpdfapi/render/cpdf_transferfunc.cpp b/core/fpdfapi/render/cpdf_transferfunc.cpp index e9ea0576ae..98528c3c14 100644 --- a/core/fpdfapi/render/cpdf_transferfunc.cpp +++ b/core/fpdfapi/render/cpdf_transferfunc.cpp @@ -20,9 +20,9 @@ FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const { m_Samples[512 + FXSYS_GetBValue(rgb)]); } -CFX_RetainPtr CPDF_TransferFunc::TranslateImage( - const CFX_RetainPtr& pSrc) { - CFX_RetainPtr pHolder(this); +RetainPtr CPDF_TransferFunc::TranslateImage( + const RetainPtr& pSrc) { + RetainPtr pHolder(this); auto pDest = pdfium::MakeRetain(pHolder); pDest->LoadSrc(pSrc); return pDest; diff --git a/core/fpdfapi/render/cpdf_transferfunc.h b/core/fpdfapi/render/cpdf_transferfunc.h index ad7bf28c2f..32811891ea 100644 --- a/core/fpdfapi/render/cpdf_transferfunc.h +++ b/core/fpdfapi/render/cpdf_transferfunc.h @@ -7,21 +7,20 @@ #ifndef CORE_FPDFAPI_RENDER_CPDF_TRANSFERFUNC_H_ #define CORE_FPDFAPI_RENDER_CPDF_TRANSFERFUNC_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" class CPDF_Document; class CFX_DIBSource; -class CPDF_TransferFunc : public CFX_Retainable { +class CPDF_TransferFunc : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); FX_COLORREF TranslateColor(FX_COLORREF src) const; - CFX_RetainPtr TranslateImage( - const CFX_RetainPtr& pSrc); + RetainPtr TranslateImage(const RetainPtr& pSrc); CFX_UnownedPtr const m_pPDFDoc; bool m_bIdentity; diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index b87b5ef74a..42b11605c5 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -53,8 +53,7 @@ bool IsScanLine8bpp(uint8_t* pBuf, int width) { return false; } -int DetectFirstLastScan(const CFX_RetainPtr& pBitmap, - bool bFirst) { +int DetectFirstLastScan(const RetainPtr& pBitmap, bool bFirst) { int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); int width = pBitmap->GetWidth(); @@ -123,12 +122,12 @@ std::unique_ptr CPDF_Type3Cache::RenderGlyph( if (!pChar || !pChar->m_pBitmap) return nullptr; - CFX_RetainPtr pBitmap = pChar->m_pBitmap; + RetainPtr pBitmap = pChar->m_pBitmap; CFX_Matrix image_matrix = pChar->m_ImageMatrix; CFX_Matrix text_matrix(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0); image_matrix.Concat(text_matrix); - CFX_RetainPtr pResBitmap; + RetainPtr pResBitmap; int left = 0; int top = 0; if (fabs(image_matrix.b) < fabs(image_matrix.a) / 100 && diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h index ab748ba989..fe681bbc99 100644 --- a/core/fpdfapi/render/cpdf_type3cache.h +++ b/core/fpdfapi/render/cpdf_type3cache.h @@ -11,17 +11,17 @@ #include #include "core/fpdfapi/font/cpdf_type3font.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Type3Glyphs; -class CPDF_Type3Cache : public CFX_Retainable { +class CPDF_Type3Cache : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); CFX_GlyphBitmap* LoadGlyph(uint32_t charcode, const CFX_Matrix* pMatrix, diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 87e5ba7808..503c533b84 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -141,7 +141,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, continue; if (pOptions) { - CFX_RetainPtr pOCContext = pOptions->m_pOCContext; + RetainPtr pOCContext = pOptions->m_pOCContext; CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict(); if (pOCContext && pAnnotDict && !pOCContext->CheckOCGVisible(pAnnotDict->GetDictFor("OC"))) { diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h index 3c93ef1d59..c4fbb25724 100644 --- a/core/fpdfdoc/cpdf_occontext.h +++ b/core/fpdfdoc/cpdf_occontext.h @@ -9,18 +9,18 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Array; class CPDF_Dictionary; class CPDF_Document; class CPDF_PageObject; -class CPDF_OCContext : public CFX_Retainable { +class CPDF_OCContext : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); enum UsageType { View = 0, Design, Print, Export }; diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h index b54487e7f8..c1e5f5001d 100644 --- a/core/fpdfdoc/cpdf_structelement.h +++ b/core/fpdfdoc/cpdf_structelement.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" class CPDF_Dictionary; @@ -27,17 +27,17 @@ class CPDF_StructKid { enum { Invalid, Element, PageContent, StreamContent, Object } m_Type; - CFX_RetainPtr m_pElement; // For Element. + RetainPtr m_pElement; // For Element. CFX_UnownedPtr m_pDict; // For Element. uint32_t m_PageObjNum; // For PageContent, StreamContent, Object. uint32_t m_RefObjNum; // For StreamContent, Object. uint32_t m_ContentId; // For PageContent, StreamContent. }; -class CPDF_StructElement : public CFX_Retainable { +class CPDF_StructElement : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); const ByteString& GetType() const { return m_Type; } const ByteString& GetTitle() const { return m_Title; } diff --git a/core/fpdfdoc/cpdf_structtree.cpp b/core/fpdfdoc/cpdf_structtree.cpp index 9168a4f01a..0e9b529ca8 100644 --- a/core/fpdfdoc/cpdf_structtree.cpp +++ b/core/fpdfdoc/cpdf_structtree.cpp @@ -85,16 +85,16 @@ void CPDF_StructTree::LoadPageTree(const CPDF_Dictionary* pPageDict) { if (!pParentArray) return; - std::map> element_map; + std::map> element_map; for (size_t i = 0; i < pParentArray->GetCount(); i++) { if (CPDF_Dictionary* pParent = pParentArray->GetDictAt(i)) AddPageNode(pParent, &element_map, 0); } } -CFX_RetainPtr CPDF_StructTree::AddPageNode( +RetainPtr CPDF_StructTree::AddPageNode( CPDF_Dictionary* pDict, - std::map>* map, + std::map>* map, int nLevel) { if (nLevel > nMaxRecursion) return nullptr; @@ -112,7 +112,7 @@ CFX_RetainPtr CPDF_StructTree::AddPageNode( return pElement; } - CFX_RetainPtr pParentElement = + RetainPtr pParentElement = AddPageNode(pParent, map, nLevel + 1); bool bSave = false; for (CPDF_StructKid& kid : *pParentElement->GetKids()) { @@ -128,7 +128,7 @@ CFX_RetainPtr CPDF_StructTree::AddPageNode( bool CPDF_StructTree::AddTopLevelNode( CPDF_Dictionary* pDict, - const CFX_RetainPtr& pElement) { + const RetainPtr& pElement) { CPDF_Object* pObj = m_pTreeRoot->GetDirectObjectFor("K"); if (!pObj) return false; diff --git a/core/fpdfdoc/cpdf_structtree.h b/core/fpdfdoc/cpdf_structtree.h index 037512acfc..9603620fc1 100644 --- a/core/fpdfdoc/cpdf_structtree.h +++ b/core/fpdfdoc/cpdf_structtree.h @@ -11,8 +11,8 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Dictionary; class CPDF_Document; @@ -35,17 +35,17 @@ class CPDF_StructTree { private: void LoadPageTree(const CPDF_Dictionary* pPageDict); - CFX_RetainPtr AddPageNode( + RetainPtr AddPageNode( CPDF_Dictionary* pElement, - std::map>* map, + std::map>* map, int nLevel); bool AddTopLevelNode(CPDF_Dictionary* pDict, - const CFX_RetainPtr& pElement); + const RetainPtr& pElement); CFX_UnownedPtr const m_pTreeRoot; CFX_UnownedPtr const m_pRoleMap; CFX_UnownedPtr m_pPage; - std::vector> m_Kids; + std::vector> m_Kids; }; #endif // CORE_FPDFDOC_CPDF_STRUCTTREE_H_ diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h index 6b36f19a6d..4fa4a81776 100644 --- a/core/fxcodec/codec/ccodec_jbig2module.h +++ b/core/fxcodec/codec/ccodec_jbig2module.h @@ -10,7 +10,7 @@ #include #include "core/fxcodec/fx_codec_def.h" -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CJBig2_Context; class CJBig2_Image; @@ -25,8 +25,8 @@ class CCodec_Jbig2Context { uint32_t m_width; uint32_t m_height; - CFX_RetainPtr m_pGlobalStream; - CFX_RetainPtr m_pSrcStream; + RetainPtr m_pGlobalStream; + RetainPtr m_pSrcStream; uint8_t* m_dest_buf; uint32_t m_dest_pitch; std::unique_ptr m_pContext; @@ -42,8 +42,8 @@ class CCodec_Jbig2Module { std::unique_ptr* pContextHolder, uint32_t width, uint32_t height, - const CFX_RetainPtr& src_stream, - const CFX_RetainPtr& global_stream, + const RetainPtr& src_stream, + const RetainPtr& global_stream, uint8_t* dest_buf, uint32_t dest_pitch, IFX_PauseIndicator* pPause); diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h index a5837177f2..d7e484d56f 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.h +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CCodec_ScanlineDecoder; class CFX_DIBSource; @@ -58,7 +58,7 @@ class CCodec_JpegModule { uint32_t GetAvailInput(Context* pContext, uint8_t** avail_buf_ptr); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ - static bool JpegEncode(const CFX_RetainPtr& pSource, + static bool JpegEncode(const RetainPtr& pSource, uint8_t** dest_buf, FX_STRSIZE* dest_size); #endif diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index 4417e47824..3ce19402d2 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -16,9 +16,9 @@ #include "core/fxcodec/codec/ccodec_pngmodule.h" #include "core/fxcodec/codec/ccodec_tiffmodule.h" #include "core/fxcodec/fx_codec_def.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" class CCodec_ModuleMgr; @@ -44,11 +44,10 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, explicit CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr); virtual ~CCodec_ProgressiveDecoder(); - FXCODEC_STATUS LoadImageInfo( - const CFX_RetainPtr& pFile, - FXCODEC_IMAGE_TYPE imageType, - CFX_DIBAttribute* pAttribute, - bool bSkipImageTypeCheck); + FXCODEC_STATUS LoadImageInfo(const RetainPtr& pFile, + FXCODEC_IMAGE_TYPE imageType, + CFX_DIBAttribute* pAttribute, + bool bSkipImageTypeCheck); FXCODEC_IMAGE_TYPE GetType() const { return m_imagType; } int32_t GetWidth() const { return m_SrcWidth; } @@ -58,7 +57,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, void SetClipBox(FX_RECT* clip); FXCODEC_STATUS GetFrames(int32_t& frames); - FXCODEC_STATUS StartDecode(const CFX_RetainPtr& pDIBitmap, + FXCODEC_STATUS StartDecode(const RetainPtr& pDIBitmap, int start_x, int start_y, int size_x, @@ -158,38 +157,36 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, FXCODEC_STATUS& err_status); bool GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status); - void GifDoubleLineResampleVert( - const CFX_RetainPtr& pDeviceBitmap, - double scale_y, - int des_row); - void PngOneOneMapResampleHorz( - const CFX_RetainPtr& pDeviceBitmap, - int32_t des_line, - uint8_t* src_scan, - FXCodec_Format src_format); + void GifDoubleLineResampleVert(const RetainPtr& pDeviceBitmap, + double scale_y, + int des_row); + void PngOneOneMapResampleHorz(const RetainPtr& pDeviceBitmap, + int32_t des_line, + uint8_t* src_scan, + FXCodec_Format src_format); bool DetectImageType(FXCODEC_IMAGE_TYPE imageType, CFX_DIBAttribute* pAttribute); void GetDownScale(int& down_scale); void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format); - void ReSampleScanline(const CFX_RetainPtr& pDeviceBitmap, + void ReSampleScanline(const RetainPtr& pDeviceBitmap, int32_t des_line, uint8_t* src_scan, FXCodec_Format src_format); - void Resample(const CFX_RetainPtr& pDeviceBitmap, + void Resample(const RetainPtr& pDeviceBitmap, int32_t src_line, uint8_t* src_scan, FXCodec_Format src_format); - void ResampleVert(const CFX_RetainPtr& pDeviceBitmap, + void ResampleVert(const RetainPtr& pDeviceBitmap, double scale_y, int des_row); bool JpegReadMoreData(CCodec_JpegModule* pJpegModule, FXCODEC_STATUS& err_status); - void ResampleVertBT(const CFX_RetainPtr& pDeviceBitmap, + void ResampleVertBT(const RetainPtr& pDeviceBitmap, double scale_y, int des_row); - CFX_RetainPtr m_pFile; - CFX_RetainPtr m_pDeviceBitmap; + RetainPtr m_pFile; + RetainPtr m_pDeviceBitmap; CFX_UnownedPtr m_pCodecMgr; std::unique_ptr m_pJpegContext; std::unique_ptr m_pPngContext; diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp index e0cb719475..07d189200e 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.cpp +++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp @@ -10,9 +10,9 @@ #include "core/fxcodec/codec/codec_int.h" #include "core/fxcodec/fx_codec.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.h" #include "third_party/base/logging.h" @@ -27,39 +27,39 @@ class CTiffContext : public CCodec_TiffModule::Context { CTiffContext(); ~CTiffContext() override; - bool InitDecoder(const CFX_RetainPtr& file_ptr); + bool InitDecoder(const RetainPtr& file_ptr); bool LoadFrameInfo(int32_t frame, int32_t* width, int32_t* height, int32_t* comps, int32_t* bpc, CFX_DIBAttribute* pAttribute); - bool Decode(const CFX_RetainPtr& pDIBitmap); + bool Decode(const RetainPtr& pDIBitmap); - CFX_RetainPtr io_in() const { return m_io_in; } + RetainPtr io_in() const { return m_io_in; } uint32_t offset() const { return m_offset; } void set_offset(uint32_t offset) { m_offset = offset; } private: - bool IsSupport(const CFX_RetainPtr& pDIBitmap) const; - void SetPalette(const CFX_RetainPtr& pDIBitmap, uint16_t bps); - bool Decode1bppRGB(const CFX_RetainPtr& pDIBitmap, + bool IsSupport(const RetainPtr& pDIBitmap) const; + void SetPalette(const RetainPtr& pDIBitmap, uint16_t bps); + bool Decode1bppRGB(const RetainPtr& pDIBitmap, int32_t height, int32_t width, uint16_t bps, uint16_t spp); - bool Decode8bppRGB(const CFX_RetainPtr& pDIBitmap, + bool Decode8bppRGB(const RetainPtr& pDIBitmap, int32_t height, int32_t width, uint16_t bps, uint16_t spp); - bool Decode24bppRGB(const CFX_RetainPtr& pDIBitmap, + bool Decode24bppRGB(const RetainPtr& pDIBitmap, int32_t height, int32_t width, uint16_t bps, uint16_t spp); - CFX_RetainPtr m_io_in; + RetainPtr m_io_in; uint32_t m_offset; TIFF* m_tif_ctx; }; @@ -228,7 +228,7 @@ CTiffContext::~CTiffContext() { } bool CTiffContext::InitDecoder( - const CFX_RetainPtr& file_ptr) { + const RetainPtr& file_ptr) { m_io_in = file_ptr; m_tif_ctx = tiff_open(this, "r"); return !!m_tif_ctx; @@ -291,8 +291,7 @@ bool CTiffContext::LoadFrameInfo(int32_t frame, return true; } -bool CTiffContext::IsSupport( - const CFX_RetainPtr& pDIBitmap) const { +bool CTiffContext::IsSupport(const RetainPtr& pDIBitmap) const { if (TIFFIsTiled(m_tif_ctx)) return false; @@ -322,7 +321,7 @@ bool CTiffContext::IsSupport( return planarconfig != PLANARCONFIG_SEPARATE; } -void CTiffContext::SetPalette(const CFX_RetainPtr& pDIBitmap, +void CTiffContext::SetPalette(const RetainPtr& pDIBitmap, uint16_t bps) { uint16_t* red_orig = nullptr; uint16_t* green_orig = nullptr; @@ -346,7 +345,7 @@ void CTiffContext::SetPalette(const CFX_RetainPtr& pDIBitmap, } } -bool CTiffContext::Decode1bppRGB(const CFX_RetainPtr& pDIBitmap, +bool CTiffContext::Decode1bppRGB(const RetainPtr& pDIBitmap, int32_t height, int32_t width, uint16_t bps, @@ -374,7 +373,7 @@ bool CTiffContext::Decode1bppRGB(const CFX_RetainPtr& pDIBitmap, return true; } -bool CTiffContext::Decode8bppRGB(const CFX_RetainPtr& pDIBitmap, +bool CTiffContext::Decode8bppRGB(const RetainPtr& pDIBitmap, int32_t height, int32_t width, uint16_t bps, @@ -410,7 +409,7 @@ bool CTiffContext::Decode8bppRGB(const CFX_RetainPtr& pDIBitmap, return true; } -bool CTiffContext::Decode24bppRGB(const CFX_RetainPtr& pDIBitmap, +bool CTiffContext::Decode24bppRGB(const RetainPtr& pDIBitmap, int32_t height, int32_t width, uint16_t bps, @@ -438,7 +437,7 @@ bool CTiffContext::Decode24bppRGB(const CFX_RetainPtr& pDIBitmap, return true; } -bool CTiffContext::Decode(const CFX_RetainPtr& pDIBitmap) { +bool CTiffContext::Decode(const RetainPtr& pDIBitmap) { uint32_t img_wid = pDIBitmap->GetWidth(); uint32_t img_hei = pDIBitmap->GetHeight(); uint32_t width = 0; @@ -480,7 +479,7 @@ bool CTiffContext::Decode(const CFX_RetainPtr& pDIBitmap) { } std::unique_ptr CCodec_TiffModule::CreateDecoder( - const CFX_RetainPtr& file_ptr) { + const RetainPtr& file_ptr) { auto pDecoder = pdfium::MakeUnique(); if (!pDecoder->InitDecoder(file_ptr)) return nullptr; @@ -500,7 +499,7 @@ bool CCodec_TiffModule::LoadFrameInfo(Context* pContext, } bool CCodec_TiffModule::Decode(Context* pContext, - const CFX_RetainPtr& pDIBitmap) { + const RetainPtr& pDIBitmap) { auto* ctx = static_cast(pContext); return ctx->Decode(pDIBitmap); } diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h index 6e6e36b697..8d3bed7df2 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.h +++ b/core/fxcodec/codec/ccodec_tiffmodule.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibitmap.h" class CFX_DIBAttribute; @@ -24,7 +24,7 @@ class CCodec_TiffModule { }; std::unique_ptr CreateDecoder( - const CFX_RetainPtr& file_ptr); + const RetainPtr& file_ptr); bool LoadFrameInfo(Context* ctx, int32_t frame, int32_t* width, @@ -32,7 +32,7 @@ class CCodec_TiffModule { int32_t* comps, int32_t* bpc, CFX_DIBAttribute* pAttribute); - bool Decode(Context* ctx, const CFX_RetainPtr& pDIBitmap); + bool Decode(Context* ctx, const RetainPtr& pDIBitmap); }; #endif // CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_ diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp index f6ace30dd3..543aeebc87 100644 --- a/core/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/fxcodec/codec/fx_codec_jbig.cpp @@ -44,8 +44,8 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( std::unique_ptr* pContextHolder, uint32_t width, uint32_t height, - const CFX_RetainPtr& src_stream, - const CFX_RetainPtr& global_stream, + const RetainPtr& src_stream, + const RetainPtr& global_stream, uint8_t* dest_buf, uint32_t dest_pitch, IFX_PauseIndicator* pPause) { diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 1084529c7d..ea32f00a2e 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -508,7 +508,7 @@ uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext, #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #define JPEG_BLOCK_SIZE 1048576 -bool CCodec_JpegModule::JpegEncode(const CFX_RetainPtr& pSource, +bool CCodec_JpegModule::JpegEncode(const RetainPtr& pSource, uint8_t** dest_buf, FX_STRSIZE* dest_size) { struct jpeg_error_mgr jerr; diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index a70041bff9..8b90d3ab84 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -396,7 +396,7 @@ bool CCodec_ProgressiveDecoder::PngReadHeader(int width, } bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t*& src_buf) { - CFX_RetainPtr pDIBitmap = m_pDeviceBitmap; + RetainPtr pDIBitmap = m_pDeviceBitmap; if (!pDIBitmap) { NOTREACHED(); return false; @@ -465,7 +465,7 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t*& src_buf) { } void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( - const CFX_RetainPtr& pDeviceBitmap, + const RetainPtr& pDeviceBitmap, int32_t des_line, uint8_t* src_scan, FXCodec_Format src_format) { @@ -538,7 +538,7 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass, int line) { - CFX_RetainPtr pDIBitmap = m_pDeviceBitmap; + RetainPtr pDIBitmap = m_pDeviceBitmap; ASSERT(pDIBitmap); int src_top = m_clipBox.top; int src_bottom = m_clipBox.bottom; @@ -645,7 +645,7 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( m_GifFrameRect = img_rc; m_SrcPassNumber = interlace ? 4 : 1; int32_t pal_index = m_GifBgIndex; - CFX_RetainPtr pDevice = m_pDeviceBitmap; + RetainPtr pDevice = m_pDeviceBitmap; if (trans_index >= pal_num) trans_index = -1; if (trans_index != -1) { @@ -695,7 +695,7 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num, uint8_t* row_buf) { - CFX_RetainPtr pDIBitmap = m_pDeviceBitmap; + RetainPtr pDIBitmap = m_pDeviceBitmap; ASSERT(pDIBitmap); int32_t img_width = m_GifFrameRect.Width(); if (!pDIBitmap->HasAlpha()) { @@ -757,7 +757,7 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num, } void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert( - const CFX_RetainPtr& pDeviceBitmap, + const RetainPtr& pDeviceBitmap, double scale_y, int des_row) { int des_Bpp = pDeviceBitmap->GetBPP() >> 3; @@ -883,7 +883,7 @@ bool CCodec_ProgressiveDecoder::BmpInputImagePositionBuf(uint32_t rcd_pos) { void CCodec_ProgressiveDecoder::BmpReadScanline( uint32_t row_num, const std::vector& row_buf) { - CFX_RetainPtr pDIBitmap = m_pDeviceBitmap; + RetainPtr pDIBitmap = m_pDeviceBitmap; ASSERT(pDIBitmap); std::copy(row_buf.begin(), row_buf.begin() + m_ScanlineSize, m_pDecodeBuf); int src_top = m_clipBox.top; @@ -914,7 +914,7 @@ void CCodec_ProgressiveDecoder::BmpReadScanline( } void CCodec_ProgressiveDecoder::ResampleVertBT( - const CFX_RetainPtr& pDeviceBitmap, + const RetainPtr& pDeviceBitmap, double scale_y, int des_row) { int des_Bpp = pDeviceBitmap->GetBPP() >> 3; @@ -1254,7 +1254,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, } FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( - const CFX_RetainPtr& pFile, + const RetainPtr& pFile, FXCODEC_IMAGE_TYPE imageType, CFX_DIBAttribute* pAttribute, bool bSkipImageTypeCheck) { @@ -1446,7 +1446,7 @@ void CCodec_ProgressiveDecoder::GetTransMethod(FXDIB_Format des_format, } void CCodec_ProgressiveDecoder::ReSampleScanline( - const CFX_RetainPtr& pDeviceBitmap, + const RetainPtr& pDeviceBitmap, int des_line, uint8_t* src_scan, FXCodec_Format src_format) { @@ -1653,7 +1653,7 @@ void CCodec_ProgressiveDecoder::ReSampleScanline( } void CCodec_ProgressiveDecoder::ResampleVert( - const CFX_RetainPtr& pDeviceBitmap, + const RetainPtr& pDeviceBitmap, double scale_y, int des_row) { int des_Bpp = pDeviceBitmap->GetBPP() >> 3; @@ -1769,7 +1769,7 @@ void CCodec_ProgressiveDecoder::ResampleVert( } void CCodec_ProgressiveDecoder::Resample( - const CFX_RetainPtr& pDeviceBitmap, + const RetainPtr& pDeviceBitmap, int32_t src_line, uint8_t* src_scan, FXCodec_Format src_format) { @@ -1837,7 +1837,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames) { } FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( - const CFX_RetainPtr& pDIBitmap, + const RetainPtr& pDIBitmap, int start_x, int start_y, int size_x, @@ -2206,7 +2206,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() { m_status = FXCODEC_STATUS_ERROR; return m_status; } - CFX_RetainPtr pClipBitmap = + RetainPtr pClipBitmap = (m_clipBox.left == 0 && m_clipBox.top == 0 && m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) ? pDIBitmap @@ -2217,7 +2217,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; } - CFX_RetainPtr pFormatBitmap; + RetainPtr pFormatBitmap; switch (m_pDeviceBitmap->GetFormat()) { case FXDIB_8bppRgb: pFormatBitmap = pdfium::MakeRetain(); @@ -2289,7 +2289,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; } - CFX_RetainPtr pStrechBitmap = pFormatBitmap->StretchTo( + RetainPtr pStrechBitmap = pFormatBitmap->StretchTo( m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE, nullptr); pFormatBitmap = nullptr; diff --git a/core/fxcodec/jbig2/JBig2_BitStream.cpp b/core/fxcodec/jbig2/JBig2_BitStream.cpp index 921fa2a661..a72099d4ff 100644 --- a/core/fxcodec/jbig2/JBig2_BitStream.cpp +++ b/core/fxcodec/jbig2/JBig2_BitStream.cpp @@ -11,8 +11,7 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" -CJBig2_BitStream::CJBig2_BitStream( - const CFX_RetainPtr& pSrcStream) +CJBig2_BitStream::CJBig2_BitStream(const RetainPtr& pSrcStream) : m_pBuf(pSrcStream->GetData()), m_dwLength(pSrcStream->GetSize()), m_dwByteIdx(0), diff --git a/core/fxcodec/jbig2/JBig2_BitStream.h b/core/fxcodec/jbig2/JBig2_BitStream.h index 0be6c4b977..0edb432dde 100644 --- a/core/fxcodec/jbig2/JBig2_BitStream.h +++ b/core/fxcodec/jbig2/JBig2_BitStream.h @@ -7,13 +7,13 @@ #ifndef CORE_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ #define CORE_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_StreamAcc; class CJBig2_BitStream { public: - explicit CJBig2_BitStream(const CFX_RetainPtr& pSrcStream); + explicit CJBig2_BitStream(const RetainPtr& pSrcStream); ~CJBig2_BitStream(); // TODO(thestig): readFoo() should return bool. diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index 363be2fc31..7c79ad8802 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -48,11 +48,10 @@ size_t GetRefAggContextSize(bool val) { // difference for typical JBIG2 documents. static const int kSymbolDictCacheMaxSize = 2; -CJBig2_Context::CJBig2_Context( - const CFX_RetainPtr& pGlobalStream, - const CFX_RetainPtr& pSrcStream, - std::list* pSymbolDictCache, - bool bIsGlobal) +CJBig2_Context::CJBig2_Context(const RetainPtr& pGlobalStream, + const RetainPtr& pSrcStream, + std::list* pSymbolDictCache, + bool bIsGlobal) : m_nSegmentDecoded(0), m_bInPage(false), m_bBufSpecified(false), diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h index c88fc6f187..bed1079db9 100644 --- a/core/fxcodec/jbig2/JBig2_Context.h +++ b/core/fxcodec/jbig2/JBig2_Context.h @@ -40,8 +40,8 @@ using CJBig2_CachePair = class CJBig2_Context { public: - CJBig2_Context(const CFX_RetainPtr& pGlobalStream, - const CFX_RetainPtr& pSrcStream, + CJBig2_Context(const RetainPtr& pGlobalStream, + const RetainPtr& pSrcStream, std::list* pSymbolDictCache, bool bIsGlobal); ~CJBig2_Context(); diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index dd4dbd99e2..2d343ffd11 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -298,7 +298,7 @@ void ByteString::ReallocBeforeWrite(FX_STRSIZE nNewLength) { return; } - CFX_RetainPtr pNewData(StringData::Create(nNewLength)); + RetainPtr pNewData(StringData::Create(nNewLength)); if (m_pData) { FX_STRSIZE nCopyLength = std::min(m_pData->m_nDataLength, nNewLength); pNewData->CopyContents(m_pData->m_String, nCopyLength); @@ -365,7 +365,7 @@ char* ByteString::GetBuffer(FX_STRSIZE nMinBufLength) { if (nMinBufLength == 0) return nullptr; - CFX_RetainPtr pNewData(StringData::Create(nMinBufLength)); + RetainPtr pNewData(StringData::Create(nMinBufLength)); pNewData->CopyContents(*m_pData); pNewData->m_nDataLength = m_pData->m_nDataLength; m_pData.Swap(pNewData); @@ -408,7 +408,7 @@ void ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) { return; } - CFX_RetainPtr pNewData( + RetainPtr pNewData( StringData::Create(m_pData->m_nDataLength + nSrcLen)); pNewData->CopyContents(*m_pData); pNewData->CopyContentsAt(m_pData->m_nDataLength, pSrcData, nSrcLen); @@ -454,7 +454,7 @@ void ByteString::AllocCopy(ByteString& dest, if (nCopyLen == 0) return; - CFX_RetainPtr pNewData( + RetainPtr pNewData( StringData::Create(m_pData->m_String + nCopyIndex, nCopyLen)); dest.m_pData.Swap(pNewData); } @@ -637,7 +637,7 @@ FX_STRSIZE ByteString::Replace(const ByteStringView& pOld, return nCount; } - CFX_RetainPtr pNewData(StringData::Create(nNewLength)); + RetainPtr pNewData(StringData::Create(nNewLength)); pStart = m_pData->m_String; char* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < nCount; i++) { diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index 0220e707cd..7342fdbea7 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -12,9 +12,9 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_string_data_template.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/string_view_template.h" #include "third_party/base/optional.h" @@ -195,7 +195,7 @@ class ByteString { void AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen); void Concat(const char* lpszSrcData, FX_STRSIZE nSrcLen); - CFX_RetainPtr m_pData; + RetainPtr m_pData; friend ByteString_Concat_Test; friend fxcrt_ByteStringPool_Test; diff --git a/core/fxcrt/cfx_char.h b/core/fxcrt/cfx_char.h index 74f0a4f9cd..fb625ee038 100644 --- a/core/fxcrt/cfx_char.h +++ b/core/fxcrt/cfx_char.h @@ -40,7 +40,7 @@ class CFX_Char { int16_t m_iBidiOrder; int32_t m_iFontSize; uint32_t m_dwIdentity; - CFX_RetainPtr m_pUserData; + RetainPtr m_pUserData; private: uint16_t m_wCharCode; diff --git a/core/fxcrt/cfx_checksumcontext.cpp b/core/fxcrt/cfx_checksumcontext.cpp index c75e440231..3d3409dceb 100644 --- a/core/fxcrt/cfx_checksumcontext.cpp +++ b/core/fxcrt/cfx_checksumcontext.cpp @@ -105,7 +105,7 @@ void CFX_ChecksumContext::StartChecksum() { } bool CFX_ChecksumContext::UpdateChecksum( - const CFX_RetainPtr& pSrcFile, + const RetainPtr& pSrcFile, FX_FILESIZE offset, size_t size) { if (!m_pSAXReader || !pSrcFile) diff --git a/core/fxcrt/cfx_checksumcontext.h b/core/fxcrt/cfx_checksumcontext.h index 4231e09a83..6d7963ad93 100644 --- a/core/fxcrt/cfx_checksumcontext.h +++ b/core/fxcrt/cfx_checksumcontext.h @@ -19,7 +19,7 @@ class CFX_ChecksumContext { void StartChecksum(); void Update(const ByteStringView& bsText); - bool UpdateChecksum(const CFX_RetainPtr& pSrcFile, + bool UpdateChecksum(const RetainPtr& pSrcFile, FX_FILESIZE offset = 0, size_t size = 0); void FinishChecksum(); diff --git a/core/fxcrt/cfx_crtfileaccess.cpp b/core/fxcrt/cfx_crtfileaccess.cpp index 2479c95654..b6a6a74d1c 100644 --- a/core/fxcrt/cfx_crtfileaccess.cpp +++ b/core/fxcrt/cfx_crtfileaccess.cpp @@ -11,7 +11,7 @@ CFX_CRTFileAccess::CFX_CRTFileAccess(const WideStringView& wsPath) CFX_CRTFileAccess::~CFX_CRTFileAccess() {} -CFX_RetainPtr CFX_CRTFileAccess::CreateFileStream( +RetainPtr CFX_CRTFileAccess::CreateFileStream( uint32_t dwModes) { return IFX_SeekableStream::CreateFromFilename(m_path.c_str(), dwModes); } diff --git a/core/fxcrt/cfx_crtfileaccess.h b/core/fxcrt/cfx_crtfileaccess.h index 3c63aa30c3..962a6d122f 100644 --- a/core/fxcrt/cfx_crtfileaccess.h +++ b/core/fxcrt/cfx_crtfileaccess.h @@ -7,16 +7,16 @@ #ifndef CORE_FXCRT_CFX_CRTFILEACCESS_H_ #define CORE_FXCRT_CFX_CRTFILEACCESS_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" -class CFX_CRTFileAccess : public CFX_Retainable { +class CFX_CRTFileAccess : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); - CFX_RetainPtr CreateFileStream(uint32_t dwModes); + RetainPtr CreateFileStream(uint32_t dwModes); private: explicit CFX_CRTFileAccess(const WideStringView& wsPath); diff --git a/core/fxcrt/cfx_memorystream.h b/core/fxcrt/cfx_memorystream.h index 2112280237..ef66080420 100644 --- a/core/fxcrt/cfx_memorystream.h +++ b/core/fxcrt/cfx_memorystream.h @@ -9,15 +9,15 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" class CFX_MemoryStream : public IFX_SeekableStream { public: enum Type { kConsecutive = 1 << 0, kTakeOver = 1 << 1 }; template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableStream FX_FILESIZE GetSize() override; diff --git a/core/fxcrt/cfx_retain_ptr.h b/core/fxcrt/cfx_retain_ptr.h deleted file mode 100644 index d3896ba6ae..0000000000 --- a/core/fxcrt/cfx_retain_ptr.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CORE_FXCRT_CFX_RETAIN_PTR_H_ -#define CORE_FXCRT_CFX_RETAIN_PTR_H_ - -#include -#include -#include - -#include "core/fxcrt/fx_system.h" - -// Used with std::unique_ptr to Release() objects that can't be deleted. -template -struct ReleaseDeleter { - inline void operator()(T* ptr) const { ptr->Release(); } -}; - -// Analogous to base's scoped_refptr. -template -class CFX_RetainPtr { - public: - explicit CFX_RetainPtr(T* pObj) : m_pObj(pObj) { - if (m_pObj) - m_pObj->Retain(); - } - - CFX_RetainPtr() {} - CFX_RetainPtr(const CFX_RetainPtr& that) : CFX_RetainPtr(that.Get()) {} - CFX_RetainPtr(CFX_RetainPtr&& that) noexcept { Swap(that); } - - // Deliberately implicit to allow returning nullptrs. - // NOLINTNEXTLINE(runtime/explicit) - CFX_RetainPtr(std::nullptr_t ptr) {} - - template - CFX_RetainPtr(const CFX_RetainPtr& that) : CFX_RetainPtr(that.Get()) {} - - template - CFX_RetainPtr As() const { - return CFX_RetainPtr(static_cast(Get())); - } - - void Reset(T* obj = nullptr) { - if (obj) - obj->Retain(); - m_pObj.reset(obj); - } - - T* Get() const { return m_pObj.get(); } - void Swap(CFX_RetainPtr& that) { m_pObj.swap(that.m_pObj); } - - // Useful for passing notion of object ownership across a C API. - T* Leak() { return m_pObj.release(); } - void Unleak(T* ptr) { m_pObj.reset(ptr); } - - CFX_RetainPtr& operator=(const CFX_RetainPtr& that) { - if (*this != that) - Reset(that.Get()); - return *this; - } - - CFX_RetainPtr& operator=(CFX_RetainPtr&& that) { - m_pObj.reset(that.Leak()); - return *this; - } - - bool operator==(const CFX_RetainPtr& that) const { - return Get() == that.Get(); - } - bool operator!=(const CFX_RetainPtr& that) const { return !(*this == that); } - - bool operator<(const CFX_RetainPtr& that) const { - return std::less()(Get(), that.Get()); - } - - explicit operator bool() const { return !!m_pObj; } - T& operator*() const { return *m_pObj.get(); } - T* operator->() const { return m_pObj.get(); } - - private: - std::unique_ptr> m_pObj; -}; - -// Trivial implementation - internal ref count with virtual destructor. -class CFX_Retainable { - public: - bool HasOneRef() const { return m_nRefCount == 1; } - - protected: - virtual ~CFX_Retainable() {} - - private: - template - friend struct ReleaseDeleter; - - template - friend class CFX_RetainPtr; - - void Retain() { ++m_nRefCount; } - void Release() { - ASSERT(m_nRefCount > 0); - if (--m_nRefCount == 0) - delete this; - } - - intptr_t m_nRefCount = 0; -}; - -namespace pdfium { - -// Helper to make a CFX_RetainPtr along the lines of std::make_unique<>(), -// or pdfium::MakeUnique<>(). Arguments are forwarded to T's constructor. -// Classes managed by CFX_RetainPtr should have protected (or private) -// constructors, and should friend this function. -template -CFX_RetainPtr MakeRetain(Args&&... args) { - return CFX_RetainPtr(new T(std::forward(args)...)); -} - -} // namespace pdfium - -#endif // CORE_FXCRT_CFX_RETAIN_PTR_H_ diff --git a/core/fxcrt/cfx_retain_ptr_unittest.cpp b/core/fxcrt/cfx_retain_ptr_unittest.cpp deleted file mode 100644 index eae542fe88..0000000000 --- a/core/fxcrt/cfx_retain_ptr_unittest.cpp +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "core/fxcrt/cfx_retain_ptr.h" - -#include -#include - -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class PseudoRetainable { - public: - PseudoRetainable() : retain_count_(0), release_count_(0) {} - void Retain() { ++retain_count_; } - void Release() { ++release_count_; } - int retain_count() const { return retain_count_; } - int release_count() const { return release_count_; } - - private: - int retain_count_; - int release_count_; -}; - -} // namespace - -TEST(fxcrt, RetainPtrNull) { - CFX_RetainPtr ptr; - EXPECT_EQ(nullptr, ptr.Get()); -} - -TEST(fxcrt, RetainPtrNormal) { - PseudoRetainable obj; - { - CFX_RetainPtr ptr(&obj); - EXPECT_EQ(&obj, ptr.Get()); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); -} - -TEST(fxcrt, RetainPtrCopyCtor) { - PseudoRetainable obj; - { - CFX_RetainPtr ptr1(&obj); - { - CFX_RetainPtr ptr2(ptr1); - EXPECT_EQ(2, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(2, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); - } - EXPECT_EQ(2, obj.retain_count()); - EXPECT_EQ(2, obj.release_count()); -} - -TEST(fxcrt, RetainPtrMoveCtor) { - PseudoRetainable obj; - { - CFX_RetainPtr ptr1(&obj); - { - CFX_RetainPtr ptr2(std::move(ptr1)); - EXPECT_EQ(nullptr, ptr1.Get()); - EXPECT_EQ(&obj, ptr2.Get()); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); -} - -TEST(fxcrt, RetainPtrResetNull) { - PseudoRetainable obj; - { - CFX_RetainPtr ptr(&obj); - ptr.Reset(); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); -} - -TEST(fxcrt, RetainPtrReset) { - PseudoRetainable obj1; - PseudoRetainable obj2; - { - CFX_RetainPtr ptr(&obj1); - ptr.Reset(&obj2); - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(1, obj1.release_count()); - EXPECT_EQ(1, obj2.retain_count()); - EXPECT_EQ(0, obj2.release_count()); - } - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(1, obj1.release_count()); - EXPECT_EQ(1, obj2.retain_count()); - EXPECT_EQ(1, obj2.release_count()); -} - -TEST(fxcrt, RetainPtrSwap) { - PseudoRetainable obj1; - PseudoRetainable obj2; - { - CFX_RetainPtr ptr1(&obj1); - { - CFX_RetainPtr ptr2(&obj2); - ptr1.Swap(ptr2); - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(0, obj1.release_count()); - EXPECT_EQ(1, obj2.retain_count()); - EXPECT_EQ(0, obj2.release_count()); - } - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(1, obj1.release_count()); - EXPECT_EQ(1, obj2.retain_count()); - EXPECT_EQ(0, obj2.release_count()); - } - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(1, obj1.release_count()); - EXPECT_EQ(1, obj2.retain_count()); - EXPECT_EQ(1, obj2.release_count()); -} - -TEST(fxcrt, RetainPtrLeak) { - PseudoRetainable obj; - PseudoRetainable* leak; - { - CFX_RetainPtr ptr(&obj); - leak = ptr.Leak(); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - { - CFX_RetainPtr ptr; - ptr.Unleak(leak); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); -} - -TEST(fxcrt, RetainPtrSwapNull) { - PseudoRetainable obj1; - { - CFX_RetainPtr ptr1(&obj1); - { - CFX_RetainPtr ptr2; - ptr1.Swap(ptr2); - EXPECT_FALSE(ptr1); - EXPECT_TRUE(ptr2); - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(0, obj1.release_count()); - } - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(1, obj1.release_count()); - } - EXPECT_EQ(1, obj1.retain_count()); - EXPECT_EQ(1, obj1.release_count()); -} - -TEST(fxcrt, RetainPtrAssign) { - PseudoRetainable obj; - { - CFX_RetainPtr ptr(&obj); - { - CFX_RetainPtr ptr2; - ptr2 = ptr; - EXPECT_EQ(2, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(2, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); - } - EXPECT_EQ(2, obj.retain_count()); - EXPECT_EQ(2, obj.release_count()); -} - -TEST(fxcrt, RetainPtrMoveAssign) { - PseudoRetainable obj; - { - CFX_RetainPtr ptr1(&obj); - { - CFX_RetainPtr ptr2; - EXPECT_EQ(&obj, ptr1.Get()); - EXPECT_EQ(nullptr, ptr2.Get()); - ptr2 = std::move(ptr1); - EXPECT_EQ(nullptr, ptr1.Get()); - EXPECT_EQ(&obj, ptr2.Get()); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); -} - -TEST(fxcrt, RetainPtrEquals) { - PseudoRetainable obj1; - PseudoRetainable obj2; - CFX_RetainPtr null_ptr1; - CFX_RetainPtr obj1_ptr1(&obj1); - CFX_RetainPtr obj2_ptr1(&obj2); - { - CFX_RetainPtr null_ptr2; - EXPECT_TRUE(null_ptr1 == null_ptr2); - - CFX_RetainPtr obj1_ptr2(&obj1); - EXPECT_TRUE(obj1_ptr1 == obj1_ptr2); - - CFX_RetainPtr obj2_ptr2(&obj2); - EXPECT_TRUE(obj2_ptr1 == obj2_ptr2); - } - EXPECT_FALSE(null_ptr1 == obj1_ptr1); - EXPECT_FALSE(null_ptr1 == obj2_ptr1); - EXPECT_FALSE(obj1_ptr1 == obj2_ptr1); -} - -TEST(fxcrt, RetainPtrNotEquals) { - PseudoRetainable obj1; - PseudoRetainable obj2; - CFX_RetainPtr null_ptr1; - CFX_RetainPtr obj1_ptr1(&obj1); - CFX_RetainPtr obj2_ptr1(&obj2); - { - CFX_RetainPtr null_ptr2; - CFX_RetainPtr obj1_ptr2(&obj1); - CFX_RetainPtr obj2_ptr2(&obj2); - EXPECT_FALSE(null_ptr1 != null_ptr2); - EXPECT_FALSE(obj1_ptr1 != obj1_ptr2); - EXPECT_FALSE(obj2_ptr1 != obj2_ptr2); - } - EXPECT_TRUE(null_ptr1 != obj1_ptr1); - EXPECT_TRUE(null_ptr1 != obj2_ptr1); - EXPECT_TRUE(obj1_ptr1 != obj2_ptr1); -} - -TEST(fxcrt, RetainPtrLessThan) { - PseudoRetainable objs[2]; - CFX_RetainPtr obj1_ptr(&objs[0]); - CFX_RetainPtr obj2_ptr(&objs[1]); - EXPECT_TRUE(obj1_ptr < obj2_ptr); - EXPECT_FALSE(obj2_ptr < obj1_ptr); -} - -TEST(fxcrt, RetainPtrBool) { - PseudoRetainable obj1; - CFX_RetainPtr null_ptr; - CFX_RetainPtr obj1_ptr(&obj1); - bool null_bool = !!null_ptr; - bool obj1_bool = !!obj1_ptr; - EXPECT_FALSE(null_bool); - EXPECT_TRUE(obj1_bool); -} - -TEST(fxcrt, RetainPtrMakeRetained) { - auto ptr = pdfium::MakeRetain(); - EXPECT_TRUE(ptr->HasOneRef()); - { - CFX_RetainPtr other = ptr; - EXPECT_FALSE(ptr->HasOneRef()); - } - EXPECT_TRUE(ptr->HasOneRef()); -} - -TEST(fxcrt, RetainPtrVectorMove) { - // Proves move ctor is selected by std::vector over copy/delete, this - // may require the ctor to be marked "noexcept". - PseudoRetainable obj; - { - CFX_RetainPtr ptr(&obj); - std::vector> vec1; - vec1.push_back(std::move(ptr)); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - - std::vector> vec2 = std::move(vec1); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - - vec2.resize(4096); - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(0, obj.release_count()); - } - EXPECT_EQ(1, obj.retain_count()); - EXPECT_EQ(1, obj.release_count()); -} diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp index 6a6c6e6c3e..611c3eb03c 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.cpp +++ b/core/fxcrt/cfx_seekablestreamproxy.cpp @@ -134,7 +134,7 @@ void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) { #define BOM_UTF16_LE 0x0000FEFF CFX_SeekableStreamProxy::CFX_SeekableStreamProxy( - const CFX_RetainPtr& stream, + const RetainPtr& stream, bool isWriteStream) : m_IsWriteStream(isWriteStream), m_wCodePage(FX_CODEPAGE_DefANSI), diff --git a/core/fxcrt/cfx_seekablestreamproxy.h b/core/fxcrt/cfx_seekablestreamproxy.h index fc041b49b5..cadc96816d 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.h +++ b/core/fxcrt/cfx_seekablestreamproxy.h @@ -9,11 +9,11 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" -class CFX_SeekableStreamProxy : public CFX_Retainable { +class CFX_SeekableStreamProxy : public Retainable { public: enum class From { Begin = 0, @@ -21,7 +21,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable { }; template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); FX_FILESIZE GetLength() const { return m_pStream->GetSize(); } FX_FILESIZE GetPosition() { return m_iPosition; } @@ -37,7 +37,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable { void SetCodePage(uint16_t wCodePage); private: - CFX_SeekableStreamProxy(const CFX_RetainPtr& stream, + CFX_SeekableStreamProxy(const RetainPtr& stream, bool isWriteSteam); CFX_SeekableStreamProxy(uint8_t* data, FX_STRSIZE size); ~CFX_SeekableStreamProxy() override; @@ -48,7 +48,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable { uint16_t m_wCodePage; FX_STRSIZE m_wBOMLength; FX_FILESIZE m_iPosition; - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; }; #endif // CORE_FXCRT_CFX_SEEKABLESTREAMPROXY_H_ diff --git a/core/fxcrt/cfx_shared_copy_on_write.h b/core/fxcrt/cfx_shared_copy_on_write.h index c87d96509d..f897368813 100644 --- a/core/fxcrt/cfx_shared_copy_on_write.h +++ b/core/fxcrt/cfx_shared_copy_on_write.h @@ -7,8 +7,8 @@ #ifndef CORE_FXCRT_CFX_SHARED_COPY_ON_WRITE_H_ #define CORE_FXCRT_CFX_SHARED_COPY_ON_WRITE_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" // A shared object with Copy on Write semantics that makes it appear as // if each one were independent. @@ -79,7 +79,7 @@ class CFX_SharedCopyOnWrite { intptr_t m_RefCount; }; - CFX_RetainPtr m_pObject; + RetainPtr m_pObject; }; #endif // CORE_FXCRT_CFX_SHARED_COPY_ON_WRITE_H_ diff --git a/core/fxcrt/cfx_weak_ptr.h b/core/fxcrt/cfx_weak_ptr.h index 4aca1c3218..da96000a1b 100644 --- a/core/fxcrt/cfx_weak_ptr.h +++ b/core/fxcrt/cfx_weak_ptr.h @@ -11,8 +11,8 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" template > class CFX_WeakPtr { @@ -80,7 +80,7 @@ class CFX_WeakPtr { std::unique_ptr m_pObj; }; - CFX_RetainPtr m_pHandle; + RetainPtr m_pHandle; }; #endif // CORE_FXCRT_CFX_WEAK_PTR_H_ diff --git a/core/fxcrt/css/cfx_csscomputedstyle.h b/core/fxcrt/css/cfx_csscomputedstyle.h index b05339ac02..4b44a6d87c 100644 --- a/core/fxcrt/css/cfx_csscomputedstyle.h +++ b/core/fxcrt/css/cfx_csscomputedstyle.h @@ -15,7 +15,7 @@ class CFX_CSSValueList; -class CFX_CSSComputedStyle : public CFX_Retainable { +class CFX_CSSComputedStyle : public Retainable { public: class InheritedData { public: @@ -25,7 +25,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable { CFX_CSSLength m_LetterSpacing; CFX_CSSLength m_WordSpacing; CFX_CSSLength m_TextIndent; - CFX_RetainPtr m_pFontFamily; + RetainPtr m_pFontFamily; float m_fFontSize; float m_fLineHeight; FX_ARGB m_dwFontColor; @@ -98,7 +98,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable { private: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); CFX_CSSComputedStyle(); ~CFX_CSSComputedStyle() override; diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp index f2c7d3930b..c44c878196 100644 --- a/core/fxcrt/css/cfx_cssdeclaration.cpp +++ b/core/fxcrt/css/cfx_cssdeclaration.cpp @@ -285,7 +285,7 @@ CFX_CSSDeclaration::CFX_CSSDeclaration() {} CFX_CSSDeclaration::~CFX_CSSDeclaration() {} -CFX_RetainPtr CFX_CSSDeclaration::GetProperty( +RetainPtr CFX_CSSDeclaration::GetProperty( CFX_CSSProperty eProperty, bool* bImportant) const { for (const auto& p : properties_) { @@ -298,7 +298,7 @@ CFX_RetainPtr CFX_CSSDeclaration::GetProperty( } void CFX_CSSDeclaration::AddPropertyHolder(CFX_CSSProperty eProperty, - CFX_RetainPtr pValue, + RetainPtr pValue, bool bImportant) { auto pHolder = pdfium::MakeUnique(); pHolder->bImportant = bImportant; @@ -335,7 +335,7 @@ void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable, if (dwMatch == 0) { continue; } - CFX_RetainPtr pCSSValue; + RetainPtr pCSSValue; switch (dwMatch) { case CFX_CSSVALUETYPE_MaybeNumber: pCSSValue = ParseNumber(pszValue, iValueLen); @@ -363,7 +363,7 @@ void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable, break; } case CFX_CSSVALUETYPE_Shorthand: { - CFX_RetainPtr pWidth; + RetainPtr pWidth; switch (pTable->eName) { case CFX_CSSProperty::Font: ParseFontProperty(pszValue, iValueLen, bImportant); @@ -428,9 +428,8 @@ void CFX_CSSDeclaration::AddProperty(const WideString& prop, pdfium::MakeUnique(prop, value)); } -CFX_RetainPtr CFX_CSSDeclaration::ParseNumber( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr CFX_CSSDeclaration::ParseNumber(const wchar_t* pszValue, + int32_t iValueLen) { float fValue; CFX_CSSNumberType eUnit; if (!ParseCSSNumber(pszValue, iValueLen, fValue, eUnit)) @@ -438,26 +437,23 @@ CFX_RetainPtr CFX_CSSDeclaration::ParseNumber( return pdfium::MakeRetain(eUnit, fValue); } -CFX_RetainPtr CFX_CSSDeclaration::ParseEnum( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr CFX_CSSDeclaration::ParseEnum(const wchar_t* pszValue, + int32_t iValueLen) { const CFX_CSSPropertyValueTable* pValue = GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen)); return pValue ? pdfium::MakeRetain(pValue->eName) : nullptr; } -CFX_RetainPtr CFX_CSSDeclaration::ParseColor( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr CFX_CSSDeclaration::ParseColor(const wchar_t* pszValue, + int32_t iValueLen) { FX_ARGB dwColor; if (!ParseCSSColor(pszValue, iValueLen, &dwColor)) return nullptr; return pdfium::MakeRetain(dwColor); } -CFX_RetainPtr CFX_CSSDeclaration::ParseString( - const wchar_t* pszValue, - int32_t iValueLen) { +RetainPtr CFX_CSSDeclaration::ParseString(const wchar_t* pszValue, + int32_t iValueLen) { int32_t iOffset; if (!ParseCSSString(pszValue, iValueLen, &iOffset, &iValueLen)) return nullptr; @@ -480,7 +476,7 @@ void CFX_CSSDeclaration::ParseValueListProperty( const uint32_t dwType = pTable->dwType; CFX_CSSPrimitiveType eType; - std::vector> list; + std::vector> list; while (parser.NextValue(eType, pszValue, iValueLen)) { switch (eType) { case CFX_CSSPrimitiveType::Number: @@ -556,7 +552,7 @@ void CFX_CSSDeclaration::ParseValueListProperty( } void CFX_CSSDeclaration::Add4ValuesProperty( - const std::vector>& list, + const std::vector>& list, bool bImportant, CFX_CSSProperty eLeft, CFX_CSSProperty eTop, @@ -595,7 +591,7 @@ void CFX_CSSDeclaration::Add4ValuesProperty( bool CFX_CSSDeclaration::ParseBorderProperty( const wchar_t* pszValue, int32_t iValueLen, - CFX_RetainPtr& pWidth) const { + RetainPtr& pWidth) const { pWidth.Reset(nullptr); CFX_CSSValueListParser parser(pszValue, iValueLen, ' '); @@ -650,12 +646,12 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue, int32_t iValueLen, bool bImportant) { CFX_CSSValueListParser parser(pszValue, iValueLen, '/'); - CFX_RetainPtr pStyle; - CFX_RetainPtr pVariant; - CFX_RetainPtr pWeight; - CFX_RetainPtr pFontSize; - CFX_RetainPtr pLineHeight; - std::vector> familyList; + RetainPtr pStyle; + RetainPtr pVariant; + RetainPtr pWeight; + RetainPtr pFontSize; + RetainPtr pLineHeight; + std::vector> familyList; CFX_CSSPrimitiveType eType; while (parser.NextValue(eType, pszValue, iValueLen)) { switch (eType) { diff --git a/core/fxcrt/css/cfx_cssdeclaration.h b/core/fxcrt/css/cfx_cssdeclaration.h index dba1d44fc7..7dd0bba90e 100644 --- a/core/fxcrt/css/cfx_cssdeclaration.h +++ b/core/fxcrt/css/cfx_cssdeclaration.h @@ -34,8 +34,8 @@ class CFX_CSSDeclaration { CFX_CSSDeclaration(); ~CFX_CSSDeclaration(); - CFX_RetainPtr GetProperty(CFX_CSSProperty eProperty, - bool* bImportant) const; + RetainPtr GetProperty(CFX_CSSProperty eProperty, + bool* bImportant) const; const_prop_iterator begin() const { return properties_.begin(); } const_prop_iterator end() const { return properties_.end(); } @@ -63,27 +63,26 @@ class CFX_CSSDeclaration { bool bImportant); bool ParseBorderProperty(const wchar_t* pszValue, int32_t iValueLen, - CFX_RetainPtr& pWidth) const; + RetainPtr& pWidth) const; void ParseValueListProperty(const CFX_CSSPropertyTable* pTable, const wchar_t* pszValue, int32_t iValueLen, bool bImportant); - void Add4ValuesProperty(const std::vector>& list, + void Add4ValuesProperty(const std::vector>& list, bool bImportant, CFX_CSSProperty eLeft, CFX_CSSProperty eTop, CFX_CSSProperty eRight, CFX_CSSProperty eBottom); - CFX_RetainPtr ParseNumber(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr ParseEnum(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr ParseColor(const wchar_t* pszValue, - int32_t iValueLen); - CFX_RetainPtr ParseString(const wchar_t* pszValue, - int32_t iValueLen); + RetainPtr ParseNumber(const wchar_t* pszValue, + int32_t iValueLen); + RetainPtr ParseEnum(const wchar_t* pszValue, int32_t iValueLen); + RetainPtr ParseColor(const wchar_t* pszValue, + int32_t iValueLen); + RetainPtr ParseString(const wchar_t* pszValue, + int32_t iValueLen); void AddPropertyHolder(CFX_CSSProperty eProperty, - CFX_RetainPtr pValue, + RetainPtr pValue, bool bImportant); std::vector> properties_; diff --git a/core/fxcrt/css/cfx_csspropertyholder.h b/core/fxcrt/css/cfx_csspropertyholder.h index ab0e0ae1fb..a271bdafc7 100644 --- a/core/fxcrt/css/cfx_csspropertyholder.h +++ b/core/fxcrt/css/cfx_csspropertyholder.h @@ -7,9 +7,9 @@ #ifndef CORE_FXCRT_CSS_CFX_CSSPROPERTYHOLDER_H_ #define CORE_FXCRT_CSS_CFX_CSSPROPERTYHOLDER_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/css/cfx_css.h" #include "core/fxcrt/css/cfx_cssvalue.h" +#include "core/fxcrt/retain_ptr.h" class CFX_CSSPropertyHolder { public: @@ -18,7 +18,7 @@ class CFX_CSSPropertyHolder { CFX_CSSProperty eProperty; bool bImportant; - CFX_RetainPtr pValue; + RetainPtr pValue; }; #endif // CORE_FXCRT_CSS_CFX_CSSPROPERTYHOLDER_H_ diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp index 9ae2b876f7..cb9ab2f499 100644 --- a/core/fxcrt/css/cfx_cssstyleselector.cpp +++ b/core/fxcrt/css/cfx_cssstyleselector.cpp @@ -31,7 +31,7 @@ void CFX_CSSStyleSelector::SetDefFontSize(float fFontSize) { m_fDefFontSize = fFontSize; } -CFX_RetainPtr CFX_CSSStyleSelector::CreateComputedStyle( +RetainPtr CFX_CSSStyleSelector::CreateComputedStyle( CFX_CSSComputedStyle* pParentStyle) { auto pStyle = pdfium::MakeRetain(); if (pParentStyle) @@ -168,10 +168,9 @@ void CFX_CSSStyleSelector::AppendInlineStyle(CFX_CSSDeclaration* pDecl, } } -void CFX_CSSStyleSelector::ApplyProperty( - CFX_CSSProperty eProperty, - const CFX_RetainPtr& pValue, - CFX_CSSComputedStyle* pComputedStyle) { +void CFX_CSSStyleSelector::ApplyProperty(CFX_CSSProperty eProperty, + const RetainPtr& pValue, + CFX_CSSComputedStyle* pComputedStyle) { if (pValue->GetType() != CFX_CSSPrimitiveType::List) { CFX_CSSPrimitiveType eType = pValue->GetType(); switch (eProperty) { @@ -192,7 +191,7 @@ void CFX_CSSStyleSelector::ApplyProperty( } break; case CFX_CSSProperty::LineHeight: if (eType == CFX_CSSPrimitiveType::Number) { - CFX_RetainPtr v = pValue.As(); + RetainPtr v = pValue.As(); if (v->Kind() == CFX_CSSNumberType::Number) { pComputedStyle->m_InheritedData.m_fLineHeight = v->Value() * pComputedStyle->m_InheritedData.m_fFontSize; @@ -392,7 +391,7 @@ void CFX_CSSStyleSelector::ApplyProperty( break; } } else if (pValue->GetType() == CFX_CSSPrimitiveType::List) { - CFX_RetainPtr pList = pValue.As(); + RetainPtr pList = pValue.As(); int32_t iCount = pList->CountValues(); if (iCount > 0) { switch (eProperty) { @@ -473,10 +472,10 @@ CFX_CSSFontStyle CFX_CSSStyleSelector::ToFontStyle( bool CFX_CSSStyleSelector::SetLengthWithPercent( CFX_CSSLength& width, CFX_CSSPrimitiveType eType, - const CFX_RetainPtr& pValue, + const RetainPtr& pValue, float fFontSize) { if (eType == CFX_CSSPrimitiveType::Number) { - CFX_RetainPtr v = pValue.As(); + RetainPtr v = pValue.As(); if (v->Kind() == CFX_CSSNumberType::Percent) { width.Set(CFX_CSSLengthUnit::Percent, pValue.As()->Value() / 100.0f); @@ -560,10 +559,10 @@ CFX_CSSVerticalAlign CFX_CSSStyleSelector::ToVerticalAlign( } uint32_t CFX_CSSStyleSelector::ToTextDecoration( - const CFX_RetainPtr& pValue) { + const RetainPtr& pValue) { uint32_t dwDecoration = 0; for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { - const CFX_RetainPtr pVal = pValue->GetValue(i); + const RetainPtr pVal = pValue->GetValue(i); if (pVal->GetType() != CFX_CSSPrimitiveType::Enum) continue; diff --git a/core/fxcrt/css/cfx_cssstyleselector.h b/core/fxcrt/css/cfx_cssstyleselector.h index b59e3048d6..13a0f74427 100644 --- a/core/fxcrt/css/cfx_cssstyleselector.h +++ b/core/fxcrt/css/cfx_cssstyleselector.h @@ -32,7 +32,7 @@ class CFX_CSSStyleSelector { void SetUAStyleSheet(std::unique_ptr pSheet); void UpdateStyleIndex(); - CFX_RetainPtr CreateComputedStyle( + RetainPtr CreateComputedStyle( CFX_CSSComputedStyle* pParentStyle); // Note, the dest style has to be an out param because the CXFA_TextParser @@ -55,7 +55,7 @@ class CFX_CSSStyleSelector { const CFX_CSSDeclaration* extraDecl, CFX_CSSComputedStyle* pDestStyle); void ApplyProperty(CFX_CSSProperty eProperty, - const CFX_RetainPtr& pValue, + const RetainPtr& pValue, CFX_CSSComputedStyle* pComputedStyle); void ExtractValues(const CFX_CSSDeclaration* decl, std::vector* importants, @@ -64,7 +64,7 @@ class CFX_CSSStyleSelector { bool SetLengthWithPercent(CFX_CSSLength& width, CFX_CSSPrimitiveType eType, - const CFX_RetainPtr& pValue, + const RetainPtr& pValue, float fFontSize); float ToFontSize(CFX_CSSPropertyValue eValue, float fCurFontSize); CFX_CSSDisplay ToDisplay(CFX_CSSPropertyValue eValue); @@ -72,7 +72,7 @@ class CFX_CSSStyleSelector { uint16_t ToFontWeight(CFX_CSSPropertyValue eValue); CFX_CSSFontStyle ToFontStyle(CFX_CSSPropertyValue eValue); CFX_CSSVerticalAlign ToVerticalAlign(CFX_CSSPropertyValue eValue); - uint32_t ToTextDecoration(const CFX_RetainPtr& pList); + uint32_t ToTextDecoration(const RetainPtr& pList); CFX_CSSFontVariant ToFontVariant(CFX_CSSPropertyValue eValue); float m_fDefFontSize; diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp index abcd2f6972..30298243bc 100644 --- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp +++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp @@ -51,7 +51,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { ASSERT(decl_); bool important; - CFX_RetainPtr v = decl_->GetProperty(prop, &important); + RetainPtr v = decl_->GetProperty(prop, &important); EXPECT_EQ(v->GetType(), CFX_CSSPrimitiveType::Number); EXPECT_EQ(v.As()->Kind(), type); EXPECT_EQ(v.As()->Value(), val); @@ -61,7 +61,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { ASSERT(decl_); bool important; - CFX_RetainPtr v = decl_->GetProperty(prop, &important); + RetainPtr v = decl_->GetProperty(prop, &important); EXPECT_EQ(v->GetType(), CFX_CSSPrimitiveType::Enum); EXPECT_EQ(v.As()->Value(), val); } @@ -71,12 +71,12 @@ class CFX_CSSStyleSheetTest : public testing::Test { ASSERT(decl_); bool important; - CFX_RetainPtr list = + RetainPtr list = decl_->GetProperty(prop, &important).As(); EXPECT_EQ(list->CountValues(), pdfium::CollectionSize(values)); for (size_t i = 0; i < values.size(); i++) { - CFX_RetainPtr val = list->GetValue(i); + RetainPtr val = list->GetValue(i); EXPECT_EQ(val->GetType(), CFX_CSSPrimitiveType::Enum); EXPECT_EQ(val.As()->Value(), values[i]); } diff --git a/core/fxcrt/css/cfx_cssvalue.h b/core/fxcrt/css/cfx_cssvalue.h index 4f11e4e0d7..f143e96036 100644 --- a/core/fxcrt/css/cfx_cssvalue.h +++ b/core/fxcrt/css/cfx_cssvalue.h @@ -9,7 +9,7 @@ #include "core/fxcrt/css/cfx_css.h" -class CFX_CSSValue : public CFX_Retainable { +class CFX_CSSValue : public Retainable { public: CFX_CSSPrimitiveType GetType() const { return m_value; } diff --git a/core/fxcrt/css/cfx_cssvaluelist.cpp b/core/fxcrt/css/cfx_cssvaluelist.cpp index 18b5d82054..b96f1658af 100644 --- a/core/fxcrt/css/cfx_cssvaluelist.cpp +++ b/core/fxcrt/css/cfx_cssvaluelist.cpp @@ -10,8 +10,7 @@ #include "core/fxcrt/css/cfx_css.h" -CFX_CSSValueList::CFX_CSSValueList( - std::vector>& list) +CFX_CSSValueList::CFX_CSSValueList(std::vector>& list) : CFX_CSSValue(CFX_CSSPrimitiveType::List), m_ppList(std::move(list)) {} CFX_CSSValueList::~CFX_CSSValueList() {} @@ -20,6 +19,6 @@ int32_t CFX_CSSValueList::CountValues() const { return m_ppList.size(); } -CFX_RetainPtr CFX_CSSValueList::GetValue(int32_t index) const { +RetainPtr CFX_CSSValueList::GetValue(int32_t index) const { return m_ppList[index]; } diff --git a/core/fxcrt/css/cfx_cssvaluelist.h b/core/fxcrt/css/cfx_cssvaluelist.h index 475abf4066..d2b0c6e7d1 100644 --- a/core/fxcrt/css/cfx_cssvaluelist.h +++ b/core/fxcrt/css/cfx_cssvaluelist.h @@ -13,14 +13,14 @@ class CFX_CSSValueList : public CFX_CSSValue { public: - explicit CFX_CSSValueList(std::vector>& list); + explicit CFX_CSSValueList(std::vector>& list); ~CFX_CSSValueList() override; int32_t CountValues() const; - CFX_RetainPtr GetValue(int32_t index) const; + RetainPtr GetValue(int32_t index) const; protected: - std::vector> m_ppList; + std::vector> m_ppList; }; #endif // CORE_FXCRT_CSS_CFX_CSSVALUELIST_H_ diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp index a04e781d0d..e15fdb0a81 100644 --- a/core/fxcrt/fx_stream.cpp +++ b/core/fxcrt/fx_stream.cpp @@ -20,7 +20,7 @@ namespace { class CFX_CRTFileStream final : public IFX_SeekableStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableStream: FX_FILESIZE GetSize() override { return m_pFile->GetSize(); } @@ -50,7 +50,7 @@ class CFX_CRTFileStream final : public IFX_SeekableStream { } // namespace // static -CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( +RetainPtr IFX_SeekableStream::CreateFromFilename( const char* filename, uint32_t dwModes) { std::unique_ptr pFA = IFX_FileAccess::Create(); @@ -60,7 +60,7 @@ CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( } // static -CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( +RetainPtr IFX_SeekableStream::CreateFromFilename( const wchar_t* filename, uint32_t dwModes) { std::unique_ptr pFA = IFX_FileAccess::Create(); @@ -70,8 +70,8 @@ CFX_RetainPtr IFX_SeekableStream::CreateFromFilename( } // static -CFX_RetainPtr -IFX_SeekableReadStream::CreateFromFilename(const char* filename) { +RetainPtr IFX_SeekableReadStream::CreateFromFilename( + const char* filename) { return IFX_SeekableStream::CreateFromFilename(filename, FX_FILEMODE_ReadOnly); } diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index 08331e9bf0..d7944167c6 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -7,9 +7,9 @@ #ifndef CORE_FXCRT_FX_STREAM_H_ #define CORE_FXCRT_FX_STREAM_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #include @@ -36,7 +36,7 @@ void FX_CloseFolder(FX_FileHandle* handle); #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -class IFX_WriteStream : virtual public CFX_Retainable { +class IFX_WriteStream : virtual public Retainable { public: virtual bool WriteBlock(const void* pData, size_t size) = 0; virtual bool WriteString(const ByteStringView& str) = 0; @@ -49,7 +49,7 @@ class IFX_ArchiveStream : public IFX_WriteStream { virtual FX_FILESIZE CurrentOffset() const = 0; }; -class IFX_ReadStream : virtual public CFX_Retainable { +class IFX_ReadStream : virtual public Retainable { public: virtual bool IsEOF() = 0; virtual FX_FILESIZE GetPosition() = 0; @@ -70,7 +70,7 @@ class IFX_SeekableWriteStream : public IFX_WriteStream { class IFX_SeekableReadStream : public IFX_ReadStream { public: - static CFX_RetainPtr CreateFromFilename( + static RetainPtr CreateFromFilename( const char* filename); // IFX_ReadStream: @@ -85,11 +85,10 @@ class IFX_SeekableReadStream : public IFX_ReadStream { class IFX_SeekableStream : public IFX_SeekableReadStream, public IFX_SeekableWriteStream { public: - static CFX_RetainPtr CreateFromFilename( - const char* filename, - uint32_t dwModes); + static RetainPtr CreateFromFilename(const char* filename, + uint32_t dwModes); - static CFX_RetainPtr CreateFromFilename( + static RetainPtr CreateFromFilename( const wchar_t* filename, uint32_t dwModes); diff --git a/core/fxcrt/fx_unicode.h b/core/fxcrt/fx_unicode.h index a4a237ae6d..18657bd0e1 100644 --- a/core/fxcrt/fx_unicode.h +++ b/core/fxcrt/fx_unicode.h @@ -7,7 +7,7 @@ #ifndef CORE_FXCRT_FX_UNICODE_H_ #define CORE_FXCRT_FX_UNICODE_H_ -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" uint32_t FX_GetUnicodeProperties(wchar_t wch); wchar_t FX_GetMirrorChar(wchar_t wch); diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h new file mode 100644 index 0000000000..481bfbba56 --- /dev/null +++ b/core/fxcrt/retain_ptr.h @@ -0,0 +1,130 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CORE_FXCRT_RETAIN_PTR_H_ +#define CORE_FXCRT_RETAIN_PTR_H_ + +#include +#include +#include + +#include "core/fxcrt/fx_system.h" + +namespace fxcrt { + +// Used with std::unique_ptr to Release() objects that can't be deleted. +template +struct ReleaseDeleter { + inline void operator()(T* ptr) const { ptr->Release(); } +}; + +// Analogous to base's scoped_refptr. +template +class RetainPtr { + public: + explicit RetainPtr(T* pObj) : m_pObj(pObj) { + if (m_pObj) + m_pObj->Retain(); + } + + RetainPtr() {} + RetainPtr(const RetainPtr& that) : RetainPtr(that.Get()) {} + RetainPtr(RetainPtr&& that) noexcept { Swap(that); } + + // Deliberately implicit to allow returning nullptrs. + // NOLINTNEXTLINE(runtime/explicit) + RetainPtr(std::nullptr_t ptr) {} + + template + RetainPtr(const RetainPtr& that) : RetainPtr(that.Get()) {} + + template + RetainPtr As() const { + return RetainPtr(static_cast(Get())); + } + + void Reset(T* obj = nullptr) { + if (obj) + obj->Retain(); + m_pObj.reset(obj); + } + + T* Get() const { return m_pObj.get(); } + void Swap(RetainPtr& that) { m_pObj.swap(that.m_pObj); } + + // Useful for passing notion of object ownership across a C API. + T* Leak() { return m_pObj.release(); } + void Unleak(T* ptr) { m_pObj.reset(ptr); } + + RetainPtr& operator=(const RetainPtr& that) { + if (*this != that) + Reset(that.Get()); + return *this; + } + + RetainPtr& operator=(RetainPtr&& that) { + m_pObj.reset(that.Leak()); + return *this; + } + + bool operator==(const RetainPtr& that) const { return Get() == that.Get(); } + bool operator!=(const RetainPtr& that) const { return !(*this == that); } + + bool operator<(const RetainPtr& that) const { + return std::less()(Get(), that.Get()); + } + + explicit operator bool() const { return !!m_pObj; } + T& operator*() const { return *m_pObj.get(); } + T* operator->() const { return m_pObj.get(); } + + private: + std::unique_ptr> m_pObj; +}; + +// Trivial implementation - internal ref count with virtual destructor. +class Retainable { + public: + bool HasOneRef() const { return m_nRefCount == 1; } + + protected: + virtual ~Retainable() {} + + private: + template + friend struct ReleaseDeleter; + + template + friend class RetainPtr; + + void Retain() { ++m_nRefCount; } + void Release() { + ASSERT(m_nRefCount > 0); + if (--m_nRefCount == 0) + delete this; + } + + intptr_t m_nRefCount = 0; +}; + +} // namespace fxcrt + +using fxcrt::ReleaseDeleter; +using fxcrt::RetainPtr; +using fxcrt::Retainable; + +namespace pdfium { + +// Helper to make a RetainPtr along the lines of std::make_unique<>(), +// or pdfium::MakeUnique<>(). Arguments are forwarded to T's constructor. +// Classes managed by RetainPtr should have protected (or private) +// constructors, and should friend this function. +template +RetainPtr MakeRetain(Args&&... args) { + return RetainPtr(new T(std::forward(args)...)); +} + +} // namespace pdfium + +#endif // CORE_FXCRT_RETAIN_PTR_H_ diff --git a/core/fxcrt/retain_ptr_unittest.cpp b/core/fxcrt/retain_ptr_unittest.cpp new file mode 100644 index 0000000000..3e14478dbf --- /dev/null +++ b/core/fxcrt/retain_ptr_unittest.cpp @@ -0,0 +1,300 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "core/fxcrt/retain_ptr.h" + +#include +#include + +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class PseudoRetainable { + public: + PseudoRetainable() : retain_count_(0), release_count_(0) {} + void Retain() { ++retain_count_; } + void Release() { ++release_count_; } + int retain_count() const { return retain_count_; } + int release_count() const { return release_count_; } + + private: + int retain_count_; + int release_count_; +}; + +} // namespace + +TEST(RetainPtr, Null) { + RetainPtr ptr; + EXPECT_EQ(nullptr, ptr.Get()); +} + +TEST(RetainPtr, Normal) { + PseudoRetainable obj; + { + RetainPtr ptr(&obj); + EXPECT_EQ(&obj, ptr.Get()); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); +} + +TEST(RetainPtr, CopyCtor) { + PseudoRetainable obj; + { + RetainPtr ptr1(&obj); + { + RetainPtr ptr2(ptr1); + EXPECT_EQ(2, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(2, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); + } + EXPECT_EQ(2, obj.retain_count()); + EXPECT_EQ(2, obj.release_count()); +} + +TEST(RetainPtr, MoveCtor) { + PseudoRetainable obj; + { + RetainPtr ptr1(&obj); + { + RetainPtr ptr2(std::move(ptr1)); + EXPECT_EQ(nullptr, ptr1.Get()); + EXPECT_EQ(&obj, ptr2.Get()); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); +} + +TEST(RetainPtr, ResetNull) { + PseudoRetainable obj; + { + RetainPtr ptr(&obj); + ptr.Reset(); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); +} + +TEST(RetainPtr, Reset) { + PseudoRetainable obj1; + PseudoRetainable obj2; + { + RetainPtr ptr(&obj1); + ptr.Reset(&obj2); + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(1, obj1.release_count()); + EXPECT_EQ(1, obj2.retain_count()); + EXPECT_EQ(0, obj2.release_count()); + } + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(1, obj1.release_count()); + EXPECT_EQ(1, obj2.retain_count()); + EXPECT_EQ(1, obj2.release_count()); +} + +TEST(RetainPtr, Swap) { + PseudoRetainable obj1; + PseudoRetainable obj2; + { + RetainPtr ptr1(&obj1); + { + RetainPtr ptr2(&obj2); + ptr1.Swap(ptr2); + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(0, obj1.release_count()); + EXPECT_EQ(1, obj2.retain_count()); + EXPECT_EQ(0, obj2.release_count()); + } + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(1, obj1.release_count()); + EXPECT_EQ(1, obj2.retain_count()); + EXPECT_EQ(0, obj2.release_count()); + } + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(1, obj1.release_count()); + EXPECT_EQ(1, obj2.retain_count()); + EXPECT_EQ(1, obj2.release_count()); +} + +TEST(RetainPtr, Leak) { + PseudoRetainable obj; + PseudoRetainable* leak; + { + RetainPtr ptr(&obj); + leak = ptr.Leak(); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + { + RetainPtr ptr; + ptr.Unleak(leak); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); +} + +TEST(RetainPtr, SwapNull) { + PseudoRetainable obj1; + { + RetainPtr ptr1(&obj1); + { + RetainPtr ptr2; + ptr1.Swap(ptr2); + EXPECT_FALSE(ptr1); + EXPECT_TRUE(ptr2); + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(0, obj1.release_count()); + } + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(1, obj1.release_count()); + } + EXPECT_EQ(1, obj1.retain_count()); + EXPECT_EQ(1, obj1.release_count()); +} + +TEST(RetainPtr, Assign) { + PseudoRetainable obj; + { + RetainPtr ptr(&obj); + { + RetainPtr ptr2; + ptr2 = ptr; + EXPECT_EQ(2, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(2, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); + } + EXPECT_EQ(2, obj.retain_count()); + EXPECT_EQ(2, obj.release_count()); +} + +TEST(RetainPtr, MoveAssign) { + PseudoRetainable obj; + { + RetainPtr ptr1(&obj); + { + RetainPtr ptr2; + EXPECT_EQ(&obj, ptr1.Get()); + EXPECT_EQ(nullptr, ptr2.Get()); + ptr2 = std::move(ptr1); + EXPECT_EQ(nullptr, ptr1.Get()); + EXPECT_EQ(&obj, ptr2.Get()); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); +} + +TEST(RetainPtr, Equals) { + PseudoRetainable obj1; + PseudoRetainable obj2; + RetainPtr null_ptr1; + RetainPtr obj1_ptr1(&obj1); + RetainPtr obj2_ptr1(&obj2); + { + RetainPtr null_ptr2; + EXPECT_TRUE(null_ptr1 == null_ptr2); + + RetainPtr obj1_ptr2(&obj1); + EXPECT_TRUE(obj1_ptr1 == obj1_ptr2); + + RetainPtr obj2_ptr2(&obj2); + EXPECT_TRUE(obj2_ptr1 == obj2_ptr2); + } + EXPECT_FALSE(null_ptr1 == obj1_ptr1); + EXPECT_FALSE(null_ptr1 == obj2_ptr1); + EXPECT_FALSE(obj1_ptr1 == obj2_ptr1); +} + +TEST(RetainPtr, NotEquals) { + PseudoRetainable obj1; + PseudoRetainable obj2; + RetainPtr null_ptr1; + RetainPtr obj1_ptr1(&obj1); + RetainPtr obj2_ptr1(&obj2); + { + RetainPtr null_ptr2; + RetainPtr obj1_ptr2(&obj1); + RetainPtr obj2_ptr2(&obj2); + EXPECT_FALSE(null_ptr1 != null_ptr2); + EXPECT_FALSE(obj1_ptr1 != obj1_ptr2); + EXPECT_FALSE(obj2_ptr1 != obj2_ptr2); + } + EXPECT_TRUE(null_ptr1 != obj1_ptr1); + EXPECT_TRUE(null_ptr1 != obj2_ptr1); + EXPECT_TRUE(obj1_ptr1 != obj2_ptr1); +} + +TEST(RetainPtr, LessThan) { + PseudoRetainable objs[2]; + RetainPtr obj1_ptr(&objs[0]); + RetainPtr obj2_ptr(&objs[1]); + EXPECT_TRUE(obj1_ptr < obj2_ptr); + EXPECT_FALSE(obj2_ptr < obj1_ptr); +} + +TEST(RetainPtr, Bool) { + PseudoRetainable obj1; + RetainPtr null_ptr; + RetainPtr obj1_ptr(&obj1); + bool null_bool = !!null_ptr; + bool obj1_bool = !!obj1_ptr; + EXPECT_FALSE(null_bool); + EXPECT_TRUE(obj1_bool); +} + +TEST(RetainPtr, MakeRetained) { + auto ptr = pdfium::MakeRetain(); + EXPECT_TRUE(ptr->HasOneRef()); + { + RetainPtr other = ptr; + EXPECT_FALSE(ptr->HasOneRef()); + } + EXPECT_TRUE(ptr->HasOneRef()); +} + +TEST(RetainPtr, VectorMove) { + // Proves move ctor is selected by std::vector over copy/delete, this + // may require the ctor to be marked "noexcept". + PseudoRetainable obj; + { + RetainPtr ptr(&obj); + std::vector> vec1; + vec1.push_back(std::move(ptr)); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + + std::vector> vec2 = std::move(vec1); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + + vec2.resize(4096); + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(0, obj.release_count()); + } + EXPECT_EQ(1, obj.retain_count()); + EXPECT_EQ(1, obj.release_count()); +} diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index fa5c80130d..e90d8ced85 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -458,7 +458,7 @@ void WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) { return; } - CFX_RetainPtr pNewData(StringData::Create(nNewLength)); + RetainPtr pNewData(StringData::Create(nNewLength)); if (m_pData) { FX_STRSIZE nCopyLength = std::min(m_pData->m_nDataLength, nNewLength); pNewData->CopyContents(m_pData->m_String, nCopyLength); @@ -525,7 +525,7 @@ wchar_t* WideString::GetBuffer(FX_STRSIZE nMinBufLength) { if (nMinBufLength == 0) return nullptr; - CFX_RetainPtr pNewData(StringData::Create(nMinBufLength)); + RetainPtr pNewData(StringData::Create(nMinBufLength)); pNewData->CopyContents(*m_pData); pNewData->m_nDataLength = m_pData->m_nDataLength; m_pData.Swap(pNewData); @@ -568,7 +568,7 @@ void WideString::Concat(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) { return; } - CFX_RetainPtr pNewData( + RetainPtr pNewData( StringData::Create(m_pData->m_nDataLength + nSrcLen)); pNewData->CopyContents(*m_pData); pNewData->CopyContentsAt(m_pData->m_nDataLength, pSrcData, nSrcLen); @@ -635,7 +635,7 @@ void WideString::AllocCopy(WideString& dest, if (nCopyLen == 0) return; - CFX_RetainPtr pNewData( + RetainPtr pNewData( StringData::Create(m_pData->m_String + nCopyIndex, nCopyLen)); dest.m_pData.Swap(pNewData); } @@ -816,7 +816,7 @@ FX_STRSIZE WideString::Replace(const WideStringView& pOld, return count; } - CFX_RetainPtr pNewData(StringData::Create(nNewLength)); + RetainPtr pNewData(StringData::Create(nNewLength)); pStart = m_pData->m_String; wchar_t* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < count; i++) { diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h index 8841c84093..4dc0abbc99 100644 --- a/core/fxcrt/widestring.h +++ b/core/fxcrt/widestring.h @@ -11,10 +11,10 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_string_data_template.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/string_view_template.h" #include "third_party/base/optional.h" @@ -192,7 +192,7 @@ class WideString { // Returns true unless we ran out of space. bool TryVSWPrintf(FX_STRSIZE size, const wchar_t* format, va_list argList); - CFX_RetainPtr m_pData; + RetainPtr m_pData; friend WideString_ConcatInPlace_Test; friend fxcrt_WideStringPool_Test; diff --git a/core/fxcrt/xml/cfx_saxreader.cpp b/core/fxcrt/xml/cfx_saxreader.cpp index e2c09d14cc..762144f4bb 100644 --- a/core/fxcrt/xml/cfx_saxreader.cpp +++ b/core/fxcrt/xml/cfx_saxreader.cpp @@ -54,7 +54,7 @@ CFX_SAXFile::CFX_SAXFile() CFX_SAXFile::~CFX_SAXFile() {} -bool CFX_SAXFile::StartFile(const CFX_RetainPtr& pFile, +bool CFX_SAXFile::StartFile(const RetainPtr& pFile, uint32_t dwStart, uint32_t dwLen) { ASSERT(!m_pFile && pFile); @@ -186,7 +186,7 @@ bool CFX_SAXReader::SkipSpace(uint8_t ch) { } int32_t CFX_SAXReader::StartParse( - const CFX_RetainPtr& pFile, + const RetainPtr& pFile, uint32_t dwStart, uint32_t dwLen, uint32_t dwParseMode) { diff --git a/core/fxcrt/xml/cfx_saxreader.h b/core/fxcrt/xml/cfx_saxreader.h index 51d9e43121..9ff755d053 100644 --- a/core/fxcrt/xml/cfx_saxreader.h +++ b/core/fxcrt/xml/cfx_saxreader.h @@ -11,8 +11,8 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" class CFX_SAXCommentContext; class CFX_SAXContext; @@ -45,13 +45,13 @@ class CFX_SAXFile { CFX_SAXFile(); ~CFX_SAXFile(); - bool StartFile(const CFX_RetainPtr& pFile, + bool StartFile(const RetainPtr& pFile, uint32_t dwStart, uint32_t dwLen); bool ReadNextBlock(); void Reset(); - CFX_RetainPtr m_pFile; + RetainPtr m_pFile; uint32_t m_dwStart; uint32_t m_dwEnd; uint32_t m_dwCur; @@ -99,7 +99,7 @@ class CFX_SAXReader { CFX_SAXReader(); ~CFX_SAXReader(); - int32_t StartParse(const CFX_RetainPtr& pFile, + int32_t StartParse(const RetainPtr& pFile, uint32_t dwStart = 0, uint32_t dwLen = -1, uint32_t dwParseMode = 0); diff --git a/core/fxcrt/xml/cfx_xmldoc.cpp b/core/fxcrt/xml/cfx_xmldoc.cpp index e9a09b761b..30e4a47e72 100644 --- a/core/fxcrt/xml/cfx_xmldoc.cpp +++ b/core/fxcrt/xml/cfx_xmldoc.cpp @@ -48,7 +48,7 @@ void CFX_XMLDoc::CloseXML() { } void CFX_XMLDoc::SaveXMLNode( - const CFX_RetainPtr& pXMLStream, + const RetainPtr& pXMLStream, CFX_XMLNode* pINode) { CFX_XMLNode* pNode = (CFX_XMLNode*)pINode; switch (pNode->GetType()) { diff --git a/core/fxcrt/xml/cfx_xmldoc.h b/core/fxcrt/xml/cfx_xmldoc.h index c182504f6f..28de7fdba1 100644 --- a/core/fxcrt/xml/cfx_xmldoc.h +++ b/core/fxcrt/xml/cfx_xmldoc.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_xmlnode.h" #include "core/fxcrt/xml/cfx_xmlparser.h" @@ -24,14 +24,14 @@ class CFX_XMLDoc { void CloseXML(); CFX_XMLNode* GetRoot() const { return m_pRoot.get(); } - void SaveXMLNode(const CFX_RetainPtr& pXMLStream, + void SaveXMLNode(const RetainPtr& pXMLStream, CFX_XMLNode* pNode); private: int32_t m_iStatus; std::unique_ptr m_pRoot; std::unique_ptr m_pXMLParser; - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; }; #endif // CORE_FXCRT_XML_CFX_XMLDOC_H_ diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index 7a893af4a0..a1e3ac2740 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -330,7 +330,7 @@ std::unique_ptr CFX_XMLNode::Clone() { } void CFX_XMLNode::SaveXMLNode( - const CFX_RetainPtr& pXMLStream) { + const RetainPtr& pXMLStream) { CFX_XMLNode* pNode = (CFX_XMLNode*)this; switch (pNode->GetType()) { case FX_XMLNODE_Instruction: { diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h index 7cbc2b6642..278b3bf15a 100644 --- a/core/fxcrt/xml/cfx_xmlnode.h +++ b/core/fxcrt/xml/cfx_xmlnode.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/retain_ptr.h" enum FX_XMLNODETYPE { FX_XMLNODE_Unknown = 0, @@ -64,7 +64,7 @@ class CFX_XMLNode { bool InsertNodeItem(CFX_XMLNode::NodeItem eItem, CFX_XMLNode* pNode); CFX_XMLNode* RemoveNodeItem(CFX_XMLNode::NodeItem eItem); - void SaveXMLNode(const CFX_RetainPtr& pXMLStream); + void SaveXMLNode(const RetainPtr& pXMLStream); CFX_XMLNode* m_pParent; CFX_XMLNode* m_pChild; diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index 280c06d3f1..a8bb2c9565 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp @@ -13,9 +13,8 @@ #include "core/fxcrt/xml/cfx_xmltext.h" #include "third_party/base/ptr_util.h" -CFX_XMLParser::CFX_XMLParser( - CFX_XMLNode* pParent, - const CFX_RetainPtr& pStream) +CFX_XMLParser::CFX_XMLParser(CFX_XMLNode* pParent, + const RetainPtr& pStream) : m_nElementStart(0), m_dwCheckStatus(0), m_dwCurrentCheckStatus(0), diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h index f98b658d9a..0038f6d9b2 100644 --- a/core/fxcrt/xml/cfx_xmlparser.h +++ b/core/fxcrt/xml/cfx_xmlparser.h @@ -10,8 +10,8 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_xmlsyntaxparser.h" class CFX_XMLElement; @@ -21,7 +21,7 @@ class CFX_SeekableStreamProxy; class CFX_XMLParser { public: CFX_XMLParser(CFX_XMLNode* pParent, - const CFX_RetainPtr& pStream); + const RetainPtr& pStream); ~CFX_XMLParser(); int32_t DoParser(); @@ -33,7 +33,7 @@ class CFX_XMLParser { uint16_t m_dwCurrentCheckStatus; private: - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; std::unique_ptr m_pParser; CFX_XMLNode* m_pParent; CFX_XMLNode* m_pChild; diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index d55985240d..5dcb867623 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -76,7 +76,7 @@ bool CFX_XMLSyntaxParser::IsXMLNameChar(wchar_t ch, bool bFirstChar) { } CFX_XMLSyntaxParser::CFX_XMLSyntaxParser( - const CFX_RetainPtr& pStream) + const RetainPtr& pStream) : m_pStream(pStream), m_iXMLPlaneSize(32 * 1024), m_iCurrentPos(0), diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.h b/core/fxcrt/xml/cfx_xmlsyntaxparser.h index d3f4bf2edb..8379aa445b 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.h +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.h @@ -11,9 +11,9 @@ #include #include "core/fxcrt/cfx_blockbuffer.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_xmlnode.h" enum class FX_XmlSyntaxResult { @@ -39,7 +39,7 @@ class CFX_XMLSyntaxParser { static bool IsXMLNameChar(wchar_t ch, bool bFirstChar); explicit CFX_XMLSyntaxParser( - const CFX_RetainPtr& pStream); + const RetainPtr& pStream); ~CFX_XMLSyntaxParser(); FX_XmlSyntaxResult DoSyntaxParse(); @@ -100,7 +100,7 @@ class CFX_XMLSyntaxParser { void ParseTextChar(wchar_t ch); - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; FX_STRSIZE m_iXMLPlaneSize; FX_FILESIZE m_iCurrentPos; int32_t m_iCurrentNodeNum; diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp index c3cc3d26bf..b7f7c416b1 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser_unittest.cpp @@ -26,7 +26,7 @@ TEST(CFX_XMLSyntaxParserTest, CData) { L" app.alert(\"Tclams\");\n" L" "; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -74,7 +74,7 @@ TEST(CFX_XMLSyntaxParserTest, CDataWithInnerScript) { L" \n" L" "; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -111,7 +111,7 @@ TEST(CFX_XMLSyntaxParserTest, ArrowBangArrow) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -146,7 +146,7 @@ TEST(CFX_XMLSyntaxParserTest, ArrowBangBracketArrow) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -176,7 +176,7 @@ TEST(CFX_XMLSyntaxParserTest, IncompleteCData) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -206,7 +206,7 @@ TEST(CFX_XMLSyntaxParserTest, UnClosedCData) { " "; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -236,7 +236,7 @@ TEST(CFX_XMLSyntaxParserTest, EmptyCData) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -273,7 +273,7 @@ TEST(CFX_XMLSyntaxParserTest, Comment) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -307,7 +307,7 @@ TEST(CFX_XMLSyntaxParserTest, IncorrectCommentStart) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -341,7 +341,7 @@ TEST(CFX_XMLSyntaxParserTest, CommentEmpty) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -375,7 +375,7 @@ TEST(CFX_XMLSyntaxParserTest, CommentThreeDash) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -403,7 +403,7 @@ TEST(CFX_XMLSyntaxParserTest, CommentTwoDash) { " \n" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -435,7 +435,7 @@ TEST(CFX_XMLSyntaxParserTest, Entities) { "�" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -467,7 +467,7 @@ TEST(CFX_XMLSyntaxParserTest, EntityOverflowHex) { "�" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); @@ -499,7 +499,7 @@ TEST(CFX_XMLSyntaxParserTest, EntityOverflowDecimal) { "�" ""; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain( reinterpret_cast(const_cast(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 5e0308c551..3ba05ce2c0 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -35,7 +35,7 @@ CFX_PointF HardClip(const CFX_PointF& pos) { pdfium::clamp(pos.y, -kMaxPos, kMaxPos)); } -void RgbByteOrderSetPixel(const CFX_RetainPtr& pBitmap, +void RgbByteOrderSetPixel(const RetainPtr& pBitmap, int x, int y, uint32_t argb) { @@ -55,7 +55,7 @@ void RgbByteOrderSetPixel(const CFX_RetainPtr& pBitmap, pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255; } -void RgbByteOrderCompositeRect(const CFX_RetainPtr& pBitmap, +void RgbByteOrderCompositeRect(const RetainPtr& pBitmap, int left, int top, int width, @@ -130,12 +130,12 @@ void RgbByteOrderCompositeRect(const CFX_RetainPtr& pBitmap, } } -void RgbByteOrderTransferBitmap(const CFX_RetainPtr& pBitmap, +void RgbByteOrderTransferBitmap(const RetainPtr& pBitmap, int dest_left, int dest_top, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { if (!pBitmap) @@ -228,7 +228,7 @@ void RgbByteOrderTransferBitmap(const CFX_RetainPtr& pBitmap, } } -bool DibSetPixel(const CFX_RetainPtr& pDevice, +bool DibSetPixel(const RetainPtr& pDevice, int x, int y, uint32_t color) { @@ -377,8 +377,8 @@ class CFX_Renderer { uint8_t* clip_scan, uint8_t* dest_extra_alpha_scan); - bool Init(const CFX_RetainPtr& pDevice, - const CFX_RetainPtr& pOriDevice, + bool Init(const RetainPtr& pDevice, + const RetainPtr& pOriDevice, const CFX_ClipRgn* pClipRgn, uint32_t color, bool bFullCover, @@ -434,9 +434,9 @@ class CFX_Renderer { bool m_bFullCover; bool m_bRgbByteOrder; FX_RECT m_ClipBox; - CFX_RetainPtr m_pOriDevice; - CFX_RetainPtr m_pClipMask; - CFX_RetainPtr m_pDevice; + RetainPtr m_pOriDevice; + RetainPtr m_pClipMask; + RetainPtr m_pDevice; CFX_UnownedPtr m_pClipRgn; }; @@ -876,8 +876,8 @@ void CFX_Renderer::CompositeSpanCMYK(uint8_t* dest_scan, } } -bool CFX_Renderer::Init(const CFX_RetainPtr& pDevice, - const CFX_RetainPtr& pOriDevice, +bool CFX_Renderer::Init(const RetainPtr& pDevice, + const RetainPtr& pOriDevice, const CFX_ClipRgn* pClipRgn, uint32_t color, bool bFullCover, @@ -938,7 +938,7 @@ void CFX_Renderer::render(const Scanline& sl) { uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * y; uint8_t* dest_scan_extra_alpha = nullptr; - CFX_RetainPtr pAlphaMask = m_pDevice->m_pAlphaMask; + RetainPtr pAlphaMask = m_pDevice->m_pAlphaMask; if (pAlphaMask) { dest_scan_extra_alpha = pAlphaMask->GetBuffer() + pAlphaMask->GetPitch() * y; @@ -1104,9 +1104,9 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, } CFX_AggDeviceDriver::CFX_AggDeviceDriver( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, + const RetainPtr& pOriDevice, bool bGroupKnockout) : m_pBitmap(pBitmap), #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ @@ -1283,7 +1283,7 @@ bool CFX_AggDeviceDriver::RenderRasterizer( uint32_t color, bool bFullCover, bool bGroupKnockout) { - CFX_RetainPtr pt = bGroupKnockout ? m_pOriDevice : nullptr; + RetainPtr pt = bGroupKnockout ? m_pOriDevice : nullptr; CFX_Renderer render; if (!render.Init(m_pBitmap, pt, m_pClipRgn.get(), color, bFullCover, m_bRgbByteOrder)) { @@ -1445,7 +1445,7 @@ bool CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) { return true; } -bool CFX_AggDeviceDriver::GetDIBits(const CFX_RetainPtr& pBitmap, +bool CFX_AggDeviceDriver::GetDIBits(const RetainPtr& pBitmap, int left, int top) { if (!m_pBitmap || !m_pBitmap->GetBuffer()) @@ -1453,7 +1453,7 @@ bool CFX_AggDeviceDriver::GetDIBits(const CFX_RetainPtr& pBitmap, FX_RECT rect(left, top, left + pBitmap->GetWidth(), top + pBitmap->GetHeight()); - CFX_RetainPtr pBack; + RetainPtr pBack; if (m_pOriDevice) { pBack = m_pOriDevice->Clone(&rect); if (!pBack) @@ -1478,11 +1478,11 @@ bool CFX_AggDeviceDriver::GetDIBits(const CFX_RetainPtr& pBitmap, top); } -CFX_RetainPtr CFX_AggDeviceDriver::GetBackDrop() { +RetainPtr CFX_AggDeviceDriver::GetBackDrop() { return m_pOriDevice; } -bool CFX_AggDeviceDriver::SetDIBits(const CFX_RetainPtr& pBitmap, +bool CFX_AggDeviceDriver::SetDIBits(const RetainPtr& pBitmap, uint32_t argb, const FX_RECT* pSrcRect, int left, @@ -1502,16 +1502,15 @@ bool CFX_AggDeviceDriver::SetDIBits(const CFX_RetainPtr& pBitmap, pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder); } -bool CFX_AggDeviceDriver::StretchDIBits( - const CFX_RetainPtr& pSource, - uint32_t argb, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CFX_AggDeviceDriver::StretchDIBits(const RetainPtr& pSource, + uint32_t argb, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { if (!m_pBitmap->GetBuffer()) return true; @@ -1537,7 +1536,7 @@ bool CFX_AggDeviceDriver::StretchDIBits( } bool CFX_AggDeviceDriver::StartDIBits( - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, int bitmap_alpha, uint32_t argb, const CFX_Matrix* pMatrix, @@ -1563,11 +1562,10 @@ CFX_DefaultRenderDevice::CFX_DefaultRenderDevice() {} CFX_DefaultRenderDevice::~CFX_DefaultRenderDevice() {} -bool CFX_DefaultRenderDevice::Attach( - const CFX_RetainPtr& pBitmap, - bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, - bool bGroupKnockout) { +bool CFX_DefaultRenderDevice::Attach(const RetainPtr& pBitmap, + bool bRgbByteOrder, + const RetainPtr& pOriDevice, + bool bGroupKnockout) { if (!pBitmap) return false; @@ -1581,7 +1579,7 @@ bool CFX_DefaultRenderDevice::Create( int width, int height, FXDIB_Format format, - const CFX_RetainPtr& pOriDevice) { + const RetainPtr& pOriDevice) { auto pBitmap = pdfium::MakeRetain(); if (!pBitmap->Create(width, height, format)) return false; diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index c6aafebffc..0afc7e3123 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -32,9 +32,9 @@ class CAgg_PathData { class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { public: - CFX_AggDeviceDriver(const CFX_RetainPtr& pBitmap, + CFX_AggDeviceDriver(const RetainPtr& pBitmap, bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, + const RetainPtr& pOriDevice, bool bGroupKnockout); ~CFX_AggDeviceDriver() override; @@ -63,17 +63,17 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { uint32_t fill_color, int blend_type) override; bool GetClipBox(FX_RECT* pRect) override; - bool GetDIBits(const CFX_RetainPtr& pBitmap, + bool GetDIBits(const RetainPtr& pBitmap, int left, int top) override; - CFX_RetainPtr GetBackDrop() override; - bool SetDIBits(const CFX_RetainPtr& pBitmap, + RetainPtr GetBackDrop() override; + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -82,7 +82,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -109,7 +109,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { virtual uint8_t* GetBuffer() const; private: - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; std::unique_ptr m_pClipRgn; std::vector> m_StateStack; #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ @@ -117,7 +117,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { #endif int m_FillFlags; bool m_bRgbByteOrder; - CFX_RetainPtr m_pOriDevice; + RetainPtr m_pOriDevice; bool m_bGroupKnockout; }; diff --git a/core/fxge/android/cfpf_skiafilefont.h b/core/fxge/android/cfpf_skiafilefont.h index 4496fde078..5e2ebbc529 100644 --- a/core/fxge/android/cfpf_skiafilefont.h +++ b/core/fxge/android/cfpf_skiafilefont.h @@ -7,7 +7,7 @@ #ifndef CORE_FXGE_ANDROID_CFPF_SKIAFILEFONT_H_ #define CORE_FXGE_ANDROID_CFPF_SKIAFILEFONT_H_ -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/android/cfpf_skiafontdescriptor.h" class IFX_SeekableReadStream; @@ -22,7 +22,7 @@ class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { // CFPF_SkiaFontDescriptor int32_t GetType() const override; - CFX_RetainPtr m_pFile; + RetainPtr m_pFile; }; #endif // CORE_FXGE_ANDROID_CFPF_SKIAFILEFONT_H_ diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index a50b9ead63..4be35668e0 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -363,7 +363,7 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname, } FXFT_Face CFPF_SkiaFontMgr::GetFontFace( - const CFX_RetainPtr& pFileRead, + const RetainPtr& pFileRead, int32_t iFaceIndex) { if (!pFileRead) return nullptr; diff --git a/core/fxge/android/cfpf_skiafontmgr.h b/core/fxge/android/cfpf_skiafontmgr.h index 78d01717b9..11ad47a360 100644 --- a/core/fxge/android/cfpf_skiafontmgr.h +++ b/core/fxge/android/cfpf_skiafontmgr.h @@ -31,7 +31,7 @@ class CFPF_SkiaFontMgr { uint32_t dwMatch = 0); bool InitFTLibrary(); - FXFT_Face GetFontFace(const CFX_RetainPtr& pFileRead, + FXFT_Face GetFontFace(const RetainPtr& pFileRead, int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const ByteStringView& bsFile, int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const uint8_t* pBuffer, diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index f1b9fcf2e8..82415ec07f 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -19,7 +19,7 @@ class CQuartz2D { public: - void* createGraphics(const CFX_RetainPtr& bitmap); + void* createGraphics(const RetainPtr& bitmap); void destroyGraphics(void* graphics); void* CreateFont(const uint8_t* pFontData, uint32_t dwFontSize); diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index b3a3f26c99..05ae70a6b7 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -131,7 +131,7 @@ bool CFX_AggDeviceDriver::DrawDeviceText(int nChars, rect_cg = CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top, m_pClipRgn->GetBox().Width(), m_pClipRgn->GetBox().Height()); - CFX_RetainPtr pClipMask = m_pClipRgn->GetMask(); + RetainPtr pClipMask = m_pClipRgn->GetMask(); if (pClipMask) { CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData( nullptr, pClipMask->GetBuffer(), diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index f92db2b30b..1e9fddaad8 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -23,7 +23,7 @@ #error Expected CGFLOAT_IS_DOUBLE to be defined by CoreGraphics headers #endif -void* CQuartz2D::createGraphics(const CFX_RetainPtr& pBitmap) { +void* CQuartz2D::createGraphics(const RetainPtr& pBitmap) { if (!pBitmap) return nullptr; CGBitmapInfo bmpInfo = kCGBitmapByteOrder32Little; diff --git a/core/fxge/cfx_cliprgn.cpp b/core/fxge/cfx_cliprgn.cpp index 087c11089a..9569ee909c 100644 --- a/core/fxge/cfx_cliprgn.cpp +++ b/core/fxge/cfx_cliprgn.cpp @@ -41,7 +41,7 @@ void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) { void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, FX_RECT mask_rect, - const CFX_RetainPtr& pMask) { + const RetainPtr& pMask) { m_Type = MaskF; m_Box = rect; m_Box.Intersect(mask_rect); @@ -53,7 +53,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, m_Mask = pMask; return; } - CFX_RetainPtr pOldMask(pMask); + RetainPtr pOldMask(pMask); m_Mask = pdfium::MakeRetain(); m_Mask->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask); for (int row = m_Box.top; row < m_Box.bottom; row++) { @@ -68,7 +68,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, void CFX_ClipRgn::IntersectMaskF(int left, int top, - const CFX_RetainPtr& pMask) { + const RetainPtr& pMask) { ASSERT(pMask->GetFormat() == FXDIB_8bppMask); FX_RECT mask_box(left, top, left + pMask->GetWidth(), top + pMask->GetHeight()); diff --git a/core/fxge/cfx_cliprgn.h b/core/fxge/cfx_cliprgn.h index 0dfc4991fd..58ebb4de73 100644 --- a/core/fxge/cfx_cliprgn.h +++ b/core/fxge/cfx_cliprgn.h @@ -7,8 +7,8 @@ #ifndef CORE_FXGE_CFX_CLIPRGN_H_ #define CORE_FXGE_CFX_CLIPRGN_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBitmap; @@ -22,22 +22,20 @@ class CFX_ClipRgn { ClipType GetType() const { return m_Type; } const FX_RECT& GetBox() const { return m_Box; } - CFX_RetainPtr GetMask() const { return m_Mask; } + RetainPtr GetMask() const { return m_Mask; } void Reset(const FX_RECT& rect); void IntersectRect(const FX_RECT& rect); - void IntersectMaskF(int left, - int top, - const CFX_RetainPtr& Mask); + void IntersectMaskF(int left, int top, const RetainPtr& Mask); private: void IntersectMaskRect(FX_RECT rect, FX_RECT mask_box, - const CFX_RetainPtr& Mask); + const RetainPtr& Mask); ClipType m_Type; FX_RECT m_Box; - CFX_RetainPtr m_Mask; + RetainPtr m_Mask; }; #endif // CORE_FXGE_CFX_CLIPRGN_H_ diff --git a/core/fxge/cfx_defaultrenderdevice.h b/core/fxge/cfx_defaultrenderdevice.h index e2dc1f3859..59415df641 100644 --- a/core/fxge/cfx_defaultrenderdevice.h +++ b/core/fxge/cfx_defaultrenderdevice.h @@ -17,22 +17,22 @@ class CFX_DefaultRenderDevice : public CFX_RenderDevice { CFX_DefaultRenderDevice(); ~CFX_DefaultRenderDevice() override; - bool Attach(const CFX_RetainPtr& pBitmap, + bool Attach(const RetainPtr& pBitmap, bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, + const RetainPtr& pOriDevice, bool bGroupKnockout); bool Create(int width, int height, FXDIB_Format format, - const CFX_RetainPtr& pOriDevice); + const RetainPtr& pOriDevice); #ifdef _SKIA_SUPPORT_ bool AttachRecorder(SkPictureRecorder* recorder); void Clear(uint32_t color); SkPictureRecorder* CreateRecorder(int size_x, int size_y); void DebugVerifyBitmapIsPreMultiplied() const override; - bool SetBitsWithMask(const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + bool SetBitsWithMask(const RetainPtr& pBitmap, + const RetainPtr& pMask, int left, int top, int bitmap_alpha, diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp index 017b120dd4..9e6a2cf982 100644 --- a/core/fxge/cfx_font.cpp +++ b/core/fxge/cfx_font.cpp @@ -54,7 +54,7 @@ void FTStreamClose(FXFT_Stream stream) {} bool LoadFileImp(FXFT_Library library, FXFT_Face* Face, - const CFX_RetainPtr& pFile, + const RetainPtr& pFile, int32_t faceIndex, std::unique_ptr* stream) { auto stream1 = pdfium::MakeUnique(); @@ -311,7 +311,7 @@ void CFX_Font::LoadSubst(const ByteString& face_name, } #ifdef PDF_ENABLE_XFA -bool CFX_Font::LoadFile(const CFX_RetainPtr& pFile, +bool CFX_Font::LoadFile(const RetainPtr& pFile, int nFaceIndex) { m_bEmbedded = false; diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index 5e9f5ae0c9..c6f9411176 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -197,8 +197,8 @@ void SetAlpha(bool has_alpha, uint8_t* alpha) { alpha[3] = 255; } -void DrawNormalTextHelper(const CFX_RetainPtr& bitmap, - const CFX_RetainPtr& pGlyph, +void DrawNormalTextHelper(const RetainPtr& bitmap, + const RetainPtr& pGlyph, int nrows, int left, int top, @@ -428,7 +428,7 @@ CFX_Matrix CFX_RenderDevice::GetCTM() const { } bool CFX_RenderDevice::CreateCompatibleBitmap( - const CFX_RetainPtr& pDIB, + const RetainPtr& pDIB, int width, int height) const { if (m_RenderCaps & FXRC_CMYK_OUTPUT) { @@ -707,19 +707,19 @@ bool CFX_RenderDevice::DrawCosmeticLine(const CFX_PointF& ptMoveTo, fill_mode, blend_type); } -bool CFX_RenderDevice::GetDIBits(const CFX_RetainPtr& pBitmap, +bool CFX_RenderDevice::GetDIBits(const RetainPtr& pBitmap, int left, int top) { return (m_RenderCaps & FXRC_GET_BITS) && m_pDeviceDriver->GetDIBits(pBitmap, left, top); } -CFX_RetainPtr CFX_RenderDevice::GetBackDrop() { +RetainPtr CFX_RenderDevice::GetBackDrop() { return m_pDeviceDriver->GetBackDrop(); } bool CFX_RenderDevice::SetDIBitsWithBlend( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int left, int top, int blend_mode) { @@ -771,7 +771,7 @@ bool CFX_RenderDevice::SetDIBitsWithBlend( } bool CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int left, int top, int dest_width, @@ -786,7 +786,7 @@ bool CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( dest_height, &clip_box, flags, blend_mode); } -bool CFX_RenderDevice::SetBitMask(const CFX_RetainPtr& pBitmap, +bool CFX_RenderDevice::SetBitMask(const RetainPtr& pBitmap, int left, int top, uint32_t argb) { @@ -795,19 +795,18 @@ bool CFX_RenderDevice::SetBitMask(const CFX_RetainPtr& pBitmap, FXDIB_BLEND_NORMAL); } -bool CFX_RenderDevice::StretchBitMask( - const CFX_RetainPtr& pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t color) { +bool CFX_RenderDevice::StretchBitMask(const RetainPtr& pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t color) { return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height, color, 0); } bool CFX_RenderDevice::StretchBitMaskWithFlags( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int left, int top, int dest_width, @@ -823,7 +822,7 @@ bool CFX_RenderDevice::StretchBitMaskWithFlags( } bool CFX_RenderDevice::StartDIBitsWithBlend( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int bitmap_alpha, uint32_t argb, const CFX_Matrix* pMatrix, @@ -844,13 +843,12 @@ void CFX_RenderDevice::DebugVerifyBitmapIsPreMultiplied() const { SkASSERT(0); } -bool CFX_RenderDevice::SetBitsWithMask( - const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, - int left, - int top, - int bitmap_alpha, - int blend_type) { +bool CFX_RenderDevice::SetBitsWithMask(const RetainPtr& pBitmap, + const RetainPtr& pMask, + int left, + int top, + int bitmap_alpha, + int blend_type) { return m_pDeviceDriver->SetBitsWithMask(pBitmap, pMask, left, top, bitmap_alpha, blend_type); } @@ -989,7 +987,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, for (const FXTEXT_GLYPHPOS& glyph : glyphs) { if (!glyph.m_pGlyph) continue; - CFX_RetainPtr pGlyph = glyph.m_pGlyph->m_pBitmap; + RetainPtr pGlyph = glyph.m_pGlyph->m_pBitmap; bitmap->TransferBitmap( glyph.m_Origin.x + glyph.m_pGlyph->m_Left - pixel_left, glyph.m_Origin.y - glyph.m_pGlyph->m_Top - pixel_top, @@ -1038,7 +1036,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, if (!top.IsValid()) return false; - CFX_RetainPtr pGlyph = glyph.m_pGlyph->m_pBitmap; + RetainPtr pGlyph = glyph.m_pGlyph->m_pBitmap; int ncols = pGlyph->GetWidth(); int nrows = pGlyph->GetHeight(); if (anti_alias == FXFT_RENDER_MODE_NORMAL) { diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 36fb5ed0f9..75b0ef3eec 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -112,11 +112,11 @@ class CFX_RenderDevice { int GetRenderCaps() const { return m_RenderCaps; } int GetDeviceCaps(int id) const; CFX_Matrix GetCTM() const; - CFX_RetainPtr GetBitmap() const { return m_pBitmap; } - void SetBitmap(const CFX_RetainPtr& pBitmap) { + RetainPtr GetBitmap() const { return m_pBitmap; } + void SetBitmap(const RetainPtr& pBitmap) { m_pBitmap = pBitmap; } - bool CreateCompatibleBitmap(const CFX_RetainPtr& pDIB, + bool CreateCompatibleBitmap(const RetainPtr& pDIB, int width, int height) const; const FX_RECT& GetClipBox() const { return m_ClipBox; } @@ -148,18 +148,16 @@ class CFX_RenderDevice { return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL); } - CFX_RetainPtr GetBackDrop(); - bool GetDIBits(const CFX_RetainPtr& pBitmap, int left, int top); - bool SetDIBits(const CFX_RetainPtr& pBitmap, - int left, - int top) { + RetainPtr GetBackDrop(); + bool GetDIBits(const RetainPtr& pBitmap, int left, int top); + bool SetDIBits(const RetainPtr& pBitmap, int left, int top) { return SetDIBitsWithBlend(pBitmap, left, top, FXDIB_BLEND_NORMAL); } - bool SetDIBitsWithBlend(const CFX_RetainPtr& pBitmap, + bool SetDIBitsWithBlend(const RetainPtr& pBitmap, int left, int top, int blend_type); - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, int left, int top, int dest_width, @@ -167,32 +165,31 @@ class CFX_RenderDevice { return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width, dest_height, 0, FXDIB_BLEND_NORMAL); } - bool StretchDIBitsWithFlagsAndBlend( - const CFX_RetainPtr& pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t flags, - int blend_type); - bool SetBitMask(const CFX_RetainPtr& pBitmap, + bool StretchDIBitsWithFlagsAndBlend(const RetainPtr& pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t flags, + int blend_type); + bool SetBitMask(const RetainPtr& pBitmap, int left, int top, uint32_t color); - bool StretchBitMask(const CFX_RetainPtr& pBitmap, + bool StretchBitMask(const RetainPtr& pBitmap, int left, int top, int dest_width, int dest_height, uint32_t color); - bool StretchBitMaskWithFlags(const CFX_RetainPtr& pBitmap, + bool StretchBitMaskWithFlags(const RetainPtr& pBitmap, int left, int top, int dest_width, int dest_height, uint32_t color, uint32_t flags); - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -201,7 +198,7 @@ class CFX_RenderDevice { return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags, handle, FXDIB_BLEND_NORMAL); } - bool StartDIBitsWithBlend(const CFX_RetainPtr& pBitmap, + bool StartDIBitsWithBlend(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -267,8 +264,8 @@ class CFX_RenderDevice { #ifdef _SKIA_SUPPORT_ virtual void DebugVerifyBitmapIsPreMultiplied() const; - virtual bool SetBitsWithMask(const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + virtual bool SetBitsWithMask(const RetainPtr& pBitmap, + const RetainPtr& pMask, int left, int top, int bitmap_alpha, @@ -295,7 +292,7 @@ class CFX_RenderDevice { int blend_type); bool FillRectWithBlend(const FX_RECT* pRect, uint32_t color, int blend_type); - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; int m_Width; int m_Height; int m_bpp; diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp index 5657190161..3854949207 100644 --- a/core/fxge/dib/cfx_bitmapcomposer.cpp +++ b/core/fxge/dib/cfx_bitmapcomposer.cpp @@ -14,7 +14,7 @@ CFX_BitmapComposer::CFX_BitmapComposer() CFX_BitmapComposer::~CFX_BitmapComposer() {} -void CFX_BitmapComposer::Compose(const CFX_RetainPtr& pDest, +void CFX_BitmapComposer::Compose(const RetainPtr& pDest, const CFX_ClipRgn* pClipRgn, int bitmap_alpha, uint32_t mask_color, diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h index cc4ecb13fe..7fb3037cc1 100644 --- a/core/fxge/dib/cfx_bitmapcomposer.h +++ b/core/fxge/dib/cfx_bitmapcomposer.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_scanlinecompositor.h" #include "core/fxge/dib/ifx_scanlinecomposer.h" @@ -23,7 +23,7 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { CFX_BitmapComposer(); ~CFX_BitmapComposer() override; - void Compose(const CFX_RetainPtr& pDest, + void Compose(const RetainPtr& pDest, const CFX_ClipRgn* pClipRgn, int bitmap_alpha, uint32_t mask_color, @@ -56,7 +56,7 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { const uint8_t* scanline, const uint8_t* scan_extra_alpha); - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; CFX_UnownedPtr m_pClipRgn; FXDIB_Format m_SrcFormat; int m_DestLeft; @@ -65,7 +65,7 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { int m_DestHeight; int m_BitmapAlpha; uint32_t m_MaskColor; - CFX_RetainPtr m_pClipMask; + RetainPtr m_pClipMask; CFX_ScanlineCompositor m_Compositor; bool m_bVertical; bool m_bFlipX; diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp index 1e09708098..f649e0caea 100644 --- a/core/fxge/dib/cfx_bitmapstorer.cpp +++ b/core/fxge/dib/cfx_bitmapstorer.cpp @@ -14,11 +14,11 @@ CFX_BitmapStorer::CFX_BitmapStorer() {} CFX_BitmapStorer::~CFX_BitmapStorer() {} -CFX_RetainPtr CFX_BitmapStorer::Detach() { +RetainPtr CFX_BitmapStorer::Detach() { return std::move(m_pBitmap); } -void CFX_BitmapStorer::Replace(CFX_RetainPtr&& pBitmap) { +void CFX_BitmapStorer::Replace(RetainPtr&& pBitmap) { m_pBitmap = std::move(pBitmap); } diff --git a/core/fxge/dib/cfx_bitmapstorer.h b/core/fxge/dib/cfx_bitmapstorer.h index a574493e6e..3d3416daa1 100644 --- a/core/fxge/dib/cfx_bitmapstorer.h +++ b/core/fxge/dib/cfx_bitmapstorer.h @@ -10,8 +10,8 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/ifx_scanlinecomposer.h" #include "third_party/base/stl_util.h" @@ -30,12 +30,12 @@ class CFX_BitmapStorer : public IFX_ScanlineComposer { FXDIB_Format src_format, uint32_t* pSrcPalette) override; - CFX_RetainPtr GetBitmap() { return m_pBitmap; } - CFX_RetainPtr Detach(); - void Replace(CFX_RetainPtr&& pBitmap); + RetainPtr GetBitmap() { return m_pBitmap; } + RetainPtr Detach(); + void Replace(RetainPtr&& pBitmap); private: - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; }; #endif // CORE_FXGE_DIB_CFX_BITMAPSTORER_H_ diff --git a/core/fxge/dib/cfx_dibextractor.cpp b/core/fxge/dib/cfx_dibextractor.cpp index 325454a580..13ad461cb1 100644 --- a/core/fxge/dib/cfx_dibextractor.cpp +++ b/core/fxge/dib/cfx_dibextractor.cpp @@ -8,12 +8,12 @@ #include "core/fxge/dib/cfx_dibsource.h" -CFX_DIBExtractor::CFX_DIBExtractor(const CFX_RetainPtr& pSrc) { +CFX_DIBExtractor::CFX_DIBExtractor(const RetainPtr& pSrc) { if (!pSrc->GetBuffer()) { m_pBitmap = pSrc->Clone(nullptr); return; } - CFX_RetainPtr pOldSrc(pSrc); + RetainPtr pOldSrc(pSrc); m_pBitmap = pdfium::MakeRetain(); if (!m_pBitmap->Create(pOldSrc->GetWidth(), pOldSrc->GetHeight(), pOldSrc->GetFormat(), pOldSrc->GetBuffer())) { diff --git a/core/fxge/dib/cfx_dibextractor.h b/core/fxge/dib/cfx_dibextractor.h index 25d80ecb94..b6c27a7bd7 100644 --- a/core/fxge/dib/cfx_dibextractor.h +++ b/core/fxge/dib/cfx_dibextractor.h @@ -7,20 +7,20 @@ #ifndef CORE_FXGE_DIB_CFX_DIBEXTRACTOR_H_ #define CORE_FXGE_DIB_CFX_DIBEXTRACTOR_H_ -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibitmap.h" class CFX_DIBSource; class CFX_DIBExtractor { public: - explicit CFX_DIBExtractor(const CFX_RetainPtr& pSrc); + explicit CFX_DIBExtractor(const RetainPtr& pSrc); ~CFX_DIBExtractor(); - CFX_RetainPtr GetBitmap() { return m_pBitmap; } + RetainPtr GetBitmap() { return m_pBitmap; } private: - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; }; #endif // CORE_FXGE_DIB_CFX_DIBEXTRACTOR_H_ diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index fd6defece2..8e105937ee 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -81,7 +81,7 @@ bool CFX_DIBitmap::Create(int width, return false; } -bool CFX_DIBitmap::Copy(const CFX_RetainPtr& pSrc) { +bool CFX_DIBitmap::Copy(const RetainPtr& pSrc) { if (m_pBuffer) return false; @@ -105,7 +105,7 @@ const uint8_t* CFX_DIBitmap::GetScanline(int line) const { return m_pBuffer.Get() ? m_pBuffer.Get() + line * m_Pitch : nullptr; } -void CFX_DIBitmap::TakeOver(CFX_RetainPtr&& pSrcBitmap) { +void CFX_DIBitmap::TakeOver(RetainPtr&& pSrcBitmap) { m_pBuffer = std::move(pSrcBitmap->m_pBuffer); m_pPalette = std::move(pSrcBitmap->m_pPalette); m_pAlphaMask = pSrcBitmap->m_pAlphaMask; @@ -180,14 +180,13 @@ void CFX_DIBitmap::Clear(uint32_t color) { } } -bool CFX_DIBitmap::TransferBitmap( - int dest_left, - int dest_top, - int width, - int height, - const CFX_RetainPtr& pSrcBitmap, - int src_left, - int src_top) { +bool CFX_DIBitmap::TransferBitmap(int dest_left, + int dest_top, + int width, + int height, + const RetainPtr& pSrcBitmap, + int src_left, + int src_top) { if (!m_pBuffer) return false; @@ -243,12 +242,12 @@ bool CFX_DIBitmap::TransferBitmap( } bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, FXDIB_Channel srcChannel) { if (!m_pBuffer) return false; - CFX_RetainPtr pSrcClone = pSrcBitmap; + RetainPtr pSrcClone = pSrcBitmap; int srcOffset; if (srcChannel == FXDIB_Alpha) { if (!pSrcBitmap->HasAlpha() && !pSrcBitmap->IsAlphaMask()) @@ -308,7 +307,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, destOffset = g_ChannelOffset[destChannel]; } if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { - CFX_RetainPtr pAlphaMask = pSrcClone->m_pAlphaMask; + RetainPtr pAlphaMask = pSrcClone->m_pAlphaMask; if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Height) { if (pAlphaMask) { @@ -321,14 +320,14 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, srcOffset = 0; } else if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Height) { - CFX_RetainPtr pSrcMatched = + RetainPtr pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height, 0, nullptr); if (!pSrcMatched) return false; pSrcClone = std::move(pSrcMatched); } - CFX_RetainPtr pDst(this); + RetainPtr pDst(this); if (destChannel == FXDIB_Alpha && m_pAlphaMask) { pDst = m_pAlphaMask; destOffset = 0; @@ -406,8 +405,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) { return true; } -bool CFX_DIBitmap::MultiplyAlpha( - const CFX_RetainPtr& pSrcBitmap) { +bool CFX_DIBitmap::MultiplyAlpha(const RetainPtr& pSrcBitmap) { if (!m_pBuffer) return false; @@ -418,7 +416,7 @@ bool CFX_DIBitmap::MultiplyAlpha( if (!IsAlphaMask() && !HasAlpha()) return LoadChannel(FXDIB_Alpha, pSrcBitmap, FXDIB_Alpha); - CFX_RetainPtr pSrcClone = pSrcBitmap.As(); + RetainPtr pSrcClone = pSrcBitmap.As(); if (pSrcBitmap->GetWidth() != m_Width || pSrcBitmap->GetHeight() != m_Height) { pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height, 0, nullptr); @@ -834,17 +832,16 @@ bool CFX_DIBitmap::CalculatePitchAndSize(int height, return true; } -bool CFX_DIBitmap::CompositeBitmap( - int dest_left, - int dest_top, - int width, - int height, - const CFX_RetainPtr& pSrcBitmap, - int src_left, - int src_top, - int blend_type, - const CFX_ClipRgn* pClipRgn, - bool bRgbByteOrder) { +bool CFX_DIBitmap::CompositeBitmap(int dest_left, + int dest_top, + int width, + int height, + const RetainPtr& pSrcBitmap, + int src_left, + int src_top, + int blend_type, + const CFX_ClipRgn* pClipRgn, + bool bRgbByteOrder) { if (!m_pBuffer) return false; @@ -858,7 +855,7 @@ bool CFX_DIBitmap::CompositeBitmap( if (width == 0 || height == 0) { return true; } - CFX_RetainPtr pClipMask; + RetainPtr pClipMask; FX_RECT clip_box; if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); @@ -874,7 +871,7 @@ bool CFX_DIBitmap::CompositeBitmap( int dest_Bpp = m_bpp / 8; int src_Bpp = pSrcBitmap->GetBPP() / 8; bool bRgb = src_Bpp > 1 && !pSrcBitmap->IsCmykImage(); - CFX_RetainPtr pSrcAlphaMask = pSrcBitmap->m_pAlphaMask; + RetainPtr pSrcAlphaMask = pSrcBitmap->m_pAlphaMask; for (int row = 0; row < height; row++) { uint8_t* dest_scan = m_pBuffer.Get() + (dest_top + row) * m_Pitch + dest_left * dest_Bpp; @@ -910,7 +907,7 @@ bool CFX_DIBitmap::CompositeMask(int dest_left, int dest_top, int width, int height, - const CFX_RetainPtr& pMask, + const RetainPtr& pMask, uint32_t color, int src_left, int src_top, @@ -936,7 +933,7 @@ bool CFX_DIBitmap::CompositeMask(int dest_left, if (src_alpha == 0) return true; - CFX_RetainPtr pClipMask; + RetainPtr pClipMask; FX_RECT clip_box; if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); @@ -1197,7 +1194,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) { if (!dest_buf) return false; - CFX_RetainPtr pAlphaMask; + RetainPtr pAlphaMask; if (dest_format == FXDIB_Argb) { memset(dest_buf.get(), 0xff, dest_pitch * m_Height + 4); if (m_pAlphaMask) { @@ -1226,7 +1223,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) { } } bool ret = false; - CFX_RetainPtr holder(this); + RetainPtr holder(this); std::unique_ptr pal_8bpp; ret = ConvertBuffer(dest_format, dest_buf.get(), dest_pitch, m_Width, m_Height, holder, 0, 0, &pal_8bpp); diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h index 79eeaeb273..7240829773 100644 --- a/core/fxge/dib/cfx_dibitmap.h +++ b/core/fxge/dib/cfx_dibitmap.h @@ -7,16 +7,16 @@ #ifndef CORE_FXGE_DIB_CFX_DIBITMAP_H_ #define CORE_FXGE_DIB_CFX_DIBITMAP_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/maybe_owned.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibsource.h" #include "third_party/base/stl_util.h" class CFX_DIBitmap : public CFX_DIBSource { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CFX_DIBitmap() override; @@ -26,7 +26,7 @@ class CFX_DIBitmap : public CFX_DIBSource { uint8_t* pBuffer = nullptr, uint32_t pitch = 0); - bool Copy(const CFX_RetainPtr& pSrc); + bool Copy(const RetainPtr& pSrc); // CFX_DIBSource uint8_t* GetBuffer() const override; @@ -39,7 +39,7 @@ class CFX_DIBitmap : public CFX_DIBSource { int clip_left, int clip_width) const override; - void TakeOver(CFX_RetainPtr&& pSrcBitmap); + void TakeOver(RetainPtr&& pSrcBitmap); bool ConvertFormat(FXDIB_Format format); void Clear(uint32_t color); @@ -47,18 +47,18 @@ class CFX_DIBitmap : public CFX_DIBSource { void SetPixel(int x, int y, uint32_t color); bool LoadChannel(FXDIB_Channel destChannel, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, FXDIB_Channel srcChannel); bool LoadChannel(FXDIB_Channel destChannel, int value); bool MultiplyAlpha(int alpha); - bool MultiplyAlpha(const CFX_RetainPtr& pAlphaMask); + bool MultiplyAlpha(const RetainPtr& pAlphaMask); bool TransferBitmap(int dest_left, int dest_top, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top); @@ -66,7 +66,7 @@ class CFX_DIBitmap : public CFX_DIBSource { int dest_top, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top, int blend_type = FXDIB_BLEND_NORMAL, @@ -77,7 +77,7 @@ class CFX_DIBitmap : public CFX_DIBSource { int dest_top, int width, int height, - const CFX_RetainPtr& pMask, + const RetainPtr& pMask, uint32_t color, int src_left, int src_top, diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp index c0e7841b89..9382917286 100644 --- a/core/fxge/dib/cfx_dibsource.cpp +++ b/core/fxge/dib/cfx_dibsource.cpp @@ -24,7 +24,7 @@ namespace { class CFX_Palette { public: - explicit CFX_Palette(const CFX_RetainPtr& pBitmap); + explicit CFX_Palette(const RetainPtr& pBitmap); ~CFX_Palette(); const uint32_t* GetPalette() { return m_Palette.data(); } @@ -64,7 +64,7 @@ void Obtain_Pal(std::pair* luts, } } -CFX_Palette::CFX_Palette(const CFX_RetainPtr& pBitmap) +CFX_Palette::CFX_Palette(const RetainPtr& pBitmap) : m_Palette(256), m_Luts(4096), m_lut(0) { int bpp = pBitmap->GetBPP() / 8; int width = pBitmap->GetWidth(); @@ -102,7 +102,7 @@ bool ConvertBuffer_1bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { uint8_t set_gray, reset_gray; @@ -126,7 +126,7 @@ bool ConvertBuffer_8bppMask2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { for (int row = 0; row < height; row++) { @@ -141,7 +141,7 @@ bool ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { uint32_t* src_plt = pSrcBitmap->GetPalette(); @@ -188,7 +188,7 @@ bool ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { uint32_t* src_plt = pSrcBitmap->GetPalette(); @@ -220,14 +220,13 @@ bool ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, return true; } -bool ConvertBuffer_RgbOrCmyk2Gray( - uint8_t* dest_buf, - int dest_pitch, - int width, - int height, - const CFX_RetainPtr& pSrcBitmap, - int src_left, - int src_top) { +bool ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf, + int dest_pitch, + int width, + int height, + const RetainPtr& pSrcBitmap, + int src_left, + int src_top) { int Bpp = pSrcBitmap->GetBPP() / 8; if (pSrcBitmap->IsCmykImage()) { for (int row = 0; row < height; row++) { @@ -265,7 +264,7 @@ void ConvertBuffer_IndexCopy(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { if (pSrcBitmap->GetBPP() == 1) { @@ -296,7 +295,7 @@ bool ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top, uint32_t* dst_plt) { @@ -324,7 +323,7 @@ bool ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top, uint32_t* dst_plt) { @@ -387,7 +386,7 @@ bool ConvertBuffer_1bppMask2Rgb(FXDIB_Format dst_format, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { int comps = (dst_format & 0xff) / 8; @@ -418,7 +417,7 @@ bool ConvertBuffer_8bppMask2Rgb(FXDIB_Format dst_format, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { int comps = (dst_format & 0xff) / 8; @@ -442,7 +441,7 @@ bool ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { int comps = (dst_format & 0xff) / 8; @@ -494,7 +493,7 @@ bool ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { int comps = (dst_format & 0xff) / 8; @@ -534,14 +533,13 @@ bool ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, return true; } -bool ConvertBuffer_24bppRgb2Rgb24( - uint8_t* dest_buf, - int dest_pitch, - int width, - int height, - const CFX_RetainPtr& pSrcBitmap, - int src_left, - int src_top) { +bool ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf, + int dest_pitch, + int width, + int height, + const RetainPtr& pSrcBitmap, + int src_left, + int src_top) { for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; const uint8_t* src_scan = @@ -551,14 +549,13 @@ bool ConvertBuffer_24bppRgb2Rgb24( return true; } -bool ConvertBuffer_32bppRgb2Rgb24( - uint8_t* dest_buf, - int dest_pitch, - int width, - int height, - const CFX_RetainPtr& pSrcBitmap, - int src_left, - int src_top) { +bool ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf, + int dest_pitch, + int width, + int height, + const RetainPtr& pSrcBitmap, + int src_left, + int src_top) { for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; const uint8_t* src_scan = @@ -577,7 +574,7 @@ bool ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { int comps = pSrcBitmap->GetBPP() / 8; @@ -596,14 +593,13 @@ bool ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, return true; } -bool ConvertBuffer_32bppCmyk2Rgb32( - uint8_t* dest_buf, - int dest_pitch, - int width, - int height, - const CFX_RetainPtr& pSrcBitmap, - int src_left, - int src_top) { +bool ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf, + int dest_pitch, + int width, + int height, + const RetainPtr& pSrcBitmap, + int src_left, + int src_top) { for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; const uint8_t* src_scan = @@ -633,7 +629,7 @@ bool CFX_DIBSource::SkipToScanline(int line, IFX_PauseIndicator* pPause) const { return false; } -CFX_RetainPtr CFX_DIBSource::Clone(const FX_RECT* pClip) const { +RetainPtr CFX_DIBSource::Clone(const FX_RECT* pClip) const { FX_RECT rect(0, 0, m_Width, m_Height); if (pClip) { rect.Intersect(*pClip); @@ -829,7 +825,7 @@ void CFX_DIBSource::GetPalette(uint32_t* pal, int alpha) const { } } -CFX_RetainPtr CFX_DIBSource::CloneAlphaMask() const { +RetainPtr CFX_DIBSource::CloneAlphaMask() const { ASSERT(GetFormat() == FXDIB_Argb); FX_RECT rect(0, 0, m_Width, m_Height); auto pMask = pdfium::MakeRetain(); @@ -848,7 +844,7 @@ CFX_RetainPtr CFX_DIBSource::CloneAlphaMask() const { return pMask; } -bool CFX_DIBSource::SetAlphaMask(const CFX_RetainPtr& pAlphaMask, +bool CFX_DIBSource::SetAlphaMask(const RetainPtr& pAlphaMask, const FX_RECT* pClip) { if (!HasAlpha() || GetFormat() == FXDIB_Argb) return false; @@ -876,8 +872,8 @@ bool CFX_DIBSource::SetAlphaMask(const CFX_RetainPtr& pAlphaMask, return true; } -CFX_RetainPtr CFX_DIBSource::FlipImage(bool bXFlip, - bool bYFlip) const { +RetainPtr CFX_DIBSource::FlipImage(bool bXFlip, + bool bYFlip) const { auto pFlipped = pdfium::MakeRetain(); if (!pFlipped->Create(m_Width, m_Height, GetFormat())) return nullptr; @@ -948,8 +944,7 @@ CFX_RetainPtr CFX_DIBSource::FlipImage(bool bXFlip, return pFlipped; } -CFX_RetainPtr CFX_DIBSource::CloneConvert( - FXDIB_Format dest_format) { +RetainPtr CFX_DIBSource::CloneConvert(FXDIB_Format dest_format) { if (dest_format == GetFormat()) return Clone(nullptr); @@ -957,7 +952,7 @@ CFX_RetainPtr CFX_DIBSource::CloneConvert( if (!pClone->Create(m_Width, m_Height, dest_format)) return nullptr; - CFX_RetainPtr pSrcAlpha; + RetainPtr pSrcAlpha; if (HasAlpha()) { if (GetFormat() == FXDIB_Argb) pSrcAlpha = CloneAlphaMask(); @@ -979,7 +974,7 @@ CFX_RetainPtr CFX_DIBSource::CloneConvert( if (!ret) return nullptr; - CFX_RetainPtr holder(this); + RetainPtr holder(this); std::unique_ptr pal_8bpp; if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), m_Width, m_Height, holder, 0, 0, &pal_8bpp)) { @@ -991,8 +986,7 @@ CFX_RetainPtr CFX_DIBSource::CloneConvert( return pClone; } -CFX_RetainPtr CFX_DIBSource::SwapXY(bool bXFlip, - bool bYFlip) const { +RetainPtr CFX_DIBSource::SwapXY(bool bXFlip, bool bYFlip) const { FX_RECT dest_clip(0, 0, m_Height, m_Width); if (dest_clip.IsEmpty()) return nullptr; @@ -1086,11 +1080,11 @@ CFX_RetainPtr CFX_DIBSource::SwapXY(bool bXFlip, return pTransBitmap; } -CFX_RetainPtr CFX_DIBSource::TransformTo( +RetainPtr CFX_DIBSource::TransformTo( const CFX_Matrix* pDestMatrix, int* result_left, int* result_top) { - CFX_RetainPtr holder(this); + RetainPtr holder(this); CFX_ImageTransformer transformer(holder, pDestMatrix, 0, nullptr); transformer.Continue(nullptr); *result_left = transformer.result().left; @@ -1098,11 +1092,11 @@ CFX_RetainPtr CFX_DIBSource::TransformTo( return transformer.DetachBitmap(); } -CFX_RetainPtr CFX_DIBSource::StretchTo(int dest_width, - int dest_height, - uint32_t flags, - const FX_RECT* pClip) { - CFX_RetainPtr holder(this); +RetainPtr CFX_DIBSource::StretchTo(int dest_width, + int dest_height, + uint32_t flags, + const FX_RECT* pClip) { + RetainPtr holder(this); FX_RECT clip_rect(0, 0, abs(dest_width), abs(dest_height)); if (pClip) clip_rect.Intersect(*pClip); @@ -1129,7 +1123,7 @@ bool CFX_DIBSource::ConvertBuffer( int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top, std::unique_ptr* p_pal) { diff --git a/core/fxge/dib/cfx_dibsource.h b/core/fxge/dib/cfx_dibsource.h index 2315318ccb..e2cdfa61ad 100644 --- a/core/fxge/dib/cfx_dibsource.h +++ b/core/fxge/dib/cfx_dibsource.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_memory.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" enum FXDIB_Channel { @@ -29,7 +29,7 @@ class CFX_ClipRgn; class CFX_DIBitmap; class IFX_PauseIndicator; -class CFX_DIBSource : public CFX_Retainable { +class CFX_DIBSource : public Retainable { public: ~CFX_DIBSource() override; @@ -72,22 +72,22 @@ class CFX_DIBSource : public CFX_Retainable { // Copies into internally-owned palette. void SetPalette(const uint32_t* pSrcPal); - CFX_RetainPtr Clone(const FX_RECT* pClip) const; - CFX_RetainPtr CloneConvert(FXDIB_Format format); - CFX_RetainPtr StretchTo(int dest_width, - int dest_height, - uint32_t flags, - const FX_RECT* pClip); - CFX_RetainPtr TransformTo(const CFX_Matrix* pMatrix, - int* left, - int* top); - CFX_RetainPtr SwapXY(bool bXFlip, bool bYFlip) const; - CFX_RetainPtr FlipImage(bool bXFlip, bool bYFlip) const; + RetainPtr Clone(const FX_RECT* pClip) const; + RetainPtr CloneConvert(FXDIB_Format format); + RetainPtr StretchTo(int dest_width, + int dest_height, + uint32_t flags, + const FX_RECT* pClip); + RetainPtr TransformTo(const CFX_Matrix* pMatrix, + int* left, + int* top); + RetainPtr SwapXY(bool bXFlip, bool bYFlip) const; + RetainPtr FlipImage(bool bXFlip, bool bYFlip) const; - CFX_RetainPtr CloneAlphaMask() const; + RetainPtr CloneAlphaMask() const; // Copies into internally-owned mask. - bool SetAlphaMask(const CFX_RetainPtr& pAlphaMask, + bool SetAlphaMask(const RetainPtr& pAlphaMask, const FX_RECT* pClip); void GetOverlapRect(int& dest_left, @@ -104,7 +104,7 @@ class CFX_DIBSource : public CFX_Retainable { void DebugVerifyBitmapIsPreMultiplied(void* buffer) const; #endif - CFX_RetainPtr m_pAlphaMask; + RetainPtr m_pAlphaMask; protected: CFX_DIBSource(); @@ -114,7 +114,7 @@ class CFX_DIBSource : public CFX_Retainable { int dest_pitch, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top, std::unique_ptr* pal); diff --git a/core/fxge/dib/cfx_filtereddib.cpp b/core/fxge/dib/cfx_filtereddib.cpp index 2d6edd0d60..96fc8062a0 100644 --- a/core/fxge/dib/cfx_filtereddib.cpp +++ b/core/fxge/dib/cfx_filtereddib.cpp @@ -12,7 +12,7 @@ CFX_FilteredDIB::CFX_FilteredDIB() {} CFX_FilteredDIB::~CFX_FilteredDIB() {} -void CFX_FilteredDIB::LoadSrc(const CFX_RetainPtr& pSrc) { +void CFX_FilteredDIB::LoadSrc(const RetainPtr& pSrc) { m_pSrc = pSrc; m_Width = pSrc->GetWidth(); m_Height = pSrc->GetHeight(); diff --git a/core/fxge/dib/cfx_filtereddib.h b/core/fxge/dib/cfx_filtereddib.h index 3a16bb0750..e998c7169a 100644 --- a/core/fxge/dib/cfx_filtereddib.h +++ b/core/fxge/dib/cfx_filtereddib.h @@ -9,13 +9,13 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibsource.h" class CFX_FilteredDIB : public CFX_DIBSource { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CFX_FilteredDIB() override; @@ -28,7 +28,7 @@ class CFX_FilteredDIB : public CFX_DIBSource { int pixels, int Bpp) const = 0; - void LoadSrc(const CFX_RetainPtr& pSrc); + void LoadSrc(const RetainPtr& pSrc); protected: CFX_FilteredDIB(); @@ -43,7 +43,7 @@ class CFX_FilteredDIB : public CFX_DIBSource { int clip_left, int clip_width) const override; - CFX_RetainPtr m_pSrc; + RetainPtr m_pSrc; mutable std::vector m_Scanline; }; diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp index 2330fe0587..658d363c89 100644 --- a/core/fxge/dib/cfx_imagerenderer.cpp +++ b/core/fxge/dib/cfx_imagerenderer.cpp @@ -13,15 +13,14 @@ #include "core/fxge/dib/cfx_imagetransformer.h" #include "third_party/base/ptr_util.h" -CFX_ImageRenderer::CFX_ImageRenderer( - const CFX_RetainPtr& pDevice, - const CFX_ClipRgn* pClipRgn, - const CFX_RetainPtr& pSource, - int bitmap_alpha, - uint32_t mask_color, - const CFX_Matrix* pMatrix, - uint32_t dib_flags, - bool bRgbByteOrder) +CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr& pDevice, + const CFX_ClipRgn* pClipRgn, + const RetainPtr& pSource, + int bitmap_alpha, + uint32_t mask_color, + const CFX_Matrix* pMatrix, + uint32_t dib_flags, + bool bRgbByteOrder) : m_pDevice(pDevice), m_pClipRgn(pClipRgn), m_Matrix(*pMatrix), @@ -96,7 +95,7 @@ bool CFX_ImageRenderer::Continue(IFX_PauseIndicator* pPause) { if (m_pTransformer->Continue(pPause)) return true; - CFX_RetainPtr pBitmap = m_pTransformer->DetachBitmap(); + RetainPtr pBitmap = m_pTransformer->DetachBitmap(); if (!pBitmap || !pBitmap->GetBuffer()) return false; diff --git a/core/fxge/dib/cfx_imagerenderer.h b/core/fxge/dib/cfx_imagerenderer.h index 068fe34a89..8a441fcea3 100644 --- a/core/fxge/dib/cfx_imagerenderer.h +++ b/core/fxge/dib/cfx_imagerenderer.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_bitmapcomposer.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_dibsource.h" @@ -23,9 +23,9 @@ class CFX_ImageStretcher; class CFX_ImageRenderer { public: - CFX_ImageRenderer(const CFX_RetainPtr& pDevice, + CFX_ImageRenderer(const RetainPtr& pDevice, const CFX_ClipRgn* pClipRgn, - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, int bitmap_alpha, uint32_t mask_color, const CFX_Matrix* pMatrix, @@ -36,7 +36,7 @@ class CFX_ImageRenderer { bool Continue(IFX_PauseIndicator* pPause); private: - const CFX_RetainPtr m_pDevice; + const RetainPtr m_pDevice; const CFX_UnownedPtr m_pClipRgn; const CFX_Matrix m_Matrix; const int m_BitmapAlpha; diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp index 0b7c542b30..03518c688e 100644 --- a/core/fxge/dib/cfx_imagestretcher.cpp +++ b/core/fxge/dib/cfx_imagestretcher.cpp @@ -42,13 +42,12 @@ std::tuple CmykDecode(const uint32_t cmyk) { } // namespace -CFX_ImageStretcher::CFX_ImageStretcher( - IFX_ScanlineComposer* pDest, - const CFX_RetainPtr& pSource, - int dest_width, - int dest_height, - const FX_RECT& bitmap_rect, - uint32_t flags) +CFX_ImageStretcher::CFX_ImageStretcher(IFX_ScanlineComposer* pDest, + const RetainPtr& pSource, + int dest_width, + int dest_height, + const FX_RECT& bitmap_rect, + uint32_t flags) : m_pDest(pDest), m_pSource(pSource), m_Flags(flags), diff --git a/core/fxge/dib/cfx_imagestretcher.h b/core/fxge/dib/cfx_imagestretcher.h index 84411015dd..5c696b79a7 100644 --- a/core/fxge/dib/cfx_imagestretcher.h +++ b/core/fxge/dib/cfx_imagestretcher.h @@ -9,10 +9,10 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_memory.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/ifx_scanlinecomposer.h" #include "core/fxge/fx_dib.h" @@ -22,7 +22,7 @@ class IFX_PauseIndicator; class CFX_ImageStretcher { public: CFX_ImageStretcher(IFX_ScanlineComposer* pDest, - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, int dest_width, int dest_height, const FX_RECT& bitmap_rect, @@ -32,7 +32,7 @@ class CFX_ImageStretcher { bool Start(); bool Continue(IFX_PauseIndicator* pPause); - CFX_RetainPtr source() { return m_pSource; } + RetainPtr source() { return m_pSource; } private: bool StartQuickStretch(); @@ -41,7 +41,7 @@ class CFX_ImageStretcher { bool ContinueStretch(IFX_PauseIndicator* pPause); CFX_UnownedPtr const m_pDest; - CFX_RetainPtr m_pSource; + RetainPtr m_pSource; std::unique_ptr m_pStretchEngine; std::unique_ptr m_pScanline; std::unique_ptr m_pMaskScanline; diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index e64a2645da..51b75350e6 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -101,7 +101,7 @@ void bicubic_get_pos_weight(int pos_pixel[], v_w[3] = SDP_Table[512 - res_y]; } -FXDIB_Format GetTransformedFormat(const CFX_RetainPtr& pDrc) { +FXDIB_Format GetTransformedFormat(const RetainPtr& pDrc) { FXDIB_Format format = pDrc->GetFormat(); if (pDrc->IsAlphaMask()) { format = FXDIB_8bppMask; @@ -177,11 +177,10 @@ class CFX_BilinearMatrix : public CPDF_FixedMatrix { } // namespace -CFX_ImageTransformer::CFX_ImageTransformer( - const CFX_RetainPtr& pSrc, - const CFX_Matrix* pMatrix, - int flags, - const FX_RECT* pClip) +CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr& pSrc, + const CFX_Matrix* pMatrix, + int flags, + const FX_RECT* pClip) : m_pSrc(pSrc), m_pMatrix(pMatrix), m_pClip(pClip), @@ -818,6 +817,6 @@ bool CFX_ImageTransformer::Continue(IFX_PauseIndicator* pPause) { return false; } -CFX_RetainPtr CFX_ImageTransformer::DetachBitmap() { +RetainPtr CFX_ImageTransformer::DetachBitmap() { return m_Storer.Detach(); } diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h index 0524a0c713..65c874585e 100644 --- a/core/fxge/dib/cfx_imagetransformer.h +++ b/core/fxge/dib/cfx_imagetransformer.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_bitmapstorer.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_dibsource.h" @@ -20,7 +20,7 @@ class CFX_ImageStretcher; class CFX_ImageTransformer { public: - CFX_ImageTransformer(const CFX_RetainPtr& pSrc, + CFX_ImageTransformer(const RetainPtr& pSrc, const CFX_Matrix* pMatrix, int flags, const FX_RECT* pClip); @@ -29,10 +29,10 @@ class CFX_ImageTransformer { bool Continue(IFX_PauseIndicator* pPause); const FX_RECT& result() const { return m_result; } - CFX_RetainPtr DetachBitmap(); + RetainPtr DetachBitmap(); private: - const CFX_RetainPtr m_pSrc; + const RetainPtr m_pSrc; CFX_UnownedPtr const m_pMatrix; const FX_RECT* const m_pClip; FX_RECT m_StretchClip; diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp index 4822d32b83..6803959730 100644 --- a/core/fxge/dib/cstretchengine.cpp +++ b/core/fxge/dib/cstretchengine.cpp @@ -222,7 +222,7 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, int dest_width, int dest_height, const FX_RECT& clip_rect, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int flags) { m_State = 0; m_DestFormat = dest_format; diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h index 14c0975023..bdf79004a1 100644 --- a/core/fxge/dib/cstretchengine.h +++ b/core/fxge/dib/cstretchengine.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" class IFX_PauseIndicator; @@ -24,7 +24,7 @@ class CStretchEngine { int dest_width, int dest_height, const FX_RECT& clip_rect, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int flags); ~CStretchEngine(); @@ -68,7 +68,7 @@ class CStretchEngine { std::vector m_DestScanline; std::vector m_DestMaskScanline; FX_RECT m_SrcClip; - CFX_RetainPtr m_pSource; + RetainPtr m_pSource; uint32_t* m_pSrcPalette; int m_SrcWidth; int m_SrcHeight; diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 021efee7d9..89cda1ee5d 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -100,8 +100,7 @@ class CFX_Font { CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); } #ifdef PDF_ENABLE_XFA - bool LoadFile(const CFX_RetainPtr& pFile, - int nFaceIndex); + bool LoadFile(const RetainPtr& pFile, int nFaceIndex); bool LoadClone(const CFX_Font* pFont); void SetFace(FXFT_Face face); @@ -205,7 +204,7 @@ class CFX_GlyphBitmap { int m_Top; int m_Left; - CFX_RetainPtr m_pBitmap; + RetainPtr m_pBitmap; }; inline CFX_GlyphBitmap::CFX_GlyphBitmap() diff --git a/core/fxge/ifx_renderdevicedriver.cpp b/core/fxge/ifx_renderdevicedriver.cpp index 378c9b89ef..669aadf0d8 100644 --- a/core/fxge/ifx_renderdevicedriver.cpp +++ b/core/fxge/ifx_renderdevicedriver.cpp @@ -46,15 +46,14 @@ bool IFX_RenderDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, return false; } -bool IFX_RenderDeviceDriver::GetDIBits( - const CFX_RetainPtr& pBitmap, - int left, - int top) { +bool IFX_RenderDeviceDriver::GetDIBits(const RetainPtr& pBitmap, + int left, + int top) { return false; } -CFX_RetainPtr IFX_RenderDeviceDriver::GetBackDrop() { - return CFX_RetainPtr(); +RetainPtr IFX_RenderDeviceDriver::GetBackDrop() { + return RetainPtr(); } bool IFX_RenderDeviceDriver::ContinueDIBits(CFX_ImageRenderer* handle, @@ -86,8 +85,8 @@ bool IFX_RenderDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, } bool IFX_RenderDeviceDriver::SetBitsWithMask( - const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + const RetainPtr& pBitmap, + const RetainPtr& pMask, int left, int top, int bitmap_alpha, diff --git a/core/fxge/ifx_renderdevicedriver.h b/core/fxge/ifx_renderdevicedriver.h index cdea22e2db..e9498bdf22 100644 --- a/core/fxge/ifx_renderdevicedriver.h +++ b/core/fxge/ifx_renderdevicedriver.h @@ -9,9 +9,9 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" class CFX_DIBitmap; class CFX_DIBSource; @@ -60,17 +60,17 @@ class IFX_RenderDeviceDriver { int blend_type); virtual bool GetClipBox(FX_RECT* pRect) = 0; - virtual bool GetDIBits(const CFX_RetainPtr& pBitmap, + virtual bool GetDIBits(const RetainPtr& pBitmap, int left, int top); - virtual CFX_RetainPtr GetBackDrop(); - virtual bool SetDIBits(const CFX_RetainPtr& pBitmap, + virtual RetainPtr GetBackDrop(); + virtual bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int dest_left, int dest_top, int blend_type) = 0; - virtual bool StretchDIBits(const CFX_RetainPtr& pBitmap, + virtual bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -79,7 +79,7 @@ class IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) = 0; - virtual bool StartDIBits(const CFX_RetainPtr& pBitmap, + virtual bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -101,8 +101,8 @@ class IFX_RenderDeviceDriver { const FX_RECT& clip_rect, int alpha, bool bAlphaMode); - virtual bool SetBitsWithMask(const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + virtual bool SetBitsWithMask(const RetainPtr& pBitmap, + const RetainPtr& pMask, int left, int top, int bitmap_alpha, diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 8ca7808df3..fe9fd1a852 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -54,12 +54,12 @@ namespace { #ifdef _SKIA_SUPPORT_PATHS_ -void RgbByteOrderTransferBitmap(const CFX_RetainPtr& pBitmap, +void RgbByteOrderTransferBitmap(const RetainPtr& pBitmap, int dest_left, int dest_top, int width, int height, - const CFX_RetainPtr& pSrcBitmap, + const RetainPtr& pSrcBitmap, int src_left, int src_top) { if (!pBitmap) @@ -262,8 +262,8 @@ void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) {} #endif // DRAW_SKIA_CLIP #ifdef _SKIA_SUPPORT_ -static void DebugValidate(const CFX_RetainPtr& bitmap, - const CFX_RetainPtr& device) { +static void DebugValidate(const RetainPtr& bitmap, + const RetainPtr& device) { if (bitmap) { SkASSERT(bitmap->GetBPP() == 8 || bitmap->GetBPP() == 32); if (bitmap->GetBPP() == 32) { @@ -564,7 +564,7 @@ void SetBitmapPaint(bool isAlphaMask, paint->setAlpha(bitmap_alpha); } -bool Upsample(const CFX_RetainPtr& pSource, +bool Upsample(const RetainPtr& pSource, std::unique_ptr& dst8Storage, std::unique_ptr& dst32Storage, SkBitmap* skBitmap, @@ -1492,9 +1492,9 @@ void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, } CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, + const RetainPtr& pOriDevice, bool bGroupKnockout) : m_pBitmap(pBitmap), m_pOriDevice(pOriDevice), @@ -2179,7 +2179,7 @@ bool CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) { return true; } -bool CFX_SkiaDeviceDriver::GetDIBits(const CFX_RetainPtr& pBitmap, +bool CFX_SkiaDeviceDriver::GetDIBits(const RetainPtr& pBitmap, int left, int top) { if (!m_pBitmap) @@ -2216,7 +2216,7 @@ bool CFX_SkiaDeviceDriver::GetDIBits(const CFX_RetainPtr& pBitmap, m_pBitmap->UnPreMultiply(); FX_RECT rect(left, top, left + pBitmap->GetWidth(), top + pBitmap->GetHeight()); - CFX_RetainPtr pBack; + RetainPtr pBack; if (m_pOriDevice) { pBack = m_pOriDevice->Clone(&rect); if (!pBack) @@ -2244,17 +2244,16 @@ bool CFX_SkiaDeviceDriver::GetDIBits(const CFX_RetainPtr& pBitmap, #endif // _SKIA_SUPPORT_PATHS_ } -CFX_RetainPtr CFX_SkiaDeviceDriver::GetBackDrop() { +RetainPtr CFX_SkiaDeviceDriver::GetBackDrop() { return m_pOriDevice; } -bool CFX_SkiaDeviceDriver::SetDIBits( - const CFX_RetainPtr& pBitmap, - uint32_t argb, - const FX_RECT* pSrcRect, - int left, - int top, - int blend_type) { +bool CFX_SkiaDeviceDriver::SetDIBits(const RetainPtr& pBitmap, + uint32_t argb, + const FX_RECT* pSrcRect, + int left, + int top, + int blend_type) { if (!m_pBitmap || !m_pBitmap->GetBuffer()) return true; @@ -2280,7 +2279,7 @@ bool CFX_SkiaDeviceDriver::SetDIBits( } bool CFX_SkiaDeviceDriver::StretchDIBits( - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, uint32_t argb, int dest_left, int dest_top, @@ -2332,7 +2331,7 @@ bool CFX_SkiaDeviceDriver::StretchDIBits( } bool CFX_SkiaDeviceDriver::StartDIBits( - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, int bitmap_alpha, uint32_t argb, const CFX_Matrix* pMatrix, @@ -2408,7 +2407,7 @@ bool CFX_SkiaDeviceDriver::ContinueDIBits(CFX_ImageRenderer* handle, #if defined _SKIA_SUPPORT_ void CFX_SkiaDeviceDriver::PreMultiply( - const CFX_RetainPtr& pDIBitmap) { + const RetainPtr& pDIBitmap) { pDIBitmap->PreMultiply(); } #endif // _SKIA_SUPPORT_ @@ -2465,8 +2464,8 @@ void CFX_DIBitmap::UnPreMultiply() { #ifdef _SKIA_SUPPORT_ bool CFX_SkiaDeviceDriver::DrawBitsWithMask( - const CFX_RetainPtr& pSource, - const CFX_RetainPtr& pMask, + const RetainPtr& pSource, + const RetainPtr& pMask, int bitmap_alpha, const CFX_Matrix* pMatrix, int blend_type) { @@ -2506,8 +2505,8 @@ bool CFX_SkiaDeviceDriver::DrawBitsWithMask( } bool CFX_SkiaDeviceDriver::SetBitsWithMask( - const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + const RetainPtr& pBitmap, + const RetainPtr& pMask, int dest_left, int dest_top, int bitmap_alpha, @@ -2555,11 +2554,10 @@ SkPictureRecorder* CFX_DefaultRenderDevice::CreateRecorder(int size_x, } #endif // _SKIA_SUPPORT_ -bool CFX_DefaultRenderDevice::Attach( - const CFX_RetainPtr& pBitmap, - bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, - bool bGroupKnockout) { +bool CFX_DefaultRenderDevice::Attach(const RetainPtr& pBitmap, + bool bRgbByteOrder, + const RetainPtr& pOriDevice, + bool bGroupKnockout) { if (!pBitmap) return false; SetBitmap(pBitmap); @@ -2581,7 +2579,7 @@ bool CFX_DefaultRenderDevice::Create( int width, int height, FXDIB_Format format, - const CFX_RetainPtr& pOriDevice) { + const RetainPtr& pOriDevice) { auto pBitmap = pdfium::MakeRetain(); if (!pBitmap->Create(width, height, format)) { return false; @@ -2607,8 +2605,8 @@ void CFX_DefaultRenderDevice::DebugVerifyBitmapIsPreMultiplied() const { } bool CFX_DefaultRenderDevice::SetBitsWithMask( - const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + const RetainPtr& pBitmap, + const RetainPtr& pMask, int left, int top, int bitmap_alpha, diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index df28479d9a..7dcf362c66 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -24,9 +24,9 @@ struct SkIRect; class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { public: - CFX_SkiaDeviceDriver(const CFX_RetainPtr& pBitmap, + CFX_SkiaDeviceDriver(const RetainPtr& pBitmap, bool bRgbByteOrder, - const CFX_RetainPtr& pOriDevice, + const RetainPtr& pOriDevice, bool bGroupKnockout); #ifdef _SKIA_SUPPORT_ explicit CFX_SkiaDeviceDriver(SkPictureRecorder* recorder); @@ -77,21 +77,21 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { bool GetClipBox(FX_RECT* pRect) override; /** Load device buffer into a DIB */ - bool GetDIBits(const CFX_RetainPtr& pBitmap, + bool GetDIBits(const RetainPtr& pBitmap, int left, int top) override; - CFX_RetainPtr GetBackDrop() override; + RetainPtr GetBackDrop() override; - bool SetDIBits(const CFX_RetainPtr& pBitmap, + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int dest_left, int dest_top, int blend_type) override; #ifdef _SKIA_SUPPORT_ - bool SetBitsWithMask(const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + bool SetBitsWithMask(const RetainPtr& pBitmap, + const RetainPtr& pMask, int dest_left, int dest_top, int bitmap_alpha, @@ -102,7 +102,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { void SetClipMask(const FX_RECT& clipBox, const SkPath& skClipPath); #endif - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -112,7 +112,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -123,8 +123,8 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { bool ContinueDIBits(CFX_ImageRenderer* handle, IFX_PauseIndicator* pPause) override; - bool DrawBitsWithMask(const CFX_RetainPtr& pBitmap, - const CFX_RetainPtr& pMask, + bool DrawBitsWithMask(const RetainPtr& pBitmap, + const RetainPtr& pMask, int bitmap_alpha, const CFX_Matrix* pMatrix, int blend_type); @@ -151,7 +151,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { void Flush() override; SkPictureRecorder* GetRecorder() const { return m_pRecorder; } void PreMultiply() { m_pBitmap->PreMultiply(); } - static void PreMultiply(const CFX_RetainPtr& pDIBitmap); + static void PreMultiply(const RetainPtr& pDIBitmap); SkCanvas* SkiaCanvas() { return m_pCanvas; } void DebugVerifyBitmapIsPreMultiplied() const; void Dump() const; @@ -159,8 +159,8 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { private: friend class SkiaState; - CFX_RetainPtr m_pBitmap; - CFX_RetainPtr m_pOriDevice; + RetainPtr m_pBitmap; + RetainPtr m_pOriDevice; SkCanvas* m_pCanvas; SkPictureRecorder* const m_pRecorder; std::unique_ptr m_pCache; diff --git a/core/fxge/skia/fx_skia_device_unittest.cpp b/core/fxge/skia/fx_skia_device_unittest.cpp index 94d9a0f2cf..a959b6e2dc 100644 --- a/core/fxge/skia/fx_skia_device_unittest.cpp +++ b/core/fxge/skia/fx_skia_device_unittest.cpp @@ -124,7 +124,7 @@ void Harness(void (*Test)(CFX_SkiaDeviceDriver*, const State&), return; FPDFBitmap_FillRect(bitmap, 0, 0, w, h, 0x00000000); CFX_DefaultRenderDevice geDevice; - CFX_RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); geDevice.Attach(pBitmap, false, nullptr, false); CFX_SkiaDeviceDriver* driver = static_cast(geDevice.GetDeviceDriver()); diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 7e21b25411..4f79ef31ad 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -101,7 +101,7 @@ CFX_PSRenderer::CFX_PSRenderer() CFX_PSRenderer::~CFX_PSRenderer() {} -void CFX_PSRenderer::Init(const CFX_RetainPtr& pStream, +void CFX_PSRenderer::Init(const RetainPtr& pStream, int pslevel, int width, int height, @@ -342,7 +342,7 @@ void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState) { m_pStream->WriteBlock(buf.str().c_str(), buf.tellp()); } -bool CFX_PSRenderer::SetDIBits(const CFX_RetainPtr& pSource, +bool CFX_PSRenderer::SetDIBits(const RetainPtr& pSource, uint32_t color, int left, int top) { @@ -353,7 +353,7 @@ bool CFX_PSRenderer::SetDIBits(const CFX_RetainPtr& pSource, return DrawDIBits(pSource, color, &matrix, 0); } -bool CFX_PSRenderer::StretchDIBits(const CFX_RetainPtr& pSource, +bool CFX_PSRenderer::StretchDIBits(const RetainPtr& pSource, uint32_t color, int dest_left, int dest_top, @@ -366,7 +366,7 @@ bool CFX_PSRenderer::StretchDIBits(const CFX_RetainPtr& pSource, return DrawDIBits(pSource, color, &matrix, flags); } -bool CFX_PSRenderer::DrawDIBits(const CFX_RetainPtr& pSource, +bool CFX_PSRenderer::DrawDIBits(const RetainPtr& pSource, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags) { @@ -428,7 +428,7 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_RetainPtr& pSource, output_buf.release(); } else { CFX_DIBExtractor source_extractor(pSource); - CFX_RetainPtr pConverted = source_extractor.GetBitmap(); + RetainPtr pConverted = source_extractor.GetBitmap(); if (!pConverted) return false; switch (pSource->GetFormat()) { diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index 01a9001b62..33829ead98 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h @@ -10,10 +10,10 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_stream.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_graphstatedata.h" class CFX_DIBSource; @@ -30,7 +30,7 @@ class CFX_PSRenderer { CFX_PSRenderer(); ~CFX_PSRenderer(); - void Init(const CFX_RetainPtr& stream, + void Init(const RetainPtr& stream, int pslevel, int width, int height, @@ -52,18 +52,18 @@ class CFX_PSRenderer { uint32_t fill_color, uint32_t stroke_color, int fill_mode); - bool SetDIBits(const CFX_RetainPtr& pBitmap, + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top); - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, int dest_width, int dest_height, uint32_t flags); - bool DrawDIBits(const CFX_RetainPtr& pBitmap, + bool DrawDIBits(const RetainPtr& pBitmap, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags); @@ -86,7 +86,7 @@ class CFX_PSRenderer { int* ps_glyphindex); void WritePSBinary(const uint8_t* data, int len); - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; int m_PSLevel; CFX_GraphStateData m_CurGraphState; bool m_bGraphStateSet; diff --git a/core/fxge/win32/cfx_windowsdib.h b/core/fxge/win32/cfx_windowsdib.h index 28f152acfa..cc2305001e 100644 --- a/core/fxge/win32/cfx_windowsdib.h +++ b/core/fxge/win32/cfx_windowsdib.h @@ -29,18 +29,17 @@ typedef struct WINDIB_Open_Args_ { class CFX_WindowsDIB : public CFX_DIBitmap { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CFX_WindowsDIB() override; - static ByteString GetBitmapInfo(const CFX_RetainPtr& pBitmap); - static HBITMAP GetDDBitmap(const CFX_RetainPtr& pBitmap, - HDC hDC); + static ByteString GetBitmapInfo(const RetainPtr& pBitmap); + static HBITMAP GetDDBitmap(const RetainPtr& pBitmap, HDC hDC); - static CFX_RetainPtr LoadFromBuf(BITMAPINFO* pbmi, void* pData); - static CFX_RetainPtr LoadFromFile(const wchar_t* filename); - static CFX_RetainPtr LoadFromFile(const char* filename); - static CFX_RetainPtr LoadDIBitmap(WINDIB_Open_Args_ args); + static RetainPtr LoadFromBuf(BITMAPINFO* pbmi, void* pData); + static RetainPtr LoadFromFile(const wchar_t* filename); + static RetainPtr LoadFromFile(const char* filename); + static RetainPtr LoadDIBitmap(WINDIB_Open_Args_ args); HBITMAP GetWindowsBitmap() const { return m_hBitmap; } diff --git a/core/fxge/win32/dwrite_int.h b/core/fxge/win32/dwrite_int.h index 2d1deb6012..7fbb929c08 100644 --- a/core/fxge/win32/dwrite_int.h +++ b/core/fxge/win32/dwrite_int.h @@ -43,7 +43,7 @@ class CDWriteExt { void* DwCreateFontFaceFromStream(uint8_t* pData, uint32_t size, int simulation_style); - bool DwCreateRenderingTarget(const CFX_RetainPtr& pSrc, + bool DwCreateRenderingTarget(const RetainPtr& pSrc, void** renderTarget); void DwDeleteRenderingTarget(void* renderTarget); bool DwRendingString(void* renderTarget, diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index ac13266444..41c3dc3ff1 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -781,13 +781,12 @@ void CGdiDeviceDriver::RestoreState(bool bKeepSaved) { SaveDC(m_hDC); } -bool CGdiDeviceDriver::GDI_SetDIBits( - const CFX_RetainPtr& pBitmap1, - const FX_RECT* pSrcRect, - int left, - int top) { +bool CGdiDeviceDriver::GDI_SetDIBits(const RetainPtr& pBitmap1, + const FX_RECT* pSrcRect, + int left, + int top) { if (m_DeviceClass == FXDC_PRINTER) { - CFX_RetainPtr pBitmap = pBitmap1->FlipImage(false, true); + RetainPtr pBitmap = pBitmap1->FlipImage(false, true); if (!pBitmap) return false; @@ -806,7 +805,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits( dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS, SRCCOPY); } else { - CFX_RetainPtr pBitmap = pBitmap1; + RetainPtr pBitmap = pBitmap1; if (pBitmap->IsCmykImage()) { pBitmap = pBitmap->CloneConvert(FXDIB_Rgb); if (!pBitmap) @@ -824,13 +823,13 @@ bool CGdiDeviceDriver::GDI_SetDIBits( } bool CGdiDeviceDriver::GDI_StretchDIBits( - const CFX_RetainPtr& pBitmap1, + const RetainPtr& pBitmap1, int dest_left, int dest_top, int dest_width, int dest_height, uint32_t flags) { - CFX_RetainPtr pBitmap = pBitmap1; + RetainPtr pBitmap = pBitmap1; if (!pBitmap || dest_width == 0 || dest_height == 0) return false; @@ -845,7 +844,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( } else { SetStretchBltMode(m_hDC, COLORONCOLOR); } - CFX_RetainPtr pToStrechBitmap = pBitmap; + RetainPtr pToStrechBitmap = pBitmap; if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { @@ -862,14 +861,14 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( } bool CGdiDeviceDriver::GDI_StretchBitMask( - const CFX_RetainPtr& pBitmap1, + const RetainPtr& pBitmap1, int dest_left, int dest_top, int dest_width, int dest_height, uint32_t bitmap_color, uint32_t flags) { - CFX_RetainPtr pBitmap = pBitmap1; + RetainPtr pBitmap = pBitmap1; if (!pBitmap || dest_width == 0 || dest_height == 0) return false; @@ -1161,7 +1160,7 @@ CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) CGdiDisplayDriver::~CGdiDisplayDriver() {} -bool CGdiDisplayDriver::GetDIBits(const CFX_RetainPtr& pBitmap, +bool CGdiDisplayDriver::GetDIBits(const RetainPtr& pBitmap, int left, int top) { bool ret = false; @@ -1201,7 +1200,7 @@ bool CGdiDisplayDriver::GetDIBits(const CFX_RetainPtr& pBitmap, return ret; } -bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr& pSource, +bool CGdiDisplayDriver::SetDIBits(const RetainPtr& pSource, uint32_t color, const FX_RECT* pSrcRect, int left, @@ -1242,14 +1241,14 @@ bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr& pSource, return SetDIBits(bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr pBitmap = temp.GetBitmap(); + RetainPtr pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_SetDIBits(pBitmap, pSrcRect, left, top); } bool CGdiDisplayDriver::UseFoxitStretchEngine( - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, uint32_t color, int dest_left, int dest_top, @@ -1265,7 +1264,7 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine( dest_top += dest_height; bitmap_clip.Offset(-dest_left, -dest_top); - CFX_RetainPtr pStretched = + RetainPtr pStretched = pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip); if (!pStretched) return true; @@ -1275,16 +1274,15 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine( pClipRect->top, FXDIB_BLEND_NORMAL); } -bool CGdiDisplayDriver::StretchDIBits( - const CFX_RetainPtr& pSource, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CGdiDisplayDriver::StretchDIBits(const RetainPtr& pSource, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { ASSERT(pSource && pClipRect); if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) { @@ -1301,7 +1299,7 @@ bool CGdiDisplayDriver::StretchDIBits( clip_rect.Intersect(*pClipRect); clip_rect.Offset(-image_rect.left, -image_rect.top); int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); - CFX_RetainPtr pStretched( + RetainPtr pStretched( pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); if (!pStretched) return true; @@ -1325,7 +1323,7 @@ bool CGdiDisplayDriver::StretchDIBits( (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { CFX_DIBExtractor temp(pSource); - CFX_RetainPtr pBitmap = temp.GetBitmap(); + RetainPtr pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return pPlatform->m_GdiplusExt.StretchDIBits( @@ -1336,14 +1334,14 @@ bool CGdiDisplayDriver::StretchDIBits( dest_width, dest_height, pClipRect, flags); } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr pBitmap = temp.GetBitmap(); + RetainPtr pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags); } -bool CGdiDisplayDriver::StartDIBits(const CFX_RetainPtr& pBitmap, +bool CGdiDisplayDriver::StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index c00543b169..6416b5af36 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -12,7 +12,7 @@ #include "core/fxge/win32/win32_int.h" ByteString CFX_WindowsDIB::GetBitmapInfo( - const CFX_RetainPtr& pBitmap) { + const RetainPtr& pBitmap) { ByteString result; int len = sizeof(BITMAPINFOHEADER); if (pBitmap->GetBPP() == 1 || pBitmap->GetBPP() == 8) { @@ -52,9 +52,9 @@ ByteString CFX_WindowsDIB::GetBitmapInfo( return result; } -CFX_RetainPtr _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, - LPVOID pData, - bool bAlpha) { +RetainPtr _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, + LPVOID pData, + bool bAlpha) { int width = pbmi->bmiHeader.biWidth; int height = pbmi->bmiHeader.biHeight; BOOL bBottomUp = true; @@ -95,12 +95,12 @@ CFX_RetainPtr _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, return pBitmap; } -CFX_RetainPtr CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, - LPVOID pData) { +RetainPtr CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, + LPVOID pData) { return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, false); } -HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_RetainPtr& pBitmap, +HBITMAP CFX_WindowsDIB::GetDDBitmap(const RetainPtr& pBitmap, HDC hDC) { ByteString info = GetBitmapInfo(pBitmap); return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, @@ -115,8 +115,7 @@ void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { h = bmp.bmHeight; } -CFX_RetainPtr CFX_WindowsDIB::LoadFromFile( - const wchar_t* filename) { +RetainPtr CFX_WindowsDIB::LoadFromFile(const wchar_t* filename) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { @@ -148,12 +147,11 @@ CFX_RetainPtr CFX_WindowsDIB::LoadFromFile( return pDIBitmap; } -CFX_RetainPtr CFX_WindowsDIB::LoadFromFile(const char* filename) { +RetainPtr CFX_WindowsDIB::LoadFromFile(const char* filename) { return LoadFromFile(WideString::FromLocal(filename).c_str()); } -CFX_RetainPtr CFX_WindowsDIB::LoadDIBitmap( - WINDIB_Open_Args_ args) { +RetainPtr CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index 8b1786a088..4d4f45f947 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -103,7 +103,7 @@ class CDwFontContext { class CDwGdiTextRenderer { public: - CDwGdiTextRenderer(const CFX_RetainPtr& pBitmap, + CDwGdiTextRenderer(const RetainPtr& pBitmap, IDWriteBitmapRenderTarget* bitmapRenderTarget, IDWriteRenderingParams* renderingParams); ~CDwGdiTextRenderer(); @@ -118,7 +118,7 @@ class CDwGdiTextRenderer { const COLORREF& textColor); private: - CFX_RetainPtr pBitmap_; + RetainPtr pBitmap_; IDWriteBitmapRenderTarget* pRenderTarget_; IDWriteRenderingParams* pRenderingParams_; }; @@ -180,9 +180,8 @@ failed: return nullptr; } -bool CDWriteExt::DwCreateRenderingTarget( - const CFX_RetainPtr& pBitmap, - void** renderTarget) { +bool CDWriteExt::DwCreateRenderingTarget(const RetainPtr& pBitmap, + void** renderTarget) { if (pBitmap->GetFormat() > FXDIB_Argb) { return false; } @@ -396,7 +395,7 @@ HRESULT CDwFontContext::Initialize() { } CDwGdiTextRenderer::CDwGdiTextRenderer( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, IDWriteBitmapRenderTarget* bitmapRenderTarget, IDWriteRenderingParams* renderingParams) : pBitmap_(pBitmap), diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 8161c5d333..70da194be4 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -462,10 +462,10 @@ static GpBrush* _GdipCreateBrush(DWORD argb) { return solidBrush; } -static CFX_RetainPtr StretchMonoToGray( +static RetainPtr StretchMonoToGray( int dest_width, int dest_height, - const CFX_RetainPtr& pSource, + const RetainPtr& pSource, FX_RECT* pClipRect) { bool bFlipX = dest_width < 0; if (bFlipX) @@ -519,7 +519,7 @@ static CFX_RetainPtr StretchMonoToGray( static void OutputImageMask(GpGraphics* pGraphics, BOOL bMonoDevice, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, @@ -563,7 +563,7 @@ static void OutputImageMask(GpGraphics* pGraphics, return; image_clip.Offset(-image_rect.left, -image_rect.top); - CFX_RetainPtr pStretched; + RetainPtr pStretched; if (src_width * src_height > 10000) { pStretched = StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip); @@ -606,7 +606,7 @@ static void OutputImageMask(GpGraphics* pGraphics, CallFunc(GdipDisposeImage)(bitmap); } static void OutputImage(GpGraphics* pGraphics, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, const FX_RECT* pSrcRect, int dest_left, int dest_top, @@ -617,7 +617,7 @@ static void OutputImage(GpGraphics* pGraphics, ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; if (pBitmap->GetBPP() == 1 && (pSrcRect->left % 8)) { FX_RECT new_rect(0, 0, src_width, src_height); - CFX_RetainPtr pCloned = pBitmap->Clone(pSrcRect); + RetainPtr pCloned = pBitmap->Clone(pSrcRect); if (!pCloned) return; OutputImage(pGraphics, pCloned, &new_rect, dest_left, dest_top, dest_width, @@ -733,7 +733,7 @@ void CGdiplusExt::DeleteMemFont(LPVOID pCollection) { ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; CallFunc(GdipDeletePrivateFontCollection)((GpFontCollection**)&pCollection); } -bool CGdiplusExt::GdipCreateBitmap(const CFX_RetainPtr& pBitmap, +bool CGdiplusExt::GdipCreateBitmap(const RetainPtr& pBitmap, void** bitmap) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; @@ -897,7 +897,7 @@ void CGdiplusExt::GdipDeleteGraphics(void* graphics) { } bool CGdiplusExt::StretchBitMask(HDC hDC, BOOL bMonoDevice, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, @@ -923,7 +923,7 @@ bool CGdiplusExt::StretchBitMask(HDC hDC, return true; } bool CGdiplusExt::StretchDIBits(HDC hDC, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, @@ -1463,11 +1463,11 @@ static void FreeDIBitmap(PREVIEW3_DIBITMAP* pInfo) { } // TODO(tsepez): Really? Really? Move to header. -CFX_RetainPtr _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, - LPVOID pData, - bool bAlpha); +RetainPtr _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, + LPVOID pData, + bool bAlpha); -CFX_RetainPtr CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { +RetainPtr CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); if (!pInfo) return nullptr; @@ -1484,7 +1484,7 @@ CFX_RetainPtr CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { dest_pitch); } } - CFX_RetainPtr pDIBitmap = _FX_WindowsDIB_LoadFromBuf( + RetainPtr pDIBitmap = _FX_WindowsDIB_LoadFromBuf( pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); FX_Free(pData); FreeDIBitmap(pInfo); diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index fa2c8b7ef3..3c08acddda 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -69,7 +69,7 @@ int CGdiPrinterDriver::GetDeviceCaps(int caps_id) const { return CGdiDeviceDriver::GetDeviceCaps(caps_id); } -bool CGdiPrinterDriver::SetDIBits(const CFX_RetainPtr& pSource, +bool CGdiPrinterDriver::SetDIBits(const RetainPtr& pSource, uint32_t color, const FX_RECT* pSrcRect, int left, @@ -89,30 +89,29 @@ bool CGdiPrinterDriver::SetDIBits(const CFX_RetainPtr& pSource, return false; CFX_DIBExtractor temp(pSource); - CFX_RetainPtr pBitmap = temp.GetBitmap(); + RetainPtr pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_SetDIBits(pBitmap, pSrcRect, left, top); } -bool CGdiPrinterDriver::StretchDIBits( - const CFX_RetainPtr& pSource, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CGdiPrinterDriver::StretchDIBits(const RetainPtr& pSource, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { if (pSource->IsAlphaMask()) { int alpha = FXARGB_A(color); if (pSource->GetBPP() != 1 || alpha != 255) return false; if (dest_width < 0 || dest_height < 0) { - CFX_RetainPtr pFlipped = + RetainPtr pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0); if (!pFlipped) return false; @@ -127,7 +126,7 @@ bool CGdiPrinterDriver::StretchDIBits( } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr pBitmap = temp.GetBitmap(); + RetainPtr pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, @@ -138,7 +137,7 @@ bool CGdiPrinterDriver::StretchDIBits( return false; if (dest_width < 0 || dest_height < 0) { - CFX_RetainPtr pFlipped = + RetainPtr pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0); if (!pFlipped) return false; @@ -153,14 +152,14 @@ bool CGdiPrinterDriver::StretchDIBits( } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr pBitmap = temp.GetBitmap(); + RetainPtr pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags); } -bool CGdiPrinterDriver::StartDIBits(const CFX_RetainPtr& pSource, +bool CGdiPrinterDriver::StartDIBits(const RetainPtr& pSource, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -187,7 +186,7 @@ bool CGdiPrinterDriver::StartDIBits(const CFX_RetainPtr& pSource, if (fabs(pMatrix->a) >= 0.5f || fabs(pMatrix->d) >= 0.5f) return false; - CFX_RetainPtr pTransformed = + RetainPtr pTransformed = pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0); if (!pTransformed) return false; @@ -440,7 +439,7 @@ bool CPSPrinterDriver::GetClipBox(FX_RECT* pRect) { return true; } -bool CPSPrinterDriver::SetDIBits(const CFX_RetainPtr& pBitmap, +bool CPSPrinterDriver::SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, @@ -451,23 +450,22 @@ bool CPSPrinterDriver::SetDIBits(const CFX_RetainPtr& pBitmap, return m_PSRenderer.SetDIBits(pBitmap, color, left, top); } -bool CPSPrinterDriver::StretchDIBits( - const CFX_RetainPtr& pBitmap, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CPSPrinterDriver::StretchDIBits(const RetainPtr& pBitmap, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { if (blend_type != FXDIB_BLEND_NORMAL) return false; return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, dest_width, dest_height, flags); } -bool CPSPrinterDriver::StartDIBits(const CFX_RetainPtr& pBitmap, +bool CPSPrinterDriver::StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -552,13 +550,12 @@ bool CTextOnlyPrinterDriver::DrawPath(const CFX_PathData* pPathData, return false; } -bool CTextOnlyPrinterDriver::SetDIBits( - const CFX_RetainPtr& pBitmap, - uint32_t color, - const FX_RECT* pSrcRect, - int left, - int top, - int blend_type) { +bool CTextOnlyPrinterDriver::SetDIBits(const RetainPtr& pBitmap, + uint32_t color, + const FX_RECT* pSrcRect, + int left, + int top, + int blend_type) { return false; } @@ -571,7 +568,7 @@ bool CTextOnlyPrinterDriver::GetClipBox(FX_RECT* pRect) { } bool CTextOnlyPrinterDriver::StretchDIBits( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -584,7 +581,7 @@ bool CTextOnlyPrinterDriver::StretchDIBits( } bool CTextOnlyPrinterDriver::StartDIBits( - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index f9fcbe83af..c4559f4741 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -11,7 +11,7 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/ifx_renderdevicedriver.h" #include "core/fxge/win32/cfx_psrenderer.h" @@ -36,7 +36,7 @@ class CGdiplusExt { bool IsAvailable() { return !!m_hModule; } bool StretchBitMask(HDC hDC, BOOL bMonoDevice, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, @@ -45,7 +45,7 @@ class CGdiplusExt { const FX_RECT* pClipRect, int flags); bool StretchDIBits(HDC hDC, - const CFX_RetainPtr& pBitmap, + const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, @@ -98,8 +98,7 @@ class CGdiplusExt { float font_size, int fontstyle); void GdipDeleteFont(void* pFont); - bool GdipCreateBitmap(const CFX_RetainPtr& pBitmap, - void** bitmap); + bool GdipCreateBitmap(const RetainPtr& pBitmap, void** bitmap); void GdipDisposeImage(void* bitmap); void GdipGetFontSize(void* pFont, float* size); void* GdiAddFontMemResourceEx(void* pFontdata, @@ -107,7 +106,7 @@ class CGdiplusExt { void* pdv, uint32_t* num_face); bool GdiRemoveFontMemResourceEx(void* handle); - CFX_RetainPtr LoadDIBitmap(WINDIB_Open_Args_ args); + RetainPtr LoadDIBitmap(WINDIB_Open_Args_ args); FARPROC m_Functions[100]; FuncType_GdiAddFontMemResourceEx m_pGdiAddFontMemResourceEx; @@ -158,17 +157,17 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver { void DrawLine(float x1, float y1, float x2, float y2); - bool GDI_SetDIBits(const CFX_RetainPtr& pBitmap, + bool GDI_SetDIBits(const RetainPtr& pBitmap, const FX_RECT* pSrcRect, int left, int top); - bool GDI_StretchDIBits(const CFX_RetainPtr& pBitmap, + bool GDI_StretchDIBits(const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, int dest_height, uint32_t flags); - bool GDI_StretchBitMask(const CFX_RetainPtr& pBitmap, + bool GDI_StretchBitMask(const RetainPtr& pBitmap, int dest_left, int dest_top, int dest_width, @@ -191,16 +190,16 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { ~CGdiDisplayDriver() override; protected: - bool GetDIBits(const CFX_RetainPtr& pBitmap, + bool GetDIBits(const RetainPtr& pBitmap, int left, int top) override; - bool SetDIBits(const CFX_RetainPtr& pBitmap, + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -209,14 +208,14 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr* handle, int blend_type) override; - bool UseFoxitStretchEngine(const CFX_RetainPtr& pSource, + bool UseFoxitStretchEngine(const RetainPtr& pSource, uint32_t color, int dest_left, int dest_top, @@ -233,13 +232,13 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { protected: int GetDeviceCaps(int caps_id) const override; - bool SetDIBits(const CFX_RetainPtr& pBitmap, + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -248,7 +247,7 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -292,13 +291,13 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver { int fill_mode, int blend_type) override; bool GetClipBox(FX_RECT* pRect) override; - bool SetDIBits(const CFX_RetainPtr& pBitmap, + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -307,7 +306,7 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -355,13 +354,13 @@ class CTextOnlyPrinterDriver : public IFX_RenderDeviceDriver { int fill_mode, int blend_type) override; bool GetClipBox(FX_RECT* pRect) override; - bool SetDIBits(const CFX_RetainPtr& pBitmap, + bool SetDIBits(const RetainPtr& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr& pBitmap, + bool StretchDIBits(const RetainPtr& pBitmap, uint32_t color, int dest_left, int dest_top, @@ -370,7 +369,7 @@ class CTextOnlyPrinterDriver : public IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr& pBitmap, + bool StartDIBits(const RetainPtr& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, -- cgit v1.2.3