diff options
author | tsepez <tsepez@chromium.org> | 2016-12-06 06:29:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-06 06:29:28 -0800 |
commit | 1a1d7648d3e338b756e464cebb2ae1a815359afa (patch) | |
tree | defa2de6d2cb61efd95ef212eb3e89e1a5811032 /core/fpdfapi/render/cpdf_renderstatus.cpp | |
parent | 7341149c634e0ab9a619898826440f6e952cf0aa (diff) | |
download | pdfium-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 'core/fpdfapi/render/cpdf_renderstatus.cpp')
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 126e04662e..88dbb030ce 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -46,6 +46,7 @@ #include "core/fpdfapi/render/render_int.h" #include "core/fpdfdoc/cpdf_occontext.h" #include "core/fxcodec/fx_codec.h" +#include "core/fxcrt/cfx_maybe_owned.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/cfx_fxgedevice.h" #include "core/fxge/cfx_graphstatedata.h" @@ -2265,7 +2266,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, std::unique_ptr<CFX_DIBitmap> pEnlargedBitmap = DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, pObj2Device, 8, 8, m_Options.m_Flags); - pPatternBitmap.reset(pEnlargedBitmap->StretchTo(width, height)); + pPatternBitmap = pEnlargedBitmap->StretchTo(width, height); } else { pPatternBitmap = DrawPatternBitmap( m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, @@ -2439,10 +2440,8 @@ void CPDF_RenderStatus::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(), @@ -2459,17 +2458,13 @@ void CPDF_RenderStatus::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()) { + if (pDIBitmap->IsAlphaMask()) return; - } m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, blend_mode); } - if (bClone) { - delete pClone; - } } return; } |