| 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 a9986138a1dbe2c3e0731d8da04ff296f1a3abbc..c98df3d58d50b96a264b2a6424f8db55cfdcded5 100644
|
| --- a/core/fxge/dib/fx_dib_convert.cpp
|
| +++ b/core/fxge/dib/fx_dib_convert.cpp
|
| @@ -649,7 +649,7 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
|
| const CFX_DIBSource* pSrcBitmap,
|
| int src_left,
|
| int src_top,
|
| - uint32_t*& d_pal) {
|
| + std::unique_ptr<uint32_t, FxFreeDeleter>* p_pal) {
|
| FXDIB_Format src_format = pSrcBitmap->GetFormat();
|
| switch (dest_format) {
|
| case FXDIB_Invalid:
|
| @@ -685,17 +685,19 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
|
| case FXDIB_8bppRgba: {
|
| if ((src_format & 0xff) == 8 && !pSrcBitmap->GetPalette()) {
|
| return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width,
|
| - height, pSrcBitmap, src_left, src_top, d_pal);
|
| + height, pSrcBitmap, src_left, src_top, p_pal);
|
| }
|
| - d_pal = FX_Alloc(uint32_t, 256);
|
| + p_pal->reset(FX_Alloc(uint32_t, 256));
|
| if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) &&
|
| pSrcBitmap->GetPalette()) {
|
| return ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height,
|
| - pSrcBitmap, src_left, src_top, d_pal);
|
| + pSrcBitmap, src_left, src_top,
|
| + p_pal->get());
|
| }
|
| if ((src_format & 0xff) >= 24) {
|
| return ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, width, height,
|
| - pSrcBitmap, src_left, src_top, d_pal);
|
| + pSrcBitmap, src_left, src_top,
|
| + p_pal->get());
|
| }
|
| return FALSE;
|
| }
|
| @@ -800,16 +802,13 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format) const {
|
| if (!ret)
|
| return nullptr;
|
|
|
| - uint32_t* pal_8bpp = nullptr;
|
| + std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp;
|
| if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(),
|
| - m_Width, m_Height, this, 0, 0, pal_8bpp)) {
|
| - FX_Free(pal_8bpp);
|
| + m_Width, m_Height, this, 0, 0, &pal_8bpp)) {
|
| return nullptr;
|
| }
|
| - if (pal_8bpp) {
|
| - pClone->CopyPalette(pal_8bpp);
|
| - FX_Free(pal_8bpp);
|
| - }
|
| + if (pal_8bpp)
|
| + pClone->CopyPalette(pal_8bpp.get());
|
| return pClone.release();
|
| }
|
|
|
| @@ -874,14 +873,12 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
|
| }
|
| }
|
| FX_BOOL ret = FALSE;
|
| - uint32_t* pal_8bpp = nullptr;
|
| + std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp;
|
| ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height,
|
| - this, 0, 0, pal_8bpp);
|
| + this, 0, 0, &pal_8bpp);
|
| if (!ret) {
|
| - FX_Free(pal_8bpp);
|
| - if (pAlphaMask != m_pAlphaMask) {
|
| + if (pAlphaMask != m_pAlphaMask)
|
| delete pAlphaMask;
|
| - }
|
| FX_Free(dest_buf);
|
| return FALSE;
|
| }
|
| @@ -889,8 +886,7 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
|
| delete m_pAlphaMask;
|
| }
|
| m_pAlphaMask = pAlphaMask;
|
| - FX_Free(m_pPalette);
|
| - m_pPalette = pal_8bpp;
|
| + m_pPalette.reset(pal_8bpp.release());
|
| if (!m_bExtBuf) {
|
| FX_Free(m_pBuffer);
|
| }
|
|
|