summaryrefslogtreecommitdiff
path: root/core/fxge/dib/fx_dib_convert.cpp
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/fxge/dib/fx_dib_convert.cpp
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/fxge/dib/fx_dib_convert.cpp')
-rw-r--r--core/fxge/dib/fx_dib_convert.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp
index b1362462c3..aad3f343e2 100644
--- a/core/fxge/dib/fx_dib_convert.cpp
+++ b/core/fxge/dib/fx_dib_convert.cpp
@@ -8,6 +8,7 @@
#include <utility>
#include "core/fxcodec/fx_codec.h"
+#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxge/fx_dib.h"
#include "third_party/base/ptr_util.h"
@@ -791,26 +792,26 @@ std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::CloneConvert(
if (!pClone->Create(m_Width, m_Height, dest_format))
return nullptr;
- CFX_DIBitmap* pSrcAlpha = nullptr;
+ CFX_MaybeOwned<CFX_DIBitmap> pSrcAlpha;
if (HasAlpha()) {
- pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
+ if (GetFormat() == FXDIB_Argb)
+ pSrcAlpha = CloneAlphaMask();
+ else
+ pSrcAlpha = m_pAlphaMask;
+
if (!pSrcAlpha)
return nullptr;
}
-
bool ret = true;
if (dest_format & 0x0200) {
if (dest_format == FXDIB_Argb) {
- ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha)
- : pClone->LoadChannel(FXDIB_Alpha, 0xff);
+ ret = pSrcAlpha
+ ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha.Get(), FXDIB_Alpha)
+ : pClone->LoadChannel(FXDIB_Alpha, 0xff);
} else {
- ret = pClone->CopyAlphaMask(pSrcAlpha);
+ ret = pClone->SetAlphaMask(pSrcAlpha.Get());
}
}
- if (pSrcAlpha && pSrcAlpha != m_pAlphaMask) {
- delete pSrcAlpha;
- pSrcAlpha = nullptr;
- }
if (!ret)
return nullptr;
@@ -820,7 +821,7 @@ std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::CloneConvert(
return nullptr;
}
if (pal_8bpp)
- pClone->CopyPalette(pal_8bpp.get());
+ pClone->SetPalette(pal_8bpp.get());
return pClone;
}
@@ -867,7 +868,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
}
} else if (dest_format & 0x0200) {
if (src_format == FXDIB_Argb) {
- pAlphaMask = GetAlphaMask();
+ pAlphaMask = CloneAlphaMask().release();
if (!pAlphaMask) {
FX_Free(dest_buf);
return false;