summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-05-03 10:54:23 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-03 15:06:31 +0000
commit1e5a98afd195930de69f7b468a852717722377b6 (patch)
tree1488f109aaab731e5f9703ab2b91d607f0d0b9fe /core/fxcodec/codec
parentf45ade3a0af908a1d6a51c5cc675f81517c9a22a (diff)
downloadpdfium-1e5a98afd195930de69f7b468a852717722377b6.tar.xz
Use enum class GifDecodeStatus instead of integers in fx_gif
Change-Id: If37147f513a87bafb3299a493393a6bc44165dbe Reviewed-on: https://pdfium-review.googlesource.com/4811 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.cpp45
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.h23
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp18
3 files changed, 44 insertions, 42 deletions
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index ca9fd07ba6..b53880587e 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -115,18 +115,18 @@ void CCodec_GifModule::Finish(FXGIF_Context* ctx) {
}
}
-int32_t CCodec_GifModule::ReadHeader(FXGIF_Context* ctx,
- int* width,
- int* height,
- int* pal_num,
- void** pal_pp,
- int* bg_index,
- CFX_DIBAttribute* pAttribute) {
+GifDecodeStatus CCodec_GifModule::ReadHeader(FXGIF_Context* ctx,
+ int* width,
+ int* height,
+ int* pal_num,
+ void** pal_pp,
+ int* bg_index,
+ CFX_DIBAttribute* pAttribute) {
if (setjmp(ctx->gif_ptr->jmpbuf))
- return 0;
+ return GifDecodeStatus::Error;
- int32_t ret = gif_read_header(ctx->gif_ptr);
- if (ret != 1)
+ GifDecodeStatus ret = gif_read_header(ctx->gif_ptr);
+ if (ret != GifDecodeStatus::Success)
return ret;
*width = ctx->gif_ptr->width;
@@ -134,29 +134,30 @@ int32_t CCodec_GifModule::ReadHeader(FXGIF_Context* ctx,
*pal_num = ctx->gif_ptr->global_pal_num;
*pal_pp = ctx->gif_ptr->global_pal_ptr;
*bg_index = ctx->gif_ptr->bc_index;
- return 1;
+ return GifDecodeStatus::Success;
}
-int32_t CCodec_GifModule::LoadFrameInfo(FXGIF_Context* ctx, int* frame_num) {
+GifDecodeStatus CCodec_GifModule::LoadFrameInfo(FXGIF_Context* ctx,
+ int* frame_num) {
if (setjmp(ctx->gif_ptr->jmpbuf))
- return 0;
+ return GifDecodeStatus::Error;
- int32_t ret = gif_get_frame(ctx->gif_ptr);
- if (ret != 1)
+ GifDecodeStatus ret = gif_get_frame(ctx->gif_ptr);
+ if (ret != GifDecodeStatus::Success)
return ret;
*frame_num = gif_get_frame_num(ctx->gif_ptr);
- return 1;
+ return GifDecodeStatus::Success;
}
-int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
- int frame_num,
- CFX_DIBAttribute* pAttribute) {
+GifDecodeStatus CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
+ int frame_num,
+ CFX_DIBAttribute* pAttribute) {
if (setjmp(ctx->gif_ptr->jmpbuf))
- return 0;
+ return GifDecodeStatus::Error;
- int32_t ret = gif_load_frame(ctx->gif_ptr, frame_num);
- if (ret == 1) {
+ GifDecodeStatus ret = gif_load_frame(ctx->gif_ptr, frame_num);
+ if (ret == GifDecodeStatus::Success) {
if (pAttribute) {
pAttribute->m_nGifLeft =
(*ctx->gif_ptr->img_ptr_arr_ptr)[frame_num]->image_info_ptr->left;
diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h
index 745f48a174..b42a86642b 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.h
+++ b/core/fxcodec/codec/ccodec_gifmodule.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
#define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
+#include "core/fxcodec/lgif/fx_gif.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -44,18 +45,18 @@ class CCodec_GifModule {
const uint8_t* src_buf,
uint32_t src_size);
- int32_t ReadHeader(FXGIF_Context* pContext,
- int* width,
- int* height,
- int* pal_num,
- void** pal_pp,
- int* bg_index,
- CFX_DIBAttribute* pAttribute);
+ GifDecodeStatus ReadHeader(FXGIF_Context* pContext,
+ int* width,
+ int* height,
+ int* pal_num,
+ void** pal_pp,
+ int* bg_index,
+ CFX_DIBAttribute* pAttribute);
- int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num);
- int32_t LoadFrame(FXGIF_Context* pContext,
- int frame_num,
- CFX_DIBAttribute* pAttribute);
+ GifDecodeStatus LoadFrameInfo(FXGIF_Context* pContext, int* frame_num);
+ GifDecodeStatus LoadFrame(FXGIF_Context* pContext,
+ int frame_num,
+ CFX_DIBAttribute* pAttribute);
Delegate* GetDelegate() const { return m_pDelegate; }
void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; }
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 6a95805dbe..9d710e582d 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -1194,10 +1194,10 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_offSet += size;
pGifModule->Input(m_pGifContext, m_pSrcBuf, size);
m_SrcComponents = 1;
- int32_t readResult = pGifModule->ReadHeader(
+ GifDecodeStatus readResult = pGifModule->ReadHeader(
m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
(void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
- while (readResult == 2) {
+ while (readResult == GifDecodeStatus::Unfinished) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
if (!GifReadMoreData(pGifModule, error_status)) {
m_status = error_status;
@@ -1207,7 +1207,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_pGifContext, &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber,
(void**)&m_pGifPalette, &m_GifBgIndex, nullptr);
}
- if (readResult == 1) {
+ if (readResult == GifDecodeStatus::Success) {
m_SrcBPC = 8;
m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
return true;
@@ -1805,9 +1805,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
return m_status;
}
while (true) {
- int32_t readResult =
+ GifDecodeStatus readResult =
pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber);
- while (readResult == 2) {
+ while (readResult == GifDecodeStatus::Unfinished) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_READ;
if (!GifReadMoreData(pGifModule, error_status)) {
return error_status;
@@ -1818,7 +1818,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
}
readResult = pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber);
}
- if (readResult == 1) {
+ if (readResult == GifDecodeStatus::Success) {
frames = m_FrameNumber;
m_status = FXCODEC_STATUS_DECODE_READY;
return m_status;
@@ -2135,9 +2135,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
return m_status;
}
while (true) {
- int32_t readRes =
+ GifDecodeStatus readRes =
pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
- while (readRes == 2) {
+ while (readRes == GifDecodeStatus::Unfinished) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
if (!GifReadMoreData(pGifModule, error_status)) {
m_pDeviceBitmap = nullptr;
@@ -2151,7 +2151,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
}
- if (readRes == 1) {
+ if (readRes == GifDecodeStatus::Success) {
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
m_status = FXCODEC_STATUS_DECODE_FINISH;