| 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> |
| 11 extern int SDP_Table[513]; | 11 extern int SDP_Table[513]; |
| 12 void CWeightTable::Calc(int dest_len, | 12 void CWeightTable::Calc(int dest_len, |
| 13 int dest_min, | 13 int dest_min, |
| 14 int dest_max, | 14 int dest_max, |
| 15 int src_len, | 15 int src_len, |
| 16 int src_min, | 16 int src_min, |
| 17 int src_max, | 17 int src_max, |
| 18 int flags) { | 18 int flags) { |
| 19 if (m_pWeightTables) { | 19 FX_Free(m_pWeightTables); |
| 20 FX_Free(m_pWeightTables); | 20 m_pWeightTables = NULL; |
| 21 m_pWeightTables = NULL; | |
| 22 } | |
| 23 double scale, base; | 21 double scale, base; |
| 24 scale = FXSYS_Div((FX_FLOAT)(src_len), (FX_FLOAT)(dest_len)); | 22 scale = FXSYS_Div((FX_FLOAT)(src_len), (FX_FLOAT)(dest_len)); |
| 25 if (dest_len < 0) { | 23 if (dest_len < 0) { |
| 26 base = (FX_FLOAT)(src_len); | 24 base = (FX_FLOAT)(src_len); |
| 27 } else { | 25 } else { |
| 28 base = 0; | 26 base = 0; |
| 29 } | 27 } |
| 30 int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; | 28 int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; |
| 31 m_ItemSize = | 29 m_ItemSize = |
| 32 sizeof(int) * 2 + | 30 sizeof(int) * 2 + |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 while (m_State == 1) { | 325 while (m_State == 1) { |
| 328 if (ContinueStretchHorz(pPause)) { | 326 if (ContinueStretchHorz(pPause)) { |
| 329 return TRUE; | 327 return TRUE; |
| 330 } | 328 } |
| 331 m_State = 2; | 329 m_State = 2; |
| 332 StretchVert(); | 330 StretchVert(); |
| 333 } | 331 } |
| 334 return FALSE; | 332 return FALSE; |
| 335 } | 333 } |
| 336 CStretchEngine::~CStretchEngine() { | 334 CStretchEngine::~CStretchEngine() { |
| 337 if (m_pDestScanline) { | 335 FX_Free(m_pDestScanline); |
| 338 FX_Free(m_pDestScanline); | 336 FX_Free(m_pInterBuf); |
| 339 } | 337 FX_Free(m_pExtraAlphaBuf); |
| 340 if (m_pInterBuf) { | 338 FX_Free(m_pDestMaskScanline); |
| 341 FX_Free(m_pInterBuf); | |
| 342 } | |
| 343 if (m_pExtraAlphaBuf) { | |
| 344 FX_Free(m_pExtraAlphaBuf); | |
| 345 } | |
| 346 if (m_pDestMaskScanline) { | |
| 347 FX_Free(m_pDestMaskScanline); | |
| 348 } | |
| 349 } | 339 } |
| 350 FX_BOOL CStretchEngine::StartStretchHorz() { | 340 FX_BOOL CStretchEngine::StartStretchHorz() { |
| 351 if (m_DestWidth == 0 || m_pDestScanline == NULL || | 341 if (m_DestWidth == 0 || m_pDestScanline == NULL || |
| 352 m_SrcClip.Height() > (int)((1U << 29) / m_InterPitch) || | 342 m_SrcClip.Height() > (int)((1U << 29) / m_InterPitch) || |
| 353 m_SrcClip.Height() == 0) { | 343 m_SrcClip.Height() == 0) { |
| 354 return FALSE; | 344 return FALSE; |
| 355 } | 345 } |
| 356 m_pInterBuf = FX_TryAlloc(unsigned char, m_SrcClip.Height() * m_InterPitch); | 346 m_pInterBuf = FX_TryAlloc(unsigned char, m_SrcClip.Height() * m_InterPitch); |
| 357 if (m_pInterBuf == NULL) { | 347 if (m_pInterBuf == NULL) { |
| 358 return FALSE; | 348 return FALSE; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 m_pDestBitmap->ComposeScanline(row - m_DestClip.top, m_pDestScanline, | 752 m_pDestBitmap->ComposeScanline(row - m_DestClip.top, m_pDestScanline, |
| 763 m_pDestMaskScanline); | 753 m_pDestMaskScanline); |
| 764 } | 754 } |
| 765 } | 755 } |
| 766 CFX_ImageStretcher::CFX_ImageStretcher() { | 756 CFX_ImageStretcher::CFX_ImageStretcher() { |
| 767 m_pScanline = NULL; | 757 m_pScanline = NULL; |
| 768 m_pStretchEngine = NULL; | 758 m_pStretchEngine = NULL; |
| 769 m_pMaskScanline = NULL; | 759 m_pMaskScanline = NULL; |
| 770 } | 760 } |
| 771 CFX_ImageStretcher::~CFX_ImageStretcher() { | 761 CFX_ImageStretcher::~CFX_ImageStretcher() { |
| 772 if (m_pScanline) { | 762 FX_Free(m_pScanline); |
| 773 FX_Free(m_pScanline); | |
| 774 } | |
| 775 delete m_pStretchEngine; | 763 delete m_pStretchEngine; |
| 776 if (m_pMaskScanline) { | 764 FX_Free(m_pMaskScanline); |
| 777 FX_Free(m_pMaskScanline); | |
| 778 } | |
| 779 } | 765 } |
| 780 FXDIB_Format _GetStretchedFormat(const CFX_DIBSource* pSrc) { | 766 FXDIB_Format _GetStretchedFormat(const CFX_DIBSource* pSrc) { |
| 781 FXDIB_Format format = pSrc->GetFormat(); | 767 FXDIB_Format format = pSrc->GetFormat(); |
| 782 if (format == FXDIB_1bppMask) { | 768 if (format == FXDIB_1bppMask) { |
| 783 format = FXDIB_8bppMask; | 769 format = FXDIB_8bppMask; |
| 784 } else if (format == FXDIB_1bppRgb) { | 770 } else if (format == FXDIB_1bppRgb) { |
| 785 format = FXDIB_8bppRgb; | 771 format = FXDIB_8bppRgb; |
| 786 } else if (format == FXDIB_8bppRgb) { | 772 } else if (format == FXDIB_8bppRgb) { |
| 787 if (pSrc->GetPalette()) { | 773 if (pSrc->GetPalette()) { |
| 788 format = FXDIB_Rgb; | 774 format = FXDIB_Rgb; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 m_bFlipX, m_ClipRect.left, result_width); | 910 m_bFlipX, m_ClipRect.left, result_width); |
| 925 if (m_pMaskScanline) { | 911 if (m_pMaskScanline) { |
| 926 m_pSource->m_pAlphaMask->DownSampleScanline( | 912 m_pSource->m_pAlphaMask->DownSampleScanline( |
| 927 src_y, m_pMaskScanline, 1, m_DestWidth, m_bFlipX, m_ClipRect.left, | 913 src_y, m_pMaskScanline, 1, m_DestWidth, m_bFlipX, m_ClipRect.left, |
| 928 result_width); | 914 result_width); |
| 929 } | 915 } |
| 930 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); | 916 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); |
| 931 } | 917 } |
| 932 return FALSE; | 918 return FALSE; |
| 933 } | 919 } |
| OLD | NEW |