| 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 14 matching lines...) Expand all Loading... |
| 25 int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; | 25 int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; |
| 26 m_ItemSize = sizeof(int) * 2 + (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((F
X_FLOAT)scale)) + ext_size)); | 26 m_ItemSize = sizeof(int) * 2 + (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((F
X_FLOAT)scale)) + ext_size)); |
| 27 m_DestMin = dest_min; | 27 m_DestMin = dest_min; |
| 28 if ((dest_max - dest_min) > (int)((1U << 30) - 4) / m_ItemSize) { | 28 if ((dest_max - dest_min) > (int)((1U << 30) - 4) / m_ItemSize) { |
| 29 return; | 29 return; |
| 30 } | 30 } |
| 31 m_pWeightTables = FX_AllocNL(FX_BYTE, (dest_max - dest_min) * m_ItemSize + 4
); | 31 m_pWeightTables = FX_AllocNL(FX_BYTE, (dest_max - dest_min) * m_ItemSize + 4
); |
| 32 if (m_pWeightTables == NULL) { | 32 if (m_pWeightTables == NULL) { |
| 33 return; | 33 return; |
| 34 } | 34 } |
| 35 FXSYS_memset32(m_pWeightTables, 0, sizeof(FX_BYTE) * ((dest_max - dest_min)*
m_ItemSize + 4)); | |
| 36 if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { | 35 if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { |
| 37 for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel ++) { | 36 for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel ++) { |
| 38 PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); | 37 PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); |
| 39 double src_pos = dest_pixel * scale + scale / 2 + base; | 38 double src_pos = dest_pixel * scale + scale / 2 + base; |
| 40 if (flags & FXDIB_INTERPOL) { | 39 if (flags & FXDIB_INTERPOL) { |
| 41 pixel_weights.m_SrcStart = (int)FXSYS_floor((FX_FLOAT)src_pos -
1.0f / 2); | 40 pixel_weights.m_SrcStart = (int)FXSYS_floor((FX_FLOAT)src_pos -
1.0f / 2); |
| 42 pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.
0f / 2); | 41 pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.
0f / 2); |
| 43 if (pixel_weights.m_SrcStart < src_min) { | 42 if (pixel_weights.m_SrcStart < src_min) { |
| 44 pixel_weights.m_SrcStart = src_min; | 43 pixel_weights.m_SrcStart = src_min; |
| 45 } | 44 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 size *= m_DestBpp; | 199 size *= m_DestBpp; |
| 201 if (size > INT_MAX - 31) { | 200 if (size > INT_MAX - 31) { |
| 202 return; | 201 return; |
| 203 } | 202 } |
| 204 size += 31; | 203 size += 31; |
| 205 size = size / 32 * 4; | 204 size = size / 32 * 4; |
| 206 m_pDestScanline = FX_AllocNL(FX_BYTE, size); | 205 m_pDestScanline = FX_AllocNL(FX_BYTE, size); |
| 207 if (m_pDestScanline == NULL) { | 206 if (m_pDestScanline == NULL) { |
| 208 return; | 207 return; |
| 209 } | 208 } |
| 210 FXSYS_memset32(m_pDestScanline, 0, sizeof(FX_BYTE) * size); | |
| 211 if (dest_format == FXDIB_Rgb32) { | 209 if (dest_format == FXDIB_Rgb32) { |
| 212 FXSYS_memset8(m_pDestScanline, 255, size); | 210 FXSYS_memset8(m_pDestScanline, 255, size); |
| 213 } | 211 } |
| 214 m_InterPitch = (m_DestClip.Width() * m_DestBpp + 31) / 32 * 4; | 212 m_InterPitch = (m_DestClip.Width() * m_DestBpp + 31) / 32 * 4; |
| 215 m_ExtraMaskPitch = (m_DestClip.Width() * 8 + 31) / 32 * 4; | 213 m_ExtraMaskPitch = (m_DestClip.Width() * 8 + 31) / 32 * 4; |
| 216 m_pInterBuf = NULL; | 214 m_pInterBuf = NULL; |
| 217 m_pSource = pSrcBitmap; | 215 m_pSource = pSrcBitmap; |
| 218 m_SrcWidth = pSrcBitmap->GetWidth(); | 216 m_SrcWidth = pSrcBitmap->GetWidth(); |
| 219 m_SrcHeight = pSrcBitmap->GetHeight(); | 217 m_SrcHeight = pSrcBitmap->GetHeight(); |
| 220 m_SrcPitch = (m_SrcWidth * m_SrcBpp + 31) / 32 * 4; | 218 m_SrcPitch = (m_SrcWidth * m_SrcBpp + 31) / 32 * 4; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 } | 856 } |
| 859 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); | 857 m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth
, m_bFlipX, m_ClipRect.left, result_width); |
| 860 FX_LPBYTE scan_extra_alpha = NULL; | 858 FX_LPBYTE scan_extra_alpha = NULL; |
| 861 if (m_pMaskScanline) { | 859 if (m_pMaskScanline) { |
| 862 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); | 860 m_pSource->m_pAlphaMask->DownSampleScanline(src_y, m_pMaskScanline,
1, m_DestWidth, m_bFlipX, m_ClipRect.left, result_width); |
| 863 } | 861 } |
| 864 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); | 862 m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline); |
| 865 } | 863 } |
| 866 return FALSE; | 864 return FALSE; |
| 867 } | 865 } |
| OLD | NEW |