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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 FX_ARGB* CPDF_DIBTransferFunc::GetDestPalette() { | 190 FX_ARGB* CPDF_DIBTransferFunc::GetDestPalette() { |
191 return nullptr; | 191 return nullptr; |
192 } | 192 } |
193 | 193 |
194 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( | 194 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( |
195 const CPDF_TransferFunc* pTransferFunc) { | 195 const CPDF_TransferFunc* pTransferFunc) { |
196 m_RampR = pTransferFunc->m_Samples; | 196 m_RampR = pTransferFunc->m_Samples; |
197 m_RampG = &pTransferFunc->m_Samples[256]; | 197 m_RampG = &pTransferFunc->m_Samples[256]; |
198 m_RampB = &pTransferFunc->m_Samples[512]; | 198 m_RampB = &pTransferFunc->m_Samples[512]; |
199 } | 199 } |
200 void CPDF_DIBTransferFunc::TranslateScanline(uint8_t* dest_buf, | 200 |
201 const uint8_t* src_buf) const { | 201 void CPDF_DIBTransferFunc::TranslateScanline( |
202 int i; | 202 const uint8_t* src_buf, |
| 203 std::vector<uint8_t>* dest_buf) const { |
203 FX_BOOL bSkip = FALSE; | 204 FX_BOOL bSkip = FALSE; |
204 switch (m_pSrc->GetFormat()) { | 205 switch (m_pSrc->GetFormat()) { |
205 case FXDIB_1bppRgb: { | 206 case FXDIB_1bppRgb: { |
206 int r0 = m_RampR[0], g0 = m_RampG[0], b0 = m_RampB[0]; | 207 int r0 = m_RampR[0]; |
207 int r1 = m_RampR[255], g1 = m_RampG[255], b1 = m_RampB[255]; | 208 int g0 = m_RampG[0]; |
208 for (i = 0; i < m_Width; i++) { | 209 int b0 = m_RampB[0]; |
| 210 int r1 = m_RampR[255]; |
| 211 int g1 = m_RampG[255]; |
| 212 int b1 = m_RampB[255]; |
| 213 int index = 0; |
| 214 for (int i = 0; i < m_Width; i++) { |
209 if (src_buf[i / 8] & (1 << (7 - i % 8))) { | 215 if (src_buf[i / 8] & (1 << (7 - i % 8))) { |
210 *dest_buf++ = b1; | 216 (*dest_buf)[index++] = b1; |
211 *dest_buf++ = g1; | 217 (*dest_buf)[index++] = g1; |
212 *dest_buf++ = r1; | 218 (*dest_buf)[index++] = r1; |
213 } else { | 219 } else { |
214 *dest_buf++ = b0; | 220 (*dest_buf)[index++] = b0; |
215 *dest_buf++ = g0; | 221 (*dest_buf)[index++] = g0; |
216 *dest_buf++ = r0; | 222 (*dest_buf)[index++] = r0; |
217 } | 223 } |
218 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 224 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
219 dest_buf++; | 225 index++; |
220 #endif | 226 #endif |
221 } | 227 } |
222 break; | 228 break; |
223 } | 229 } |
224 case FXDIB_1bppMask: { | 230 case FXDIB_1bppMask: { |
225 int m0 = m_RampR[0], m1 = m_RampR[255]; | 231 int m0 = m_RampR[0]; |
226 for (i = 0; i < m_Width; i++) { | 232 int m1 = m_RampR[255]; |
227 if (src_buf[i / 8] & (1 << (7 - i % 8))) { | 233 int index = 0; |
228 *dest_buf++ = m1; | 234 for (int i = 0; i < m_Width; i++) { |
229 } else { | 235 if (src_buf[i / 8] & (1 << (7 - i % 8))) |
230 *dest_buf++ = m0; | 236 (*dest_buf)[index++] = m1; |
231 } | 237 else |
| 238 (*dest_buf)[index++] = m0; |
232 } | 239 } |
233 break; | 240 break; |
234 } | 241 } |
235 case FXDIB_8bppRgb: { | 242 case FXDIB_8bppRgb: { |
236 FX_ARGB* pPal = m_pSrc->GetPalette(); | 243 FX_ARGB* pPal = m_pSrc->GetPalette(); |
237 for (i = 0; i < m_Width; i++) { | 244 int index = 0; |
| 245 for (int i = 0; i < m_Width; i++) { |
238 if (pPal) { | 246 if (pPal) { |
239 FX_ARGB src_argb = pPal[*src_buf]; | 247 FX_ARGB src_argb = pPal[*src_buf]; |
240 *dest_buf++ = m_RampB[FXARGB_R(src_argb)]; | 248 (*dest_buf)[index++] = m_RampB[FXARGB_R(src_argb)]; |
241 *dest_buf++ = m_RampG[FXARGB_G(src_argb)]; | 249 (*dest_buf)[index++] = m_RampG[FXARGB_G(src_argb)]; |
242 *dest_buf++ = m_RampR[FXARGB_B(src_argb)]; | 250 (*dest_buf)[index++] = m_RampR[FXARGB_B(src_argb)]; |
243 } else { | 251 } else { |
244 uint32_t src_byte = *src_buf; | 252 uint32_t src_byte = *src_buf; |
245 *dest_buf++ = m_RampB[src_byte]; | 253 (*dest_buf)[index++] = m_RampB[src_byte]; |
246 *dest_buf++ = m_RampG[src_byte]; | 254 (*dest_buf)[index++] = m_RampG[src_byte]; |
247 *dest_buf++ = m_RampR[src_byte]; | 255 (*dest_buf)[index++] = m_RampR[src_byte]; |
248 } | 256 } |
249 src_buf++; | 257 src_buf++; |
250 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 258 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
251 dest_buf++; | 259 index++; |
252 #endif | 260 #endif |
253 } | 261 } |
254 break; | 262 break; |
255 } | 263 } |
256 case FXDIB_8bppMask: | 264 case FXDIB_8bppMask: { |
257 for (i = 0; i < m_Width; i++) { | 265 int index = 0; |
258 *dest_buf++ = m_RampR[*(src_buf++)]; | 266 for (int i = 0; i < m_Width; i++) { |
| 267 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; |
259 } | 268 } |
260 break; | 269 break; |
261 case FXDIB_Rgb: | 270 } |
262 for (i = 0; i < m_Width; i++) { | 271 case FXDIB_Rgb: { |
263 *dest_buf++ = m_RampB[*(src_buf++)]; | 272 int index = 0; |
264 *dest_buf++ = m_RampG[*(src_buf++)]; | 273 for (int i = 0; i < m_Width; i++) { |
265 *dest_buf++ = m_RampR[*(src_buf++)]; | 274 (*dest_buf)[index++] = m_RampB[*(src_buf++)]; |
| 275 (*dest_buf)[index++] = m_RampG[*(src_buf++)]; |
| 276 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; |
266 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 277 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
267 dest_buf++; | 278 index++; |
268 #endif | 279 #endif |
269 } | 280 } |
270 break; | 281 break; |
| 282 } |
271 case FXDIB_Rgb32: | 283 case FXDIB_Rgb32: |
272 bSkip = TRUE; | 284 bSkip = TRUE; |
273 case FXDIB_Argb: | 285 case FXDIB_Argb: { |
274 for (i = 0; i < m_Width; i++) { | 286 int index = 0; |
275 *dest_buf++ = m_RampB[*(src_buf++)]; | 287 for (int i = 0; i < m_Width; i++) { |
276 *dest_buf++ = m_RampG[*(src_buf++)]; | 288 (*dest_buf)[index++] = m_RampB[*(src_buf++)]; |
277 *dest_buf++ = m_RampR[*(src_buf++)]; | 289 (*dest_buf)[index++] = m_RampG[*(src_buf++)]; |
| 290 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; |
278 if (!bSkip) { | 291 if (!bSkip) { |
279 *dest_buf++ = *src_buf; | 292 (*dest_buf)[index++] = *src_buf; |
280 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 293 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
281 } else { | 294 } else { |
282 dest_buf++; | 295 index++; |
283 #endif | 296 #endif |
284 } | 297 } |
285 src_buf++; | 298 src_buf++; |
286 } | 299 } |
287 break; | 300 break; |
| 301 } |
288 default: | 302 default: |
289 break; | 303 break; |
290 } | 304 } |
291 } | 305 } |
| 306 |
292 void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, | 307 void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, |
293 const uint8_t* src_buf, | 308 const uint8_t* src_buf, |
294 int pixels, | 309 int pixels, |
295 int Bpp) const { | 310 int Bpp) const { |
296 if (Bpp == 8) { | 311 if (Bpp == 8) { |
297 for (int i = 0; i < pixels; i++) { | 312 for (int i = 0; i < pixels; i++) { |
298 *dest_buf++ = m_RampR[*(src_buf++)]; | 313 *dest_buf++ = m_RampR[*(src_buf++)]; |
299 } | 314 } |
300 } else if (Bpp == 24) { | 315 } else if (Bpp == 24) { |
301 for (int i = 0; i < pixels; i++) { | 316 for (int i = 0; i < pixels; i++) { |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 } else if (pFunc) { | 1052 } else if (pFunc) { |
1038 int size = dest_pitch * height; | 1053 int size = dest_pitch * height; |
1039 for (int i = 0; i < size; i++) { | 1054 for (int i = 0; i < size; i++) { |
1040 dest_buf[i] = transfers[src_buf[i]]; | 1055 dest_buf[i] = transfers[src_buf[i]]; |
1041 } | 1056 } |
1042 } else { | 1057 } else { |
1043 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1058 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1044 } | 1059 } |
1045 return pMask.release(); | 1060 return pMask.release(); |
1046 } | 1061 } |
OLD | NEW |