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