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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
10 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 10 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 } | 1078 } |
1079 } | 1079 } |
1080 uint8_t* CPDF_DIBSource::GetBuffer() const { | 1080 uint8_t* CPDF_DIBSource::GetBuffer() const { |
1081 if (m_pCachedBitmap) { | 1081 if (m_pCachedBitmap) { |
1082 return m_pCachedBitmap->GetBuffer(); | 1082 return m_pCachedBitmap->GetBuffer(); |
1083 } | 1083 } |
1084 return NULL; | 1084 return NULL; |
1085 } | 1085 } |
1086 const uint8_t* CPDF_DIBSource::GetScanline(int line) const { | 1086 const uint8_t* CPDF_DIBSource::GetScanline(int line) const { |
1087 if (m_bpc == 0) { | 1087 if (m_bpc == 0) { |
1088 return NULL; | 1088 return nullptr; |
1089 } | 1089 } |
1090 FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width, 1); | 1090 FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width, 1); |
1091 if (!src_pitch.IsValid()) | 1091 if (!src_pitch.IsValid()) |
1092 return NULL; | 1092 return nullptr; |
1093 FX_DWORD src_pitch_value = src_pitch.ValueOrDie(); | 1093 FX_DWORD src_pitch_value = src_pitch.ValueOrDie(); |
1094 const uint8_t* pSrcLine = NULL; | 1094 const uint8_t* pSrcLine = nullptr; |
1095 if (m_pCachedBitmap) { | 1095 if (m_pCachedBitmap && src_pitch_value == m_pCachedBitmap->GetPitch()) { |
1096 if (line >= m_pCachedBitmap->GetHeight()) { | 1096 if (line >= m_pCachedBitmap->GetHeight()) { |
1097 line = m_pCachedBitmap->GetHeight() - 1; | 1097 line = m_pCachedBitmap->GetHeight() - 1; |
1098 } | 1098 } |
1099 pSrcLine = m_pCachedBitmap->GetScanline(line); | 1099 pSrcLine = m_pCachedBitmap->GetScanline(line); |
1100 } else if (m_pDecoder) { | 1100 } else if (m_pDecoder) { |
1101 pSrcLine = m_pDecoder->GetScanline(line); | 1101 pSrcLine = m_pDecoder->GetScanline(line); |
1102 } else { | 1102 } else { |
1103 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch_value) { | 1103 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch_value) { |
1104 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch_value; | 1104 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch_value; |
1105 } | 1105 } |
1106 } | 1106 } |
1107 if (pSrcLine == NULL) { | 1107 if (!pSrcLine) { |
1108 uint8_t* pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; | 1108 uint8_t* pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; |
1109 FXSYS_memset(pLineBuf, 0xFF, m_Pitch); | 1109 FXSYS_memset(pLineBuf, 0xFF, m_Pitch); |
1110 return pLineBuf; | 1110 return pLineBuf; |
1111 } | 1111 } |
1112 if (m_bpc * m_nComponents == 1) { | 1112 if (m_bpc * m_nComponents == 1) { |
1113 if (m_bImageMask && m_bDefaultDecode) { | 1113 if (m_bImageMask && m_bDefaultDecode) { |
1114 for (FX_DWORD i = 0; i < src_pitch_value; i++) { | 1114 for (FX_DWORD i = 0; i < src_pitch_value; i++) { |
1115 m_pLineBuf[i] = ~pSrcLine[i]; | 1115 m_pLineBuf[i] = ~pSrcLine[i]; |
1116 } | 1116 } |
1117 } else if (m_bColorKey) { | 1117 } else if (m_bColorKey) { |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 } | 1644 } |
1645 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { | 1645 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { |
1646 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); | 1646 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); |
1647 } | 1647 } |
1648 CPDF_ImageLoader::~CPDF_ImageLoader() { | 1648 CPDF_ImageLoader::~CPDF_ImageLoader() { |
1649 if (!m_bCached) { | 1649 if (!m_bCached) { |
1650 delete m_pBitmap; | 1650 delete m_pBitmap; |
1651 delete m_pMask; | 1651 delete m_pMask; |
1652 } | 1652 } |
1653 } | 1653 } |
OLD | NEW |