diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-04-27 21:30:57 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-27 21:30:57 +0000 |
commit | 74c8b8e6e561b4ff1059441d70f7f1476494dfbb (patch) | |
tree | 95ef6ba2458a8c21a71e63841a91a178274495cf | |
parent | 82f4f7f01bcac4acae86e179a57ae78cc5691a50 (diff) | |
download | pdfium-74c8b8e6e561b4ff1059441d70f7f1476494dfbb.tar.xz |
Replace void* with CFX_GifPalette* in fxcodec
The type is known where we need it, and we avoid some dubious
casts in the process. Also avoid clumsy indexing and use the
members directly in computations.
Bug: pdfium:243
Change-Id: I1e061465fd0f9045cf5b82067204f26ac7df53f0
Reviewed-on: https://pdfium-review.googlesource.com/31651
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fxcodec/codec/ccodec_gifmodule.cpp | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_gifmodule.h | 4 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_progressivedecoder.h | 4 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_progress.cpp | 17 |
4 files changed, 13 insertions, 14 deletions
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp index dc2c0c83a4..9911d0f5e0 100644 --- a/core/fxcodec/codec/ccodec_gifmodule.cpp +++ b/core/fxcodec/codec/ccodec_gifmodule.cpp @@ -26,7 +26,7 @@ CFX_GifDecodeStatus CCodec_GifModule::ReadHeader(Context* pContext, int* width, int* height, int* pal_num, - void** pal_pp, + CFX_GifPalette** pal_pp, int* bg_index, CFX_DIBAttribute* pAttribute) { auto* context = static_cast<CFX_GifContext*>(pContext); diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h index 5ceff7bc4e..e7b250fe27 100644 --- a/core/fxcodec/codec/ccodec_gifmodule.h +++ b/core/fxcodec/codec/ccodec_gifmodule.h @@ -29,7 +29,7 @@ class CCodec_GifModule { virtual bool GifInputRecordPositionBuf(uint32_t rcd_pos, const FX_RECT& img_rc, int32_t pal_num, - void* pal_ptr, + CFX_GifPalette* pal_ptr, int32_t delay_time, bool user_input, int32_t trans_index, @@ -48,7 +48,7 @@ class CCodec_GifModule { int* width, int* height, int* pal_num, - void** pal_pp, + CFX_GifPalette** pal_pp, int* bg_index, CFX_DIBAttribute* pAttribute); std::pair<CFX_GifDecodeStatus, size_t> LoadFrameInfo(Context* context); diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index 18da3b3a63..4a67bbb335 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -137,7 +137,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, bool GifInputRecordPositionBuf(uint32_t rcd_pos, const FX_RECT& img_rc, int32_t pal_num, - void* pal_ptr, + CFX_GifPalette* pal_ptr, int32_t delay_time, bool user_input, int32_t trans_index, @@ -236,7 +236,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, size_t m_FrameNumber; size_t m_FrameCur; int m_GifBgIndex; - uint8_t* m_pGifPalette; + CFX_GifPalette* m_pGifPalette; int32_t m_GifPltNumber; int m_GifTransIndex; FX_RECT m_GifFrameRect; diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index f2799dcb45..9d25d3f140 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -609,7 +609,7 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( uint32_t rcd_pos, const FX_RECT& img_rc, int32_t pal_num, - void* pal_ptr, + CFX_GifPalette* pal_ptr, int32_t delay_time, bool user_input, int32_t trans_index, @@ -620,9 +620,9 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( if (!GifReadMoreData(m_pCodecMgr->GetGifModule(), error_status)) { return false; } - uint8_t* pPalette = nullptr; + CFX_GifPalette* pPalette = nullptr; if (pal_num != 0 && pal_ptr) { - pPalette = (uint8_t*)pal_ptr; + pPalette = pal_ptr; } else { if (!m_pGifPalette) return false; @@ -638,9 +638,8 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf( m_SrcPaletteNumber = pal_num; for (int i = 0; i < pal_num; i++) { - uint32_t j = i * 3; m_pSrcPalette[i] = - ArgbEncode(0xff, pPalette[j], pPalette[j + 1], pPalette[j + 2]); + ArgbEncode(0xff, pPalette[i].r, pPalette[i].g, pPalette[i].b); } m_GifTransIndex = trans_index; m_GifFrameRect = img_rc; @@ -1250,7 +1249,7 @@ bool CCodec_ProgressiveDecoder::GifDetectImageType(CFX_DIBAttribute* pAttribute, m_SrcComponents = 1; CFX_GifDecodeStatus readResult = pGifModule->ReadHeader( m_pGifContext.get(), &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, - (void**)&m_pGifPalette, &m_GifBgIndex, nullptr); + &m_pGifPalette, &m_GifBgIndex, nullptr); while (readResult == CFX_GifDecodeStatus::Unfinished) { FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT; if (!GifReadMoreData(pGifModule, error_status)) { @@ -1258,9 +1257,9 @@ bool CCodec_ProgressiveDecoder::GifDetectImageType(CFX_DIBAttribute* pAttribute, m_status = error_status; return false; } - readResult = pGifModule->ReadHeader( - m_pGifContext.get(), &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, - (void**)&m_pGifPalette, &m_GifBgIndex, nullptr); + readResult = pGifModule->ReadHeader(m_pGifContext.get(), &m_SrcWidth, + &m_SrcHeight, &m_GifPltNumber, + &m_pGifPalette, &m_GifBgIndex, nullptr); } if (readResult == CFX_GifDecodeStatus::Success) { m_SrcBPC = 8; |