| OLD | NEW | 
|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 
| 6 | 6 | 
| 7 #include "core/include/fxcodec/fx_codec.h" | 7 #include "core/include/fxcodec/fx_codec.h" | 
| 8 #include "core/include/fxge/fx_dib.h" | 8 #include "core/include/fxge/fx_dib.h" | 
| 9 #include "core/src/fxcodec/codec/codec_int.h" | 9 #include "core/src/fxcodec/codec/codec_int.h" | 
| 10 #include "core/src/fxcodec/lgif/fx_gif.h" | 10 #include "core/src/fxcodec/lgif/fx_gif.h" | 
| 11 struct FXGIF_Context { | 11 struct FXGIF_Context { | 
| 12   gif_decompress_struct_p gif_ptr; | 12   gif_decompress_struct_p gif_ptr; | 
| 13   void* parent_ptr; | 13   void* parent_ptr; | 
| 14   void* child_ptr; | 14   void* child_ptr; | 
| 15 | 15 | 
| 16   void* (*m_AllocFunc)(unsigned int); | 16   void* (*m_AllocFunc)(unsigned int); | 
| 17   void (*m_FreeFunc)(void*); | 17   void (*m_FreeFunc)(void*); | 
| 18 }; | 18 }; | 
| 19 extern "C" { | 19 extern "C" { | 
| 20 static void* _gif_alloc_func(unsigned int size) { | 20 static void* _gif_alloc_func(unsigned int size) { | 
| 21   return FX_Alloc(char, size); | 21   return FX_Alloc(char, size); | 
| 22 } | 22 } | 
| 23 static void _gif_free_func(void* p) { | 23 static void _gif_free_func(void* p) { | 
| 24   if (p != NULL) { | 24   FX_Free(p); | 
| 25     FX_Free(p); |  | 
| 26   } |  | 
| 27 } | 25 } | 
| 28 }; | 26 }; | 
| 29 static void _gif_error_data(gif_decompress_struct_p gif_ptr, | 27 static void _gif_error_data(gif_decompress_struct_p gif_ptr, | 
| 30                             const FX_CHAR* err_msg) { | 28                             const FX_CHAR* err_msg) { | 
| 31   FXSYS_strncpy((char*)gif_ptr->err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1); | 29   FXSYS_strncpy((char*)gif_ptr->err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1); | 
| 32   longjmp(gif_ptr->jmpbuf, 1); | 30   longjmp(gif_ptr->jmpbuf, 1); | 
| 33 } | 31 } | 
| 34 static uint8_t* _gif_ask_buf_for_pal(gif_decompress_struct_p gif_ptr, | 32 static uint8_t* _gif_ask_buf_for_pal(gif_decompress_struct_p gif_ptr, | 
| 35                                      int32_t pal_size) { | 33                                      int32_t pal_size) { | 
| 36   FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr; | 34   FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr; | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 91   p->gif_ptr->err_ptr = m_szLastError; | 89   p->gif_ptr->err_ptr = m_szLastError; | 
| 92   p->gif_ptr->_gif_error_fn = _gif_error_data; | 90   p->gif_ptr->_gif_error_fn = _gif_error_data; | 
| 93   p->gif_ptr->_gif_ask_buf_for_pal_fn = _gif_ask_buf_for_pal; | 91   p->gif_ptr->_gif_ask_buf_for_pal_fn = _gif_ask_buf_for_pal; | 
| 94   p->gif_ptr->_gif_record_current_position_fn = _gif_record_current_position; | 92   p->gif_ptr->_gif_record_current_position_fn = _gif_record_current_position; | 
| 95   p->gif_ptr->_gif_get_row_fn = _gif_read_scanline; | 93   p->gif_ptr->_gif_get_row_fn = _gif_read_scanline; | 
| 96   p->gif_ptr->_gif_get_record_position_fn = _gif_get_record_position; | 94   p->gif_ptr->_gif_get_record_position_fn = _gif_get_record_position; | 
| 97   return p; | 95   return p; | 
| 98 } | 96 } | 
| 99 void CCodec_GifModule::Finish(void* pContext) { | 97 void CCodec_GifModule::Finish(void* pContext) { | 
| 100   FXGIF_Context* p = (FXGIF_Context*)pContext; | 98   FXGIF_Context* p = (FXGIF_Context*)pContext; | 
| 101   if (p != NULL) { | 99   if (p) { | 
| 102     _gif_destroy_decompress(&p->gif_ptr); | 100     _gif_destroy_decompress(&p->gif_ptr); | 
| 103     p->m_FreeFunc(p); | 101     p->m_FreeFunc(p); | 
| 104   } | 102   } | 
| 105 } | 103 } | 
| 106 int32_t CCodec_GifModule::ReadHeader(void* pContext, | 104 int32_t CCodec_GifModule::ReadHeader(void* pContext, | 
| 107                                      int* width, | 105                                      int* width, | 
| 108                                      int* height, | 106                                      int* height, | 
| 109                                      int* pal_num, | 107                                      int* pal_num, | 
| 110                                      void** pal_pp, | 108                                      void** pal_pp, | 
| 111                                      int* bg_index, | 109                                      int* bg_index, | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 180                                          uint8_t** avial_buf_ptr) { | 178                                          uint8_t** avial_buf_ptr) { | 
| 181   FXGIF_Context* p = (FXGIF_Context*)pContext; | 179   FXGIF_Context* p = (FXGIF_Context*)pContext; | 
| 182   return _gif_get_avail_input(p->gif_ptr, avial_buf_ptr); | 180   return _gif_get_avail_input(p->gif_ptr, avial_buf_ptr); | 
| 183 } | 181 } | 
| 184 void CCodec_GifModule::Input(void* pContext, | 182 void CCodec_GifModule::Input(void* pContext, | 
| 185                              const uint8_t* src_buf, | 183                              const uint8_t* src_buf, | 
| 186                              FX_DWORD src_size) { | 184                              FX_DWORD src_size) { | 
| 187   FXGIF_Context* p = (FXGIF_Context*)pContext; | 185   FXGIF_Context* p = (FXGIF_Context*)pContext; | 
| 188   _gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size); | 186   _gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size); | 
| 189 } | 187 } | 
| OLD | NEW | 
|---|