summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 14:15:14 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 14:15:14 -0800
commit72c1bda4efaf0121e13b794cb886acd9806b6c89 (patch)
tree42930bca08650730ef2aba728799c9428edab79e /core/fpdfapi/page
parent5e4388ef805b1666a1064e4dc73f4f1e792aa041 (diff)
downloadpdfium-72c1bda4efaf0121e13b794cb886acd9806b6c89.tar.xz
Return unique_ptr from GetAlphaMask.
Rename GetAlphaMask => CloneAlphaMask since it does more than get. Rename CopyAlphaMask => SetAlphaMask, as it copies IN, not OUT. ditto for CopyPalette => SetPalette. BUG= Review-Url: https://codereview.chromium.org/2572243002
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index feafde3b36..97969551c6 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -247,8 +247,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap) {
bCopyWithoutAlpha = false;
}
- const CFX_DIBitmap* pMaskBitmap =
- pBitmap->HasAlpha() ? pBitmap->GetAlphaMask() : nullptr;
+ std::unique_ptr<CFX_DIBitmap> pMaskBitmap;
+ if (pBitmap->HasAlpha())
+ pMaskBitmap = pBitmap->CloneAlphaMask();
+
if (pMaskBitmap) {
int32_t maskWidth = pMaskBitmap->GetWidth();
int32_t maskHeight = pMaskBitmap->GetHeight();
@@ -275,7 +277,6 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap) {
mask_buf, mask_size, std::move(pMaskDict));
pDict->SetNewFor<CPDF_Reference>("SMask", m_pDocument,
pNewStream->GetObjNum());
- delete pMaskBitmap;
}
uint8_t* src_buf = pBitmap->GetBuffer();