Chromium Code Reviews| 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(); |
|
Tom Sepez
2016/12/14 21:31:43
battle for another day ...
|
| if (!pAlphaMask) { |
| FX_Free(dest_buf); |
| return false; |