summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-02-05 17:37:11 -0800
committerLei Zhang <thestig@chromium.org>2016-02-05 17:37:11 -0800
commit2a1f9736c2e459a9abec00853f0bff21a87e31d4 (patch)
tree3150e0ef09892a1f54eacc04464fcaf1f17e0c3c /core
parent5ef071fe48737c9e5d6165825404755ce2c877c9 (diff)
downloadpdfium-2a1f9736c2e459a9abec00853f0bff21a87e31d4.tar.xz
Combine two if/else blocks in CPDF_DIBSource::DownSampleScanline32Bit().
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1671843002 .
Diffstat (limited to 'core')
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index e62290fdbb..6e4dec3b6a 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -1446,38 +1446,33 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp,
(int64_t)src_width / dest_width;
src_x %= src_width;
- // No need to check for 32-bit overflow, as |src_x| is bounded by
- // |src_width| and DownSampleScanline already checked for overflow with the
- // pitch calculation.
- const uint8_t* pSrcPixel = nullptr;
- size_t bit_offset = 0;
- if (m_bpc % 8 == 0) {
- pSrcPixel = pSrcLine + src_x * orig_Bpp;
- } else {
- size_t num_bits = src_x * m_bpc * m_nComponents;
- pSrcPixel = pSrcLine + num_bits / 8;
- bit_offset = num_bits % 8;
- }
-
uint8_t* pDestPixel = dest_scan + i * dest_Bpp;
FX_ARGB argb;
if (src_x == last_src_x) {
argb = last_argb;
} else {
CFX_FixedBufGrow<uint8_t, 128> extracted_components(m_nComponents);
+ const uint8_t* pSrcPixel = nullptr;
if (m_bpc % 8 != 0) {
- uint64_t src_bit_pos = bit_offset;
+ // No need to check for 32-bit overflow, as |src_x| is bounded by
+ // |src_width| and DownSampleScanline() already checked for overflow
+ // with the pitch calculation.
+ size_t num_bits = src_x * m_bpc * m_nComponents;
+ uint64_t src_bit_pos = num_bits % 8;
+ pSrcPixel = pSrcLine + num_bits / 8;
for (FX_DWORD j = 0; j < m_nComponents; ++j) {
extracted_components[j] = static_cast<uint8_t>(
GetBits8(pSrcPixel, src_bit_pos, m_bpc) * unit_To8Bpc);
src_bit_pos += m_bpc;
}
pSrcPixel = extracted_components;
- } else if (m_bpc == 16) {
- for (FX_DWORD j = 0; j < m_nComponents; ++j) {
- extracted_components[j] = pSrcPixel[j * 2];
+ } else {
+ pSrcPixel = pSrcLine + src_x * orig_Bpp;
+ if (m_bpc == 16) {
+ for (FX_DWORD j = 0; j < m_nComponents; ++j)
+ extracted_components[j] = pSrcPixel[j * 2];
+ pSrcPixel = extracted_components;
}
- pSrcPixel = extracted_components;
}
if (m_pColorSpace) {