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 --- BUILD.gn | 4 +- 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 ++-- fpdfsdk/cpdfsdk_formfillenvironment.cpp | 4 +- fpdfsdk/cpdfsdk_formfillenvironment.h | 2 +- fpdfsdk/cpdfsdk_pageview.cpp | 2 +- fpdfsdk/fpdf_dataavail.cpp | 6 +- fpdfsdk/fpdf_progressive.cpp | 2 +- fpdfsdk/fpdfeditimg.cpp | 19 +- fpdfsdk/fpdfformfill.cpp | 2 +- fpdfsdk/fpdfsave.cpp | 18 +- fpdfsdk/fpdfview.cpp | 54 ++-- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 6 +- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 10 +- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 25 +- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h | 4 +- fpdfsdk/fpdfxfa/cpdfxfa_page.h | 6 +- fpdfsdk/fsdk_define.h | 4 +- fpdfsdk/fsdk_filewriteadapter.h | 4 +- fxbarcode/BC_Writer.cpp | 4 +- fxbarcode/BC_Writer.h | 2 +- testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc | 2 +- testing/libfuzzer/pdf_css_fuzzer.cc | 2 +- testing/libfuzzer/pdf_xml_fuzzer.cc | 2 +- xfa/fde/cfde_texteditengine.cpp | 2 +- xfa/fde/cfde_texteditengine.h | 8 +- xfa/fde/cfde_texteditengine_unittest.cpp | 2 +- xfa/fde/cfde_textout.cpp | 8 +- xfa/fde/cfde_textout.h | 6 +- xfa/fgas/font/cfgas_defaultfontmanager.cpp | 8 +- xfa/fgas/font/cfgas_defaultfontmanager.h | 20 +- xfa/fgas/font/cfgas_fontmgr.cpp | 82 +++--- xfa/fgas/font/cfgas_fontmgr.h | 90 +++---- xfa/fgas/font/cfgas_gefont.cpp | 36 +-- xfa/fgas/font/cfgas_gefont.h | 46 ++-- xfa/fgas/font/cfgas_pdffontmgr.cpp | 19 +- xfa/fgas/font/cfgas_pdffontmgr.h | 28 +- xfa/fgas/layout/cfx_break.cpp | 2 +- xfa/fgas/layout/cfx_break.h | 6 +- xfa/fgas/layout/cfx_breakpiece.h | 4 +- xfa/fgas/layout/cfx_rtfbreak.cpp | 5 +- xfa/fgas/layout/cfx_rtfbreak.h | 8 +- xfa/fgas/layout/cfx_rtfbreak_unittest.cpp | 2 +- xfa/fgas/layout/cfx_txtbreak.cpp | 4 +- xfa/fgas/layout/cfx_txtbreak.h | 2 +- xfa/fwl/cfwl_barcode.cpp | 2 +- xfa/fwl/cfwl_edit.cpp | 4 +- xfa/fwl/cfwl_themebackground.h | 2 +- xfa/fwl/cfx_barcode_unittest.cpp | 2 +- xfa/fwl/ifwl_themeprovider.h | 5 +- xfa/fwl/theme/cfwl_widgettp.cpp | 2 +- xfa/fwl/theme/cfwl_widgettp.h | 16 +- xfa/fxfa/cxfa_ffapp.h | 2 +- xfa/fxfa/cxfa_ffdoc.cpp | 10 +- xfa/fxfa/cxfa_ffdoc.h | 18 +- xfa/fxfa/cxfa_ffimage.cpp | 2 +- xfa/fxfa/cxfa_ffimageedit.cpp | 2 +- xfa/fxfa/cxfa_ffwidget.cpp | 49 ++-- xfa/fxfa/cxfa_ffwidget.h | 16 +- xfa/fxfa/cxfa_fileread.h | 4 +- xfa/fxfa/cxfa_fontmgr.cpp | 4 +- xfa/fxfa/cxfa_fontmgr.h | 12 +- xfa/fxfa/cxfa_fwltheme.cpp | 2 +- xfa/fxfa/cxfa_fwltheme.h | 5 +- xfa/fxfa/cxfa_linkuserdata.h | 6 +- xfa/fxfa/cxfa_loadercontext.h | 2 +- xfa/fxfa/cxfa_textlayout.cpp | 8 +- xfa/fxfa/cxfa_textlayout.h | 4 +- xfa/fxfa/cxfa_textparsecontext.h | 2 +- xfa/fxfa/cxfa_textparser.cpp | 10 +- xfa/fxfa/cxfa_textparser.h | 12 +- xfa/fxfa/cxfa_textpiece.h | 4 +- xfa/fxfa/cxfa_textuserdata.cpp | 6 +- xfa/fxfa/cxfa_textuserdata.h | 16 +- xfa/fxfa/cxfa_widgetacc.cpp | 19 +- xfa/fxfa/cxfa_widgetacc.h | 12 +- xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp | 2 +- xfa/fxfa/fxfa.h | 6 +- xfa/fxfa/parser/cxfa_dataexporter.cpp | 11 +- xfa/fxfa/parser/cxfa_dataexporter.h | 8 +- xfa/fxfa/parser/cxfa_dataimporter.cpp | 2 +- xfa/fxfa/parser/cxfa_dataimporter.h | 4 +- xfa/fxfa/parser/cxfa_document_parser.cpp | 2 +- xfa/fxfa/parser/cxfa_document_parser.h | 2 +- xfa/fxfa/parser/cxfa_simple_parser.cpp | 2 +- xfa/fxfa/parser/cxfa_simple_parser.h | 6 +- xfa/fxfa/parser/xfa_utils.h | 2 +- xfa/fxgraphics/cxfa_graphics.cpp | 25 +- xfa/fxgraphics/cxfa_graphics.h | 6 +- 268 files changed, 1882 insertions(+), 1963 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 diff --git a/BUILD.gn b/BUILD.gn index 9a08d047fd..5ba2d78f6b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -821,7 +821,6 @@ static_library("fxcrt") { "core/fxcrt/cfx_fixedbufgrow.h", "core/fxcrt/cfx_memorystream.cpp", "core/fxcrt/cfx_memorystream.h", - "core/fxcrt/cfx_retain_ptr.h", "core/fxcrt/cfx_shared_copy_on_write.h", "core/fxcrt/cfx_string_data_template.h", "core/fxcrt/cfx_string_pool_template.h", @@ -857,6 +856,7 @@ static_library("fxcrt") { "core/fxcrt/ifx_pauseindicator.h", "core/fxcrt/maybe_owned.h", "core/fxcrt/observable.h", + "core/fxcrt/retain_ptr.h", "core/fxcrt/string_view_template.h", "core/fxcrt/widestring.cpp", "core/fxcrt/widestring.h", @@ -1920,7 +1920,6 @@ test("pdfium_unittests") { "core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp", "core/fxcodec/jbig2/JBig2_Image_unittest.cpp", "core/fxcrt/bytestring_unittest.cpp", - "core/fxcrt/cfx_retain_ptr_unittest.cpp", "core/fxcrt/cfx_shared_copy_on_write_unittest.cpp", "core/fxcrt/cfx_string_pool_template_unittest.cpp", "core/fxcrt/cfx_unowned_ptr_unittest.cpp", @@ -1934,6 +1933,7 @@ test("pdfium_unittests") { "core/fxcrt/fx_system_unittest.cpp", "core/fxcrt/maybe_owned_unittest.cpp", "core/fxcrt/observable_unittest.cpp", + "core/fxcrt/retain_ptr_unittest.cpp", "core/fxcrt/widestring_unittest.cpp", "core/fxge/dib/cstretchengine_unittest.cpp", "fpdfsdk/fpdfdoc_unittest.cpp", 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, diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index 300a742809..9e65b46f44 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -441,8 +441,8 @@ FPDF_FILEHANDLER* CPDFSDK_FormFillEnvironment::OpenFile(int fileType, return nullptr; } -CFX_RetainPtr -CPDFSDK_FormFillEnvironment::DownloadFromURL(const wchar_t* url) { +RetainPtr CPDFSDK_FormFillEnvironment::DownloadFromURL( + const wchar_t* url) { if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) return nullptr; diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h index ea7b3c7e38..d6f7088c1f 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.h +++ b/fpdfsdk/cpdfsdk_formfillenvironment.h @@ -156,7 +156,7 @@ class CPDFSDK_FormFillEnvironment FPDF_FILEHANDLER* OpenFile(int fileType, FPDF_WIDESTRING wsURL, const char* mode); - CFX_RetainPtr DownloadFromURL(const wchar_t* url); + RetainPtr DownloadFromURL(const wchar_t* url); WideString PostRequestURL(const wchar_t* wsURL, const wchar_t* wsData, const wchar_t* wsContentType, diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index a8dc88c7d6..bdde975267 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -426,7 +426,7 @@ void CPDFSDK_PageView::LoadFXAnnots() { m_bLocked = true; #ifdef PDF_ENABLE_XFA - CFX_RetainPtr protector(m_page); + RetainPtr protector(m_page); if (m_pFormFillEnv->GetXFAContext()->GetDocType() == XFA_DocType::Dynamic) { CXFA_FFPageView* pageView = m_page->GetXFAPageView(); std::unique_ptr pWidgetHandler( diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp index e659db7be1..7232def75d 100644 --- a/fpdfsdk/fpdf_dataavail.cpp +++ b/fpdfsdk/fpdf_dataavail.cpp @@ -11,8 +11,8 @@ #include "core/fpdfapi/parser/cpdf_data_avail.h" #include "core/fpdfapi/parser/cpdf_document.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" #include "fpdfsdk/fsdk_define.h" #include "public/fpdf_formfill.h" #include "third_party/base/ptr_util.h" @@ -62,7 +62,7 @@ class CFPDF_FileAvailWrap : public CPDF_DataAvail::FileAvail { class CFPDF_FileAccessWrap : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CFPDF_FileAccessWrap() override {} @@ -107,7 +107,7 @@ class CFPDF_DataAvail { ~CFPDF_DataAvail() {} std::unique_ptr m_FileAvail; - CFX_RetainPtr m_FileRead; + RetainPtr m_FileRead; std::unique_ptr m_pDataAvail; }; diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp index c52f3707cc..730ba48162 100644 --- a/fpdfsdk/fpdf_progressive.cpp +++ b/fpdfsdk/fpdf_progressive.cpp @@ -50,7 +50,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, CPDF_PageRenderContext* pContext = pOwnedContext.get(); pPage->SetRenderContext(std::move(pOwnedContext)); - CFX_RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); auto pOwnedDevice = pdfium::MakeUnique(); CFX_DefaultRenderDevice* pDevice = pOwnedDevice.get(); pContext->m_pDevice = std::move(pOwnedDevice); diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp index 7036aa2ffd..4842e35c76 100644 --- a/fpdfsdk/fpdfeditimg.cpp +++ b/fpdfsdk/fpdfeditimg.cpp @@ -51,8 +51,7 @@ bool LoadJpegHelper(FPDF_PAGE* pages, if (!image_object || !fileAccess) return false; - CFX_RetainPtr pFile = - MakeSeekableReadStream(fileAccess); + RetainPtr pFile = MakeSeekableReadStream(fileAccess); CPDF_ImageObject* pImgObj = static_cast(image_object); if (pages) { @@ -134,7 +133,7 @@ FPDFImageObj_SetBitmap(FPDF_PAGE* pages, if (pPage) pImgObj->GetImage()->ResetCache(pPage, nullptr); } - CFX_RetainPtr holder(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr holder(CFXBitmapFromFPDFBitmap(bitmap)); pImgObj->GetImage()->SetImage(holder); pImgObj->CalcBoundingBox(); pImgObj->SetDirty(true); @@ -147,15 +146,15 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) { if (!pObj || !pObj->IsImage()) return nullptr; - CFX_RetainPtr pImg = pObj->AsImage()->GetImage(); + RetainPtr pImg = pObj->AsImage()->GetImage(); if (!pImg) return nullptr; - CFX_RetainPtr pSource = pImg->LoadDIBSource(); + RetainPtr pSource = pImg->LoadDIBSource(); if (!pSource) return nullptr; - CFX_RetainPtr pBitmap; + RetainPtr pBitmap; // If the source image has a representation of 1 bit per pixel, then convert // it to a grayscale bitmap having 1 byte per pixel, since bitmaps have no // concept of bits. Otherwise, convert the source image to a bitmap directly, @@ -176,7 +175,7 @@ FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object, if (!pObj || !pObj->IsImage()) return 0; - CFX_RetainPtr pImg = pObj->AsImage()->GetImage(); + RetainPtr pImg = pObj->AsImage()->GetImage(); if (!pImg) return 0; @@ -195,7 +194,7 @@ FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object, if (!pObj || !pObj->IsImage()) return 0; - CFX_RetainPtr pImg = pObj->AsImage()->GetImage(); + RetainPtr pImg = pObj->AsImage()->GetImage(); if (!pImg) return 0; @@ -216,7 +215,7 @@ FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object) { if (!pObj || !pObj->IsImage()) return 0; - CFX_RetainPtr pImg = pObj->AsImage()->GetImage(); + RetainPtr pImg = pObj->AsImage()->GetImage(); if (!pImg) return 0; @@ -264,7 +263,7 @@ FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object, if (!pObj || !pObj->IsImage() || !metadata) return false; - CFX_RetainPtr pImg = pObj->AsImage()->GetImage(); + RetainPtr pImg = pObj->AsImage()->GetImage(); if (!pImg) return false; diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 77cba50c7c..65b0ae9852 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -113,7 +113,7 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, #ifdef _SKIA_SUPPORT_ pDevice->AttachRecorder(static_cast(recorder)); #endif - CFX_RetainPtr holder(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr holder(CFXBitmapFromFPDFBitmap(bitmap)); pDevice->Attach(holder, false, nullptr, false); { CFX_RenderDevice::StateRestorer restorer(pDevice.get()); diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index 455b5ba9ba..9f1e684d72 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -43,9 +43,8 @@ namespace { #ifdef PDF_ENABLE_XFA -bool SaveXFADocumentData( - CPDFXFA_Context* pContext, - std::vector>* fileList) { +bool SaveXFADocumentData(CPDFXFA_Context* pContext, + std::vector>* fileList) { if (!pContext) return false; @@ -102,7 +101,7 @@ bool SaveXFADocumentData( CPDF_Stream* pTemplateStream = pArray->GetStreamAt(iTemplate); auto pAcc = pdfium::MakeRetain(pTemplateStream); pAcc->LoadAllData(); - CFX_RetainPtr pTemplate = + RetainPtr pTemplate = pdfium::MakeRetain( const_cast(pAcc->GetData()), pAcc->GetSize(), false); pChecksum->UpdateChecksum(pTemplate); @@ -137,7 +136,7 @@ bool SaveXFADocumentData( } // L"datasets" { - CFX_RetainPtr pDsfileWrite = + RetainPtr pDsfileWrite = pdfium::MakeRetain(false); if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, pDsfileWrite, nullptr) && @@ -165,7 +164,7 @@ bool SaveXFADocumentData( } // L"form" { - CFX_RetainPtr pfileWrite = + RetainPtr pfileWrite = pdfium::MakeRetain(false); if (pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, pfileWrite, pChecksum.get()) && @@ -214,9 +213,8 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) { return true; } -bool SendPreSaveToXFADoc( - CPDFXFA_Context* pContext, - std::vector>* fileList) { +bool SendPreSaveToXFADoc(CPDFXFA_Context* pContext, + std::vector>* fileList) { if (pContext->GetDocType() != XFA_DocType::Dynamic && pContext->GetDocType() != XFA_DocType::Static) return true; @@ -249,7 +247,7 @@ bool FPDF_Doc_Save(FPDF_DOCUMENT document, #ifdef PDF_ENABLE_XFA CPDFXFA_Context* pContext = static_cast(document); - std::vector> fileList; + std::vector> fileList; SendPreSaveToXFADoc(pContext, &fileList); #endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index c52c598783..df46ec5218 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -132,7 +132,7 @@ void RenderPageImpl(CPDF_PageRenderContext* pContext, class CPDF_CustomAccess final : public IFX_SeekableReadStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); // IFX_SeekableReadStream FX_FILESIZE GetSize() override; @@ -171,7 +171,7 @@ bool CPDF_CustomAccess::ReadBlock(void* buffer, class CFPDF_FileStream : public IFX_SeekableStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); ~CFPDF_FileStream() override; @@ -273,7 +273,7 @@ bool CFPDF_FileStream::Flush() { #endif // PDF_ENABLE_XFA FPDF_DOCUMENT LoadDocumentImpl( - const CFX_RetainPtr& pFileAccess, + const RetainPtr& pFileAccess, FPDF_BYTESTRING password) { if (!pFileAccess) { ProcessParseError(CPDF_Parser::FILE_ERROR); @@ -409,13 +409,13 @@ unsigned long DecodeStreamMaybeCopyAndReturnLength(const CPDF_Stream* stream, return len; } -CFX_RetainPtr MakeSeekableReadStream( +RetainPtr MakeSeekableReadStream( FPDF_FILEACCESS* pFileAccess) { return pdfium::MakeRetain(pFileAccess); } #ifdef PDF_ENABLE_XFA -CFX_RetainPtr MakeSeekableStream( +RetainPtr MakeSeekableStream( FPDF_FILEHANDLER* pFilehandler) { return pdfium::MakeRetain(pFilehandler); } @@ -598,8 +598,8 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_LoadXFA(FPDF_DOCUMENT document) { class CMemFile final : public IFX_SeekableReadStream { public: - static CFX_RetainPtr Create(uint8_t* pBuf, FX_FILESIZE size) { - return CFX_RetainPtr(new CMemFile(pBuf, size)); + static RetainPtr Create(uint8_t* pBuf, FX_FILESIZE size) { + return RetainPtr(new CMemFile(pBuf, size)); } FX_FILESIZE GetSize() override { return m_size; } @@ -799,15 +799,15 @@ FX_RECT GetMaskDimensionsAndOffsets(CPDF_Page* pPage, // Get a bitmap of just the mask section defined by |mask_box| from a full page // bitmap |pBitmap|. -CFX_RetainPtr GetMaskBitmap(CPDF_Page* pPage, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - CFX_RetainPtr& pSrc, - const CFX_FloatRect& mask_box, - FX_RECT* bitmap_area) { +RetainPtr GetMaskBitmap(CPDF_Page* pPage, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + RetainPtr& pSrc, + const CFX_FloatRect& mask_box, + FX_RECT* bitmap_area) { ASSERT(bitmap_area); *bitmap_area = GetMaskDimensionsAndOffsets(pPage, start_x, start_y, size_x, size_y, rotate, mask_box); @@ -815,7 +815,7 @@ CFX_RetainPtr GetMaskBitmap(CPDF_Page* pPage, return nullptr; // Create a new bitmap to transfer part of the page bitmap to. - CFX_RetainPtr pDst = pdfium::MakeRetain(); + RetainPtr pDst = pdfium::MakeRetain(); pDst->Create(bitmap_area->Width(), bitmap_area->Height(), FXDIB_Argb); pDst->Clear(0x00ffffff); pDst->TransferBitmap(0, 0, bitmap_area->Width(), bitmap_area->Height(), pSrc, @@ -824,7 +824,7 @@ CFX_RetainPtr GetMaskBitmap(CPDF_Page* pPage, } void RenderBitmap(CFX_RenderDevice* device, - const CFX_RetainPtr& pSrc, + const RetainPtr& pSrc, const FX_RECT& mask_area) { int size_x_bm = mask_area.Width(); int size_y_bm = mask_area.Height(); @@ -832,7 +832,7 @@ void RenderBitmap(CFX_RenderDevice* device, return; // Create a new bitmap from the old one - CFX_RetainPtr pDst = pdfium::MakeRetain(); + RetainPtr pDst = pdfium::MakeRetain(); pDst->Create(size_x_bm, size_y_bm, FXDIB_Rgb32); pDst->Clear(0xffffffff); pDst->CompositeBitmap(0, 0, size_x_bm, size_y_bm, pSrc, 0, 0, @@ -862,7 +862,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc, pPage->SetRenderContext(pdfium::MakeUnique()); CPDF_PageRenderContext* pContext = pPage->GetRenderContext(); - CFX_RetainPtr pBitmap; + RetainPtr pBitmap; // Don't render the full page to bitmap for a mask unless there are a lot // of masks. Full page bitmaps result in large spool sizes, so they should // only be used when necessary. For large numbers of masks, rendering each @@ -896,7 +896,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc, const std::vector& mask_boxes = pPage->GetMaskBoundingBoxes(); std::vector bitmap_areas(mask_boxes.size()); - std::vector> bitmaps(mask_boxes.size()); + std::vector> bitmaps(mask_boxes.size()); for (size_t i = 0; i < mask_boxes.size(); i++) { bitmaps[i] = GetMaskBitmap(pPage, start_x, start_y, size_x, size_y, rotate, @@ -966,7 +966,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, CFX_DefaultRenderDevice* pDevice = new CFX_DefaultRenderDevice; pContext->m_pDevice.reset(pDevice); - CFX_RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, rotate, flags, true, nullptr); @@ -997,7 +997,7 @@ FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap, CFX_DefaultRenderDevice* pDevice = new CFX_DefaultRenderDevice; pContext->m_pDevice.reset(pDevice); - CFX_RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); CFX_FloatRect clipping_rect; @@ -1045,7 +1045,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page) { return; #ifdef PDF_ENABLE_XFA // Take it back across the API and throw it away. - CFX_RetainPtr().Unleak(pPage); + RetainPtr().Unleak(pPage); #else // PDF_ENABLE_XFA CPDFSDK_PageView* pPageView = static_cast(pPage->GetView()); @@ -1204,7 +1204,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap, return; CFX_DefaultRenderDevice device; - CFX_RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); + RetainPtr pBitmap(CFXBitmapFromFPDFBitmap(bitmap)); device.Attach(pBitmap, false, nullptr, false); if (!pBitmap->HasAlpha()) color |= 0xFF000000; @@ -1229,7 +1229,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap) { } FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap) { - CFX_RetainPtr destroyer; + RetainPtr destroyer; destroyer.Unleak(CFXBitmapFromFPDFBitmap(bitmap)); } @@ -1265,7 +1265,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int count = pDoc->GetPageCount(); if (page_index < 0 || page_index >= count) return false; - CFX_RetainPtr pPage = pDoc->GetXFAPage(page_index); + RetainPtr pPage = pDoc->GetXFAPage(page_index); if (!pPage) return false; *width = pPage->GetPageWidth(); diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index b7dd33fa32..a67ac0178b 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -153,7 +153,7 @@ int CPDFXFA_Context::GetPageCount() const { } } -CFX_RetainPtr CPDFXFA_Context::GetXFAPage(int page_index) { +RetainPtr CPDFXFA_Context::GetXFAPage(int page_index) { if (page_index < 0) return nullptr; @@ -175,7 +175,7 @@ CFX_RetainPtr CPDFXFA_Context::GetXFAPage(int page_index) { return pPage; } -CFX_RetainPtr CPDFXFA_Context::GetXFAPage( +RetainPtr CPDFXFA_Context::GetXFAPage( CXFA_FFPageView* pPage) const { if (!pPage) return nullptr; @@ -314,7 +314,7 @@ WideString CPDFXFA_Context::Response(const WideString& wsQuestion, nLength / sizeof(uint16_t)); } -CFX_RetainPtr CPDFXFA_Context::DownloadURL( +RetainPtr CPDFXFA_Context::DownloadURL( const WideString& wsURL) { return m_pFormFillEnv ? m_pFormFillEnv->DownloadFromURL(wsURL.c_str()) : nullptr; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index 0dbc51e54b..df42cbb9fd 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -51,8 +51,8 @@ class CPDFXFA_Context : public IXFA_AppProvider { int GetPageCount() const; void DeletePage(int page_index); - CFX_RetainPtr GetXFAPage(int page_index); - CFX_RetainPtr GetXFAPage(CXFA_FFPageView* pPage) const; + RetainPtr GetXFAPage(int page_index); + RetainPtr GetXFAPage(CXFA_FFPageView* pPage) const; void ClearChangeMark(); // IFXA_AppProvider: @@ -70,7 +70,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { const WideString& wsTitle, const WideString& wsDefaultAnswer, bool bMark) override; - CFX_RetainPtr DownloadURL( + RetainPtr DownloadURL( const WideString& wsURL) override; bool PostRequestURL(const WideString& wsURL, const WideString& wsData, @@ -94,7 +94,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { } LoadStatus GetLoadStatus() const { return m_nLoadStatus; } - std::vector>* GetXFAPageList() { + std::vector>* GetXFAPageList() { return &m_XFAPageList; } @@ -108,7 +108,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { CFX_UnownedPtr m_pXFADocView; std::unique_ptr m_pXFAApp; std::unique_ptr m_pRuntime; - std::vector> m_XFAPageList; + std::vector> m_XFAPageList; LoadStatus m_nLoadStatus; int m_nPageCount; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index b4dc3f1ed0..4dcdcac0f6 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -11,7 +11,7 @@ #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fpdfapi/parser/cpdf_string.h" -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fpdfsdk/cpdfsdk_interform.h" #include "fpdfsdk/cpdfsdk_pageview.h" @@ -58,7 +58,7 @@ void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, if (m_pContext->GetDocType() != XFA_DocType::Dynamic) return; - CFX_RetainPtr pPage = m_pContext->GetXFAPage(pPageView); + RetainPtr pPage = m_pContext->GetXFAPage(pPageView); if (!pPage) return; @@ -88,7 +88,7 @@ void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, if (!pPageView) return; - CFX_RetainPtr pPage = m_pContext->GetXFAPage(pPageView); + RetainPtr pPage = m_pContext->GetXFAPage(pPageView); if (!pPage) return; @@ -113,7 +113,7 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, if (!pXFAPageView) return false; - CFX_RetainPtr pPage = m_pContext->GetXFAPage(pXFAPageView); + RetainPtr pPage = m_pContext->GetXFAPage(pXFAPageView); if (!pPage) return false; @@ -225,7 +225,7 @@ bool CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget, if (!pXFAPageView) return false; - CFX_RetainPtr pPage = m_pContext->GetXFAPage(pXFAPageView); + RetainPtr pPage = m_pContext->GetXFAPage(pXFAPageView); if (!pPage) return false; @@ -271,8 +271,7 @@ void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, for (int iPageIter = 0; iPageIter < m_pContext->GetOriginalPageCount(); iPageIter++) { - CFX_RetainPtr pPage = - (*m_pContext->GetXFAPageList())[iPageIter]; + RetainPtr pPage = (*m_pContext->GetXFAPageList())[iPageIter]; if (!pPage) continue; @@ -297,7 +296,7 @@ void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, if (!pPageView) return; - CFX_RetainPtr pXFAPage = m_pContext->GetXFAPage(pPageView); + RetainPtr pXFAPage = m_pContext->GetXFAPage(pPageView); if (!pXFAPage) return; @@ -315,7 +314,7 @@ void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, if (!pPageView) return; - CFX_RetainPtr pXFAPage = m_pContext->GetXFAPage(pPageView); + RetainPtr pXFAPage = m_pContext->GetXFAPage(pPageView); if (!pXFAPage) return; @@ -436,8 +435,7 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, if (!pFileHandler) return; - CFX_RetainPtr fileWrite = - MakeSeekableStream(pFileHandler); + RetainPtr fileWrite = MakeSeekableStream(pFileHandler); ByteString content; if (fileType == FXFA_SAVEAS_XML) { content = "\r\n"; @@ -697,7 +695,7 @@ bool CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { return ret; } -CFX_RetainPtr CPDFXFA_DocEnvironment::OpenLinkedFile( +RetainPtr CPDFXFA_DocEnvironment::OpenLinkedFile( CXFA_FFDoc* hDoc, const WideString& wsLink) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); @@ -727,8 +725,7 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, if (!pFormFillEnv) return false; - CFX_RetainPtr fileStream = - MakeSeekableStream(pFileHandler); + RetainPtr fileStream = MakeSeekableStream(pFileHandler); if (fileType == FXFA_SAVEAS_XML) { const char kContent[] = "\r\n"; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h index e6a0f926af..6f7d41d86e 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h @@ -7,8 +7,8 @@ #ifndef FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_ #define FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "public/fpdfview.h" #include "xfa/fxfa/fxfa.h" @@ -85,7 +85,7 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { const ByteStringView& szPropName, CFXJSE_Value* pValue) override; - CFX_RetainPtr OpenLinkedFile( + RetainPtr OpenLinkedFile( CXFA_FFDoc* hDoc, const WideString& wsLink) override; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h index 19dc0f29b1..5c4e0dca76 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.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_Matrix; class CPDFXFA_Context; @@ -19,10 +19,10 @@ class CPDF_Dictionary; class CPDF_Page; class CXFA_FFPageView; -class CPDFXFA_Page : public CFX_Retainable { +class CPDFXFA_Page : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); bool LoadPage(); bool LoadPDFPage(CPDF_Dictionary* pageDict); diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h index 68ba585c0a..f52e57abcc 100644 --- a/fpdfsdk/fsdk_define.h +++ b/fpdfsdk/fsdk_define.h @@ -32,13 +32,13 @@ class FX_PATHPOINT; // Layering prevents fxcrt from knowing about FPDF_FILEACCESS, so this can't // be a static method of IFX_SeekableReadStream. -CFX_RetainPtr MakeSeekableReadStream( +RetainPtr MakeSeekableReadStream( FPDF_FILEACCESS* pFileAccess); #ifdef PDF_ENABLE_XFA // Layering prevents fxcrt from knowing about FPDF_FILEHANDLER, so this can't // be a static method of IFX_SeekableStream. -CFX_RetainPtr MakeSeekableStream( +RetainPtr MakeSeekableStream( FPDF_FILEHANDLER* pFileHandler); #endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/fsdk_filewriteadapter.h b/fpdfsdk/fsdk_filewriteadapter.h index 5e9eaabea6..6bba1da9a7 100644 --- a/fpdfsdk/fsdk_filewriteadapter.h +++ b/fpdfsdk/fsdk_filewriteadapter.h @@ -7,14 +7,14 @@ #ifndef FPDFSDK_FSDK_FILEWRITEADAPTER_H_ #define FPDFSDK_FSDK_FILEWRITEADAPTER_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" #include "public/fpdf_save.h" class FSDK_FileWriteAdapter : public IFX_WriteStream { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); bool WriteBlock(const void* data, size_t size) override; bool WriteString(const ByteStringView& str) override; diff --git a/fxbarcode/BC_Writer.cpp b/fxbarcode/BC_Writer.cpp index 9a109bfbdd..5c8e0cf3b7 100644 --- a/fxbarcode/BC_Writer.cpp +++ b/fxbarcode/BC_Writer.cpp @@ -50,8 +50,8 @@ void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { m_barColor = foregroundColor; } -CFX_RetainPtr CBC_Writer::CreateDIBitmap(int32_t width, - int32_t height) { +RetainPtr CBC_Writer::CreateDIBitmap(int32_t width, + int32_t height) { auto pDIBitmap = pdfium::MakeRetain(); pDIBitmap->Create(width, height, m_colorSpace); return pDIBitmap; diff --git a/fxbarcode/BC_Writer.h b/fxbarcode/BC_Writer.h index fc98a4cfd4..565c03f1a5 100644 --- a/fxbarcode/BC_Writer.h +++ b/fxbarcode/BC_Writer.h @@ -25,7 +25,7 @@ class CBC_Writer { virtual void SetBarcodeColor(FX_ARGB foregroundColor); protected: - CFX_RetainPtr CreateDIBitmap(int32_t width, int32_t height); + RetainPtr CreateDIBitmap(int32_t width, int32_t height); int32_t m_CharEncoding; int32_t m_ModuleHeight; int32_t m_ModuleWidth; diff --git a/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc b/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc index fcf8b09e90..a811a8e96c 100644 --- a/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc +++ b/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc @@ -5,8 +5,8 @@ #include #include "core/fxcrt/cfx_memorystream.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/xml/cfx_saxreader.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/testing/libfuzzer/pdf_css_fuzzer.cc b/testing/libfuzzer/pdf_css_fuzzer.cc index 74745a20be..b21d9d2554 100644 --- a/testing/libfuzzer/pdf_css_fuzzer.cc +++ b/testing/libfuzzer/pdf_css_fuzzer.cc @@ -4,11 +4,11 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/css/cfx_css.h" #include "core/fxcrt/css/cfx_csssyntaxparser.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { WideString input = diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc index a648dc2199..0c3cf4fb3f 100644 --- a/testing/libfuzzer/pdf_xml_fuzzer.cc +++ b/testing/libfuzzer/pdf_xml_fuzzer.cc @@ -50,7 +50,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (!safe_size.IsValid()) return 0; - CFX_RetainPtr stream = + RetainPtr stream = pdfium::MakeRetain(const_cast(data), size); auto doc = pdfium::MakeUnique(); diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp index 143bac49f9..d54126f3c3 100644 --- a/xfa/fde/cfde_texteditengine.cpp +++ b/xfa/fde/cfde_texteditengine.cpp @@ -623,7 +623,7 @@ void CFDE_TextEditEngine::SetCharacterLimit(size_t limit) { is_dirty_ = true; } -void CFDE_TextEditEngine::SetFont(CFX_RetainPtr font) { +void CFDE_TextEditEngine::SetFont(RetainPtr font) { if (font_ == font) return; diff --git a/xfa/fde/cfde_texteditengine.h b/xfa/fde/cfde_texteditengine.h index dbb12f3953..7b739be711 100644 --- a/xfa/fde/cfde_texteditengine.h +++ b/xfa/fde/cfde_texteditengine.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" #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/fx_dib.h" #include "xfa/fgas/font/cfgas_gefont.h" @@ -96,8 +96,8 @@ class CFDE_TextEditEngine { CFX_RectF GetContentsBoundingBox(); void SetAvailableWidth(size_t width); - void SetFont(CFX_RetainPtr font); - CFX_RetainPtr GetFont() const { return font_; } + void SetFont(RetainPtr font); + RetainPtr GetFont() const { return font_; } void SetFontSize(float size); float GetFontSize() const { return font_size_; } void SetFontColor(FX_ARGB color) { font_color_ = color; } @@ -204,7 +204,7 @@ class CFDE_TextEditEngine { std::vector text_piece_info_; std::vector char_widths_; CFX_TxtBreak text_break_; - CFX_RetainPtr font_; + RetainPtr font_; FX_ARGB font_color_; float font_size_; float line_spacing_; diff --git a/xfa/fde/cfde_texteditengine_unittest.cpp b/xfa/fde/cfde_texteditengine_unittest.cpp index b0a27f331c..e6cff04507 100644 --- a/xfa/fde/cfde_texteditengine_unittest.cpp +++ b/xfa/fde/cfde_texteditengine_unittest.cpp @@ -49,7 +49,7 @@ class CFDE_TextEditEngineTest : public testing::Test { CFDE_TextEditEngine* engine() const { return engine_.get(); } private: - CFX_RetainPtr font_; + RetainPtr font_; std::unique_ptr engine_; }; diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp index 3cf4ed36e0..0e9005d88e 100644 --- a/xfa/fde/cfde_textout.cpp +++ b/xfa/fde/cfde_textout.cpp @@ -33,7 +33,7 @@ bool IsTextAlignmentTop(const FDE_TextAlignment align) { // static bool CFDE_TextOut::DrawString(CFX_RenderDevice* device, FX_ARGB color, - const CFX_RetainPtr& pFont, + const RetainPtr& pFont, FXTEXT_CHARPOS* pCharPos, int32_t iCount, float fFontSize, @@ -63,11 +63,11 @@ bool CFDE_TextOut::DrawString(CFX_RenderDevice* device, FxFont.SetSubstFont(std::move(SubstFxFont)); #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - CFX_RetainPtr pCurFont; + RetainPtr pCurFont; FXTEXT_CHARPOS* pCurCP = nullptr; int32_t iCurCount = 0; for (int32_t i = 0; i < iCount; ++i) { - CFX_RetainPtr pSTFont = + RetainPtr pSTFont = pFont->GetSubstFont(static_cast(pCharPos->m_GlyphIndex)); pCharPos->m_GlyphIndex &= 0x00FFFFFF; pCharPos->m_bFontStyle = false; @@ -140,7 +140,7 @@ CFDE_TextOut::CFDE_TextOut() CFDE_TextOut::~CFDE_TextOut() {} -void CFDE_TextOut::SetFont(const CFX_RetainPtr& pFont) { +void CFDE_TextOut::SetFont(const RetainPtr& pFont) { ASSERT(pFont); m_pFont = pFont; m_pTxtBreak->SetFont(pFont); diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h index b936eb4415..f69c0a8717 100644 --- a/xfa/fde/cfde_textout.h +++ b/xfa/fde/cfde_textout.h @@ -77,7 +77,7 @@ class CFDE_TextOut { public: static bool DrawString(CFX_RenderDevice* device, FX_ARGB color, - const CFX_RetainPtr& pFont, + const RetainPtr& pFont, FXTEXT_CHARPOS* pCharPos, int32_t iCount, float fFontSize, @@ -86,7 +86,7 @@ class CFDE_TextOut { CFDE_TextOut(); ~CFDE_TextOut(); - void SetFont(const CFX_RetainPtr& pFont); + void SetFont(const RetainPtr& pFont); void SetFontSize(float fFontSize); void SetTextColor(FX_ARGB color) { m_TxtColor = color; } void SetStyles(const FDE_TextStyle& dwStyles); @@ -121,7 +121,7 @@ class CFDE_TextOut { int32_t GetDisplayPos(FDE_TTOPIECE* pPiece); std::unique_ptr m_pTxtBreak; - CFX_RetainPtr m_pFont; + RetainPtr m_pFont; float m_fFontSize; float m_fLineSpace; float m_fLinePos; diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp index 480525802b..d3864be16a 100644 --- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp +++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp @@ -12,13 +12,13 @@ CFGAS_DefaultFontManager::CFGAS_DefaultFontManager() {} CFGAS_DefaultFontManager::~CFGAS_DefaultFontManager() {} -CFX_RetainPtr CFGAS_DefaultFontManager::GetFont( +RetainPtr CFGAS_DefaultFontManager::GetFont( CFGAS_FontMgr* pFontMgr, const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { WideString wsFontName(wsFontFamily); - CFX_RetainPtr pFont = + RetainPtr pFont = pFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage); if (!pFont) { const FGAS_FontInfo* pCurFont = @@ -54,12 +54,12 @@ CFX_RetainPtr CFGAS_DefaultFontManager::GetFont( return pFont; } -CFX_RetainPtr CFGAS_DefaultFontManager::GetDefaultFont( +RetainPtr CFGAS_DefaultFontManager::GetDefaultFont( CFGAS_FontMgr* pFontMgr, const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { - CFX_RetainPtr pFont = + RetainPtr pFont = pFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); if (!pFont) { pFont = pFontMgr->LoadFont(static_cast(nullptr), diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.h b/xfa/fgas/font/cfgas_defaultfontmanager.h index b596efc719..4e2e5e10d4 100644 --- a/xfa/fgas/font/cfgas_defaultfontmanager.h +++ b/xfa/fgas/font/cfgas_defaultfontmanager.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_gefont.h" class CFGAS_DefaultFontManager { @@ -18,17 +18,17 @@ class CFGAS_DefaultFontManager { CFGAS_DefaultFontManager(); ~CFGAS_DefaultFontManager(); - CFX_RetainPtr GetFont(CFGAS_FontMgr* pFontMgr, - const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); - CFX_RetainPtr GetDefaultFont(CFGAS_FontMgr* pFontMgr, - const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); + RetainPtr GetFont(CFGAS_FontMgr* pFontMgr, + const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + RetainPtr GetDefaultFont(CFGAS_FontMgr* pFontMgr, + const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); private: - std::vector> m_CacheFonts; + std::vector> m_CacheFonts; }; #endif // XFA_FGAS_FONT_CFGAS_DEFAULTFONTMANAGER_H_ diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index f2405e9844..da1763214b 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -197,7 +197,7 @@ CFGAS_FontMgr::CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator) CFGAS_FontMgr::~CFGAS_FontMgr() {} -CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( +RetainPtr CFGAS_FontMgr::GetFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -215,7 +215,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( if (!pFD) return nullptr; - CFX_RetainPtr pFont = + RetainPtr pFont = CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); if (!pFont) return nullptr; @@ -227,7 +227,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( return LoadFont(pFont, dwFontStyles, wCodePage); } -CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( +RetainPtr CFGAS_FontMgr::GetFontByUnicode( wchar_t wUnicode, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -254,7 +254,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( uint16_t wCodePage = GetCodePageFromCharset(pFD->uCharSet); const wchar_t* pFontFace = pFD->wsFontFace; - CFX_RetainPtr pFont = + RetainPtr pFont = CFGAS_GEFont::LoadFont(pFontFace, dwFontStyles, wCodePage, this); if (!pFont) return nullptr; @@ -266,11 +266,10 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( return LoadFont(pFont, dwFontStyles, wCodePage); } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - CFX_RetainPtr pFont; +RetainPtr CFGAS_FontMgr::LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + RetainPtr pFont; uint32_t dwHash = GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); auto it = m_FamilyFonts.find(dwHash); if (it != m_FamilyFonts.end()) @@ -298,8 +297,8 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( return LoadFont(pFont, dwFontStyles, wCodePage); } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const CFX_RetainPtr& pSrcFont, +RetainPtr CFGAS_FontMgr::LoadFont( + const RetainPtr& pSrcFont, uint32_t dwFontStyles, uint16_t wCodePage) { if (pSrcFont->GetFontStyles() == dwFontStyles) @@ -313,7 +312,7 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( if (it != m_DeriveFonts.end() && it->second) return it->second; - CFX_RetainPtr pFont = pSrcFont->Derive(dwFontStyles, wCodePage); + RetainPtr pFont = pSrcFont->Derive(dwFontStyles, wCodePage); if (!pFont) return nullptr; @@ -325,8 +324,8 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( } void CFGAS_FontMgr::RemoveFont( - std::map>* pFontMap, - const CFX_RetainPtr& pFont) { + std::map>* pFontMap, + const RetainPtr& pFont) { auto iter = pFontMap->begin(); while (iter != pFontMap->end()) { auto old_iter = iter++; @@ -335,7 +334,7 @@ void CFGAS_FontMgr::RemoveFont( } } -void CFGAS_FontMgr::RemoveFont(const CFX_RetainPtr& pFont) { +void CFGAS_FontMgr::RemoveFont(const RetainPtr& pFont) { RemoveFont(&m_CPFonts, pFont); RemoveFont(&m_FamilyFonts, pFont); RemoveFont(&m_UnicodeFonts, pFont); @@ -680,7 +679,7 @@ bool CFX_FontSourceEnum_File::HasStartPosition() { return m_wsNext.GetLength() != 0; } -CFX_RetainPtr CFX_FontSourceEnum_File::GetNext() { +RetainPtr CFX_FontSourceEnum_File::GetNext() { if (m_wsNext.GetLength() == 0) return nullptr; @@ -717,7 +716,7 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() { pSystemFontInfo->EnumFontList(pFontMapper); for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { - CFX_RetainPtr pFontStream = + RetainPtr pFontStream = CreateFontStream(pFontMapper, pSystemFontInfo, i); if (!pFontStream) continue; @@ -734,9 +733,8 @@ bool CFGAS_FontMgr::EnumFontsFromFiles() { if (!m_pFontSource->HasStartPosition()) return !m_InstalledFonts.empty(); - while (CFX_RetainPtr pFontSource = - m_pFontSource->GetNext()) { - CFX_RetainPtr pFontStream = + while (RetainPtr pFontSource = m_pFontSource->GetNext()) { + RetainPtr pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); if (pFontStream) RegisterFaces(pFontStream, nullptr); @@ -748,14 +746,13 @@ bool CFGAS_FontMgr::EnumFonts() { return EnumFontsFromFontMapper() || EnumFontsFromFiles(); } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { +RetainPtr CFGAS_FontMgr::LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); } -CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( +RetainPtr CFGAS_FontMgr::GetFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -763,7 +760,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( bsHash.Format("%d, %d", wCodePage, dwFontStyles); bsHash += FX_UTF8Encode(WideStringView(pszFontFamily)); uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false); - std::vector>* pFontArray = &m_Hash2Fonts[dwHash]; + std::vector>* pFontArray = &m_Hash2Fonts[dwHash]; if (!pFontArray->empty()) return (*pFontArray)[0]; @@ -780,7 +777,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( return nullptr; CFX_FontDescriptor* pDesc = (*sortedFontInfos)[0].pFont; - CFX_RetainPtr pFont = + RetainPtr pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); if (!pFont) return nullptr; @@ -790,7 +787,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( return pFont; } -CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( +RetainPtr CFGAS_FontMgr::GetFontByUnicode( wchar_t wUnicode, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -807,7 +804,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( bsHash.Format("%d, %d", wCodePage, dwFontStyles); bsHash += FX_UTF8Encode(WideStringView(pszFontFamily)); uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false); - std::vector>* pFonts = &m_Hash2Fonts[dwHash]; + std::vector>* pFonts = &m_Hash2Fonts[dwHash]; for (size_t i = 0; i < pFonts->size(); ++i) { if (VerifyUnicode((*pFonts)[i], wUnicode)) return (*pFonts)[i]; @@ -825,7 +822,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( CFX_FontDescriptor* pDesc = info.pFont; if (!VerifyUnicode(pDesc, wUnicode)) continue; - CFX_RetainPtr pFont = + RetainPtr pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); if (!pFont) continue; @@ -840,7 +837,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, wchar_t wcUnicode) { - CFX_RetainPtr pFileRead = + RetainPtr pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); if (!pFileRead) return false; @@ -858,7 +855,7 @@ bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, return !retCharmap && retIndex; } -bool CFGAS_FontMgr::VerifyUnicode(const CFX_RetainPtr& pFont, +bool CFGAS_FontMgr::VerifyUnicode(const RetainPtr& pFont, wchar_t wcUnicode) { if (!pFont) return false; @@ -875,10 +872,9 @@ bool CFGAS_FontMgr::VerifyUnicode(const CFX_RetainPtr& pFont, return true; } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const WideString& wsFaceName, - int32_t iFaceIndex, - int32_t* pFaceCount) { +RetainPtr CFGAS_FontMgr::LoadFont(const WideString& wsFaceName, + int32_t iFaceIndex, + int32_t* pFaceCount) { CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); if (!pFontMapper) @@ -888,7 +884,7 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( if (!pSystemFontInfo) return nullptr; - CFX_RetainPtr pFontStream = + RetainPtr pFontStream = CreateFontStream(wsFaceName.UTF8Encode()); if (!pFontStream) return nullptr; @@ -897,7 +893,7 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) return nullptr; - CFX_RetainPtr pFont = + RetainPtr pFont = CFGAS_GEFont::LoadFont(std::move(pInternalFont), this); if (!pFont) return nullptr; @@ -930,7 +926,7 @@ void _ftStreamClose(FXFT_Stream stream) {} }; // extern "C" FXFT_Face CFGAS_FontMgr::LoadFace( - const CFX_RetainPtr& pFontStream, + const RetainPtr& pFontStream, int32_t iFaceIndex) { if (!pFontStream) return nullptr; @@ -971,7 +967,7 @@ FXFT_Face CFGAS_FontMgr::LoadFace( return pFace; } -CFX_RetainPtr CFGAS_FontMgr::CreateFontStream( +RetainPtr CFGAS_FontMgr::CreateFontStream( CFX_FontMapper* pFontMapper, IFX_SystemFontInfo* pSystemFontInfo, uint32_t index) { @@ -992,7 +988,7 @@ CFX_RetainPtr CFGAS_FontMgr::CreateFontStream( return pdfium::MakeRetain(pBuffer, dwFileSize, true); } -CFX_RetainPtr CFGAS_FontMgr::CreateFontStream( +RetainPtr CFGAS_FontMgr::CreateFontStream( const ByteString& bsFaceName) { CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); @@ -1101,7 +1097,7 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled, return nPenalty; } -void CFGAS_FontMgr::RemoveFont(const CFX_RetainPtr& pEFont) { +void CFGAS_FontMgr::RemoveFont(const RetainPtr& pEFont) { if (!pEFont) return; @@ -1155,7 +1151,7 @@ void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace, const WideString* pFaceName) { } void CFGAS_FontMgr::RegisterFaces( - const CFX_RetainPtr& pFontStream, + const RetainPtr& pFontStream, const WideString* pFaceName) { int32_t index = 0; int32_t num_faces = 0; diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h index 642ba6fb67..0bcee12e4d 100644 --- a/xfa/fgas/font/cfgas_fontmgr.h +++ b/xfa/fgas/font/cfgas_fontmgr.h @@ -14,10 +14,10 @@ #include #include "core/fxcrt/cfx_crtfileaccess.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/observable.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ifx_systemfontinfo.h" @@ -88,24 +88,23 @@ class CFGAS_FontMgr : public Observable { explicit CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator); ~CFGAS_FontMgr(); - CFX_RetainPtr GetFontByCodePage(uint16_t wCodePage, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr GetFontByUnicode(wchar_t wUnicode, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - void RemoveFont(const CFX_RetainPtr& pFont); + RetainPtr GetFontByCodePage(uint16_t wCodePage, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr GetFontByUnicode(wchar_t wUnicode, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + void RemoveFont(const RetainPtr& pFont); private: - CFX_RetainPtr LoadFont( - const CFX_RetainPtr& pSrcFont, - uint32_t dwFontStyles, - uint16_t wCodePage); - void RemoveFont(std::map>* pFontMap, - const CFX_RetainPtr& pFont); + RetainPtr LoadFont(const RetainPtr& pSrcFont, + uint32_t dwFontStyles, + uint16_t wCodePage); + void RemoveFont(std::map>* pFontMap, + const RetainPtr& pFont); const FX_FONTDESCRIPTOR* FindFont(const wchar_t* pszFontFamily, uint32_t dwFontStyles, uint32_t dwMatchFlags, @@ -115,13 +114,13 @@ class CFGAS_FontMgr : public Observable { FX_LPEnumAllFonts m_pEnumerator; std::deque m_FontFaces; - std::vector> m_Fonts; - std::map> m_CPFonts; - std::map> m_FamilyFonts; - std::map> m_UnicodeFonts; - std::map> m_BufferFonts; - std::map> m_StreamFonts; - std::map> m_DeriveFonts; + std::vector> m_Fonts; + std::map> m_CPFonts; + std::map> m_FamilyFonts; + std::map> m_UnicodeFonts; + std::map> m_BufferFonts; + std::map> m_StreamFonts; + std::map> m_DeriveFonts; }; #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -170,7 +169,7 @@ class CFX_FontSourceEnum_File { ~CFX_FontSourceEnum_File(); bool HasStartPosition(); - CFX_RetainPtr GetNext(); + RetainPtr GetNext(); private: ByteString GetNextFile(); @@ -188,31 +187,30 @@ class CFGAS_FontMgr : public Observable { explicit CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum); ~CFGAS_FontMgr(); - CFX_RetainPtr GetFontByCodePage(uint16_t wCodePage, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr GetFontByUnicode(wchar_t wUnicode, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - void RemoveFont(const CFX_RetainPtr& pFont); + RetainPtr GetFontByCodePage(uint16_t wCodePage, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr GetFontByUnicode(wchar_t wUnicode, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + void RemoveFont(const RetainPtr& pFont); private: bool EnumFonts(); bool EnumFontsFromFontMapper(); bool EnumFontsFromFiles(); void RegisterFace(FXFT_Face pFace, const WideString* pFaceName); - void RegisterFaces(const CFX_RetainPtr& pFontStream, + void RegisterFaces(const RetainPtr& pFontStream, const WideString* pFaceName); void GetNames(const uint8_t* name_table, std::vector& Names); std::vector GetCharsets(FXFT_Face pFace) const; void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); uint32_t GetFlags(FXFT_Face pFace); bool VerifyUnicode(CFX_FontDescriptor* pDesc, wchar_t wcUnicode); - bool VerifyUnicode(const CFX_RetainPtr& pFont, - wchar_t wcUnicode); + bool VerifyUnicode(const RetainPtr& pFont, wchar_t wcUnicode); int32_t IsPartName(const WideString& Name1, const WideString& Name2); void MatchFonts(std::vector* MatchedFonts, uint16_t wCodePage, @@ -224,24 +222,24 @@ class CFGAS_FontMgr : public Observable { uint32_t dwFontStyles, const WideString& FontName, wchar_t wcUnicode = 0xFFFE); - CFX_RetainPtr LoadFont(const WideString& wsFaceName, - int32_t iFaceIndex, - int32_t* pFaceCount); - FXFT_Face LoadFace(const CFX_RetainPtr& pFontStream, + RetainPtr LoadFont(const WideString& wsFaceName, + int32_t iFaceIndex, + int32_t* pFaceCount); + FXFT_Face LoadFace(const RetainPtr& pFontStream, int32_t iFaceIndex); - CFX_RetainPtr CreateFontStream( + RetainPtr CreateFontStream( CFX_FontMapper* pFontMapper, IFX_SystemFontInfo* pSystemFontInfo, uint32_t index); - CFX_RetainPtr CreateFontStream( + RetainPtr CreateFontStream( const ByteString& bsFaceName); CFX_FontSourceEnum_File* const m_pFontSource; std::vector> m_InstalledFonts; std::map>> m_Hash2CandidateList; - std::map>> m_Hash2Fonts; - std::map, CFX_RetainPtr> + std::map>> m_Hash2Fonts; + std::map, RetainPtr> m_IFXFont2FileRead; std::set m_FailedUnicodesSet; }; diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index 404b23cf7b..ba79d77ca0 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -17,10 +17,10 @@ #include "xfa/fgas/font/fgas_fontutils.h" // static -CFX_RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage, - CFGAS_FontMgr* pFontMgr) { +RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage, + CFGAS_FontMgr* pFontMgr) { #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ if (!pFontMgr) return nullptr; @@ -35,8 +35,8 @@ CFX_RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, } // static -CFX_RetainPtr CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, - CFGAS_FontMgr* pFontMgr) { +RetainPtr CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, + CFGAS_FontMgr* pFontMgr) { auto pFont = pdfium::MakeRetain(pFontMgr); if (!pFont->LoadFontInternal(pExternalFont)) return nullptr; @@ -44,7 +44,7 @@ CFX_RetainPtr CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, } // static -CFX_RetainPtr CFGAS_GEFont::LoadFont( +RetainPtr CFGAS_GEFont::LoadFont( std::unique_ptr pInternalFont, CFGAS_FontMgr* pFontMgr) { auto pFont = pdfium::MakeRetain(pFontMgr); @@ -64,7 +64,7 @@ CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr) m_pFontMgr(pFontMgr) { } -CFGAS_GEFont::CFGAS_GEFont(const CFX_RetainPtr& src, +CFGAS_GEFont::CFGAS_GEFont(const RetainPtr& src, uint32_t dwFontStyles) : #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ @@ -164,9 +164,9 @@ bool CFGAS_GEFont::InitFont() { return !!m_pFontEncoding; } -CFX_RetainPtr CFGAS_GEFont::Derive(uint32_t dwFontStyles, - uint16_t wCodePage) { - CFX_RetainPtr pFont(this); +RetainPtr CFGAS_GEFont::Derive(uint32_t dwFontStyles, + uint16_t wCodePage) { + RetainPtr pFont(this); if (GetFontStyles() == dwFontStyles) return pFont; return pdfium::MakeRetain(pFont, dwFontStyles); @@ -223,9 +223,9 @@ bool CFGAS_GEFont::GetCharWidthInternal(wchar_t wUnicode, return true; if (!m_pProvider || - !m_pProvider->GetCharWidth(CFX_RetainPtr(this), wUnicode, + !m_pProvider->GetCharWidth(RetainPtr(this), wUnicode, bCharCode, &iWidth)) { - CFX_RetainPtr pFont; + RetainPtr pFont; int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); if (iGlyph != 0xFFFF && pFont) { if (pFont.Get() == this) { @@ -260,7 +260,7 @@ bool CFGAS_GEFont::GetCharBBoxInternal(wchar_t wUnicode, return true; } - CFX_RetainPtr pFont; + RetainPtr pFont; int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); if (!pFont || iGlyph == 0xFFFF) return false; @@ -296,7 +296,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode, bool bCharCode) { int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode, bool bRecursive, - CFX_RetainPtr* ppFont, + RetainPtr* ppFont, bool bCharCode) { int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); if (iGlyphIndex > 0) { @@ -330,7 +330,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode, return 0xFFFF; WideString wsFamily = GetFamilyName(); - CFX_RetainPtr pFont = + RetainPtr pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), wsFamily.c_str()); #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ if (!pFont) @@ -358,9 +358,9 @@ int32_t CFGAS_GEFont::GetDescent() const { return m_pFont->GetDescent(); } -CFX_RetainPtr CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) { +RetainPtr CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) { iGlyphIndex = static_cast(iGlyphIndex) >> 24; if (iGlyphIndex == 0) - return CFX_RetainPtr(this); + return RetainPtr(this); return m_SubstFonts[iGlyphIndex - 1]; } diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index c83fc4319d..f88f8b4cd9 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.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_memory.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fgas/font/cfgas_pdffontmgr.h" @@ -22,25 +22,24 @@ class CFGAS_FontMgr; class CFX_UnicodeEncoding; -class CFGAS_GEFont : public CFX_Retainable { +class CFGAS_GEFont : public Retainable { public: template - friend class CFX_RetainPtr; + friend class RetainPtr; template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); - static CFX_RetainPtr LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage, - CFGAS_FontMgr* pFontMgr); - static CFX_RetainPtr LoadFont(CFX_Font* pExternalFont, - CFGAS_FontMgr* pFontMgr); - static CFX_RetainPtr LoadFont( + static RetainPtr LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage, + CFGAS_FontMgr* pFontMgr); + static RetainPtr LoadFont(CFX_Font* pExternalFont, + CFGAS_FontMgr* pFontMgr); + static RetainPtr LoadFont( std::unique_ptr pInternalFont, CFGAS_FontMgr* pFontMgr); - CFX_RetainPtr Derive(uint32_t dwFontStyles, - uint16_t wCodePage = 0); + RetainPtr Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); uint32_t GetFontStyles() const; bool GetCharWidth(wchar_t wUnicode, int32_t& iWidth, bool bCharCode); int32_t GetGlyphIndex(wchar_t wUnicode, bool bCharCode = false); @@ -48,7 +47,7 @@ class CFGAS_GEFont : public CFX_Retainable { int32_t GetDescent() const; bool GetCharBBox(wchar_t wUnicode, CFX_Rect* bbox, bool bCharCode = false); bool GetBBox(CFX_Rect* bbox); - CFX_RetainPtr GetSubstFont(int32_t iGlyphIndex); + RetainPtr GetSubstFont(int32_t iGlyphIndex); CFX_Font* GetDevFont() const { return m_pFont; } void SetFontProvider(CFGAS_PDFFontMgr* pProvider) { m_pProvider.Reset(pProvider); @@ -62,7 +61,7 @@ class CFGAS_GEFont : public CFX_Retainable { private: explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); - CFGAS_GEFont(const CFX_RetainPtr& src, uint32_t dwFontStyles); + CFGAS_GEFont(const RetainPtr& src, uint32_t dwFontStyles); ~CFGAS_GEFont() override; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -70,9 +69,8 @@ class CFGAS_GEFont : public CFX_Retainable { uint32_t dwFontStyles, uint16_t wCodePage); bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); - bool LoadFontInternal( - const CFX_RetainPtr& pFontStream, - bool bSaveStream); + bool LoadFontInternal(const RetainPtr& pFontStream, + bool bSaveStream); #endif bool LoadFontInternal(CFX_Font* pExternalFont); bool LoadFontInternal(std::unique_ptr pInternalFont); @@ -87,7 +85,7 @@ class CFGAS_GEFont : public CFX_Retainable { bool bCharCode); int32_t GetGlyphIndex(wchar_t wUnicode, bool bRecursive, - CFX_RetainPtr* ppFont, + RetainPtr* ppFont, bool bCharCode = false); WideString GetFamilyName() const; @@ -97,16 +95,16 @@ class CFGAS_GEFont : public CFX_Retainable { #endif CFX_Font* m_pFont; bool m_bExternalFont; - CFX_RetainPtr m_pSrcFont; // Only set by ctor, so no cycles. + RetainPtr m_pSrcFont; // Only set by ctor, so no cycles. CFGAS_FontMgr::ObservedPtr m_pFontMgr; CFGAS_PDFFontMgr::ObservedPtr m_pProvider; - CFX_RetainPtr m_pStream; - CFX_RetainPtr m_pFileRead; + RetainPtr m_pStream; + RetainPtr m_pFileRead; std::unique_ptr m_pFontEncoding; std::map m_CharWidthMap; std::map m_BBoxMap; - std::vector> m_SubstFonts; - std::map> m_FontMapper; + std::vector> m_SubstFonts; + std::map> m_FontMapper; }; #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp index 2b8e30e5ee..0fd18aa9b9 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.cpp +++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp @@ -32,12 +32,11 @@ CFGAS_PDFFontMgr::CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr) CFGAS_PDFFontMgr::~CFGAS_PDFFontMgr() {} -CFX_RetainPtr CFGAS_PDFFontMgr::FindFont( - const ByteString& strPsName, - bool bBold, - bool bItalic, - CPDF_Font** pDstPDFFont, - bool bStrictMatch) { +RetainPtr CFGAS_PDFFontMgr::FindFont(const ByteString& strPsName, + bool bBold, + bool bItalic, + CPDF_Font** pDstPDFFont, + bool bStrictMatch) { CPDF_Dictionary* pFontSetDict = m_pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR"); if (!pFontSetDict) @@ -73,7 +72,7 @@ CFX_RetainPtr CFGAS_PDFFontMgr::FindFont( return nullptr; } -CFX_RetainPtr CFGAS_PDFFontMgr::GetFont( +RetainPtr CFGAS_PDFFontMgr::GetFont( const WideStringView& wsFontFamily, uint32_t dwFontStyles, CPDF_Font** pPDFFont, @@ -89,7 +88,7 @@ CFX_RetainPtr CFGAS_PDFFontMgr::GetFont( bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); - CFX_RetainPtr pFont = + RetainPtr pFont = FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); if (pFont) m_FontMap[strKey] = pFont; @@ -185,7 +184,7 @@ bool CFGAS_PDFFontMgr::PsNameMatchDRFontName(const ByteStringView& bsPsName, return true; } -bool CFGAS_PDFFontMgr::GetCharWidth(const CFX_RetainPtr& pFont, +bool CFGAS_PDFFontMgr::GetCharWidth(const RetainPtr& pFont, wchar_t wUnicode, bool bCharCode, int32_t* pWidth) { @@ -201,7 +200,7 @@ bool CFGAS_PDFFontMgr::GetCharWidth(const CFX_RetainPtr& pFont, return true; } -void CFGAS_PDFFontMgr::SetFont(const CFX_RetainPtr& pFont, +void CFGAS_PDFFontMgr::SetFont(const RetainPtr& pFont, CPDF_Font* pPDFFont) { m_FDE2PDFFont[pFont] = pPDFFont; } diff --git a/xfa/fgas/font/cfgas_pdffontmgr.h b/xfa/fgas/font/cfgas_pdffontmgr.h index a31d865cec..1f7d49a4e7 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.h +++ b/xfa/fgas/font/cfgas_pdffontmgr.h @@ -11,9 +11,9 @@ #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_document.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/observable.h" +#include "core/fxcrt/retain_ptr.h" class CFGAS_FontMgr; class CFGAS_GEFont; @@ -25,22 +25,22 @@ class CFGAS_PDFFontMgr : public Observable { explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr); ~CFGAS_PDFFontMgr(); - CFX_RetainPtr GetFont(const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - CPDF_Font** pPDFFont, - bool bStrictMatch); - bool GetCharWidth(const CFX_RetainPtr& pFont, + RetainPtr GetFont(const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + bool bStrictMatch); + bool GetCharWidth(const RetainPtr& pFont, wchar_t wUnicode, bool bCharCode, int32_t* pWidth); - void SetFont(const CFX_RetainPtr& pFont, CPDF_Font* pPDFFont); + void SetFont(const RetainPtr& pFont, CPDF_Font* pPDFFont); private: - CFX_RetainPtr FindFont(const ByteString& strFamilyName, - bool bBold, - bool bItalic, - CPDF_Font** pPDFFont, - bool bStrictMatch); + RetainPtr FindFont(const ByteString& strFamilyName, + bool bBold, + bool bItalic, + CPDF_Font** pPDFFont, + bool bStrictMatch); ByteString PsNameToFontName(const ByteString& strPsName, bool bBold, bool bItalic); @@ -52,8 +52,8 @@ class CFGAS_PDFFontMgr : public Observable { CFX_UnownedPtr const m_pDoc; CFX_UnownedPtr const m_pFontMgr; - std::map, CPDF_Font*> m_FDE2PDFFont; - std::map> m_FontMap; + std::map, CPDF_Font*> m_FDE2PDFFont; + std::map> m_FontMap; }; #endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp index 52236f3176..5c5569ad44 100644 --- a/xfa/fgas/layout/cfx_break.cpp +++ b/xfa/fgas/layout/cfx_break.cpp @@ -73,7 +73,7 @@ void CFX_Break::SetVerticalScale(int32_t iScale) { m_iVerticalScale = iScale; } -void CFX_Break::SetFont(const CFX_RetainPtr& pFont) { +void CFX_Break::SetFont(const RetainPtr& pFont) { if (!pFont || pFont == m_pFont) return; diff --git a/xfa/fgas/layout/cfx_break.h b/xfa/fgas/layout/cfx_break.h index b45924e1e7..322fa2be8e 100644 --- a/xfa/fgas/layout/cfx_break.h +++ b/xfa/fgas/layout/cfx_break.h @@ -9,7 +9,7 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/layout/cfx_breakline.h" @@ -37,7 +37,7 @@ class CFX_Break { void SetLayoutStyles(uint32_t dwLayoutStyles); uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; } - void SetFont(const CFX_RetainPtr& pFont); + void SetFont(const RetainPtr& pFont); void SetFontSize(float fFontSize); void SetTabWidth(float fTabWidth); int32_t GetTabWidth() const { return m_iTabWidth; } @@ -80,7 +80,7 @@ class CFX_Break { int32_t m_iCharSpace; int32_t m_iDefChar; wchar_t m_wDefChar; - CFX_RetainPtr m_pFont; + RetainPtr m_pFont; CFX_BreakLine m_Line[2]; CFX_BreakLine* m_pCurLine; int8_t m_iReadyLineIndex; diff --git a/xfa/fgas/layout/cfx_breakpiece.h b/xfa/fgas/layout/cfx_breakpiece.h index bbf4558eb1..1109e2296b 100644 --- a/xfa/fgas/layout/cfx_breakpiece.h +++ b/xfa/fgas/layout/cfx_breakpiece.h @@ -10,9 +10,9 @@ #include #include "core/fxcrt/cfx_char.h" -#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 "xfa/fxfa/cxfa_textuserdata.h" class CFX_BreakPiece { @@ -41,7 +41,7 @@ class CFX_BreakPiece { uint32_t m_dwIdentity; uint32_t m_dwCharStyles; CFX_UnownedPtr> m_pChars; - CFX_RetainPtr m_pUserData; + RetainPtr m_pUserData; }; #endif // XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_ diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp index be5780fc7a..8768aa34ff 100644 --- a/xfa/fgas/layout/cfx_rtfbreak.cpp +++ b/xfa/fgas/layout/cfx_rtfbreak.cpp @@ -41,8 +41,7 @@ void CFX_RTFBreak::AddPositionedTab(float fTabPos) { m_PositionedTabs.insert(it, iTabPos); } -void CFX_RTFBreak::SetUserData( - const CFX_RetainPtr& pUserData) { +void CFX_RTFBreak::SetUserData(const RetainPtr& pUserData) { if (m_pUserData == pUserData) return; @@ -668,7 +667,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, ASSERT(pText->pFont && pText->pRect); - CFX_RetainPtr pFont = pText->pFont; + RetainPtr pFont = pText->pFont; CFX_RectF rtText(*pText->pRect); bool bRTLPiece = FX_IsOdd(pText->iBidiLevel); float fFontSize = pText->fFontSize; diff --git a/xfa/fgas/layout/cfx_rtfbreak.h b/xfa/fgas/layout/cfx_rtfbreak.h index f5ad90838f..5a3f4313b5 100644 --- a/xfa/fgas/layout/cfx_rtfbreak.h +++ b/xfa/fgas/layout/cfx_rtfbreak.h @@ -10,9 +10,9 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_unicode.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_renderdevice.h" #include "xfa/fgas/layout/cfx_break.h" #include "xfa/fxfa/cxfa_textuserdata.h" @@ -33,7 +33,7 @@ struct FX_RTFTEXTOBJ { WideString pStr; std::vector pWidths; - CFX_RetainPtr pFont; + RetainPtr pFont; const CFX_RectF* pRect; wchar_t wLineBreakChar; float fFontSize; @@ -51,7 +51,7 @@ class CFX_RTFBreak : public CFX_Break { void SetLineStartPos(float fLinePos); void SetAlignment(CFX_RTFLineAlignment align) { m_iAlignment = align; } - void SetUserData(const CFX_RetainPtr& pUserData); + void SetUserData(const RetainPtr& pUserData); void AddPositionedTab(float fTabPos); @@ -92,7 +92,7 @@ class CFX_RTFBreak : public CFX_Break { bool m_bPagination; std::vector m_PositionedTabs; CFX_RTFLineAlignment m_iAlignment; - CFX_RetainPtr m_pUserData; + RetainPtr m_pUserData; }; #endif // XFA_FGAS_LAYOUT_CFX_RTFBREAK_H_ diff --git a/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp b/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp index bda52fc76a..5f24631315 100644 --- a/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp +++ b/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp @@ -30,7 +30,7 @@ class CFX_RTFBreakTest : public testing::Test { } private: - CFX_RetainPtr font_; + RetainPtr font_; }; // As soon as you get one of the control characters the break is complete diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp index 9fe5a432f6..403b7e6c11 100644 --- a/xfa/fgas/layout/cfx_txtbreak.cpp +++ b/xfa/fgas/layout/cfx_txtbreak.cpp @@ -651,7 +651,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, const wchar_t* pStr = pTxtRun->wsStr.c_str(); int32_t* pWidths = pTxtRun->pWidths; int32_t iLength = pTxtRun->iLength - 1; - CFX_RetainPtr pFont = pTxtRun->pFont; + RetainPtr pFont = pTxtRun->pFont; uint32_t dwStyles = pTxtRun->dwStyles; CFX_RectF rtText(*pTxtRun->pRect); bool bRTLPiece = (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; @@ -909,7 +909,7 @@ std::vector CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, float fFontSize = pTxtRun->fFontSize; int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); float fScale = fFontSize / 1000.0f; - CFX_RetainPtr pFont = pTxtRun->pFont; + RetainPtr pFont = pTxtRun->pFont; if (!pFont) bCharBBox = false; diff --git a/xfa/fgas/layout/cfx_txtbreak.h b/xfa/fgas/layout/cfx_txtbreak.h index 959cd8eb48..e6f8da03d2 100644 --- a/xfa/fgas/layout/cfx_txtbreak.h +++ b/xfa/fgas/layout/cfx_txtbreak.h @@ -44,7 +44,7 @@ struct FX_TXTRUN { WideString wsStr; int32_t* pWidths; int32_t iLength; - CFX_RetainPtr pFont; + RetainPtr pFont; float fFontSize; uint32_t dwStyles; int32_t iHorizontalScale; diff --git a/xfa/fwl/cfwl_barcode.cpp b/xfa/fwl/cfwl_barcode.cpp index 1f2a978171..f5d6ea98b2 100644 --- a/xfa/fwl/cfwl_barcode.cpp +++ b/xfa/fwl/cfwl_barcode.cpp @@ -167,7 +167,7 @@ void CFWL_Barcode::GenerateBarcodeImageCache() { if (pTheme) { CFWL_ThemePart part; part.m_pWidget = this; - if (CFX_RetainPtr pFont = pTheme->GetFont(&part)) { + if (RetainPtr pFont = pTheme->GetFont(&part)) { if (CFX_Font* pCXFont = pFont->GetDevFont()) m_pBarcodeEngine->SetFont(pCXFont); } diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index d1f0c99a39..fa5ee63b77 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -538,7 +538,7 @@ void CFWL_Edit::RenderText(CFX_RenderDevice* pRenderDev, const CFX_Matrix& mt) { ASSERT(pRenderDev); - CFX_RetainPtr font = m_EdtEngine.GetFont(); + RetainPtr font = m_EdtEngine.GetFont(); if (!font) return; @@ -635,7 +635,7 @@ void CFWL_Edit::UpdateEditParams() { } m_fFontSize = theme->GetFontSize(&part); - CFX_RetainPtr pFont = theme->GetFont(&part); + RetainPtr pFont = theme->GetFont(&part); if (!pFont) return; diff --git a/xfa/fwl/cfwl_themebackground.h b/xfa/fwl/cfwl_themebackground.h index 0141754c1e..65c29ebd7a 100644 --- a/xfa/fwl/cfwl_themebackground.h +++ b/xfa/fwl/cfwl_themebackground.h @@ -21,7 +21,7 @@ class CFWL_ThemeBackground : public CFWL_ThemePart { CXFA_Graphics* m_pGraphics; CXFA_Path* m_pPath; - CFX_RetainPtr m_pImage; + RetainPtr m_pImage; }; inline CFWL_ThemeBackground::CFWL_ThemeBackground() diff --git a/xfa/fwl/cfx_barcode_unittest.cpp b/xfa/fwl/cfx_barcode_unittest.cpp index b66d90495e..fe8aee4709 100644 --- a/xfa/fwl/cfx_barcode_unittest.cpp +++ b/xfa/fwl/cfx_barcode_unittest.cpp @@ -64,7 +64,7 @@ class BarcodeTest : public testing::Test { CFX_Matrix matrix_; std::unique_ptr barcode_; std::unique_ptr device_; - CFX_RetainPtr bitmap_; + RetainPtr bitmap_; }; TEST_F(BarcodeTest, Code39) { diff --git a/xfa/fwl/ifwl_themeprovider.h b/xfa/fwl/ifwl_themeprovider.h index 03767cfc06..32dc901377 100644 --- a/xfa/fwl/ifwl_themeprovider.h +++ b/xfa/fwl/ifwl_themeprovider.h @@ -7,8 +7,8 @@ #ifndef XFA_FWL_IFWL_THEMEPROVIDER_H_ #define XFA_FWL_IFWL_THEMEPROVIDER_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_gefont.h" class CFWL_ThemeBackground; @@ -27,8 +27,7 @@ class IFWL_ThemeProvider { virtual float GetCYBorderSize() const = 0; virtual CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const = 0; virtual float GetFontSize(CFWL_ThemePart* pThemePart) const = 0; - virtual CFX_RetainPtr GetFont( - CFWL_ThemePart* pThemePart) const = 0; + virtual RetainPtr GetFont(CFWL_ThemePart* pThemePart) const = 0; virtual float GetLineHeight(CFWL_ThemePart* pThemePart) const = 0; virtual float GetScrollBarWidth() const = 0; virtual FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const = 0; diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index 1eade9c70b..630da7793d 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -303,7 +303,7 @@ CFWL_FontManager::CFWL_FontManager() {} CFWL_FontManager::~CFWL_FontManager() {} -CFX_RetainPtr CFWL_FontManager::FindFont( +RetainPtr CFWL_FontManager::FindFont( const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h index dd36778704..eb1423e602 100644 --- a/xfa/fwl/theme/cfwl_widgettp.h +++ b/xfa/fwl/theme/cfwl_widgettp.h @@ -10,9 +10,9 @@ #include #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" #include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fwl/theme/cfwl_utils.h" #include "xfa/fxgraphics/cxfa_graphics.h" @@ -39,7 +39,7 @@ class CFWL_WidgetTP { virtual void DrawBackground(CFWL_ThemeBackground* pParams); virtual void DrawText(CFWL_ThemeText* pParams); - const CFX_RetainPtr& GetFont() const { return m_pFDEFont; } + const RetainPtr& GetFont() const { return m_pFDEFont; } protected: struct CColorData { @@ -95,7 +95,7 @@ class CFWL_WidgetTP { uint32_t m_dwRefCount; std::unique_ptr m_pTextOut; - CFX_RetainPtr m_pFDEFont; + RetainPtr m_pFDEFont; std::unique_ptr m_pColorData; }; @@ -112,7 +112,7 @@ class CFWL_FontData { bool LoadFont(const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage); - CFX_RetainPtr GetFont() const { return m_pFont; } + RetainPtr GetFont() const { return m_pFont; } protected: WideString m_wsFamily; @@ -122,7 +122,7 @@ class CFWL_FontData { std::unique_ptr m_pFontSource; #endif std::unique_ptr m_pFontMgr; - CFX_RetainPtr m_pFont; + RetainPtr m_pFont; }; class CFWL_FontManager { @@ -130,9 +130,9 @@ class CFWL_FontManager { static CFWL_FontManager* GetInstance(); static void DestroyInstance(); - CFX_RetainPtr FindFont(const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - uint16_t dwCodePage); + RetainPtr FindFont(const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + uint16_t dwCodePage); protected: CFWL_FontManager(); diff --git a/xfa/fxfa/cxfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h index 6ee9e45a13..857e9c03bb 100644 --- a/xfa/fxfa/cxfa_ffapp.h +++ b/xfa/fxfa/cxfa_ffapp.h @@ -12,8 +12,8 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fwl/cfwl_app.h" #include "xfa/fxfa/fxfa.h" diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index 316987fcc3..ee31a46f50 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -334,7 +334,7 @@ void CXFA_FFDoc::CloseDoc() { m_pApp->ClearEventTargets(); } -CFX_RetainPtr CXFA_FFDoc::GetPDFNamedImage( +RetainPtr CXFA_FFDoc::GetPDFNamedImage( const WideStringView& wsName, int32_t& iImageXDpi, int32_t& iImageYDpi) { @@ -381,18 +381,18 @@ CFX_RetainPtr CXFA_FFDoc::GetPDFNamedImage( auto pAcc = pdfium::MakeRetain(pStream); pAcc->LoadAllData(); - CFX_RetainPtr pImageFileRead = + RetainPtr pImageFileRead = pdfium::MakeRetain( const_cast(pAcc->GetData()), pAcc->GetSize(), false); - CFX_RetainPtr pDibSource = XFA_LoadImageFromBuffer( + RetainPtr pDibSource = XFA_LoadImageFromBuffer( pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi}; return pDibSource; } bool CXFA_FFDoc::SavePackage(XFA_HashCode code, - const CFX_RetainPtr& pFile, + const RetainPtr& pFile, CFX_ChecksumContext* pCSContext) { CXFA_Document* doc = m_pDocumentParser->GetDocument(); auto pExport = pdfium::MakeUnique(doc); @@ -409,7 +409,7 @@ bool CXFA_FFDoc::SavePackage(XFA_HashCode code, pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); } -bool CXFA_FFDoc::ImportData(const CFX_RetainPtr& pStream, +bool CXFA_FFDoc::ImportData(const RetainPtr& pStream, bool bXDP) { auto importer = pdfium::MakeUnique(m_pDocumentParser->GetDocument()); diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h index 1d35c669da..ceec91f7db 100644 --- a/xfa/fxfa/cxfa_ffdoc.h +++ b/xfa/fxfa/cxfa_ffdoc.h @@ -24,12 +24,12 @@ class CXFA_FFDocView; struct FX_IMAGEDIB_AND_DPI { FX_IMAGEDIB_AND_DPI(); FX_IMAGEDIB_AND_DPI(const FX_IMAGEDIB_AND_DPI& that); - FX_IMAGEDIB_AND_DPI(const CFX_RetainPtr& pDib, + FX_IMAGEDIB_AND_DPI(const RetainPtr& pDib, int32_t xDpi, int32_t yDpi); ~FX_IMAGEDIB_AND_DPI(); - CFX_RetainPtr pDibSource; + RetainPtr pDibSource; int32_t iImageXDpi; int32_t iImageYDpi; }; @@ -39,7 +39,7 @@ inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI( const FX_IMAGEDIB_AND_DPI& that) = default; inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI( - const CFX_RetainPtr& pDib, + const RetainPtr& pDib, int32_t xDpi, int32_t yDpi) : pDibSource(pDib), iImageXDpi(xDpi), iImageYDpi(yDpi) {} @@ -70,21 +70,21 @@ class CXFA_FFDoc { CPDF_Document* GetPDFDoc() const { return m_pPDFDoc.Get(); } CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout); CXFA_FFDocView* GetDocView(); - CFX_RetainPtr GetPDFNamedImage(const WideStringView& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi); + RetainPtr GetPDFNamedImage(const WideStringView& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi); CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); } bool SavePackage(XFA_HashCode code, - const CFX_RetainPtr& pFile, + const RetainPtr& pFile, CFX_ChecksumContext* pCSContext); - bool ImportData(const CFX_RetainPtr& pStream, + bool ImportData(const RetainPtr& pStream, bool bXDP = true); private: CFX_UnownedPtr const m_pDocEnvironment; std::unique_ptr m_pDocumentParser; - CFX_RetainPtr m_pStream; + RetainPtr m_pStream; CFX_UnownedPtr m_pApp; std::unique_ptr m_pNotify; CFX_UnownedPtr m_pPDFDoc; diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index ec6a29cd28..757867f076 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -45,7 +45,7 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus); - CFX_RetainPtr pDIBitmap = GetDataAcc()->GetImageImage(); + RetainPtr pDIBitmap = GetDataAcc()->GetImageImage(); if (!pDIBitmap) return; diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 1c9e014256..2189877afb 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -64,7 +64,7 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); DrawBorder(pGS, borderUI, m_rtUI, mtRotate); RenderCaption(pGS, &mtRotate); - CFX_RetainPtr pDIBitmap = m_pDataAcc->GetImageEditImage(); + RetainPtr pDIBitmap = m_pDataAcc->GetImageEditImage(); if (!pDIBitmap) return; diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 0935f56b90..7763a19972 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -1414,7 +1414,7 @@ class CXFA_ImageRenderer { ~CXFA_ImageRenderer(); bool Start(CFX_RenderDevice* pDevice, - const CFX_RetainPtr& pDIBSource, + const RetainPtr& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -1424,7 +1424,7 @@ class CXFA_ImageRenderer { protected: bool StartDIBSource(); - void CompositeDIBitmap(const CFX_RetainPtr& pDIBitmap, + void CompositeDIBitmap(const RetainPtr& pDIBitmap, int left, int top, FX_ARGB mask_argb, @@ -1435,8 +1435,8 @@ class CXFA_ImageRenderer { CFX_RenderDevice* m_pDevice; int m_Status; CFX_Matrix m_ImageMatrix; - CFX_RetainPtr m_pDIBSource; - CFX_RetainPtr m_pCloneConvert; + RetainPtr m_pDIBSource; + RetainPtr m_pCloneConvert; int m_BitmapAlpha; FX_ARGB m_FillArgb; uint32_t m_Flags; @@ -1461,7 +1461,7 @@ CXFA_ImageRenderer::CXFA_ImageRenderer() CXFA_ImageRenderer::~CXFA_ImageRenderer() {} bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, - const CFX_RetainPtr& pDIBSource, + const RetainPtr& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -1497,7 +1497,7 @@ bool CXFA_ImageRenderer::StartDIBSource() { m_Result = false; return false; } - CFX_RetainPtr pDib = m_pDIBSource; + RetainPtr pDib = m_pDIBSource; if (m_pDIBSource->HasAlpha() && !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { @@ -1549,7 +1549,7 @@ bool CXFA_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) { CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb, @@ -1563,7 +1563,7 @@ bool CXFA_ImageRenderer::Continue() { if (m_pTransformer->Continue(nullptr)) return true; - CFX_RetainPtr pBitmap = m_pTransformer->DetachBitmap(); + RetainPtr pBitmap = m_pTransformer->DetachBitmap(); if (!pBitmap) return false; @@ -1589,7 +1589,7 @@ bool CXFA_ImageRenderer::Continue() { } void CXFA_ImageRenderer::CompositeDIBitmap( - const CFX_RetainPtr& pDIBitmap, + const RetainPtr& pDIBitmap, int left, int top, FX_ARGB mask_argb, @@ -1635,10 +1635,10 @@ void CXFA_ImageRenderer::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; @@ -1667,8 +1667,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap( (m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { return; } - CFX_RetainPtr pCloneConvert = - pDIBitmap->CloneConvert(FXDIB_Rgb); + RetainPtr pCloneConvert = pDIBitmap->CloneConvert(FXDIB_Rgb); if (!pCloneConvert) return; @@ -1684,7 +1683,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap( void XFA_DrawImage(CXFA_Graphics* pGS, const CFX_RectF& rtImage, const CFX_Matrix& matrix, - const CFX_RetainPtr& pDIBitmap, + const RetainPtr& pDIBitmap, int32_t iAspect, int32_t iImageXDpi, int32_t iImageYDpi, @@ -1885,11 +1884,11 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) { return FXCODEC_IMAGE_UNKNOWN; } -CFX_RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - bool& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { +RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + bool& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { WideString wsHref; WideString wsImage; pImage->GetHref(wsHref); @@ -1902,7 +1901,7 @@ CFX_RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); ByteString bsContent; uint8_t* pImageBuffer = nullptr; - CFX_RetainPtr pImageFileRead; + RetainPtr pImageFileRead; if (wsImage.GetLength() > 0) { XFA_ATTRIBUTEENUM iEncoding = (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); @@ -1924,7 +1923,7 @@ CFX_RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, } else { WideString wsURL = wsHref; if (wsURL.Left(7) != L"http://" && wsURL.Left(6) != L"ftp://") { - CFX_RetainPtr pBitmap = + RetainPtr pBitmap = pDoc->GetPDFNamedImage(wsURL.AsStringView(), iImageXDpi, iImageYDpi); if (pBitmap) { bNameImage = true; @@ -1938,7 +1937,7 @@ CFX_RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, return nullptr; } bNameImage = false; - CFX_RetainPtr pBitmap = + RetainPtr pBitmap = XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); FX_Free(pImageBuffer); return pBitmap; @@ -1964,8 +1963,8 @@ static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, return dibFormat; } -CFX_RetainPtr XFA_LoadImageFromBuffer( - const CFX_RetainPtr& pImageFileRead, +RetainPtr XFA_LoadImageFromBuffer( + const RetainPtr& pImageFileRead, FXCODEC_IMAGE_TYPE type, int32_t& iImageXDpi, int32_t& iImageYDpi) { @@ -1998,7 +1997,7 @@ CFX_RetainPtr XFA_LoadImageFromBuffer( int32_t iComponents = pProgressiveDecoder->GetNumComponents(); int32_t iBpc = pProgressiveDecoder->GetBPC(); FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); - CFX_RetainPtr pBitmap = pdfium::MakeRetain(); + RetainPtr pBitmap = pdfium::MakeRetain(); pBitmap->Create(pProgressiveDecoder->GetWidth(), pProgressiveDecoder->GetHeight(), dibFormat); pBitmap->Clear(0xffffffff); diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 41bb94164b..c743742890 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -42,21 +42,21 @@ CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); void XFA_DrawImage(CXFA_Graphics* pGS, const CFX_RectF& rtImage, const CFX_Matrix& matrix, - const CFX_RetainPtr& pDIBitmap, + const RetainPtr& pDIBitmap, int32_t iAspect, int32_t iImageXDpi, int32_t iImageYDpi, int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); -CFX_RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - bool& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi); +RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + bool& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi); -CFX_RetainPtr XFA_LoadImageFromBuffer( - const CFX_RetainPtr& pImageFileRead, +RetainPtr XFA_LoadImageFromBuffer( + const RetainPtr& pImageFileRead, FXCODEC_IMAGE_TYPE type, int32_t& iImageXDpi, int32_t& iImageYDpi); diff --git a/xfa/fxfa/cxfa_fileread.h b/xfa/fxfa/cxfa_fileread.h index 2dba4d23df..62fa4c67bb 100644 --- a/xfa/fxfa/cxfa_fileread.h +++ b/xfa/fxfa/cxfa_fileread.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/retain_ptr.h" class CPDF_Stream; class CPDF_StreamAcc; @@ -30,7 +30,7 @@ class CXFA_FileRead : public IFX_SeekableStream { bool WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) override; private: - std::vector> m_Data; + std::vector> m_Data; }; #endif // XFA_FXFA_CXFA_FILEREAD_H_ diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp index 5a11dd5dc0..ddf8ffada4 100644 --- a/xfa/fxfa/cxfa_fontmgr.cpp +++ b/xfa/fxfa/cxfa_fontmgr.cpp @@ -23,7 +23,7 @@ CXFA_FontMgr::CXFA_FontMgr() {} CXFA_FontMgr::~CXFA_FontMgr() {} -CFX_RetainPtr CXFA_FontMgr::GetFont( +RetainPtr CXFA_FontMgr::GetFont( CXFA_FFDoc* hDoc, const WideStringView& wsFontFamily, uint32_t dwFontStyles, @@ -39,7 +39,7 @@ CFX_RetainPtr CXFA_FontMgr::GetFont( CFGAS_PDFFontMgr* pMgr = hDoc->GetPDFFontMgr(); CPDF_Font* pPDFFont = nullptr; - CFX_RetainPtr pFont; + RetainPtr pFont; if (pMgr) { pFont = pMgr->GetFont(wsEnglishName.AsStringView(), dwFontStyles, &pPDFFont, true); diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h index b7d1f51ff2..55ee6bbc4d 100644 --- a/xfa/fxfa/cxfa_fontmgr.h +++ b/xfa/fxfa/cxfa_fontmgr.h @@ -11,9 +11,9 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_defaultfontmanager.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fgas/font/cfgas_pdffontmgr.h" @@ -26,15 +26,15 @@ class CXFA_FontMgr { CXFA_FontMgr(); ~CXFA_FontMgr(); - CFX_RetainPtr GetFont(CXFA_FFDoc* hDoc, - const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); + RetainPtr GetFont(CXFA_FFDoc* hDoc, + const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); void SetDefFontMgr(std::unique_ptr pFontMgr); private: std::unique_ptr m_pDefFontMgr; - std::map> m_FontMap; + std::map> m_FontMap; }; #endif // XFA_FXFA_CXFA_FONTMGR_H_ diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp index 35456eff16..f27b5ddef5 100644 --- a/xfa/fxfa/cxfa_fwltheme.cpp +++ b/xfa/fxfa/cxfa_fwltheme.cpp @@ -185,7 +185,7 @@ float CXFA_FWLTheme::GetFontSize(CFWL_ThemePart* pThemePart) const { return FWLTHEME_CAPACITY_FontSize; } -CFX_RetainPtr CXFA_FWLTheme::GetFont( +RetainPtr CXFA_FWLTheme::GetFont( CFWL_ThemePart* pThemePart) const { if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) return pWidget->GetDataAcc()->GetFDEFont(); diff --git a/xfa/fxfa/cxfa_fwltheme.h b/xfa/fxfa/cxfa_fwltheme.h index 48fb744cb2..7813545447 100644 --- a/xfa/fxfa/cxfa_fwltheme.h +++ b/xfa/fxfa/cxfa_fwltheme.h @@ -37,8 +37,7 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { float GetCYBorderSize() const override; CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const override; float GetFontSize(CFWL_ThemePart* pThemePart) const override; - CFX_RetainPtr GetFont( - CFWL_ThemePart* pThemePart) const override; + RetainPtr GetFont(CFWL_ThemePart* pThemePart) const override; float GetLineHeight(CFWL_ThemePart* pThemePart) const override; float GetScrollBarWidth() const override; FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const override; @@ -59,7 +58,7 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { std::unique_ptr m_pCaretTP; std::unique_ptr m_pBarcodeTP; std::unique_ptr m_pTextOut; - CFX_RetainPtr m_pCalendarFont; + RetainPtr m_pCalendarFont; WideString m_wsResource; CFX_UnownedPtr const m_pApp; CFX_RectF m_Rect; diff --git a/xfa/fxfa/cxfa_linkuserdata.h b/xfa/fxfa/cxfa_linkuserdata.h index 7a9648c9b5..3d0f95e91c 100644 --- a/xfa/fxfa/cxfa_linkuserdata.h +++ b/xfa/fxfa/cxfa_linkuserdata.h @@ -7,14 +7,14 @@ #ifndef XFA_FXFA_CXFA_LINKUSERDATA_H_ #define XFA_FXFA_CXFA_LINKUSERDATA_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 CXFA_LinkUserData : public CFX_Retainable { +class CXFA_LinkUserData : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); const wchar_t* GetLinkURL() const { return m_wsURLContent.c_str(); } diff --git a/xfa/fxfa/cxfa_loadercontext.h b/xfa/fxfa/cxfa_loadercontext.h index 64ab50696b..06e3f117d8 100644 --- a/xfa/fxfa/cxfa_loadercontext.h +++ b/xfa/fxfa/cxfa_loadercontext.h @@ -31,7 +31,7 @@ class CXFA_LoaderContext { uint32_t m_dwFlags; CFX_XMLNode* m_pXMLNode; CXFA_Node* m_pNode; - CFX_RetainPtr m_pParentStyle; + RetainPtr m_pParentStyle; std::vector m_lineHeights; std::vector m_BlocksHeight; }; diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index bbc61d40f2..038f451ad9 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -689,9 +689,9 @@ bool CXFA_TextLayout::LoadRichText( CFX_XMLNode* pXMLNode, const CFX_SizeF& szText, float& fLinePos, - const CFX_RetainPtr& pParentStyle, + const RetainPtr& pParentStyle, bool bSavePieces, - CFX_RetainPtr pLinkData, + RetainPtr pLinkData, bool bEndBreak, bool bIsOl, int32_t iLiCount) { @@ -703,7 +703,7 @@ bool CXFA_TextLayout::LoadRichText( CFX_CSSDisplay eDisplay = CFX_CSSDisplay::None; bool bContentNode = false; float fSpaceBelow = 0; - CFX_RetainPtr pStyle; + RetainPtr pStyle; WideString wsName; if (bEndBreak) { bool bCurOl = false; @@ -1008,7 +1008,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, if (iPieces < 1) return; - CFX_RetainPtr pStyle; + RetainPtr pStyle; if (bSavePieces) { auto pNew = pdfium::MakeUnique(); CXFA_PieceLine* pPieceLine = pNew.get(); diff --git a/xfa/fxfa/cxfa_textlayout.h b/xfa/fxfa/cxfa_textlayout.h index 50ee83fd75..5856826166 100644 --- a/xfa/fxfa/cxfa_textlayout.h +++ b/xfa/fxfa/cxfa_textlayout.h @@ -79,9 +79,9 @@ class CXFA_TextLayout { bool LoadRichText(CFX_XMLNode* pXMLNode, const CFX_SizeF& szText, float& fLinePos, - const CFX_RetainPtr& pParentStyle, + const RetainPtr& pParentStyle, bool bSavePieces, - CFX_RetainPtr pLinkData, + RetainPtr pLinkData, bool bEndBreak = true, bool bIsOl = false, int32_t iLiCount = 0); diff --git a/xfa/fxfa/cxfa_textparsecontext.h b/xfa/fxfa/cxfa_textparsecontext.h index 3cd5710728..20d914bc59 100644 --- a/xfa/fxfa/cxfa_textparsecontext.h +++ b/xfa/fxfa/cxfa_textparsecontext.h @@ -29,7 +29,7 @@ class CXFA_TextParseContext { } const std::vector& GetDecls() { return decls_; } - CFX_RetainPtr m_pParentStyle; + RetainPtr m_pParentStyle; private: std::vector decls_; diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index 3c78a8686d..9cbb72aa19 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -88,7 +88,7 @@ std::unique_ptr CXFA_TextParser::LoadDefaultSheetStyle() { : nullptr; } -CFX_RetainPtr CXFA_TextParser::CreateRootStyle( +RetainPtr CXFA_TextParser::CreateRootStyle( CXFA_TextProvider* pTextProvider) { CXFA_Font font = pTextProvider->GetFontNode(); CXFA_Para para = pTextProvider->GetParaNode(); @@ -150,7 +150,7 @@ CFX_RetainPtr CXFA_TextParser::CreateRootStyle( return pStyle; } -CFX_RetainPtr CXFA_TextParser::CreateStyle( +RetainPtr CXFA_TextParser::CreateStyle( CFX_CSSComputedStyle* pParentStyle) { auto pNewStyle = m_pSelector->CreateComputedStyle(pParentStyle); ASSERT(pNewStyle); @@ -171,7 +171,7 @@ CFX_RetainPtr CXFA_TextParser::CreateStyle( return pNewStyle; } -CFX_RetainPtr CXFA_TextParser::ComputeStyle( +RetainPtr CXFA_TextParser::ComputeStyle( CFX_XMLNode* pXMLNode, CFX_CSSComputedStyle* pParentStyle) { auto it = m_mapXMLNodeToParseContext.find(pXMLNode); @@ -215,7 +215,7 @@ void CXFA_TextParser::ParseRichText(CFX_XMLNode* pXMLNode, if (!tagProvider->m_bTagAvailable) return; - CFX_RetainPtr pNewStyle; + RetainPtr pNewStyle; if ((tagProvider->GetTagName() != L"body") || (tagProvider->GetTagName() != L"html")) { auto pTextContext = pdfium::MakeUnique(); @@ -315,7 +315,7 @@ bool CXFA_TextParser::IsSpaceRun(CFX_CSSComputedStyle* pStyle) const { return false; } -CFX_RetainPtr CXFA_TextParser::GetFont( +RetainPtr CXFA_TextParser::GetFont( CXFA_TextProvider* pTextProvider, CFX_CSSComputedStyle* pStyle) const { WideStringView wsFamily = L"Courier"; diff --git a/xfa/fxfa/cxfa_textparser.h b/xfa/fxfa/cxfa_textparser.h index ee5c38d2af..9a2232efa1 100644 --- a/xfa/fxfa/cxfa_textparser.h +++ b/xfa/fxfa/cxfa_textparser.h @@ -10,9 +10,9 @@ #include #include -#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" #include "core/fxge/fx_dib.h" #include "xfa/fgas/font/cfgas_gefont.h" @@ -32,9 +32,9 @@ class CXFA_TextParser { void Reset(); void DoParse(CFX_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider); - CFX_RetainPtr CreateRootStyle( + RetainPtr CreateRootStyle( CXFA_TextProvider* pTextProvider); - CFX_RetainPtr ComputeStyle( + RetainPtr ComputeStyle( CFX_XMLNode* pXMLNode, CFX_CSSComputedStyle* pParentStyle); @@ -49,8 +49,8 @@ class CXFA_TextParser { bool GetTabstops(CFX_CSSComputedStyle* pStyle, CXFA_TextTabstopsContext* pTabstopContext); - CFX_RetainPtr GetFont(CXFA_TextProvider* pTextProvider, - CFX_CSSComputedStyle* pStyle) const; + RetainPtr GetFont(CXFA_TextProvider* pTextProvider, + CFX_CSSComputedStyle* pStyle) const; float GetFontSize(CXFA_TextProvider* pTextProvider, CFX_CSSComputedStyle* pStyle) const; @@ -113,7 +113,7 @@ class CXFA_TextParser { void ParseRichText(CFX_XMLNode* pXMLNode, CFX_CSSComputedStyle* pParentStyle); std::unique_ptr ParseTagInfo(CFX_XMLNode* pXMLNode); std::unique_ptr LoadDefaultSheetStyle(); - CFX_RetainPtr CreateStyle( + RetainPtr CreateStyle( CFX_CSSComputedStyle* pParentStyle); bool m_bParsed; diff --git a/xfa/fxfa/cxfa_textpiece.h b/xfa/fxfa/cxfa_textpiece.h index 4ea5a4158c..b5025d2970 100644 --- a/xfa/fxfa/cxfa_textpiece.h +++ b/xfa/fxfa/cxfa_textpiece.h @@ -33,8 +33,8 @@ class CXFA_TextPiece { FX_ARGB dwColor; float fFontSize; CFX_RectF rtPiece; - CFX_RetainPtr pFont; - CFX_RetainPtr pLinkData; + RetainPtr pFont; + RetainPtr pLinkData; }; #endif // XFA_FXFA_CXFA_TEXTPIECE_H_ diff --git a/xfa/fxfa/cxfa_textuserdata.cpp b/xfa/fxfa/cxfa_textuserdata.cpp index 51a2f43194..6c46978609 100644 --- a/xfa/fxfa/cxfa_textuserdata.cpp +++ b/xfa/fxfa/cxfa_textuserdata.cpp @@ -12,12 +12,12 @@ #include "xfa/fxfa/cxfa_linkuserdata.h" CXFA_TextUserData::CXFA_TextUserData( - const CFX_RetainPtr& pStyle) + const RetainPtr& pStyle) : m_pStyle(pStyle) {} CXFA_TextUserData::CXFA_TextUserData( - const CFX_RetainPtr& pStyle, - const CFX_RetainPtr& pLinkData) + const RetainPtr& pStyle, + const RetainPtr& pLinkData) : m_pStyle(pStyle), m_pLinkData(pLinkData) {} CXFA_TextUserData::~CXFA_TextUserData() {} diff --git a/xfa/fxfa/cxfa_textuserdata.h b/xfa/fxfa/cxfa_textuserdata.h index 442e6318c0..c1af217bf1 100644 --- a/xfa/fxfa/cxfa_textuserdata.h +++ b/xfa/fxfa/cxfa_textuserdata.h @@ -7,23 +7,23 @@ #ifndef XFA_FXFA_CXFA_TEXTUSERDATA_H_ #define XFA_FXFA_CXFA_TEXTUSERDATA_H_ -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" class CFX_CSSComputedStyle; class CXFA_LinkUserData; -class CXFA_TextUserData : public CFX_Retainable { +class CXFA_TextUserData : public Retainable { public: template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); - CFX_RetainPtr m_pStyle; - CFX_RetainPtr m_pLinkData; + RetainPtr m_pStyle; + RetainPtr m_pLinkData; private: - explicit CXFA_TextUserData(const CFX_RetainPtr& pStyle); - CXFA_TextUserData(const CFX_RetainPtr& pStyle, - const CFX_RetainPtr& pLinkData); + explicit CXFA_TextUserData(const RetainPtr& pStyle); + CXFA_TextUserData(const RetainPtr& pStyle, + const RetainPtr& pLinkData); ~CXFA_TextUserData() override; }; diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 791b814d9e..260581e73b 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -91,7 +91,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { return !!m_pDIBitmap; } - CFX_RetainPtr m_pDIBitmap; + RetainPtr m_pDIBitmap; bool m_bNamedImage; int32_t m_iImageXDpi; int32_t m_iImageYDpi; @@ -147,7 +147,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { return !!m_pDIBitmap; } - CFX_RetainPtr m_pDIBitmap; + RetainPtr m_pDIBitmap; bool m_bNamedImage; int32_t m_iImageXDpi; int32_t m_iImageYDpi; @@ -919,7 +919,7 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { LoadImageImage(); size.clear(); - CFX_RetainPtr pBitmap = GetImageImage(); + RetainPtr pBitmap = GetImageImage(); if (pBitmap) { int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; @@ -949,7 +949,7 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { LoadImageEditImage(); size.clear(); - CFX_RetainPtr pBitmap = GetImageEditImage(); + RetainPtr pBitmap = GetImageEditImage(); if (pBitmap) { int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; @@ -1459,22 +1459,21 @@ CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() { : nullptr; } -CFX_RetainPtr CXFA_WidgetAcc::GetImageImage() { +RetainPtr CXFA_WidgetAcc::GetImageImage() { return m_pLayoutData ? static_cast(m_pLayoutData.get()) ->m_pDIBitmap : nullptr; } -CFX_RetainPtr CXFA_WidgetAcc::GetImageEditImage() { +RetainPtr CXFA_WidgetAcc::GetImageEditImage() { return m_pLayoutData ? static_cast(m_pLayoutData.get()) ->m_pDIBitmap : nullptr; } -void CXFA_WidgetAcc::SetImageImage( - const CFX_RetainPtr& newImage) { +void CXFA_WidgetAcc::SetImageImage(const RetainPtr& newImage) { CXFA_ImageLayoutData* pData = static_cast(m_pLayoutData.get()); if (pData->m_pDIBitmap != newImage) @@ -1482,7 +1481,7 @@ void CXFA_WidgetAcc::SetImageImage( } void CXFA_WidgetAcc::SetImageEditImage( - const CFX_RetainPtr& newImage) { + const RetainPtr& newImage) { CXFA_ImageEditData* pData = static_cast(m_pLayoutData.get()); if (pData->m_pDIBitmap != newImage) @@ -1493,7 +1492,7 @@ CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { return m_pLayoutData.get(); } -CFX_RetainPtr CXFA_WidgetAcc::GetFDEFont() { +RetainPtr CXFA_WidgetAcc::GetFDEFont() { WideStringView wsFontName = L"Courier"; uint32_t dwFontStyle = 0; if (CXFA_Font font = GetFont(false)) { diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 54fd36077d..be26b94806 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -9,8 +9,8 @@ #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/fx_dib.h" #include "xfa/fxfa/parser/cxfa_box.h" @@ -70,14 +70,14 @@ class CXFA_WidgetAcc : public CXFA_WidgetData { void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); CXFA_TextLayout* GetCaptionTextLayout(); CXFA_TextLayout* GetTextLayout(); - CFX_RetainPtr GetImageImage(); - CFX_RetainPtr GetImageEditImage(); - void SetImageImage(const CFX_RetainPtr& newImage); - void SetImageEditImage(const CFX_RetainPtr& newImage); + RetainPtr GetImageImage(); + RetainPtr GetImageEditImage(); + void SetImageImage(const RetainPtr& newImage); + void SetImageEditImage(const RetainPtr& newImage); void UpdateUIDisplay(CXFA_FFWidget* pExcept = nullptr); CXFA_Node* GetDatasets(); - CFX_RetainPtr GetFDEFont(); + RetainPtr GetFDEFont(); float GetFontSize(); FX_ARGB GetTextColor(); float GetLineHeight(); diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp index 6af7bb7445..0b38fd1fab 100644 --- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp @@ -4591,7 +4591,7 @@ void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, std::unique_ptr argOne = GetSimpleValue(pThis, args, 0); ByteString urlString = ValueToUTF8String(argOne.get()); - CFX_RetainPtr pFile = + RetainPtr pFile = pAppProvider->DownloadURL(WideString::FromUTF8(urlString.AsStringView())); if (!pFile) return; diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index b8595d41dd..929594ff38 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -9,7 +9,7 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/fxfa_basic.h" @@ -170,7 +170,7 @@ class IXFA_AppProvider { * @param[in] wsURL - http, ftp, such as * "http://www.w3.org/TR/REC-xml-names/". */ - virtual CFX_RetainPtr DownloadURL( + virtual RetainPtr DownloadURL( const WideString& wsURL) = 0; /** @@ -259,7 +259,7 @@ class IXFA_DocEnvironment { virtual bool SetGlobalProperty(CXFA_FFDoc* hDoc, const ByteStringView& szPropName, CFXJSE_Value* pValue) = 0; - virtual CFX_RetainPtr OpenLinkedFile( + virtual RetainPtr OpenLinkedFile( CXFA_FFDoc* hDoc, const WideString& wsLink) = 0; }; diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index edc7b23b6b..b0de057e2a 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -328,7 +328,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, void RegenerateFormFile_Container( CXFA_Node* pNode, - const CFX_RetainPtr& pStream, + const RetainPtr& pStream, bool bSaveXML) { XFA_Element eType = pNode->GetElementType(); if (eType == XFA_Element::Field || eType == XFA_Element::Draw || @@ -385,7 +385,7 @@ void RegenerateFormFile_Container( void XFA_DataExporter_RegenerateFormFile( CXFA_Node* pNode, - const CFX_RetainPtr& pStream, + const RetainPtr& pStream, const char* pChecksum, bool bSaveXML) { if (pNode->IsModelNode()) { @@ -460,12 +460,11 @@ CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) CXFA_DataExporter::~CXFA_DataExporter() {} -bool CXFA_DataExporter::Export( - const CFX_RetainPtr& pWrite) { +bool CXFA_DataExporter::Export(const RetainPtr& pWrite) { return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr); } -bool CXFA_DataExporter::Export(const CFX_RetainPtr& pWrite, +bool CXFA_DataExporter::Export(const RetainPtr& pWrite, CXFA_Node* pNode, uint32_t dwFlag, const char* pChecksum) { @@ -479,7 +478,7 @@ bool CXFA_DataExporter::Export(const CFX_RetainPtr& pWrite, } bool CXFA_DataExporter::Export( - const CFX_RetainPtr& pStream, + const RetainPtr& pStream, CXFA_Node* pNode, uint32_t dwFlag, const char* pChecksum) { diff --git a/xfa/fxfa/parser/cxfa_dataexporter.h b/xfa/fxfa/parser/cxfa_dataexporter.h index 4c0d90af9e..0820560c87 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.h +++ b/xfa/fxfa/parser/cxfa_dataexporter.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_PARSER_CXFA_DATAEXPORTER_H_ #define XFA_FXFA_PARSER_CXFA_DATAEXPORTER_H_ -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" class CXFA_Document; class CXFA_Node; @@ -20,14 +20,14 @@ class CXFA_DataExporter { explicit CXFA_DataExporter(CXFA_Document* pDocument); ~CXFA_DataExporter(); - bool Export(const CFX_RetainPtr& pWrite); - bool Export(const CFX_RetainPtr& pWrite, + bool Export(const RetainPtr& pWrite); + bool Export(const RetainPtr& pWrite, CXFA_Node* pNode, uint32_t dwFlag, const char* pChecksum); private: - bool Export(const CFX_RetainPtr& pStream, + bool Export(const RetainPtr& pStream, CXFA_Node* pNode, uint32_t dwFlag, const char* pChecksum); diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp index e4ae3d0796..ab18f6182d 100644 --- a/xfa/fxfa/parser/cxfa_dataimporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp @@ -25,7 +25,7 @@ CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument) CXFA_DataImporter::~CXFA_DataImporter() {} bool CXFA_DataImporter::ImportData( - const CFX_RetainPtr& pDataDocument) { + const RetainPtr& pDataDocument) { auto pDataDocumentParser = pdfium::MakeUnique(m_pDocument.Get(), false); if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) != diff --git a/xfa/fxfa/parser/cxfa_dataimporter.h b/xfa/fxfa/parser/cxfa_dataimporter.h index d3af1de517..dc7764ccad 100644 --- a/xfa/fxfa/parser/cxfa_dataimporter.h +++ b/xfa/fxfa/parser/cxfa_dataimporter.h @@ -7,9 +7,9 @@ #ifndef XFA_FXFA_PARSER_CXFA_DATAIMPORTER_H_ #define XFA_FXFA_PARSER_CXFA_DATAIMPORTER_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" class CXFA_Document; class IFX_SeekableStream; @@ -19,7 +19,7 @@ class CXFA_DataImporter { explicit CXFA_DataImporter(CXFA_Document* pDocument); ~CXFA_DataImporter(); - bool ImportData(const CFX_RetainPtr& pDataDocument); + bool ImportData(const RetainPtr& pDataDocument); private: CFX_UnownedPtr const m_pDocument; diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index 99b36749d1..b8ff8f860c 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -18,7 +18,7 @@ CXFA_DocumentParser::~CXFA_DocumentParser() { } int32_t CXFA_DocumentParser::StartParse( - const CFX_RetainPtr& pStream, + const RetainPtr& pStream, XFA_XDPPACKET ePacketID) { m_pDocument.reset(); m_nodeParser.CloseParser(); diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h index ad3f17f8e8..e788480751 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.h +++ b/xfa/fxfa/parser/cxfa_document_parser.h @@ -22,7 +22,7 @@ class CXFA_DocumentParser { explicit CXFA_DocumentParser(CXFA_FFNotify* pNotify); ~CXFA_DocumentParser(); - int32_t StartParse(const CFX_RetainPtr& pStream, + int32_t StartParse(const RetainPtr& pStream, XFA_XDPPACKET ePacketID); int32_t DoParse(); diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 5b58761712..4574ae48d7 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -273,7 +273,7 @@ void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) { } int32_t CXFA_SimpleParser::StartParse( - const CFX_RetainPtr& pStream, + const RetainPtr& pStream, XFA_XDPPACKET ePacketID) { CloseParser(); m_pFileRead = pStream; diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index 91bfb054b5..00250e7257 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.h +++ b/xfa/fxfa/parser/cxfa_simple_parser.h @@ -25,7 +25,7 @@ class CXFA_SimpleParser { CXFA_SimpleParser(CXFA_Document* pFactory, bool bDocumentParser); ~CXFA_SimpleParser(); - int32_t StartParse(const CFX_RetainPtr& pStream, + int32_t StartParse(const RetainPtr& pStream, XFA_XDPPACKET ePacketID); int32_t DoParse(); CFX_XMLNode* ParseXMLData(const ByteString& wsXML); @@ -77,8 +77,8 @@ class CXFA_SimpleParser { CFX_XMLParser* m_pXMLParser; std::unique_ptr m_pXMLDoc; - CFX_RetainPtr m_pStream; - CFX_RetainPtr m_pFileRead; + RetainPtr m_pStream; + RetainPtr m_pFileRead; CXFA_Document* m_pFactory; CXFA_Node* m_pRootNode; XFA_XDPPACKET m_ePacketID; diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h index 404586bd56..b6839ef708 100644 --- a/xfa/fxfa/parser/xfa_utils.h +++ b/xfa/fxfa/parser/xfa_utils.h @@ -155,7 +155,7 @@ bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode); void XFA_DataExporter_RegenerateFormFile( CXFA_Node* pNode, - const CFX_RetainPtr& pStream, + const RetainPtr& pStream, const char* pChecksum = nullptr, bool bSaveXML = false); diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp index a94e99e200..7cb83e10aa 100644 --- a/xfa/fxgraphics/cxfa_graphics.cpp +++ b/xfa/fxgraphics/cxfa_graphics.cpp @@ -194,7 +194,7 @@ void CXFA_Graphics::FillPath(CXFA_Path* path, RenderDeviceFillPath(path, fillMode, matrix); } -void CXFA_Graphics::StretchImage(const CFX_RetainPtr& source, +void CXFA_Graphics::StretchImage(const RetainPtr& source, const CFX_RectF& rect, const CFX_Matrix& matrix) { if (!source) @@ -305,14 +305,14 @@ void CXFA_Graphics::RenderDeviceFillPath(const CXFA_Path* path, } void CXFA_Graphics::RenderDeviceStretchImage( - const CFX_RetainPtr& source, + const RetainPtr& source, const CFX_RectF& rect, const CFX_Matrix& matrix) { CFX_Matrix m1(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, m_info.CTM.f); m1.Concat(matrix); - CFX_RetainPtr bmp1 = + RetainPtr bmp1 = source->StretchTo(static_cast(rect.Width()), static_cast(rect.Height()), 0, nullptr); CFX_Matrix m2(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); @@ -320,10 +320,10 @@ void CXFA_Graphics::RenderDeviceStretchImage( int32_t left; int32_t top; - CFX_RetainPtr bmp2 = bmp1->FlipImage(false, true); - CFX_RetainPtr bmp3 = bmp2->TransformTo(&m2, &left, &top); + RetainPtr bmp2 = bmp1->FlipImage(false, true); + RetainPtr bmp3 = bmp2->TransformTo(&m2, &left, &top); CFX_RectF r = GetClipRect(); - CFX_RetainPtr bitmap = m_renderDevice->GetBitmap(); + RetainPtr bitmap = m_renderDevice->GetBitmap(); bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), FXSYS_round(r.Width()), FXSYS_round(r.Height()), bmp3, FXSYS_round(r.left - left), FXSYS_round(r.top - top)); @@ -333,7 +333,7 @@ void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path, FX_FillMode fillMode, const CFX_Matrix& matrix) { CXFA_Pattern* pattern = m_info.fillColor.GetPattern(); - CFX_RetainPtr bitmap = m_renderDevice->GetBitmap(); + RetainPtr bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); int32_t height = bitmap->GetHeight(); auto bmp = pdfium::MakeRetain(); @@ -366,7 +366,7 @@ void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path, void CXFA_Graphics::FillPathWithShading(const CXFA_Path* path, FX_FillMode fillMode, const CFX_Matrix& matrix) { - CFX_RetainPtr bitmap = m_renderDevice->GetBitmap(); + RetainPtr bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); int32_t height = bitmap->GetHeight(); float start_x = m_info.fillColor.GetShading()->m_beginPoint.x; @@ -481,9 +481,8 @@ void CXFA_Graphics::FillPathWithShading(const CXFA_Path* path, } } -void CXFA_Graphics::SetDIBitsWithMatrix( - const CFX_RetainPtr& source, - const CFX_Matrix& matrix) { +void CXFA_Graphics::SetDIBitsWithMatrix(const RetainPtr& source, + const CFX_Matrix& matrix) { if (matrix.IsIdentity()) { m_renderDevice->SetDIBits(source, 0, 0); } else { @@ -492,8 +491,8 @@ void CXFA_Graphics::SetDIBitsWithMatrix( m.Concat(matrix); int32_t left; int32_t top; - CFX_RetainPtr bmp1 = source->FlipImage(false, true); - CFX_RetainPtr bmp2 = bmp1->TransformTo(&m, &left, &top); + RetainPtr bmp1 = source->FlipImage(false, true); + RetainPtr bmp2 = bmp1->TransformTo(&m, &left, &top); m_renderDevice->SetDIBits(bmp2, left, top); } } diff --git a/xfa/fxgraphics/cxfa_graphics.h b/xfa/fxgraphics/cxfa_graphics.h index 99f86870c3..6b9dcb9a86 100644 --- a/xfa/fxgraphics/cxfa_graphics.h +++ b/xfa/fxgraphics/cxfa_graphics.h @@ -65,7 +65,7 @@ class CXFA_Graphics { void FillPath(CXFA_Path* path, FX_FillMode fillMode, const CFX_Matrix* matrix); - void StretchImage(const CFX_RetainPtr& source, + void StretchImage(const RetainPtr& source, const CFX_RectF& rect, const CFX_Matrix& matrix); void ConcatMatrix(const CFX_Matrix* matrix); @@ -91,7 +91,7 @@ class CXFA_Graphics { void RenderDeviceFillPath(const CXFA_Path* path, FX_FillMode fillMode, const CFX_Matrix* matrix); - void RenderDeviceStretchImage(const CFX_RetainPtr& source, + void RenderDeviceStretchImage(const RetainPtr& source, const CFX_RectF& rect, const CFX_Matrix& matrix); @@ -102,7 +102,7 @@ class CXFA_Graphics { FX_FillMode fillMode, const CFX_Matrix& matrix); - void SetDIBitsWithMatrix(const CFX_RetainPtr& source, + void SetDIBitsWithMatrix(const RetainPtr& source, const CFX_Matrix& matrix); CFX_RenderDevice* const m_renderDevice; // Not owned. -- cgit v1.2.3