diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffimage.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffimageedit.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 15 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.h | 27 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 91 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.h | 14 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 58 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.h | 8 |
8 files changed, 108 insertions, 109 deletions
diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp index 81188c14d1..23ed88616d 100644 --- a/xfa/fxfa/app/xfa_ffimage.cpp +++ b/xfa/fxfa/app/xfa_ffimage.cpp @@ -43,7 +43,7 @@ void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS, CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CFX_DIBitmap* pDIBitmap = GetDataAcc()->GetImageImage(); + CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = GetDataAcc()->GetImageImage(); if (!pDIBitmap) return; diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index b776579152..624ef3f442 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -60,7 +60,7 @@ void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); RenderCaption(pGS, &mtRotate); - CFX_DIBitmap* pDIBitmap = m_pDataAcc->GetImageEditImage(); + CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDataAcc->GetImageEditImage(); if (!pDIBitmap) return; 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; diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h index 1d46387a5e..80dafba029 100644 --- a/xfa/fxfa/cxfa_ffdoc.h +++ b/xfa/fxfa/cxfa_ffdoc.h @@ -20,11 +20,30 @@ class CXFA_FFNotify; class CXFA_FFDocView; struct FX_IMAGEDIB_AND_DPI { - CFX_DIBSource* pDibSource; + FX_IMAGEDIB_AND_DPI(); + FX_IMAGEDIB_AND_DPI(const FX_IMAGEDIB_AND_DPI& that); + FX_IMAGEDIB_AND_DPI(const CFX_RetainPtr<CFX_DIBSource>& pDib, + int32_t xDpi, + int32_t yDpi); + ~FX_IMAGEDIB_AND_DPI(); + + CFX_RetainPtr<CFX_DIBSource> pDibSource; int32_t iImageXDpi; int32_t iImageYDpi; }; +inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI() = default; +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<CFX_DIBSource>& pDib, + int32_t xDpi, + int32_t yDpi) + : pDibSource(pDib), iImageXDpi(xDpi), iImageYDpi(yDpi) {} + +inline FX_IMAGEDIB_AND_DPI::~FX_IMAGEDIB_AND_DPI() = default; + class CXFA_FFDoc { public: CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment); @@ -48,9 +67,9 @@ class CXFA_FFDoc { CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout); CXFA_FFDocView* GetDocView(); CPDF_Document* GetPDFDoc(); - CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi); + CFX_RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const CFX_WideStringC& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi); bool SavePackage(XFA_HashCode code, const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile, diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 504ce70ad9..2e9c9a6ac8 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -558,7 +558,7 @@ class CXFA_ImageRenderer { ~CXFA_ImageRenderer(); bool Start(CFX_RenderDevice* pDevice, - CFX_DIBSource* pDIBSource, + const CFX_RetainPtr<CFX_DIBSource>& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -568,7 +568,7 @@ class CXFA_ImageRenderer { protected: bool StartDIBSource(); - void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + void CompositeDIBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, int left, int top, FX_ARGB mask_argb, @@ -579,8 +579,8 @@ class CXFA_ImageRenderer { CFX_RenderDevice* m_pDevice; int m_Status; CFX_Matrix m_ImageMatrix; - CFX_DIBSource* m_pDIBSource; - std::unique_ptr<CFX_DIBitmap> m_pCloneConvert; + CFX_RetainPtr<CFX_DIBSource> m_pDIBSource; + CFX_RetainPtr<CFX_DIBitmap> m_pCloneConvert; int m_BitmapAlpha; FX_ARGB m_FillArgb; uint32_t m_Flags; @@ -594,7 +594,6 @@ class CXFA_ImageRenderer { CXFA_ImageRenderer::CXFA_ImageRenderer() : m_pDevice(nullptr), m_Status(0), - m_pDIBSource(nullptr), m_BitmapAlpha(255), m_FillArgb(0), m_Flags(0), @@ -609,7 +608,7 @@ CXFA_ImageRenderer::~CXFA_ImageRenderer() { } bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, - CFX_DIBSource* pDIBSource, + const CFX_RetainPtr<CFX_DIBSource>& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -645,7 +644,7 @@ bool CXFA_ImageRenderer::StartDIBSource() { m_Result = false; return false; } - CFX_DIBSource* pDib = m_pDIBSource; + CFX_RetainPtr<CFX_DIBSource> pDib = m_pDIBSource; if (m_pDIBSource->HasAlpha() && !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { @@ -654,13 +653,13 @@ bool CXFA_ImageRenderer::StartDIBSource() { m_Result = false; return false; } - pDib = m_pCloneConvert.get(); + pDib = m_pCloneConvert; } FX_RECT clip_box = m_pDevice->GetClipBox(); clip_box.Intersect(image_rect); m_Status = 2; - m_pTransformer.reset( - new CFX_ImageTransformer(pDib, &m_ImageMatrix, m_Flags, &clip_box)); + m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>( + pDib, &m_ImageMatrix, m_Flags, &clip_box); m_pTransformer->Start(); return true; } @@ -700,11 +699,11 @@ 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); - std::unique_ptr<CFX_DIBitmap> pStretched( - m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); + CFX_RetainPtr<CFX_DIBitmap> pStretched = + m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip); if (pStretched) { - CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top, - m_FillArgb, m_BitmapAlpha, m_BlendType, false); + CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb, + m_BitmapAlpha, m_BlendType, false); } return false; } @@ -714,7 +713,7 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_pTransformer->Continue(pPause)) return true; - std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap()); + CFX_RetainPtr<CFX_DIBitmap> pBitmap = m_pTransformer->DetachBitmap(); if (!pBitmap) return false; @@ -722,14 +721,14 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_BitmapAlpha != 255) m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); m_Result = - m_pDevice->SetBitMask(pBitmap.get(), m_pTransformer->result().left, + m_pDevice->SetBitMask(pBitmap, m_pTransformer->result().left, m_pTransformer->result().top, m_FillArgb); } else { if (m_BitmapAlpha != 255) pBitmap->MultiplyAlpha(m_BitmapAlpha); m_Result = m_pDevice->SetDIBitsWithBlend( - pBitmap.get(), m_pTransformer->result().left, - m_pTransformer->result().top, m_BlendType); + pBitmap, m_pTransformer->result().left, m_pTransformer->result().top, + m_BlendType); } return false; } @@ -739,13 +738,14 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { return false; } -void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency) { +void CXFA_ImageRenderer::CompositeDIBitmap( + const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency) { if (!pDIBitmap) { return; } @@ -785,10 +785,10 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitmap->GetHeight()); rect.Intersect(m_pDevice->GetClipBox()); - CFX_MaybeOwned<CFX_DIBitmap> pClone; + CFX_RetainPtr<CFX_DIBitmap> pClone; if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { pClone = m_pDevice->GetBackDrop()->Clone(&rect); - CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); + CFX_RetainPtr<CFX_DIBitmap> pForeBitmap = m_pDevice->GetBitmap(); pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), pForeBitmap, rect.left, rect.top); left = left >= 0 ? 0 : left; @@ -803,7 +803,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, pClone = pDIBitmap; } if (m_pDevice->GetBackDrop()) { - m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top); + m_pDevice->SetDIBits(pClone, rect.left, rect.top); } else { if (pDIBitmap->IsAlphaMask()) return; @@ -817,14 +817,14 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, (m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { return; } - std::unique_ptr<CFX_DIBitmap> pCloneConvert = + CFX_RetainPtr<CFX_DIBitmap> pCloneConvert = pDIBitmap->CloneConvert(FXDIB_Rgb); if (!pCloneConvert) return; CXFA_ImageRenderer imageRender; - if (!imageRender.Start(m_pDevice, pCloneConvert.get(), m_FillArgb, - m_BitmapAlpha, &m_ImageMatrix, m_Flags)) { + if (!imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb, m_BitmapAlpha, + &m_ImageMatrix, m_Flags)) { return; } while (imageRender.Continue(nullptr)) @@ -834,7 +834,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, void XFA_DrawImage(CFX_Graphics* pGS, const CFX_RectF& rtImage, CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, + const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, int32_t iAspect, int32_t iImageXDpi, int32_t iImageYDpi, @@ -1034,18 +1034,19 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType) { return FXCODEC_IMAGE_TIF; return FXCODEC_IMAGE_UNKNOWN; } -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - bool& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { + +CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + bool& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { CFX_WideString wsHref; - pImage->GetHref(wsHref); CFX_WideString wsImage; + pImage->GetHref(wsHref); pImage->GetContent(wsImage); - if (wsHref.IsEmpty() && wsImage.IsEmpty()) { + if (wsHref.IsEmpty() && wsImage.IsEmpty()) return nullptr; - } + CFX_WideString wsContentType; pImage->GetContentType(wsContentType); FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); @@ -1071,7 +1072,7 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, } else { CFX_WideString wsURL = wsHref; if (wsURL.Left(7) != L"http://" && wsURL.Left(6) != L"ftp://") { - CFX_DIBitmap* pBitmap = + CFX_RetainPtr<CFX_DIBitmap> pBitmap = pDoc->GetPDFNamedImage(wsURL.AsStringC(), iImageXDpi, iImageYDpi); if (pBitmap) { bNameImage = true; @@ -1085,7 +1086,7 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, return nullptr; } bNameImage = false; - CFX_DIBitmap* pBitmap = + CFX_RetainPtr<CFX_DIBitmap> pBitmap = XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); FX_Free(pImageBuffer); return pBitmap; @@ -1111,7 +1112,7 @@ static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, return dibFormat; } -CFX_DIBitmap* XFA_LoadImageFromBuffer( +CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer( const CFX_RetainPtr<IFX_SeekableReadStream>& pImageFileRead, FXCODEC_IMAGE_TYPE type, int32_t& iImageXDpi, @@ -1125,7 +1126,7 @@ CFX_DIBitmap* XFA_LoadImageFromBuffer( return nullptr; CFX_DIBAttribute dibAttr; - CFX_DIBitmap* pBitmap = nullptr; + CFX_RetainPtr<CFX_DIBitmap> pBitmap; std::unique_ptr<CCodec_ProgressiveDecoder> pProgressiveDecoder = pCodecMgr->CreateProgressiveDecoder(); pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false); @@ -1149,7 +1150,7 @@ CFX_DIBitmap* XFA_LoadImageFromBuffer( int32_t iComponents = pProgressiveDecoder->GetNumComponents(); int32_t iBpc = pProgressiveDecoder->GetBPC(); FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); - pBitmap = new CFX_DIBitmap(); + pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); 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 02a7b21b15..8c83c4cf4c 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -41,20 +41,20 @@ CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); void XFA_DrawImage(CFX_Graphics* pGS, const CFX_RectF& rtImage, CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, + const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, int32_t iAspect, int32_t iImageXDpi, int32_t iImageYDpi, int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - bool& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi); +CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + bool& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi); -CFX_DIBitmap* XFA_LoadImageFromBuffer( +CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer( const CFX_RetainPtr<IFX_SeekableReadStream>& pImageFileRead, FXCODEC_IMAGE_TYPE type, int32_t& iImageXDpi, diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 4c8e37291a..6e76119115 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -67,15 +67,9 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { public: CXFA_ImageLayoutData() - : m_pDIBitmap(nullptr), - m_bNamedImage(false), - m_iImageXDpi(0), - m_iImageYDpi(0) {} + : m_bNamedImage(false), m_iImageXDpi(0), m_iImageYDpi(0) {} - ~CXFA_ImageLayoutData() override { - if (m_pDIBitmap && !m_bNamedImage) - delete m_pDIBitmap; - } + ~CXFA_ImageLayoutData() override {} bool LoadImageData(CXFA_WidgetAcc* pAcc) { if (m_pDIBitmap) @@ -95,7 +89,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { return !!m_pDIBitmap; } - CFX_DIBitmap* m_pDIBitmap; + CFX_RetainPtr<CFX_DIBitmap> m_pDIBitmap; bool m_bNamedImage; int32_t m_iImageXDpi; int32_t m_iImageYDpi; @@ -132,15 +126,9 @@ class CXFA_TextEditData : public CXFA_FieldLayoutData { class CXFA_ImageEditData : public CXFA_FieldLayoutData { public: CXFA_ImageEditData() - : m_pDIBitmap(nullptr), - m_bNamedImage(false), - m_iImageXDpi(0), - m_iImageYDpi(0) {} + : m_bNamedImage(false), m_iImageXDpi(0), m_iImageYDpi(0) {} - ~CXFA_ImageEditData() override { - if (m_pDIBitmap && !m_bNamedImage) - delete m_pDIBitmap; - } + ~CXFA_ImageEditData() override {} bool LoadImageData(CXFA_WidgetAcc* pAcc) { if (m_pDIBitmap) @@ -157,7 +145,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { return !!m_pDIBitmap; } - CFX_DIBitmap* m_pDIBitmap; + CFX_RetainPtr<CFX_DIBitmap> m_pDIBitmap; bool m_bNamedImage; int32_t m_iImageXDpi; int32_t m_iImageYDpi; @@ -929,7 +917,8 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { LoadImageImage(); size.clear(); - if (CFX_DIBitmap* pBitmap = GetImageImage()) { + CFX_RetainPtr<CFX_DIBitmap> pBitmap = GetImageImage(); + if (pBitmap) { int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; GetImageDpi(iImageXDpi, iImageYDpi); @@ -958,7 +947,8 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { LoadImageEditImage(); size.clear(); - if (CFX_DIBitmap* pBitmap = GetImageEditImage()) { + CFX_RetainPtr<CFX_DIBitmap> pBitmap = GetImageEditImage(); + if (pBitmap) { int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; GetImageEditDpi(iImageXDpi, iImageYDpi); @@ -1467,42 +1457,34 @@ CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() { : nullptr; } -CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() { +CFX_RetainPtr<CFX_DIBitmap> CXFA_WidgetAcc::GetImageImage() { return m_pLayoutData ? static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get()) ->m_pDIBitmap : nullptr; } -CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() { +CFX_RetainPtr<CFX_DIBitmap> CXFA_WidgetAcc::GetImageEditImage() { return m_pLayoutData ? static_cast<CXFA_ImageEditData*>(m_pLayoutData.get()) ->m_pDIBitmap : nullptr; } -void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) { +void CXFA_WidgetAcc::SetImageImage( + const CFX_RetainPtr<CFX_DIBitmap>& newImage) { CXFA_ImageLayoutData* pData = static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get()); - if (pData->m_pDIBitmap == newImage) - return; - - if (pData->m_pDIBitmap && !pData->m_bNamedImage) - delete pData->m_pDIBitmap; - - pData->m_pDIBitmap = newImage; + if (pData->m_pDIBitmap != newImage) + pData->m_pDIBitmap = newImage; } -void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) { +void CXFA_WidgetAcc::SetImageEditImage( + const CFX_RetainPtr<CFX_DIBitmap>& newImage) { CXFA_ImageEditData* pData = static_cast<CXFA_ImageEditData*>(m_pLayoutData.get()); - if (pData->m_pDIBitmap == newImage) - return; - - if (pData->m_pDIBitmap && !pData->m_bNamedImage) - delete pData->m_pDIBitmap; - - pData->m_pDIBitmap = newImage; + if (pData->m_pDIBitmap != newImage) + pData->m_pDIBitmap = newImage; } CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 8a7a7eb73d..c08aa1d587 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -69,10 +69,10 @@ class CXFA_WidgetAcc : public CXFA_WidgetData { void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); CXFA_TextLayout* GetCaptionTextLayout(); CXFA_TextLayout* GetTextLayout(); - CFX_DIBitmap* GetImageImage(); - CFX_DIBitmap* GetImageEditImage(); - void SetImageImage(CFX_DIBitmap* newImage); - void SetImageEditImage(CFX_DIBitmap* newImage); + CFX_RetainPtr<CFX_DIBitmap> GetImageImage(); + CFX_RetainPtr<CFX_DIBitmap> GetImageEditImage(); + void SetImageImage(const CFX_RetainPtr<CFX_DIBitmap>& newImage); + void SetImageEditImage(const CFX_RetainPtr<CFX_DIBitmap>& newImage); void UpdateUIDisplay(CXFA_FFWidget* pExcept = nullptr); CXFA_Node* GetDatasets(); |