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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1075 } | 1075 } |
1076 } | 1076 } |
1077 uint8_t* CPDF_DIBSource::GetBuffer() const { | 1077 uint8_t* CPDF_DIBSource::GetBuffer() const { |
1078 if (m_pCachedBitmap) { | 1078 if (m_pCachedBitmap) { |
1079 return m_pCachedBitmap->GetBuffer(); | 1079 return m_pCachedBitmap->GetBuffer(); |
1080 } | 1080 } |
1081 return NULL; | 1081 return NULL; |
1082 } | 1082 } |
1083 const uint8_t* CPDF_DIBSource::GetScanline(int line) const { | 1083 const uint8_t* CPDF_DIBSource::GetScanline(int line) const { |
1084 if (m_bpc == 0) { | 1084 if (m_bpc == 0) { |
1085 return NULL; | 1085 return nullptr; |
1086 } | 1086 } |
1087 FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); | 1087 FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); |
1088 if (!src_pitch.IsValid()) | 1088 if (!src_pitch.IsValid()) |
1089 return NULL; | 1089 return nullptr; |
1090 FX_DWORD src_pitch_value = src_pitch.ValueOrDie(); | 1090 FX_DWORD src_pitch_value = src_pitch.ValueOrDie(); |
1091 const uint8_t* pSrcLine = NULL; | 1091 const uint8_t* pSrcLine = nullptr; |
1092 if (m_pCachedBitmap) { | 1092 if (m_pCachedBitmap && src_pitch_value <= m_pCachedBitmap->GetPitch()) { |
jun_fang
2015/11/12 05:41:07
src_pitch_value should equal m_pCachedBitmap->GetP
Oliver Chang
2015/11/12 18:39:45
This broke some things, as DIBitmap calculates the
| |
1093 if (line >= m_pCachedBitmap->GetHeight()) { | 1093 if (line >= m_pCachedBitmap->GetHeight()) { |
1094 line = m_pCachedBitmap->GetHeight() - 1; | 1094 line = m_pCachedBitmap->GetHeight() - 1; |
1095 } | 1095 } |
1096 pSrcLine = m_pCachedBitmap->GetScanline(line); | 1096 pSrcLine = m_pCachedBitmap->GetScanline(line); |
1097 } else if (m_pDecoder) { | 1097 } else if (m_pDecoder) { |
1098 pSrcLine = m_pDecoder->GetScanline(line); | 1098 pSrcLine = m_pDecoder->GetScanline(line); |
1099 } else { | 1099 } else { |
1100 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch_value) { | 1100 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch_value) { |
1101 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch_value; | 1101 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch_value; |
1102 } | 1102 } |
1103 } | 1103 } |
1104 if (pSrcLine == NULL) { | 1104 if (!pSrcLine) { |
1105 uint8_t* pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; | 1105 uint8_t* pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; |
1106 FXSYS_memset(pLineBuf, 0xFF, m_Pitch); | 1106 FXSYS_memset(pLineBuf, 0xFF, m_Pitch); |
1107 return pLineBuf; | 1107 return pLineBuf; |
1108 } | 1108 } |
1109 if (m_bpc * m_nComponents == 1) { | 1109 if (m_bpc * m_nComponents == 1) { |
1110 if (m_bImageMask && m_bDefaultDecode) { | 1110 if (m_bImageMask && m_bDefaultDecode) { |
1111 for (FX_DWORD i = 0; i < src_pitch_value; i++) { | 1111 for (FX_DWORD i = 0; i < src_pitch_value; i++) { |
1112 m_pLineBuf[i] = ~pSrcLine[i]; | 1112 m_pLineBuf[i] = ~pSrcLine[i]; |
1113 } | 1113 } |
1114 } else if (m_bColorKey) { | 1114 } else if (m_bColorKey) { |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1641 } | 1641 } |
1642 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { | 1642 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { |
1643 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); | 1643 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); |
1644 } | 1644 } |
1645 CPDF_ImageLoader::~CPDF_ImageLoader() { | 1645 CPDF_ImageLoader::~CPDF_ImageLoader() { |
1646 if (!m_bCached) { | 1646 if (!m_bCached) { |
1647 delete m_pBitmap; | 1647 delete m_pBitmap; |
1648 delete m_pMask; | 1648 delete m_pMask; |
1649 } | 1649 } |
1650 } | 1650 } |
OLD | NEW |