Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Unified Diff: core/fpdfapi/page/cpdf_image.cpp

Issue 2572243002: Return unique_ptr from GetAlphaMask. (Closed)
Patch Set: rebase, nits, typo. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/render/cpdf_imagerenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/page/cpdf_image.cpp
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index feafde3b36bcfcaa8158fab2fb8602a013802463..97969551c6541632623916f9c5b94671243a1255 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();
« no previous file with comments | « no previous file | core/fpdfapi/render/cpdf_imagerenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698