summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-06 06:29:28 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-06 06:29:28 -0800
commit1a1d7648d3e338b756e464cebb2ae1a815359afa (patch)
treedefa2de6d2cb61efd95ef212eb3e89e1a5811032 /xfa/fxfa/app
parent7341149c634e0ab9a619898826440f6e952cf0aa (diff)
downloadpdfium-1a1d7648d3e338b756e464cebb2ae1a815359afa.tar.xz
Return unique_ptrs from CFX_DIBitmap::Clone().
Because that's what clone does. Perform immediate release in some spots to avoid disrupting too much at once. Review-Url: https://codereview.chromium.org/2534953004
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index bc1854eb42..dfe418b76b 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
#include "core/fxcodec/codec/ccodec_progressivedecoder.h"
#include "core/fxcodec/fx_codec.h"
+#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -647,7 +648,7 @@ bool CXFA_ImageRenderer::StartDIBSource() {
if (m_pDIBSource->HasAlpha() &&
!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) &&
!(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
- m_pCloneConvert.reset(m_pDIBSource->CloneConvert(FXDIB_Rgb));
+ m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb);
if (!m_pCloneConvert) {
m_Result = false;
return false;
@@ -783,10 +784,8 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
top + pDIBitmap->GetHeight());
rect.Intersect(m_pDevice->GetClipBox());
- CFX_DIBitmap* pClone = nullptr;
- bool bClone = false;
+ CFX_MaybeOwned<CFX_DIBitmap> pClone;
if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) {
- bClone = true;
pClone = m_pDevice->GetBackDrop()->Clone(&rect);
CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap();
pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(),
@@ -803,35 +802,34 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
pClone = pDIBitmap;
}
if (m_pDevice->GetBackDrop()) {
- m_pDevice->SetDIBits(pClone, rect.left, rect.top);
+ m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top);
} else {
if (pDIBitmap->IsAlphaMask())
return;
m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top,
blend_mode);
}
- if (bClone) {
- delete pClone;
- }
}
return;
}
- if (pDIBitmap->HasAlpha() &&
- !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) {
- CFX_DIBitmap* pCloneConvert = pDIBitmap->CloneConvert(FXDIB_Rgb);
- if (!pCloneConvert) {
- return;
- }
- CXFA_ImageRenderer imageRender;
- bool bRet = imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb,
- m_BitmapAlpha, &m_ImageMatrix, m_Flags);
- while (bRet) {
- bRet = imageRender.Continue(nullptr);
- }
- delete pCloneConvert;
+ if (!pDIBitmap->HasAlpha() ||
+ (m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) {
+ return;
+ }
+ std::unique_ptr<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)) {
return;
}
+ while (imageRender.Continue(nullptr))
+ continue;
}
+
void XFA_DrawImage(CFX_Graphics* pGS,
const CFX_RectF& rtImage,
CFX_Matrix* pMatrix,