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