summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-05 20:55:27 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-05 20:55:27 +0000
commit0c5928825d0bc0c397e90d2c4861feaf9bdc6d24 (patch)
tree32ea23743d79e4078ec83b62b1f2de4b4fed40cf /core
parentcd39a7ca8c97e486aeeba1015667064bc22308e2 (diff)
downloadpdfium-0c5928825d0bc0c397e90d2c4861feaf9bdc6d24.tar.xz
Combine if/else blocks in CPDF_DIBSource::TranslateScanline24bpp().
The two branches are very similar. Change-Id: I2a9502858e9ce997f28b17bc1051b71fa058c2c4 Reviewed-on: https://pdfium-review.googlesource.com/24350 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp66
1 files changed, 24 insertions, 42 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index bb925398a4..eb7acac62c 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -857,57 +857,39 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan,
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
- if (m_bpc == 8) {
- uint64_t src_byte_pos = 0;
- size_t dest_byte_pos = 0;
- for (int column = 0; column < m_Width; column++) {
- for (uint32_t color = 0; color < m_nComponents; color++) {
+ uint64_t src_bit_pos = 0;
+ uint64_t src_byte_pos = 0;
+ size_t dest_byte_pos = 0;
+ const bool bpp8 = m_bpc == 8;
+ for (int column = 0; column < m_Width; column++) {
+ for (uint32_t color = 0; color < m_nComponents; color++) {
+ if (bpp8) {
uint8_t data = src_scan[src_byte_pos++];
color_values[color] = m_pCompData[color].m_DecodeMin +
m_pCompData[color].m_DecodeStep * data;
- }
- if (TransMask()) {
- float k = 1.0f - color_values[3];
- R = (1.0f - color_values[0]) * k;
- G = (1.0f - color_values[1]) * k;
- B = (1.0f - color_values[2]) * k;
- } else if (m_Family != PDFCS_PATTERN) {
- m_pColorSpace->GetRGB(color_values, &R, &G, &B);
- }
- R = pdfium::clamp(R, 0.0f, 1.0f);
- G = pdfium::clamp(G, 0.0f, 1.0f);
- B = pdfium::clamp(B, 0.0f, 1.0f);
- dest_scan[dest_byte_pos] = static_cast<uint8_t>(B * 255);
- dest_scan[dest_byte_pos + 1] = static_cast<uint8_t>(G * 255);
- dest_scan[dest_byte_pos + 2] = static_cast<uint8_t>(R * 255);
- dest_byte_pos += 3;
- }
- } else {
- uint64_t src_bit_pos = 0;
- size_t dest_byte_pos = 0;
- for (int column = 0; column < m_Width; column++) {
- for (uint32_t color = 0; color < m_nComponents; color++) {
+ } else {
unsigned int data = GetBits8(src_scan, src_bit_pos, m_bpc);
color_values[color] = m_pCompData[color].m_DecodeMin +
m_pCompData[color].m_DecodeStep * data;
src_bit_pos += m_bpc;
}
- if (TransMask()) {
- float k = 1.0f - color_values[3];
- R = (1.0f - color_values[0]) * k;
- G = (1.0f - color_values[1]) * k;
- B = (1.0f - color_values[2]) * k;
- } else if (m_Family != PDFCS_PATTERN) {
- m_pColorSpace->GetRGB(color_values, &R, &G, &B);
- }
- R = pdfium::clamp(R, 0.0f, 1.0f);
- G = pdfium::clamp(G, 0.0f, 1.0f);
- B = pdfium::clamp(B, 0.0f, 1.0f);
- dest_scan[dest_byte_pos] = static_cast<uint8_t>(B * 255);
- dest_scan[dest_byte_pos + 1] = static_cast<uint8_t>(G * 255);
- dest_scan[dest_byte_pos + 2] = static_cast<uint8_t>(R * 255);
- dest_byte_pos += 3;
}
+
+ if (TransMask()) {
+ float k = 1.0f - color_values[3];
+ R = (1.0f - color_values[0]) * k;
+ G = (1.0f - color_values[1]) * k;
+ B = (1.0f - color_values[2]) * k;
+ } else if (m_Family != PDFCS_PATTERN) {
+ m_pColorSpace->GetRGB(color_values, &R, &G, &B);
+ }
+ R = pdfium::clamp(R, 0.0f, 1.0f);
+ G = pdfium::clamp(G, 0.0f, 1.0f);
+ B = pdfium::clamp(B, 0.0f, 1.0f);
+ dest_scan[dest_byte_pos] = static_cast<uint8_t>(B * 255);
+ dest_scan[dest_byte_pos + 1] = static_cast<uint8_t>(G * 255);
+ dest_scan[dest_byte_pos + 2] = static_cast<uint8_t>(R * 255);
+ dest_byte_pos += 3;
}
}