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_widgetacc.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_widgetacc.cpp')
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 58 |
1 files changed, 20 insertions, 38 deletions
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() { |