Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Unified Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 1671843002: Combine two if/else blocks in CPDF_DIBSource::DownSampleScanline32Bit(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index e62290fdbbf34a6e1e201c268418e0bc3a7eae61..6e4dec3b6ab8f200fafe4a0d620f0b494f918f5a 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698