diff options
author | dsinclair <dsinclair@chromium.org> | 2017-03-28 15:47:47 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-28 15:48:01 +0000 |
commit | 31b08d4cdaa17d7a03f35e087096a77036af98ec (patch) | |
tree | 40234b81f2972c857a33a86cb4b59868e56bb86b /core/fxcodec | |
parent | a3e9bf66c3483db926602aa62b0bd1ff8d1357a1 (diff) | |
download | pdfium-31b08d4cdaa17d7a03f35e087096a77036af98ec.tar.xz |
Revert "Refcount all CFX_DIBSources (and subclasses) all the time."
This reverts commit 0004f29bf6ee3c6060a272c79f14993e92e053c7.
Reason for revert: Breaks build with skia_paths enabled (which will break the chrome roll).
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1858:38: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>'
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1861:42: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>'
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2987:15: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2991:18: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2999:17: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:3001:43: error: no member named 'GetObject' in 'CFX_RetainPtr<CFX_DIBitmap>'
Original change's description:
> Refcount all CFX_DIBSources (and subclasses) all the time.
>
> There are currently several ownership models for these objects,
> including ad-hoc logic for sharing and deletion, and the
> now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs.
>
> Replace them all with the internal refcount scheme.
>
> Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872
> Reviewed-on: https://pdfium-review.googlesource.com/3166
> Reviewed-by: dsinclair <dsinclair@chromium.org>
> Commit-Queue: dsinclair <dsinclair@chromium.org>
>
TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I678b1fbc5e666cf7a19372ebaff3270fb115ba5e
Reviewed-on: https://pdfium-review.googlesource.com/3243
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcodec')
-rw-r--r-- | core/fxcodec/codec/ccodec_jpegmodule.h | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_progressivedecoder.h | 32 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_tiffmodule.cpp | 56 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_tiffmodule.h | 3 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_jpeg.cpp | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_progress.cpp | 90 | ||||
-rw-r--r-- | core/fxcodec/codec/icodec_tiffmodule.h | 2 |
7 files changed, 89 insertions, 98 deletions
diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h index 7782b5fad1..bad6fa6a94 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.h +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -60,7 +60,7 @@ class CCodec_JpegModule { uint32_t GetAvailInput(FXJPEG_Context* pContext, uint8_t** avail_buf_ptr); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ - static bool JpegEncode(const CFX_RetainPtr<CFX_DIBSource>& pSource, + static bool JpegEncode(const CFX_DIBSource* pSource, uint8_t** dest_buf, FX_STRSIZE* dest_size); #endif diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index cd96ee76a0..61703dde29 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -58,7 +58,7 @@ class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, void SetClipBox(FX_RECT* clip); FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause = nullptr); - FXCODEC_STATUS StartDecode(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, + FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap, int start_x, int start_y, int size_x, @@ -138,7 +138,7 @@ class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, uint32_t m_SrcSize; uint8_t* m_pDecodeBuf; int m_ScanlineSize; - CFX_RetainPtr<CFX_DIBitmap> m_pDeviceBitmap; + CFX_DIBitmap* m_pDeviceBitmap; bool m_bInterpol; CFXCODEC_WeightTable m_WeightHorz; CFXCODEC_VertTable m_WeightVert; @@ -201,35 +201,29 @@ class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, FXCODEC_STATUS& err_status); bool GifReadMoreData(ICodec_GifModule* pGifModule, FXCODEC_STATUS& err_status); - void GifDoubleLineResampleVert( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - double scale_y, - int des_row); - void PngOneOneMapResampleHorz( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - int32_t des_line, - uint8_t* src_scan, - FXCodec_Format src_format); + void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap, + double scale_y, + int des_row); + void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap, + int32_t des_line, + uint8_t* src_scan, + FXCodec_Format src_format); bool DetectImageType(FXCODEC_IMAGE_TYPE imageType, CFX_DIBAttribute* pAttribute); void GetDownScale(int& down_scale); void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format); - void ReSampleScanline(const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, + void ReSampleScanline(CFX_DIBitmap* pDeviceBitmap, int32_t des_line, uint8_t* src_scan, FXCodec_Format src_format); - void Resample(const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, + void Resample(CFX_DIBitmap* pDeviceBitmap, int32_t src_line, uint8_t* src_scan, FXCodec_Format src_format); - void ResampleVert(const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - double scale_y, - int des_row); + void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); bool JpegReadMoreData(CCodec_JpegModule* pJpegModule, FXCODEC_STATUS& err_status); - void ResampleVertBT(const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - double scale_y, - int des_row); + void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); }; #endif // CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp index 0a0b56ce94..3807ec75aa 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.cpp +++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp @@ -31,26 +31,26 @@ class CCodec_TiffContext { int32_t* comps, int32_t* bpc, CFX_DIBAttribute* pAttribute); - bool Decode(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap); + bool Decode(CFX_DIBitmap* pDIBitmap); CFX_RetainPtr<IFX_SeekableReadStream> io_in() const { return m_io_in; } uint32_t offset() const { return m_offset; } void set_offset(uint32_t offset) { m_offset = offset; } private: - bool IsSupport(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap) const; - void SetPalette(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, uint16_t bps); - bool Decode1bppRGB(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, + bool IsSupport(const CFX_DIBitmap* pDIBitmap) const; + void SetPalette(CFX_DIBitmap* pDIBitmap, uint16_t bps); + bool Decode1bppRGB(CFX_DIBitmap* pDIBitmap, int32_t height, int32_t width, uint16_t bps, uint16_t spp); - bool Decode8bppRGB(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, + bool Decode8bppRGB(CFX_DIBitmap* pDIBitmap, int32_t height, int32_t width, uint16_t bps, uint16_t spp); - bool Decode24bppRGB(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, + bool Decode24bppRGB(CFX_DIBitmap* pDIBitmap, int32_t height, int32_t width, uint16_t bps, @@ -287,8 +287,7 @@ bool CCodec_TiffContext::LoadFrameInfo(int32_t frame, return true; } -bool CCodec_TiffContext::IsSupport( - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap) const { +bool CCodec_TiffContext::IsSupport(const CFX_DIBitmap* pDIBitmap) const { if (TIFFIsTiled(m_tif_ctx)) return false; @@ -318,9 +317,7 @@ bool CCodec_TiffContext::IsSupport( return planarconfig != PLANARCONFIG_SEPARATE; } -void CCodec_TiffContext::SetPalette( - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, - uint16_t bps) { +void CCodec_TiffContext::SetPalette(CFX_DIBitmap* pDIBitmap, uint16_t bps) { uint16_t* red_orig = nullptr; uint16_t* green_orig = nullptr; uint16_t* blue_orig = nullptr; @@ -343,12 +340,11 @@ void CCodec_TiffContext::SetPalette( } } -bool CCodec_TiffContext::Decode1bppRGB( - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, - int32_t height, - int32_t width, - uint16_t bps, - uint16_t spp) { +bool CCodec_TiffContext::Decode1bppRGB(CFX_DIBitmap* pDIBitmap, + int32_t height, + int32_t width, + uint16_t bps, + uint16_t spp) { if (pDIBitmap->GetBPP() != 1 || spp != 1 || bps != 1 || !IsSupport(pDIBitmap)) { return false; @@ -372,12 +368,11 @@ bool CCodec_TiffContext::Decode1bppRGB( return true; } -bool CCodec_TiffContext::Decode8bppRGB( - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, - int32_t height, - int32_t width, - uint16_t bps, - uint16_t spp) { +bool CCodec_TiffContext::Decode8bppRGB(CFX_DIBitmap* pDIBitmap, + int32_t height, + int32_t width, + uint16_t bps, + uint16_t spp) { if (pDIBitmap->GetBPP() != 8 || spp != 1 || (bps != 4 && bps != 8) || !IsSupport(pDIBitmap)) { return false; @@ -409,12 +404,11 @@ bool CCodec_TiffContext::Decode8bppRGB( return true; } -bool CCodec_TiffContext::Decode24bppRGB( - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, - int32_t height, - int32_t width, - uint16_t bps, - uint16_t spp) { +bool CCodec_TiffContext::Decode24bppRGB(CFX_DIBitmap* pDIBitmap, + int32_t height, + int32_t width, + uint16_t bps, + uint16_t spp) { if (pDIBitmap->GetBPP() != 24 || !IsSupport(pDIBitmap)) return false; @@ -438,7 +432,7 @@ bool CCodec_TiffContext::Decode24bppRGB( return true; } -bool CCodec_TiffContext::Decode(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap) { +bool CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) { uint32_t img_wid = pDIBitmap->GetWidth(); uint32_t img_hei = pDIBitmap->GetHeight(); uint32_t width = 0; @@ -499,7 +493,7 @@ bool CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx, } bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx, - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap) { + class CFX_DIBitmap* pDIBitmap) { return ctx->Decode(pDIBitmap); } diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h index 8878ad504e..a8820f4aac 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.h +++ b/core/fxcodec/codec/ccodec_tiffmodule.h @@ -24,8 +24,7 @@ class CCodec_TiffModule : public ICodec_TiffModule { int32_t* comps, int32_t* bpc, CFX_DIBAttribute* pAttribute) override; - bool Decode(CCodec_TiffContext* ctx, - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap) override; + bool Decode(CCodec_TiffContext* ctx, class CFX_DIBitmap* pDIBitmap) override; void DestroyDecoder(CCodec_TiffContext* ctx) override; }; diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 0431560529..c797605575 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -484,7 +484,7 @@ uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx, #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #define JPEG_BLOCK_SIZE 1048576 -bool CCodec_JpegModule::JpegEncode(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CCodec_JpegModule::JpegEncode(const CFX_DIBSource* pSource, uint8_t** dest_buf, FX_STRSIZE* dest_size) { struct jpeg_error_mgr jerr; diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index bd890f89ff..af7f24e4fe 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -404,7 +404,7 @@ bool CCodec_ProgressiveDecoder::PngReadHeader(int width, } bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t*& src_buf) { - CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDeviceBitmap; + CFX_DIBitmap* pDIBitmap = m_pDeviceBitmap; if (!pDIBitmap) { ASSERT(false); return false; @@ -473,7 +473,7 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t*& src_buf) { } void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, + CFX_DIBitmap* pDeviceBitmap, int32_t des_line, uint8_t* src_scan, FXCodec_Format src_format) { @@ -546,7 +546,7 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass, int line) { - CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDeviceBitmap; + CFX_DIBitmap* pDIBitmap = m_pDeviceBitmap; ASSERT(pDIBitmap); int src_top = m_clipBox.top; int src_bottom = m_clipBox.bottom; @@ -658,7 +658,7 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( m_GifFrameRect = img_rc; m_SrcPassNumber = interlace ? 4 : 1; int32_t pal_index = m_GifBgIndex; - CFX_RetainPtr<CFX_DIBitmap> pDevice = m_pDeviceBitmap; + CFX_DIBitmap* pDevice = m_pDeviceBitmap; if (trans_index >= pal_num) trans_index = -1; if (trans_index != -1) { @@ -708,7 +708,7 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num, uint8_t* row_buf) { - CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDeviceBitmap; + CFX_DIBitmap* pDIBitmap = m_pDeviceBitmap; ASSERT(pDIBitmap); int32_t img_width = m_GifFrameRect.Width(); if (!pDIBitmap->HasAlpha()) { @@ -770,7 +770,7 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num, } void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, + CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row) { int des_Bpp = pDeviceBitmap->GetBPP() >> 3; @@ -895,7 +895,7 @@ bool CCodec_ProgressiveDecoder::BmpInputImagePositionBuf(uint32_t rcd_pos) { void CCodec_ProgressiveDecoder::BmpReadScanline(int32_t row_num, uint8_t* row_buf) { - CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDeviceBitmap; + CFX_DIBitmap* pDIBitmap = m_pDeviceBitmap; ASSERT(pDIBitmap); FXSYS_memcpy(m_pDecodeBuf, row_buf, m_ScanlineSize); int src_top = m_clipBox.top; @@ -923,10 +923,9 @@ void CCodec_ProgressiveDecoder::BmpReadScanline(int32_t row_num, ResampleVertBT(pDIBitmap, scale_y, des_row); } -void CCodec_ProgressiveDecoder::ResampleVertBT( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - double scale_y, - int des_row) { +void CCodec_ProgressiveDecoder::ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, + double scale_y, + int des_row) { int des_Bpp = pDeviceBitmap->GetBPP() >> 3; uint32_t des_ScanOffet = m_startX * des_Bpp; int des_top = m_startY; @@ -1441,11 +1440,10 @@ void CCodec_ProgressiveDecoder::GetTransMethod(FXDIB_Format des_format, } } -void CCodec_ProgressiveDecoder::ReSampleScanline( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - int des_line, - uint8_t* src_scan, - FXCodec_Format src_format) { +void CCodec_ProgressiveDecoder::ReSampleScanline(CFX_DIBitmap* pDeviceBitmap, + int des_line, + uint8_t* src_scan, + FXCodec_Format src_format) { int src_left = m_clipBox.left; int des_left = m_startX; uint8_t* des_scan = @@ -1644,10 +1642,9 @@ void CCodec_ProgressiveDecoder::ReSampleScanline( } } -void CCodec_ProgressiveDecoder::ResampleVert( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - double scale_y, - int des_row) { +void CCodec_ProgressiveDecoder::ResampleVert(CFX_DIBitmap* pDeviceBitmap, + double scale_y, + int des_row) { int des_Bpp = pDeviceBitmap->GetBPP() >> 3; uint32_t des_ScanOffet = m_startX * des_Bpp; if (m_bInterpol) { @@ -1760,11 +1757,10 @@ void CCodec_ProgressiveDecoder::ResampleVert( } } -void CCodec_ProgressiveDecoder::Resample( - const CFX_RetainPtr<CFX_DIBitmap>& pDeviceBitmap, - int32_t src_line, - uint8_t* src_scan, - FXCodec_Format src_format) { +void CCodec_ProgressiveDecoder::Resample(CFX_DIBitmap* pDeviceBitmap, + int32_t src_line, + uint8_t* src_scan, + FXCodec_Format src_format) { int src_top = m_clipBox.top; int des_top = m_startY; int src_hei = m_clipBox.Height(); @@ -1835,14 +1831,13 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames, } } -FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap, - int start_x, - int start_y, - int size_x, - int size_y, - int32_t frames, - bool bInterpol) { +FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, + int start_x, + int start_y, + int size_x, + int size_y, + int32_t frames, + bool bInterpol) { if (m_status != FXCODEC_STATUS_DECODE_READY) return FXCODEC_STATUS_ERROR; @@ -2220,9 +2215,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { return m_status; } - auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb); if (!pDIBitmap->GetBuffer()) { + delete pDIBitmap; m_pDeviceBitmap = nullptr; m_pFile = nullptr; m_status = FXCODEC_STATUS_ERR_MEMORY; @@ -2230,41 +2226,45 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } ret = pTiffModule->Decode(m_pTiffContext, pDIBitmap); if (!ret) { + delete pDIBitmap; m_pDeviceBitmap = nullptr; m_pFile = nullptr; m_status = FXCODEC_STATUS_ERROR; return m_status; } - CFX_RetainPtr<CFX_DIBitmap> pClipBitmap = + CFX_DIBitmap* pClipBitmap = (m_clipBox.left == 0 && m_clipBox.top == 0 && m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) ? pDIBitmap - : pDIBitmap->Clone(&m_clipBox); + : pDIBitmap->Clone(&m_clipBox).release(); + if (pDIBitmap != pClipBitmap) { + delete pDIBitmap; + } if (!pClipBitmap) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; } - CFX_RetainPtr<CFX_DIBitmap> pFormatBitmap; + CFX_DIBitmap* pFormatBitmap = nullptr; switch (m_pDeviceBitmap->GetFormat()) { case FXDIB_8bppRgb: - pFormatBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + pFormatBitmap = new CFX_DIBitmap; pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_8bppRgb); break; case FXDIB_8bppMask: - pFormatBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + pFormatBitmap = new CFX_DIBitmap; pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_8bppMask); break; case FXDIB_Rgb: - pFormatBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + pFormatBitmap = new CFX_DIBitmap; pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_Rgb); break; case FXDIB_Rgb32: - pFormatBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + pFormatBitmap = new CFX_DIBitmap; pFormatBitmap->Create(pClipBitmap->GetWidth(), pClipBitmap->GetHeight(), FXDIB_Rgb32); break; @@ -2312,14 +2312,18 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { default: break; } + if (pClipBitmap != pFormatBitmap) { + delete pClipBitmap; + } if (!pFormatBitmap) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; } - CFX_RetainPtr<CFX_DIBitmap> pStrechBitmap = pFormatBitmap->StretchTo( + std::unique_ptr<CFX_DIBitmap> pStrechBitmap = pFormatBitmap->StretchTo( m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE); + delete pFormatBitmap; pFormatBitmap = nullptr; if (!pStrechBitmap) { m_pDeviceBitmap = nullptr; @@ -2328,7 +2332,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { return m_status; } m_pDeviceBitmap->TransferBitmap(m_startX, m_startY, m_sizeX, m_sizeY, - pStrechBitmap, 0, 0); + pStrechBitmap.get(), 0, 0); m_pDeviceBitmap = nullptr; m_pFile = nullptr; m_status = FXCODEC_STATUS_DECODE_FINISH; diff --git a/core/fxcodec/codec/icodec_tiffmodule.h b/core/fxcodec/codec/icodec_tiffmodule.h index 49abd1865f..540d82ff63 100644 --- a/core/fxcodec/codec/icodec_tiffmodule.h +++ b/core/fxcodec/codec/icodec_tiffmodule.h @@ -29,7 +29,7 @@ class ICodec_TiffModule { int32_t* bpc, CFX_DIBAttribute* pAttribute) = 0; virtual bool Decode(CCodec_TiffContext* ctx, - const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap) = 0; + class CFX_DIBitmap* pDIBitmap) = 0; virtual void DestroyDecoder(CCodec_TiffContext* ctx) = 0; }; |