diff options
Diffstat (limited to 'core/fpdfapi')
20 files changed, 92 insertions, 65 deletions
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.cpp b/core/fpdfapi/cmaps/fpdf_cmaps.cpp index cb2f09fb3c..13aec268ae 100644 --- a/core/fpdfapi/cmaps/fpdf_cmaps.cpp +++ b/core/fpdfapi/cmaps/fpdf_cmaps.cpp @@ -61,7 +61,7 @@ void FPDFAPI_FindEmbeddedCMap(const CFX_ByteString& bsName, CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); const FXCMAP_CMap* pCMaps = - pFontGlobals->m_EmbeddedCharsets[charset].m_pMapList; + pFontGlobals->m_EmbeddedCharsets[charset].m_pMapList.Get(); for (uint32_t i = 0; i < pFontGlobals->m_EmbeddedCharsets[charset].m_Count; i++) { if (bsName == pCMaps[i].m_Name) { diff --git a/core/fpdfapi/font/font_int.h b/core/fpdfapi/font/font_int.h index ebd08e258a..5544a1b016 100644 --- a/core/fpdfapi/font/font_int.h +++ b/core/fpdfapi/font/font_int.h @@ -14,6 +14,7 @@ #include "core/fpdfapi/font/cpdf_cidfont.h" #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" class CPDF_CID2UnicodeMap; @@ -194,7 +195,7 @@ class CPDF_ToUnicodeMap { uint32_t GetUnicode(); std::map<uint32_t, uint32_t> m_Map; - CPDF_CID2UnicodeMap* m_pBaseMap; + CFX_UnownedPtr<CPDF_CID2UnicodeMap> m_pBaseMap; CFX_WideTextBuf m_MultiCharBuf; }; @@ -213,7 +214,7 @@ class CPDF_FontGlobals { CPDF_CMapManager m_CMapManager; struct { - const FXCMAP_CMap* m_pMapList; + CFX_UnownedPtr<const FXCMAP_CMap> m_pMapList; uint32_t m_Count; } m_EmbeddedCharsets[CIDSET_NUM_SETS]; struct { diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp index e6665c83ac..747e6844ec 100644 --- a/core/fpdfapi/page/cpdf_color.cpp +++ b/core/fpdfapi/page/cpdf_color.cpp @@ -160,6 +160,6 @@ CPDF_Pattern* CPDF_Color::GetPattern() const { if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) return nullptr; - PatternValue* pvalue = (PatternValue*)m_pBuffer; + PatternValue* pvalue = reinterpret_cast<PatternValue*>(m_pBuffer); return pvalue->m_pPattern; } diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index 345180f368..90ef8944d3 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -190,7 +190,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace { void EnableStdConversion(bool bEnabled) override; CPDF_ColorSpace* m_pBaseCS; - CPDF_CountedColorSpace* m_pCountedBaseCS; + CFX_UnownedPtr<CPDF_CountedColorSpace> m_pCountedBaseCS; int m_nBaseComponents; int m_MaxIndex; CFX_ByteString m_Table; diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h index ffd622379e..9db6712824 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.h +++ b/core/fpdfapi/page/cpdf_shadingobject.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_PAGE_CPDF_SHADINGOBJECT_H_ #include "core/fpdfapi/page/cpdf_pageobject.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" class CPDF_ShadingPattern; @@ -26,7 +27,7 @@ class CPDF_ShadingObject : public CPDF_PageObject { void CalcBoundingBox(); - CPDF_ShadingPattern* m_pShading; + CFX_UnownedPtr<CPDF_ShadingPattern> m_pShading; CFX_Matrix m_Matrix; }; diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h index 068d772bc3..24ad4c200e 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.h +++ b/core/fpdfapi/page/cpdf_shadingpattern.h @@ -55,7 +55,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern { ShadingType GetShadingType() const { return m_ShadingType; } bool IsShadingObject() const { return m_bShadingObj; } CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); } - CPDF_ColorSpace* GetCS() const { return m_pCS; } + CPDF_ColorSpace* GetCS() const { return m_pCS.Get(); } const std::vector<std::unique_ptr<CPDF_Function>>& GetFuncs() const { return m_pFunctions; } @@ -67,9 +67,9 @@ class CPDF_ShadingPattern : public CPDF_Pattern { // Still keep |m_pCS| as some CPDF_ColorSpace (name object) are not managed // as counted objects. Refer to CPDF_DocPageData::GetColorSpace. - CPDF_ColorSpace* m_pCS; + CFX_UnownedPtr<CPDF_ColorSpace> m_pCS; - CPDF_CountedColorSpace* m_pCountedCS; + CFX_UnownedPtr<CPDF_CountedColorSpace> m_pCountedCS; std::vector<std::unique_ptr<CPDF_Function>> m_pFunctions; }; diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h index f83adc1a30..9a13877544 100644 --- a/core/fpdfapi/parser/cfdf_document.h +++ b/core/fpdfapi/parser/cfdf_document.h @@ -11,6 +11,7 @@ #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" #include "core/fpdfapi/parser/cpdf_object.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" class CPDF_Dictionary; @@ -27,12 +28,12 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { ~CFDF_Document() override; bool WriteBuf(CFX_ByteTextBuf& buf) const; - CPDF_Dictionary* GetRoot() const { return m_pRootDict; } + CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); } protected: void ParseStream(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile); - CPDF_Dictionary* m_pRootDict; + CFX_UnownedPtr<CPDF_Dictionary> m_pRootDict; CFX_RetainPtr<IFX_SeekableReadStream> m_pFile; }; diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index 8edf062590..f47c859697 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -13,6 +13,7 @@ #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_syntax_parser.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" class CPDF_Dictionary; @@ -204,7 +205,7 @@ class CPDF_DataAvail final { uint32_t m_dwRootObjNum; uint32_t m_dwInfoObjNum; std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized; - CPDF_Object* m_pTrailer; + CFX_UnownedPtr<CPDF_Object> m_pTrailer; bool m_bDocAvail; FX_FILESIZE m_dwHeaderOffset; FX_FILESIZE m_dwLastXRefOffset; diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 1923992d7a..24a989665f 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -82,7 +82,7 @@ class PDFObjectsTest : public testing::Test { // All direct objects. CPDF_Object* objs[] = {boolean_false_obj, boolean_true_obj, number_int_obj, number_float_obj, str_reg_obj, str_spec_obj, - name_obj, m_ArrayObj, m_DictObj, + name_obj, m_ArrayObj.Get(), m_DictObj.Get(), stream_obj, null_obj}; m_DirectObjTypes = { CPDF_Object::BOOLEAN, CPDF_Object::BOOLEAN, CPDF_Object::NUMBER, @@ -179,9 +179,9 @@ class PDFObjectsTest : public testing::Test { std::vector<std::unique_ptr<CPDF_Object>> m_DirectObjs; std::vector<int> m_DirectObjTypes; std::vector<std::unique_ptr<CPDF_Object>> m_RefObjs; - CPDF_Dictionary* m_DictObj; - CPDF_Dictionary* m_StreamDictObj; - CPDF_Array* m_ArrayObj; + CFX_UnownedPtr<CPDF_Dictionary> m_DictObj; + CFX_UnownedPtr<CPDF_Dictionary> m_StreamDictObj; + CFX_UnownedPtr<CPDF_Array> m_ArrayObj; std::vector<CPDF_Object*> m_IndirectObjs; }; @@ -244,23 +244,29 @@ TEST_F(PDFObjectsTest, GetInteger) { TEST_F(PDFObjectsTest, GetDict) { const CPDF_Dictionary* const direct_obj_results[] = { - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, m_DictObj, m_StreamDictObj, nullptr}; + nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, m_DictObj.Get(), m_StreamDictObj.Get(), + nullptr}; // Check for direct objects. for (size_t i = 0; i < m_DirectObjs.size(); ++i) EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetDict()); // Check indirect references. - const CPDF_Dictionary* const indirect_obj_results[] = { - nullptr, nullptr, nullptr, nullptr, nullptr, m_DictObj, m_StreamDictObj}; + const CPDF_Dictionary* const indirect_obj_results[] = {nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + m_DictObj.Get(), + m_StreamDictObj.Get()}; for (size_t i = 0; i < m_RefObjs.size(); ++i) EXPECT_TRUE(Equal(indirect_obj_results[i], m_RefObjs[i]->GetDict())); } TEST_F(PDFObjectsTest, GetArray) { const CPDF_Array* const direct_obj_results[] = { - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, m_ArrayObj, nullptr, nullptr, nullptr}; + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, m_ArrayObj.Get(), nullptr, nullptr, nullptr}; // Check for direct objects. for (size_t i = 0; i < m_DirectObjs.size(); ++i) EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->AsArray()); diff --git a/core/fpdfapi/render/cpdf_imageloader.cpp b/core/fpdfapi/render/cpdf_imageloader.cpp index 53b6009c15..b09b919baa 100644 --- a/core/fpdfapi/render/cpdf_imageloader.cpp +++ b/core/fpdfapi/render/cpdf_imageloader.cpp @@ -36,8 +36,8 @@ bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage, GroupFamily, bLoadMask, pRenderStatus); } else { ret = m_pImageObject->GetImage()->StartLoadDIBSource( - pRenderStatus->m_pFormResource, pRenderStatus->m_pPageResource, bStdCS, - GroupFamily, bLoadMask); + pRenderStatus->m_pFormResource.Get(), + pRenderStatus->m_pPageResource.Get(), bStdCS, GroupFamily, bLoadMask); } if (!ret) HandleFailure(); diff --git a/core/fpdfapi/render/cpdf_imageloader.h b/core/fpdfapi/render/cpdf_imageloader.h index f17f29cce5..47dd2f9812 100644 --- a/core/fpdfapi/render/cpdf_imageloader.h +++ b/core/fpdfapi/render/cpdf_imageloader.h @@ -9,6 +9,7 @@ #include <memory> +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" #include "core/fxge/fx_dib.h" @@ -37,8 +38,8 @@ class CPDF_ImageLoader { private: void HandleFailure(); - CPDF_PageRenderCache* m_pCache; - CPDF_ImageObject* m_pImageObject; + CFX_UnownedPtr<CPDF_PageRenderCache> m_pCache; + CFX_UnownedPtr<CPDF_ImageObject> m_pImageObject; }; #endif // CORE_FPDFAPI_RENDER_CPDF_IMAGELOADER_H_ diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index ff4ed9c7d9..716203a7a5 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -225,8 +225,8 @@ void CPDF_ImageRenderer::CalculateDrawImage( CFX_Matrix* pNewMatrix, const FX_RECT& rect) const { CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, pBitmapDevice2, nullptr, - nullptr, nullptr, nullptr, nullptr, 0, + bitmap_render.Initialize(m_pRenderStatus->m_pContext.Get(), pBitmapDevice2, + nullptr, nullptr, nullptr, nullptr, nullptr, 0, m_pRenderStatus->m_bDropObjects, nullptr, true); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, pDIBSource, 0xffffffff, 255, @@ -276,7 +276,7 @@ bool CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { bitmap_device1.GetBitmap()->Clear(0xffffff); CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, + bitmap_render.Initialize(m_pRenderStatus->m_pContext.Get(), &bitmap_device1, nullptr, nullptr, nullptr, nullptr, &m_pRenderStatus->m_Options, 0, m_pRenderStatus->m_bDropObjects, nullptr, true); @@ -329,7 +329,7 @@ bool CPDF_ImageRenderer::DrawMaskedImage() { bitmap_device1.GetBitmap()->Clear(0xffffff); #endif CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, + bitmap_render.Initialize(m_pRenderStatus->m_pContext.Get(), &bitmap_device1, nullptr, nullptr, nullptr, nullptr, nullptr, 0, m_pRenderStatus->m_bDropObjects, nullptr, true); CPDF_ImageRenderer image_render; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h index bf73098cde..46159284b2 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.h +++ b/core/fpdfapi/render/cpdf_imagerenderer.h @@ -10,6 +10,7 @@ #include <memory> #include "core/fpdfapi/render/cpdf_imageloader.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxge/dib/cfx_imagerenderer.h" @@ -72,7 +73,7 @@ class CPDF_ImageRenderer { CFX_RetainPtr<CFX_DIBitmap> m_pClone; int m_BitmapAlpha; bool m_bPatternColor; - CPDF_Pattern* m_pPattern; + CFX_UnownedPtr<CPDF_Pattern> m_pPattern; FX_ARGB m_FillArgb; uint32_t m_Flags; std::unique_ptr<CFX_ImageTransformer> m_pTransformer; diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp index a997e34906..455b7f5ddb 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.cpp +++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp @@ -95,8 +95,8 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap( new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pImage); } int ret = m_pCurImageCacheEntry->StartGetCachedBitmap( - pRenderStatus->m_pFormResource, m_pPage->m_pPageResources.Get(), bStdCS, - GroupFamily, bLoadMask, pRenderStatus); + pRenderStatus->m_pFormResource.Get(), m_pPage->m_pPageResources.Get(), + bStdCS, GroupFamily, bLoadMask, pRenderStatus); if (ret == 2) return true; diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp index 2cd59cac18..dec513276d 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.cpp +++ b/core/fpdfapi/render/cpdf_rendercontext.cpp @@ -72,12 +72,12 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, pOptions, layer.m_pObjectHolder->m_Transparency, false, nullptr); - status.RenderObjectList(layer.m_pObjectHolder, &FinalMatrix); + status.RenderObjectList(layer.m_pObjectHolder.Get(), &FinalMatrix); } else { status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, pOptions, layer.m_pObjectHolder->m_Transparency, false, nullptr); - status.RenderObjectList(layer.m_pObjectHolder, &layer.m_Matrix); + status.RenderObjectList(layer.m_pObjectHolder.Get(), &layer.m_Matrix); } if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); @@ -85,3 +85,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, break; } } + +CPDF_RenderContext::Layer::Layer() {} + +CPDF_RenderContext::Layer::Layer(const Layer& that) = default; + +CPDF_RenderContext::Layer::~Layer() {} diff --git a/core/fpdfapi/render/cpdf_rendercontext.h b/core/fpdfapi/render/cpdf_rendercontext.h index 4980d37ed6..220ff2b775 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.h +++ b/core/fpdfapi/render/cpdf_rendercontext.h @@ -9,6 +9,7 @@ #include <vector> +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_coordinates.h" @@ -27,7 +28,11 @@ class CPDF_RenderContext { public: class Layer { public: - CPDF_PageObjectHolder* m_pObjectHolder; + Layer(); + Layer(const Layer& that); + ~Layer(); + + CFX_UnownedPtr<CPDF_PageObjectHolder> m_pObjectHolder; CFX_Matrix m_Matrix; }; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 7c17ff56b4..beeca3febe 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1235,7 +1235,8 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, res = 0; } CPDF_ScaledRenderBuffer buffer; - if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { + if (!buffer.Initialize(m_pContext.Get(), m_pDevice, rect, pObj, &m_Options, + res)) { return; } CFX_Matrix matrix = *pObj2Device; @@ -1249,8 +1250,8 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, } } CPDF_RenderStatus status; - status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr, - nullptr, nullptr, &m_Options, m_Transparency, + status.Initialize(m_pContext.Get(), buffer.GetDevice(), buffer.GetMatrix(), + nullptr, nullptr, nullptr, &m_Options, m_Transparency, m_bDropObjects, pFormResource); status.RenderSingleObject(pObj, &matrix); buffer.OutputToDevice(); @@ -1273,9 +1274,9 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, pResources = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); } CPDF_RenderStatus status; - status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, - &m_Options, m_Transparency, m_bDropObjects, pResources, - false); + status.Initialize(m_pContext.Get(), m_pDevice, nullptr, m_pStopObj, this, + pFormObj, &m_Options, m_Transparency, m_bDropObjects, + pResources, false); status.m_curBlend = m_curBlend; { CFX_RenderDevice::StateRestorer restorer(m_pDevice); @@ -1605,9 +1606,9 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, } } CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, - nullptr, nullptr, &m_Options, 0, m_bDropObjects, - pFormResource, true); + bitmap_render.Initialize(m_pContext.Get(), &bitmap_device, nullptr, + m_pStopObj, nullptr, nullptr, &m_Options, 0, + m_bDropObjects, pFormResource, true); bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); #if defined _SKIA_SUPPORT_PATHS_ bitmap_device.Flush(); @@ -1871,7 +1872,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, matrix.e += iChar ? textobj->m_CharPos[iChar - 1] : 0; matrix.Concat(text_matrix); matrix.Concat(*pObj2Device); - if (!pType3Char->LoadBitmap(m_pContext)) { + if (!pType3Char->LoadBitmap(m_pContext.Get())) { if (!glyphs.empty()) { for (int i = 0; i < iChar; i++) { const FXTEXT_GLYPHPOS& glyph = glyphs[i]; @@ -1897,7 +1898,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, } if (fill_alpha == 255) { CPDF_RenderStatus status; - status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, + status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this, pStates.get(), &Options, pType3Char->m_pForm->m_Transparency, m_bDropObjects, pFormResource, false, pType3Char, fill_argb); @@ -1919,8 +1920,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, } bitmap_device.GetBitmap()->Clear(0); CPDF_RenderStatus status; - status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this, - pStates.get(), &Options, + status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr, + this, pStates.get(), &Options, pType3Char->m_pForm->m_Transparency, m_bDropObjects, pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache = m_Type3FontCache; @@ -2093,7 +2094,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, return; } CPDF_DeviceBuffer buffer; - buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150); + buffer.Initialize(m_pContext.Get(), m_pDevice, &clip_rect, m_pCurObj, 150); CFX_Matrix FinalMatrix = *pMatrix; FinalMatrix.Concat(*buffer.GetMatrix()); CFX_RetainPtr<CFX_DIBitmap> pBitmap = buffer.GetBitmap(); @@ -2190,7 +2191,7 @@ void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj, CFX_Matrix matrix = pShadingObj->m_Matrix; matrix.Concat(*pObj2Device); - DrawShading(pShadingObj->m_pShading, &matrix, rect, + DrawShading(pShadingObj->m_pShading.Get(), &matrix, rect, FXSYS_round(255 * pShadingObj->m_GeneralState.GetFillAlpha()), m_Options.m_ColorMode == RENDER_COLOR_ALPHA); } @@ -2276,7 +2277,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, original.y - mtPattern2Device.f); CFX_RenderDevice::StateRestorer restorer2(m_pDevice); CPDF_RenderStatus status; - status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, + status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this, pStates.get(), &m_Options, pPattern->form()->m_Transparency, m_bDropObjects, pFormResource); @@ -2628,7 +2629,7 @@ CFX_RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( CPDF_RenderOptions options; options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; CPDF_RenderStatus status; - status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, + status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr, nullptr, nullptr, &options, 0, m_bDropObjects, pFormResource, true, nullptr, 0, color_space_family, bLuminosity); status.RenderObjectList(&form, &matrix); diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h index ab5ddd9f0d..47fbac8a7c 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.h +++ b/core/fpdfapi/render/cpdf_renderstatus.h @@ -13,6 +13,7 @@ #include "core/fpdfapi/page/cpdf_clippath.h" #include "core/fpdfapi/page/cpdf_graphicstates.h" #include "core/fpdfapi/render/cpdf_renderoptions.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxge/cfx_renderdevice.h" class CFX_PathData; @@ -61,15 +62,15 @@ class CPDF_RenderStatus { bool ContinueSingleObject(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device, IFX_Pause* pPause); - CPDF_RenderContext* GetContext() { return m_pContext; } + CPDF_RenderContext* GetContext() const { return m_pContext.Get(); } #if defined _SKIA_SUPPORT_ void DebugVerifyDeviceIsPreMultiplied() const; #endif CPDF_RenderOptions m_Options; - CPDF_Dictionary* m_pFormResource; - CPDF_Dictionary* m_pPageResource; + CFX_UnownedPtr<CPDF_Dictionary> m_pFormResource; + CFX_UnownedPtr<CPDF_Dictionary> m_pPageResource; std::vector<CPDF_Type3Font*> m_Type3FontCache; private: @@ -157,7 +158,7 @@ class CPDF_RenderStatus { static const int kRenderMaxRecursionDepth = 64; static int s_CurrentRecursionDepth; - CPDF_RenderContext* m_pContext; + CFX_UnownedPtr<CPDF_RenderContext> m_pContext; bool m_bStopped; CFX_RenderDevice* m_pDevice; CFX_Matrix m_DeviceMatrix; @@ -172,7 +173,7 @@ class CPDF_RenderStatus { bool m_bStdCS; uint32_t m_GroupFamily; bool m_bLoadMask; - CPDF_Type3Char* m_pType3Char; + CFX_UnownedPtr<CPDF_Type3Char> m_pType3Char; FX_ARGB m_T3FillColor; int m_curBlend; }; diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp index 74d506c05c..17e33af3b1 100644 --- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp +++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp @@ -67,8 +67,8 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, } m_Matrix.Scale(0.5f, 0.5f); } - m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, - &m_Matrix); + m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject.Get(), + pOptions, &m_Matrix); return true; } diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.h b/core/fpdfapi/render/cpdf_scaledrenderbuffer.h index 92fabefbee..47ab5ad39f 100644 --- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.h +++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.h @@ -9,6 +9,7 @@ #include <memory> +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxge/cfx_defaultrenderdevice.h" @@ -28,17 +29,18 @@ class CPDF_ScaledRenderBuffer { const CPDF_PageObject* pObj, const CPDF_RenderOptions* pOptions, int max_dpi); - CFX_RenderDevice* GetDevice() { - return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice; + + CFX_RenderDevice* GetDevice() const { + return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice.Get(); } CFX_Matrix* GetMatrix() { return &m_Matrix; } void OutputToDevice(); private: - CFX_RenderDevice* m_pDevice; - CPDF_RenderContext* m_pContext; + CFX_UnownedPtr<CFX_RenderDevice> m_pDevice; + CFX_UnownedPtr<CPDF_RenderContext> m_pContext; FX_RECT m_Rect; - const CPDF_PageObject* m_pObject; + CFX_UnownedPtr<const CPDF_PageObject> m_pObject; std::unique_ptr<CFX_DefaultRenderDevice> m_pBitmapDevice; CFX_Matrix m_Matrix; }; |