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 "../../../include/fxge/fx_dib.h" | 7 #include "../../../include/fxge/fx_dib.h" |
8 #include "../../../include/fxge/fx_ge.h" | 8 #include "../../../include/fxge/fx_ge.h" |
9 #include "dib_int.h" | 9 #include "dib_int.h" |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 int Bpp = m_DestBpp / 8; | 343 int Bpp = m_DestBpp / 8; |
344 int rows_to_go = FX_STRECH_PAUSE_ROWS; | 344 int rows_to_go = FX_STRECH_PAUSE_ROWS; |
345 for (; m_CurRow < m_SrcClip.bottom; m_CurRow ++) { | 345 for (; m_CurRow < m_SrcClip.bottom; m_CurRow ++) { |
346 if (rows_to_go == 0) { | 346 if (rows_to_go == 0) { |
347 if (pPause && pPause->NeedToPauseNow()) { | 347 if (pPause && pPause->NeedToPauseNow()) { |
348 return TRUE; | 348 return TRUE; |
349 } else { | 349 } else { |
350 rows_to_go = FX_STRECH_PAUSE_ROWS; | 350 rows_to_go = FX_STRECH_PAUSE_ROWS; |
351 } | 351 } |
352 } | 352 } |
353 FX_LPCBYTE src_scan = m_pSource->GetScanline(m_CurRow); | 353 const uint8_t* src_scan = m_pSource->GetScanline(m_CurRow); |
354 FX_LPBYTE dest_scan = m_pInterBuf + (m_CurRow - m_SrcClip.top) * m_Inter
Pitch; | 354 uint8_t* dest_scan = m_pInterBuf + (m_CurRow - m_SrcClip.top) * m_InterP
itch; |
355 FX_LPCBYTE src_scan_mask = NULL; | 355 const uint8_t* src_scan_mask = NULL; |
356 FX_LPBYTE dest_scan_mask = NULL; | 356 uint8_t* dest_scan_mask = NULL; |
357 if (m_pExtraAlphaBuf) { | 357 if (m_pExtraAlphaBuf) { |
358 src_scan_mask = m_pSource->m_pAlphaMask->GetScanline(m_CurRow); | 358 src_scan_mask = m_pSource->m_pAlphaMask->GetScanline(m_CurRow); |
359 dest_scan_mask = m_pExtraAlphaBuf + (m_CurRow - m_SrcClip.top) * m_E
xtraMaskPitch; | 359 dest_scan_mask = m_pExtraAlphaBuf + (m_CurRow - m_SrcClip.top) * m_E
xtraMaskPitch; |
360 } | 360 } |
361 switch (m_TransMethod) { | 361 switch (m_TransMethod) { |
362 case 1: | 362 case 1: |
363 case 2: { | 363 case 2: { |
364 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 364 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
365 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 365 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
366 int dest_a = 0; | 366 int dest_a = 0; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 *dest_scan_mask++ = (uint8_t)((dest_a * 255) >> 16); | 470 *dest_scan_mask++ = (uint8_t)((dest_a * 255) >> 16); |
471 } | 471 } |
472 break; | 472 break; |
473 } | 473 } |
474 case 7: { | 474 case 7: { |
475 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 475 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
476 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 476 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
477 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; | 477 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; |
478 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 478 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
479 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 479 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
480 FX_LPCBYTE src_pixel = src_scan + j * Bpp; | 480 const uint8_t* src_pixel = src_scan + j * Bpp; |
481 dest_b_c += pixel_weight * (*src_pixel++); | 481 dest_b_c += pixel_weight * (*src_pixel++); |
482 dest_g_m += pixel_weight * (*src_pixel++); | 482 dest_g_m += pixel_weight * (*src_pixel++); |
483 dest_r_y += pixel_weight * (*src_pixel); | 483 dest_r_y += pixel_weight * (*src_pixel); |
484 } | 484 } |
485 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 485 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
486 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 486 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
487 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 487 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
488 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 488 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
489 } | 489 } |
490 *dest_scan++ = (uint8_t)((dest_b_c) >> 16); | 490 *dest_scan++ = (uint8_t)((dest_b_c) >> 16); |
491 *dest_scan++ = (uint8_t)((dest_g_m) >> 16); | 491 *dest_scan++ = (uint8_t)((dest_g_m) >> 16); |
492 *dest_scan++ = (uint8_t)((dest_r_y) >> 16); | 492 *dest_scan++ = (uint8_t)((dest_r_y) >> 16); |
493 dest_scan += Bpp - 3; | 493 dest_scan += Bpp - 3; |
494 } | 494 } |
495 break; | 495 break; |
496 } | 496 } |
497 case 8: { | 497 case 8: { |
498 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 498 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
499 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); | 499 PixelWeight* pPixelWeights = m_WeightTable.GetPixelWeigh
t(col); |
500 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; | 500 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; |
501 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 501 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
502 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 502 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
503 FX_LPCBYTE src_pixel = src_scan + j * Bpp; | 503 const uint8_t* src_pixel = src_scan + j * Bpp; |
504 if (m_DestFormat == FXDIB_Argb) { | 504 if (m_DestFormat == FXDIB_Argb) { |
505 pixel_weight = pixel_weight * src_pixel[3] / 255
; | 505 pixel_weight = pixel_weight * src_pixel[3] / 255
; |
506 } else { | 506 } else { |
507 pixel_weight = pixel_weight * src_scan_mask[j] /
255; | 507 pixel_weight = pixel_weight * src_scan_mask[j] /
255; |
508 } | 508 } |
509 dest_b_c += pixel_weight * (*src_pixel++); | 509 dest_b_c += pixel_weight * (*src_pixel++); |
510 dest_g_m += pixel_weight * (*src_pixel++); | 510 dest_g_m += pixel_weight * (*src_pixel++); |
511 dest_r_y += pixel_weight * (*src_pixel); | 511 dest_r_y += pixel_weight * (*src_pixel); |
512 dest_a += pixel_weight; | 512 dest_a += pixel_weight; |
513 } | 513 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 } | 589 } |
590 break; | 590 break; |
591 } | 591 } |
592 case 5: | 592 case 5: |
593 case 7: { | 593 case 7: { |
594 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 594 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
595 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; | 595 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; |
596 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; | 596 int dest_r_y = 0, dest_g_m = 0, dest_b_c = 0; |
597 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 597 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
598 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 598 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
599 FX_LPCBYTE src_pixel = src_scan + (j - m_SrcClip.top
) * m_InterPitch; | 599 const uint8_t* src_pixel = src_scan + (j - m_SrcClip
.top) * m_InterPitch; |
600 dest_b_c += pixel_weight * (*src_pixel++); | 600 dest_b_c += pixel_weight * (*src_pixel++); |
601 dest_g_m += pixel_weight * (*src_pixel++); | 601 dest_g_m += pixel_weight * (*src_pixel++); |
602 dest_r_y += pixel_weight * (*src_pixel); | 602 dest_r_y += pixel_weight * (*src_pixel); |
603 } | 603 } |
604 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { | 604 if (m_Flags & FXDIB_BICUBIC_INTERPOL) { |
605 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; | 605 dest_r_y = dest_r_y < 0 ? 0 : dest_r_y > 16711680 ?
16711680 : dest_r_y; |
606 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; | 606 dest_g_m = dest_g_m < 0 ? 0 : dest_g_m > 16711680 ?
16711680 : dest_g_m; |
607 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; | 607 dest_b_c = dest_b_c < 0 ? 0 : dest_b_c > 16711680 ?
16711680 : dest_b_c; |
608 } | 608 } |
609 dest_scan[0] = (uint8_t)((dest_b_c) >> 16); | 609 dest_scan[0] = (uint8_t)((dest_b_c) >> 16); |
610 dest_scan[1] = (uint8_t)((dest_g_m) >> 16); | 610 dest_scan[1] = (uint8_t)((dest_g_m) >> 16); |
611 dest_scan[2] = (uint8_t)((dest_r_y) >> 16); | 611 dest_scan[2] = (uint8_t)((dest_r_y) >> 16); |
612 dest_scan += DestBpp; | 612 dest_scan += DestBpp; |
613 } | 613 } |
614 break; | 614 break; |
615 } | 615 } |
616 case 6: | 616 case 6: |
617 case 8: { | 617 case 8: { |
618 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { | 618 for (int col = m_DestClip.left; col < m_DestClip.right; col
++) { |
619 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; | 619 unsigned char* src_scan = m_pInterBuf + (col - m_DestCli
p.left) * DestBpp; |
620 unsigned char* src_scan_mask = NULL; | 620 unsigned char* src_scan_mask = NULL; |
621 if (m_DestFormat != FXDIB_Argb) { | 621 if (m_DestFormat != FXDIB_Argb) { |
622 src_scan_mask = m_pExtraAlphaBuf + (col - m_DestClip
.left); | 622 src_scan_mask = m_pExtraAlphaBuf + (col - m_DestClip
.left); |
623 } | 623 } |
624 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; | 624 int dest_a = 0, dest_r_y = 0, dest_g_m = 0, dest_b_c = 0
; |
625 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { | 625 for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeigh
ts->m_SrcEnd; j ++) { |
626 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; | 626 int pixel_weight = pPixelWeights->m_Weights[j - pPix
elWeights->m_SrcStart]; |
627 FX_LPCBYTE src_pixel = src_scan + (j - m_SrcClip.top
) * m_InterPitch; | 627 const uint8_t* src_pixel = src_scan + (j - m_SrcClip
.top) * m_InterPitch; |
628 int mask_v = 255; | 628 int mask_v = 255; |
629 if (src_scan_mask) { | 629 if (src_scan_mask) { |
630 mask_v = src_scan_mask[(j - m_SrcClip.top) * m_E
xtraMaskPitch]; | 630 mask_v = src_scan_mask[(j - m_SrcClip.top) * m_E
xtraMaskPitch]; |
631 } | 631 } |
632 dest_b_c += pixel_weight * (*src_pixel++); | 632 dest_b_c += pixel_weight * (*src_pixel++); |
633 dest_g_m += pixel_weight * (*src_pixel++); | 633 dest_g_m += pixel_weight * (*src_pixel++); |
634 dest_r_y += pixel_weight * (*src_pixel); | 634 dest_r_y += pixel_weight * (*src_pixel); |
635 if (m_DestFormat == FXDIB_Argb) { | 635 if (m_DestFormat == FXDIB_Argb) { |
636 dest_a += pixel_weight * (*(src_pixel + 1)); | 636 dest_a += pixel_weight * (*(src_pixel + 1)); |
637 } else { | 637 } else { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 return TRUE; | 831 return TRUE; |
832 } | 832 } |
833 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); | 833 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); |
834 if (m_pMaskScanline) { | 834 if (m_pMaskScanline) { |
835 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); | 835 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); |
836 } | 836 } |
837 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); | 837 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); |
838 } | 838 } |
839 return FALSE; | 839 return FALSE; |
840 } | 840 } |
OLD | NEW |