diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-27 13:51:46 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-28 14:14:50 +0000 |
commit | 0004f29bf6ee3c6060a272c79f14993e92e053c7 (patch) | |
tree | b82385e4853a157e10148af8d95ebb6bae4fb4c7 /xfa/fxfa/cxfa_ffdoc.cpp | |
parent | 369fe1f7f9f3a424ee3cf8f992c3128db27fa479 (diff) | |
download | pdfium-0004f29bf6ee3c6060a272c79f14993e92e053c7.tar.xz |
Refcount all CFX_DIBSources (and subclasses) all the time.
There are currently several ownership models for these objects,
including ad-hoc logic for sharing and deletion, and the
now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs.
Replace them all with the internal refcount scheme.
Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872
Reviewed-on: https://pdfium-review.googlesource.com/3166
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_ffdoc.cpp')
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index fdeacf7f0f..e14500a725 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -332,10 +332,6 @@ bool CXFA_FFDoc::CloseDoc() { m_DocView.reset(); m_pNotify.reset(nullptr); m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this); - - for (const auto& pair : m_HashToDibDpiMap) - delete pair.second.pDibSource; - m_HashToDibDpiMap.clear(); m_pApp->ClearEventTargets(); return true; @@ -345,9 +341,10 @@ CPDF_Document* CXFA_FFDoc::GetPDFDoc() { return m_pPDFDoc; } -CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { +CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage( + const CFX_WideStringC& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { if (!m_pPDFDoc) return nullptr; @@ -356,7 +353,7 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, if (it != m_HashToDibDpiMap.end()) { iImageXDpi = it->second.iImageXDpi; iImageYDpi = it->second.iImageYDpi; - return static_cast<CFX_DIBitmap*>(it->second.pDibSource); + return it->second.pDibSource.As<CFX_DIBitmap>(); } CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); @@ -396,7 +393,7 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, IFX_MemoryStream::Create((uint8_t*)streamAcc.GetData(), streamAcc.GetSize()); - CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer( + CFX_RetainPtr<CFX_DIBitmap> pDibSource = XFA_LoadImageFromBuffer( pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi}; return pDibSource; |