Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: core/fxcodec/codec/fx_codec_gif.cpp

Issue 1876023003: Remove ICodec_* Interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcodec/codec/fx_codec_flate.cpp ('k') | core/fxcodec/codec/fx_codec_icc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fxcodec/codec/codec_int.h" 7 #include "core/fxcodec/codec/codec_int.h"
8 #include "core/fxcodec/include/fx_codec.h" 8 #include "core/fxcodec/include/fx_codec.h"
9 #include "core/fxcodec/lgif/fx_gif.h" 9 #include "core/fxcodec/lgif/fx_gif.h"
10 #include "core/fxge/include/fx_dib.h" 10 #include "core/fxge/include/fx_dib.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int32_t trans_index, 62 int32_t trans_index,
63 int32_t disposal_method, 63 int32_t disposal_method,
64 FX_BOOL interlace) { 64 FX_BOOL interlace) {
65 FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr; 65 FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
66 CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr; 66 CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
67 return pModule->InputRecordPositionBufCallback( 67 return pModule->InputRecordPositionBufCallback(
68 p->child_ptr, cur_pos, FX_RECT(left, top, left + width, top + height), 68 p->child_ptr, cur_pos, FX_RECT(left, top, left + width, top + height),
69 pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method, 69 pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method,
70 interlace); 70 interlace);
71 } 71 }
72 void* CCodec_GifModule::Start(void* pModule) { 72
73 FXGIF_Context* p = (FXGIF_Context*)FX_Alloc(uint8_t, sizeof(FXGIF_Context)); 73 FXGIF_Context* CCodec_GifModule::Start(void* pModule) {
74 if (p == NULL) { 74 FXGIF_Context* p = FX_Alloc(FXGIF_Context, 1);
75 return NULL; 75 if (!p)
76 } 76 return nullptr;
77
77 FXSYS_memset(p, 0, sizeof(FXGIF_Context)); 78 FXSYS_memset(p, 0, sizeof(FXGIF_Context));
78 p->m_AllocFunc = gif_alloc_func; 79 p->m_AllocFunc = gif_alloc_func;
79 p->m_FreeFunc = gif_free_func; 80 p->m_FreeFunc = gif_free_func;
80 p->gif_ptr = NULL; 81 p->gif_ptr = nullptr;
81 p->parent_ptr = (void*)this; 82 p->parent_ptr = (void*)this;
82 p->child_ptr = pModule; 83 p->child_ptr = pModule;
83 p->gif_ptr = gif_create_decompress(); 84 p->gif_ptr = gif_create_decompress();
84 if (p->gif_ptr == NULL) { 85 if (!p->gif_ptr) {
85 FX_Free(p); 86 FX_Free(p);
86 return NULL; 87 return nullptr;
87 } 88 }
88 p->gif_ptr->context_ptr = (void*)p; 89 p->gif_ptr->context_ptr = (void*)p;
89 p->gif_ptr->err_ptr = m_szLastError; 90 p->gif_ptr->err_ptr = m_szLastError;
90 p->gif_ptr->gif_error_fn = gif_error_data; 91 p->gif_ptr->gif_error_fn = gif_error_data;
91 p->gif_ptr->gif_ask_buf_for_pal_fn = gif_ask_buf_for_pal; 92 p->gif_ptr->gif_ask_buf_for_pal_fn = gif_ask_buf_for_pal;
92 p->gif_ptr->gif_record_current_position_fn = gif_record_current_position; 93 p->gif_ptr->gif_record_current_position_fn = gif_record_current_position;
93 p->gif_ptr->gif_get_row_fn = gif_read_scanline; 94 p->gif_ptr->gif_get_row_fn = gif_read_scanline;
94 p->gif_ptr->gif_get_record_position_fn = gif_get_record_position; 95 p->gif_ptr->gif_get_record_position_fn = gif_get_record_position;
95 return p; 96 return p;
96 } 97 }
97 void CCodec_GifModule::Finish(void* pContext) { 98
98 FXGIF_Context* p = (FXGIF_Context*)pContext; 99 void CCodec_GifModule::Finish(FXGIF_Context* ctx) {
99 if (p) { 100 if (ctx) {
100 gif_destroy_decompress(&p->gif_ptr); 101 gif_destroy_decompress(&ctx->gif_ptr);
101 p->m_FreeFunc(p); 102 ctx->m_FreeFunc(ctx);
102 } 103 }
103 } 104 }
104 int32_t CCodec_GifModule::ReadHeader(void* pContext, 105
106 int32_t CCodec_GifModule::ReadHeader(FXGIF_Context* ctx,
105 int* width, 107 int* width,
106 int* height, 108 int* height,
107 int* pal_num, 109 int* pal_num,
108 void** pal_pp, 110 void** pal_pp,
109 int* bg_index, 111 int* bg_index,
110 CFX_DIBAttribute* pAttribute) { 112 CFX_DIBAttribute* pAttribute) {
111 FXGIF_Context* p = (FXGIF_Context*)pContext; 113 if (setjmp(ctx->gif_ptr->jmpbuf))
112 if (setjmp(p->gif_ptr->jmpbuf)) {
113 return 0; 114 return 0;
114 } 115
115 int32_t ret = gif_read_header(p->gif_ptr); 116 int32_t ret = gif_read_header(ctx->gif_ptr);
116 if (ret != 1) { 117 if (ret != 1)
117 return ret; 118 return ret;
118 } 119
119 if (pAttribute) { 120 *width = ctx->gif_ptr->width;
120 } 121 *height = ctx->gif_ptr->height;
121 *width = p->gif_ptr->width; 122 *pal_num = ctx->gif_ptr->global_pal_num;
122 *height = p->gif_ptr->height; 123 *pal_pp = ctx->gif_ptr->global_pal_ptr;
123 *pal_num = p->gif_ptr->global_pal_num; 124 *bg_index = ctx->gif_ptr->bc_index;
124 *pal_pp = p->gif_ptr->global_pal_ptr;
125 *bg_index = p->gif_ptr->bc_index;
126 return 1; 125 return 1;
127 } 126 }
128 int32_t CCodec_GifModule::LoadFrameInfo(void* pContext, int* frame_num) { 127
129 FXGIF_Context* p = (FXGIF_Context*)pContext; 128 int32_t CCodec_GifModule::LoadFrameInfo(FXGIF_Context* ctx, int* frame_num) {
130 if (setjmp(p->gif_ptr->jmpbuf)) { 129 if (setjmp(ctx->gif_ptr->jmpbuf))
131 return 0; 130 return 0;
132 } 131
133 int32_t ret = gif_get_frame(p->gif_ptr); 132 int32_t ret = gif_get_frame(ctx->gif_ptr);
134 if (ret != 1) { 133 if (ret != 1)
135 return ret; 134 return ret;
136 } 135
137 *frame_num = gif_get_frame_num(p->gif_ptr); 136 *frame_num = gif_get_frame_num(ctx->gif_ptr);
138 return 1; 137 return 1;
139 } 138 }
140 int32_t CCodec_GifModule::LoadFrame(void* pContext, 139
140 int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
141 int frame_num, 141 int frame_num,
142 CFX_DIBAttribute* pAttribute) { 142 CFX_DIBAttribute* pAttribute) {
143 FXGIF_Context* p = (FXGIF_Context*)pContext; 143 if (setjmp(ctx->gif_ptr->jmpbuf))
144 if (setjmp(p->gif_ptr->jmpbuf)) {
145 return 0; 144 return 0;
146 } 145
147 int32_t ret = gif_load_frame(p->gif_ptr, frame_num); 146 int32_t ret = gif_load_frame(ctx->gif_ptr, frame_num);
148 if (ret == 1) { 147 if (ret == 1) {
149 if (pAttribute) { 148 if (pAttribute) {
150 pAttribute->m_nGifLeft = 149 pAttribute->m_nGifLeft =
151 p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left; 150 ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left;
152 pAttribute->m_nGifTop = 151 pAttribute->m_nGifTop =
153 p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top; 152 ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top;
154 pAttribute->m_fAspectRatio = p->gif_ptr->pixel_aspect; 153 pAttribute->m_fAspectRatio = ctx->gif_ptr->pixel_aspect;
155 if (p->gif_ptr->cmt_data_ptr) { 154 if (ctx->gif_ptr->cmt_data_ptr) {
156 const uint8_t* buf = 155 const uint8_t* buf =
157 (const uint8_t*)p->gif_ptr->cmt_data_ptr->GetBuffer(0); 156 (const uint8_t*)ctx->gif_ptr->cmt_data_ptr->GetBuffer(0);
158 uint32_t len = p->gif_ptr->cmt_data_ptr->GetLength(); 157 uint32_t len = ctx->gif_ptr->cmt_data_ptr->GetLength();
159 if (len > 21) { 158 if (len > 21) {
160 uint8_t size = *buf++; 159 uint8_t size = *buf++;
161 if (size) { 160 if (size) {
162 pAttribute->m_strAuthor = CFX_ByteString(buf, size); 161 pAttribute->m_strAuthor = CFX_ByteString(buf, size);
163 } else { 162 } else {
164 pAttribute->m_strAuthor.Empty(); 163 pAttribute->m_strAuthor.Empty();
165 } 164 }
166 buf += size; 165 buf += size;
167 size = *buf++; 166 size = *buf++;
168 if (size == 20) { 167 if (size == 20) {
169 FXSYS_memcpy(pAttribute->m_strTime, buf, size); 168 FXSYS_memcpy(pAttribute->m_strTime, buf, size);
170 } 169 }
171 } 170 }
172 } 171 }
173 } 172 }
174 } 173 }
175 return ret; 174 return ret;
176 } 175 }
177 uint32_t CCodec_GifModule::GetAvailInput(void* pContext, 176
177 uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx,
178 uint8_t** avial_buf_ptr) { 178 uint8_t** avial_buf_ptr) {
179 FXGIF_Context* p = (FXGIF_Context*)pContext; 179 return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr);
180 return gif_get_avail_input(p->gif_ptr, avial_buf_ptr);
181 } 180 }
182 void CCodec_GifModule::Input(void* pContext, 181
182 void CCodec_GifModule::Input(FXGIF_Context* ctx,
183 const uint8_t* src_buf, 183 const uint8_t* src_buf,
184 uint32_t src_size) { 184 uint32_t src_size) {
185 FXGIF_Context* p = (FXGIF_Context*)pContext; 185 gif_input_buffer(ctx->gif_ptr, (uint8_t*)src_buf, src_size);
186 gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size);
187 } 186 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_flate.cpp ('k') | core/fxcodec/codec/fx_codec_icc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698