| 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 <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 CWeightTable::CWeightTable() | 34 CWeightTable::CWeightTable() |
| 35 : m_DestMin(0), | 35 : m_DestMin(0), |
| 36 m_ItemSize(0), | 36 m_ItemSize(0), |
| 37 m_pWeightTables(nullptr), | 37 m_pWeightTables(nullptr), |
| 38 m_dwWeightTablesSize(0) {} | 38 m_dwWeightTablesSize(0) {} |
| 39 | 39 |
| 40 CWeightTable::~CWeightTable() { | 40 CWeightTable::~CWeightTable() { |
| 41 FX_Free(m_pWeightTables); | 41 FX_Free(m_pWeightTables); |
| 42 } | 42 } |
| 43 | 43 |
| 44 size_t CWeightTable::GetPixelWeightSize() const { |
| 45 return m_dwWeightTablesSize / sizeof(int); |
| 46 } |
| 47 |
| 44 bool CWeightTable::Calc(int dest_len, | 48 bool CWeightTable::Calc(int dest_len, |
| 45 int dest_min, | 49 int dest_min, |
| 46 int dest_max, | 50 int dest_max, |
| 47 int src_len, | 51 int src_len, |
| 48 int src_min, | 52 int src_min, |
| 49 int src_max, | 53 int src_max, |
| 50 int flags) { | 54 int flags) { |
| 51 FX_Free(m_pWeightTables); | 55 FX_Free(m_pWeightTables); |
| 52 m_pWeightTables = nullptr; | 56 m_pWeightTables = nullptr; |
| 53 m_dwWeightTablesSize = 0; | 57 m_dwWeightTablesSize = 0; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 : (FX_FLOAT)(dest_pixel); | 232 : (FX_FLOAT)(dest_pixel); |
| 229 double area_end = dest_end > (FX_FLOAT)(dest_pixel + 1) | 233 double area_end = dest_end > (FX_FLOAT)(dest_pixel + 1) |
| 230 ? (FX_FLOAT)(dest_pixel + 1) | 234 ? (FX_FLOAT)(dest_pixel + 1) |
| 231 : dest_end; | 235 : dest_end; |
| 232 double weight = area_start >= area_end ? 0.0f : area_end - area_start; | 236 double weight = area_start >= area_end ? 0.0f : area_end - area_start; |
| 233 if (weight == 0 && j == end_i) { | 237 if (weight == 0 && j == end_i) { |
| 234 pixel_weights.m_SrcEnd--; | 238 pixel_weights.m_SrcEnd--; |
| 235 break; | 239 break; |
| 236 } | 240 } |
| 237 size_t idx = j - start_i; | 241 size_t idx = j - start_i; |
| 238 if (idx >= m_dwWeightTablesSize) | 242 if (idx >= GetPixelWeightSize()) |
| 239 return false; | 243 return false; |
| 240 pixel_weights.m_Weights[idx] = FXSYS_round((FX_FLOAT)(weight * 65536)); | 244 pixel_weights.m_Weights[idx] = FXSYS_round((FX_FLOAT)(weight * 65536)); |
| 241 } | 245 } |
| 242 } | 246 } |
| 243 return true; | 247 return true; |
| 244 } | 248 } |
| 245 | 249 |
| 246 PixelWeight* CWeightTable::GetPixelWeight(int pixel) const { | 250 PixelWeight* CWeightTable::GetPixelWeight(int pixel) const { |
| 247 ASSERT(pixel >= m_DestMin); | 251 ASSERT(pixel >= m_DestMin); |
| 248 return reinterpret_cast<PixelWeight*>(m_pWeightTables + | 252 return reinterpret_cast<PixelWeight*>(m_pWeightTables + |
| 249 (pixel - m_DestMin) * m_ItemSize); | 253 (pixel - m_DestMin) * m_ItemSize); |
| 250 } | 254 } |
| 251 | 255 |
| 252 int* CWeightTable::GetValueFromPixelWeight(PixelWeight* pWeight, | 256 int* CWeightTable::GetValueFromPixelWeight(PixelWeight* pWeight, |
| 253 int index) const { | 257 int index) const { |
| 254 if (index < pWeight->m_SrcStart) | 258 if (index < pWeight->m_SrcStart) |
| 255 return nullptr; | 259 return nullptr; |
| 256 | 260 |
| 257 size_t idx = index - pWeight->m_SrcStart; | 261 size_t idx = index - pWeight->m_SrcStart; |
| 258 return idx < m_dwWeightTablesSize ? &pWeight->m_Weights[idx] : nullptr; | 262 return idx < GetPixelWeightSize() ? &pWeight->m_Weights[idx] : nullptr; |
| 259 } | 263 } |
| 260 | 264 |
| 261 CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, | 265 CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, |
| 262 FXDIB_Format dest_format, | 266 FXDIB_Format dest_format, |
| 263 int dest_width, | 267 int dest_width, |
| 264 int dest_height, | 268 int dest_height, |
| 265 const FX_RECT& clip_rect, | 269 const FX_RECT& clip_rect, |
| 266 const CFX_DIBSource* pSrcBitmap, | 270 const CFX_DIBSource* pSrcBitmap, |
| 267 int flags) { | 271 int flags) { |
| 268 m_State = 0; | 272 m_State = 0; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 result_width); | 998 result_width); |
| 995 if (m_pMaskScanline) { | 999 if (m_pMaskScanline) { |
| 996 m_pSource->m_pAlphaMask->DownSampleScanline( | 1000 m_pSource->m_pAlphaMask->DownSampleScanline( |
| 997 src_y, m_pMaskScanline.get(), 1, m_DestWidth, m_bFlipX, | 1001 src_y, m_pMaskScanline.get(), 1, m_DestWidth, m_bFlipX, |
| 998 m_ClipRect.left, result_width); | 1002 m_ClipRect.left, result_width); |
| 999 } | 1003 } |
| 1000 m_pDest->ComposeScanline(dest_y, m_pScanline.get(), m_pMaskScanline.get()); | 1004 m_pDest->ComposeScanline(dest_y, m_pScanline.get(), m_pMaskScanline.get()); |
| 1001 } | 1005 } |
| 1002 return FALSE; | 1006 return FALSE; |
| 1003 } | 1007 } |
| OLD | NEW |