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

Unified Diff: core/fxge/dib/fx_dib_convert.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 | « core/fpdfapi/render/cpdf_imagerenderer.cpp ('k') | core/fxge/dib/fx_dib_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/dib/fx_dib_convert.cpp
diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp
index b1362462c3c72bc750134bedcd3d2f4b21b8bcd3..aad3f343e209a538f78a58504681536748f6f8b3 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;
« no previous file with comments | « core/fpdfapi/render/cpdf_imagerenderer.cpp ('k') | core/fxge/dib/fx_dib_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698