| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 if (m_pDestMaskScanline) { | 305 if (m_pDestMaskScanline) { |
| 306 FX_Free(m_pDestMaskScanline); | 306 FX_Free(m_pDestMaskScanline); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 FX_BOOL CStretchEngine::StartStretchHorz() | 309 FX_BOOL CStretchEngine::StartStretchHorz() |
| 310 { | 310 { |
| 311 if (m_DestWidth == 0 || m_pDestScanline == NULL || m_SrcClip.Height() > (int
)((1U << 29) / m_InterPitch) || m_SrcClip.Height() == 0) { | 311 if (m_DestWidth == 0 || m_pDestScanline == NULL || m_SrcClip.Height() > (int
)((1U << 29) / m_InterPitch) || m_SrcClip.Height() == 0) { |
| 312 return FALSE; | 312 return FALSE; |
| 313 } | 313 } |
| 314 #ifndef _FPDFAPI_MINI_ | |
| 315 m_pInterBuf = FX_AllocNL(unsigned char, m_SrcClip.Height() * m_InterPitch); | 314 m_pInterBuf = FX_AllocNL(unsigned char, m_SrcClip.Height() * m_InterPitch); |
| 316 #else | |
| 317 m_pInterBuf = FX_Alloc(unsigned char, m_SrcClip.Height() * m_InterPitch); | |
| 318 #endif | |
| 319 if (m_pInterBuf == NULL) { | 315 if (m_pInterBuf == NULL) { |
| 320 return FALSE; | 316 return FALSE; |
| 321 } | 317 } |
| 322 if (m_pSource && m_bHasAlpha && m_pSource->m_pAlphaMask) { | 318 if (m_pSource && m_bHasAlpha && m_pSource->m_pAlphaMask) { |
| 323 m_pExtraAlphaBuf = FX_Alloc(unsigned char, m_SrcClip.Height() * m_ExtraM
askPitch); | 319 m_pExtraAlphaBuf = FX_Alloc(unsigned char, m_SrcClip.Height() * m_ExtraM
askPitch); |
| 324 if (!m_pExtraAlphaBuf) { | 320 if (!m_pExtraAlphaBuf) { |
| 325 return FALSE; | 321 return FALSE; |
| 326 } | 322 } |
| 327 FX_DWORD size = (m_DestClip.Width() * 8 + 31) / 32 * 4; | 323 FX_DWORD size = (m_DestClip.Width() * 8 + 31) / 32 * 4; |
| 328 m_pDestMaskScanline = FX_AllocNL(unsigned char, size); | 324 m_pDestMaskScanline = FX_AllocNL(unsigned char, size); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 } | 755 } |
| 760 } | 756 } |
| 761 FX_BOOL CFX_ImageStretcher::Continue(IFX_Pause* pPause) | 757 FX_BOOL CFX_ImageStretcher::Continue(IFX_Pause* pPause) |
| 762 { | 758 { |
| 763 if (m_Flags & FXDIB_DOWNSAMPLE) { | 759 if (m_Flags & FXDIB_DOWNSAMPLE) { |
| 764 return ContinueQuickStretch(pPause); | 760 return ContinueQuickStretch(pPause); |
| 765 } else { | 761 } else { |
| 766 return ContinueStretch(pPause); | 762 return ContinueStretch(pPause); |
| 767 } | 763 } |
| 768 } | 764 } |
| 769 #ifndef _FPDFAPI_MINI_ | |
| 770 #define MAX_PROGRESSIVE_STRETCH_PIXELS 1000000 | 765 #define MAX_PROGRESSIVE_STRETCH_PIXELS 1000000 |
| 771 #else | |
| 772 #define MAX_PROGRESSIVE_STRETCH_PIXELS 100000 | |
| 773 #endif | |
| 774 FX_BOOL CFX_ImageStretcher::StartStretch() | 766 FX_BOOL CFX_ImageStretcher::StartStretch() |
| 775 { | 767 { |
| 776 m_pStretchEngine = FX_NEW CStretchEngine(m_pDest, m_DestFormat, m_DestWidth,
m_DestHeight, m_ClipRect, m_pSource, m_Flags); | 768 m_pStretchEngine = FX_NEW CStretchEngine(m_pDest, m_DestFormat, m_DestWidth,
m_DestHeight, m_ClipRect, m_pSource, m_Flags); |
| 777 if (!m_pStretchEngine) { | 769 if (!m_pStretchEngine) { |
| 778 return FALSE; | 770 return FALSE; |
| 779 } | 771 } |
| 780 m_pStretchEngine->StartStretchHorz(); | 772 m_pStretchEngine->StartStretchHorz(); |
| 781 if (m_pSource->GetWidth() * m_pSource->GetHeight() < MAX_PROGRESSIVE_STRETCH
_PIXELS) { | 773 if (m_pSource->GetWidth() * m_pSource->GetHeight() < MAX_PROGRESSIVE_STRETCH
_PIXELS) { |
| 782 m_pStretchEngine->Continue(NULL); | 774 m_pStretchEngine->Continue(NULL); |
| 783 return FALSE; | 775 return FALSE; |
| 784 } | 776 } |
| 785 return TRUE; | 777 return TRUE; |
| 786 } | 778 } |
| 787 FX_BOOL CFX_ImageStretcher::ContinueStretch(IFX_Pause* pPause) | 779 FX_BOOL CFX_ImageStretcher::ContinueStretch(IFX_Pause* pPause) |
| 788 { | 780 { |
| 789 if (m_pStretchEngine == NULL) { | 781 if (m_pStretchEngine == NULL) { |
| 790 return FALSE; | 782 return FALSE; |
| 791 } | 783 } |
| 792 return m_pStretchEngine->Continue(pPause); | 784 return m_pStretchEngine->Continue(pPause); |
| 793 } | 785 } |
| 794 FX_BOOL CFX_ImageStretcher::StartQuickStretch() | 786 FX_BOOL CFX_ImageStretcher::StartQuickStretch() |
| 795 { | 787 { |
| 796 #ifdef _FPDFAPI_MINI_ | |
| 797 m_pSource->SetDownSampleSize(m_DestWidth, m_DestHeight); | |
| 798 #endif | |
| 799 m_bFlipX = FALSE; | 788 m_bFlipX = FALSE; |
| 800 m_bFlipY = FALSE; | 789 m_bFlipY = FALSE; |
| 801 if (m_DestWidth < 0) { | 790 if (m_DestWidth < 0) { |
| 802 m_bFlipX = TRUE; | 791 m_bFlipX = TRUE; |
| 803 m_DestWidth = -m_DestWidth; | 792 m_DestWidth = -m_DestWidth; |
| 804 } | 793 } |
| 805 if (m_DestHeight < 0) { | 794 if (m_DestHeight < 0) { |
| 806 m_bFlipY = TRUE; | 795 m_bFlipY = TRUE; |
| 807 m_DestHeight = -m_DestHeight; | 796 m_DestHeight = -m_DestHeight; |
| 808 } | 797 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 return TRUE; | 843 return TRUE; |
| 855 } | 844 } |
| 856 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); | 845 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); |
| 857 if (m_pMaskScanline) { | 846 if (m_pMaskScanline) { |
| 858 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); | 847 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); |
| 859 } | 848 } |
| 860 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); | 849 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); |
| 861 } | 850 } |
| 862 return FALSE; | 851 return FALSE; |
| 863 } | 852 } |
| OLD | NEW |