Bicubic image transforms are not used by PDFium.
The corresponding option is never set, so remove the
unreachable code. Also remove some unreachable downsampling
code as well.
Change-Id: I8c354e50308c5e6c3d56aa9e1ffd69cd38550a01
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75630
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 58e97b6..5364a58 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -48,59 +48,6 @@
return (r_pos_0 * (255 - res_y) + r_pos_1 * res_y) >> 8;
}
-uint8_t bicubic_interpol(const uint8_t* buf,
- uint32_t pitch,
- const int pos_pixel[],
- const int u_w[],
- const int v_w[],
- int res_x,
- int res_y,
- int bpp,
- int c_offset) {
- int s_result = 0;
- for (int i = 0; i < 4; i++) {
- int a_result = 0;
- for (int j = 0; j < 4; j++) {
- uint8_t val =
- *(buf + pos_pixel[i + 4] * pitch + pos_pixel[j] * bpp + c_offset);
- a_result += u_w[j] * val;
- }
- s_result += a_result * v_w[i];
- }
- s_result >>= 16;
- return static_cast<uint8_t>(pdfium::clamp(s_result, 0, 255));
-}
-
-void bicubic_get_pos_weight(int pos_pixel[],
- int u_w[],
- int v_w[],
- int src_col_l,
- int src_row_l,
- int res_x,
- int res_y,
- int stretch_width,
- int stretch_height) {
- pos_pixel[0] = src_col_l - 1;
- pos_pixel[1] = src_col_l;
- pos_pixel[2] = src_col_l + 1;
- pos_pixel[3] = src_col_l + 2;
- pos_pixel[4] = src_row_l - 1;
- pos_pixel[5] = src_row_l;
- pos_pixel[6] = src_row_l + 1;
- pos_pixel[7] = src_row_l + 2;
- for (int i = 0; i < 4; i++) {
- pos_pixel[i] = pdfium::clamp(pos_pixel[i], 0, stretch_width - 1);
- pos_pixel[i + 4] = pdfium::clamp(pos_pixel[i + 4], 0, stretch_height - 1);
- }
- u_w[0] = SDP_Table[256 + res_x];
- u_w[1] = SDP_Table[res_x];
- u_w[2] = SDP_Table[256 - res_x];
- u_w[3] = SDP_Table[512 - res_x];
- v_w[0] = SDP_Table[256 + res_y];
- v_w[1] = SDP_Table[res_y];
- v_w[2] = SDP_Table[256 - res_y];
- v_w[3] = SDP_Table[512 - res_y];
-}
// Let the compiler deduce the type for |func|, which cheaper than specifying it
// with std::function.
@@ -221,62 +168,6 @@
}
}
-// Let the compiler deduce the type for |func|, which cheaper than specifying it
-// with std::function.
-template <typename F>
-void DoBicubicLoop(const CFX_ImageTransformer::CalcData& cdata,
- const FX_RECT& result_rect,
- const FX_RECT& clip_rect,
- int increment,
- const F& func) {
- CFX_BilinearMatrix matrix_fix(cdata.matrix);
- for (int row = 0; row < result_rect.Height(); row++) {
- uint8_t* dest = cdata.bitmap->GetWritableScanline(row);
- for (int col = 0; col < result_rect.Width(); col++) {
- CFX_ImageTransformer::BicubicData d;
- d.res_x = 0;
- d.res_y = 0;
- d.src_col_l = 0;
- d.src_row_l = 0;
- matrix_fix.Transform(col, row, &d.src_col_l, &d.src_row_l, &d.res_x,
- &d.res_y);
- if (LIKELY(InStretchBounds(clip_rect, d.src_col_l, d.src_row_l))) {
- AdjustCoords(clip_rect, &d.src_col_l, &d.src_row_l);
- bicubic_get_pos_weight(d.pos_pixel, d.u_w, d.v_w, d.src_col_l,
- d.src_row_l, d.res_x, d.res_y, clip_rect.Width(),
- clip_rect.Height());
- func(d, dest);
- }
- dest += increment;
- }
- }
-}
-
-// Let the compiler deduce the type for |func|, which cheaper than specifying it
-// with std::function.
-template <typename F>
-void DoDownSampleLoop(const CFX_ImageTransformer::CalcData& cdata,
- const FX_RECT& result_rect,
- const FX_RECT& clip_rect,
- int increment,
- const F& func) {
- CPDF_FixedMatrix matrix_fix(cdata.matrix);
- for (int row = 0; row < result_rect.Height(); row++) {
- uint8_t* dest = cdata.bitmap->GetWritableScanline(row);
- for (int col = 0; col < result_rect.Width(); col++) {
- CFX_ImageTransformer::DownSampleData d;
- d.src_col = 0;
- d.src_row = 0;
- matrix_fix.Transform(col, row, &d.src_col, &d.src_row);
- if (LIKELY(InStretchBounds(clip_rect, d.src_col, d.src_row))) {
- AdjustCoords(clip_rect, &d.src_col, &d.src_row);
- func(d, dest);
- }
- dest += increment;
- }
- }
-}
-
} // namespace
CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
@@ -438,49 +329,21 @@
}
void CFX_ImageTransformer::CalcMask(const CalcData& cdata) {
- if (IsBilinear()) {
- auto func = [&cdata](const BilinearData& data, uint8_t* dest) {
- *dest = bilinear_interpol(cdata.buf, data.row_offset_l, data.row_offset_r,
- data.src_col_l, data.src_col_r, data.res_x,
- data.res_y, 1, 0);
- };
- DoBilinearLoop(cdata, m_result, m_StretchClip, 1, func);
- } else if (IsBiCubic()) {
- auto func = [&cdata](const BicubicData& data, uint8_t* dest) {
- *dest = bicubic_interpol(cdata.buf, cdata.pitch, data.pos_pixel, data.u_w,
- data.v_w, data.res_x, data.res_y, 1, 0);
- };
- DoBicubicLoop(cdata, m_result, m_StretchClip, 1, func);
- } else {
- auto func = [&cdata](const DownSampleData& data, uint8_t* dest) {
- *dest = cdata.buf[data.src_row * cdata.pitch + data.src_col];
- };
- DoDownSampleLoop(cdata, m_result, m_StretchClip, 1, func);
- }
+ auto func = [&cdata](const BilinearData& data, uint8_t* dest) {
+ *dest = bilinear_interpol(cdata.buf, data.row_offset_l, data.row_offset_r,
+ data.src_col_l, data.src_col_r, data.res_x,
+ data.res_y, 1, 0);
+ };
+ DoBilinearLoop(cdata, m_result, m_StretchClip, 1, func);
}
void CFX_ImageTransformer::CalcAlpha(const CalcData& cdata) {
- if (IsBilinear()) {
- auto func = [&cdata](const BilinearData& data, uint8_t* dest) {
- *dest = bilinear_interpol(cdata.buf, data.row_offset_l, data.row_offset_r,
- data.src_col_l, data.src_col_r, data.res_x,
- data.res_y, 1, 0);
- };
- DoBilinearLoop(cdata, m_result, m_StretchClip, 1, func);
- } else if (IsBiCubic()) {
- auto func = [&cdata](const BicubicData& data, uint8_t* dest) {
- *dest = bicubic_interpol(cdata.buf, cdata.pitch, data.pos_pixel, data.u_w,
- data.v_w, data.res_x, data.res_y, 1, 0);
- };
- DoBicubicLoop(cdata, m_result, m_StretchClip, 1, func);
- } else {
- auto func = [&cdata](const DownSampleData& data, uint8_t* dest) {
- const uint8_t* src_pixel =
- cdata.buf + cdata.pitch * data.src_row + data.src_col;
- *dest = *src_pixel;
- };
- DoDownSampleLoop(cdata, m_result, m_StretchClip, 1, func);
- }
+ auto func = [&cdata](const BilinearData& data, uint8_t* dest) {
+ *dest = bilinear_interpol(cdata.buf, data.row_offset_l, data.row_offset_r,
+ data.src_col_l, data.src_col_r, data.res_x,
+ data.res_y, 1, 0);
+ };
+ DoBilinearLoop(cdata, m_result, m_StretchClip, 1, func);
}
void CFX_ImageTransformer::CalcMono(const CalcData& cdata) {
@@ -495,28 +358,13 @@
argb[i] = 0xff000000 | (i * 0x010101);
}
int destBpp = cdata.bitmap->GetBPP() / 8;
- if (IsBilinear()) {
- auto func = [&cdata, &argb](const BilinearData& data, uint8_t* dest) {
- uint8_t idx = bilinear_interpol(
- cdata.buf, data.row_offset_l, data.row_offset_r, data.src_col_l,
- data.src_col_r, data.res_x, data.res_y, 1, 0);
- *reinterpret_cast<uint32_t*>(dest) = argb[idx];
- };
- DoBilinearLoop(cdata, m_result, m_StretchClip, destBpp, func);
- } else if (IsBiCubic()) {
- auto func = [&cdata, &argb](const BicubicData& data, uint8_t* dest) {
- *reinterpret_cast<uint32_t*>(dest) = argb[bicubic_interpol(
- cdata.buf, cdata.pitch, data.pos_pixel, data.u_w, data.v_w,
- data.res_x, data.res_y, 1, 0)];
- };
- DoBicubicLoop(cdata, m_result, m_StretchClip, destBpp, func);
- } else {
- auto func = [&cdata, &argb](const DownSampleData& data, uint8_t* dest) {
- *reinterpret_cast<uint32_t*>(dest) =
- argb[cdata.buf[data.src_row * cdata.pitch + data.src_col]];
- };
- DoDownSampleLoop(cdata, m_result, m_StretchClip, destBpp, func);
- }
+ auto func = [&cdata, &argb](const BilinearData& data, uint8_t* dest) {
+ uint8_t idx = bilinear_interpol(
+ cdata.buf, data.row_offset_l, data.row_offset_r, data.src_col_l,
+ data.src_col_r, data.res_x, data.res_y, 1, 0);
+ *reinterpret_cast<uint32_t*>(dest) = argb[idx];
+ };
+ DoBilinearLoop(cdata, m_result, m_StretchClip, destBpp, func);
}
void CFX_ImageTransformer::CalcColor(const CalcData& cdata,
@@ -525,44 +373,14 @@
DCHECK(format == FXDIB_Format::k8bppMask || format == FXDIB_Format::kArgb);
bool bHasAlpha = m_Storer.GetBitmap()->HasAlpha();
int destBpp = cdata.bitmap->GetBPP() / 8;
- if (IsBilinear()) {
- auto func = [&cdata, format, Bpp, bHasAlpha](const BilinearData& data,
- uint8_t* dest) {
- auto bilinear_interpol_func = [&cdata, &data, Bpp](int offset) {
- return bilinear_interpol(
- cdata.buf, data.row_offset_l, data.row_offset_r, data.src_col_l,
- data.src_col_r, data.res_x, data.res_y, Bpp, offset);
- };
- WriteColorResult(bilinear_interpol_func, bHasAlpha, format, dest);
+ auto func = [&cdata, format, Bpp, bHasAlpha](const BilinearData& data,
+ uint8_t* dest) {
+ auto bilinear_interpol_func = [&cdata, &data, Bpp](int offset) {
+ return bilinear_interpol(cdata.buf, data.row_offset_l, data.row_offset_r,
+ data.src_col_l, data.src_col_r, data.res_x,
+ data.res_y, Bpp, offset);
};
- DoBilinearLoop(cdata, m_result, m_StretchClip, destBpp, func);
- } else if (IsBiCubic()) {
- auto func = [&cdata, format, Bpp, bHasAlpha](const BicubicData& data,
- uint8_t* dest) {
- auto bicubic_interpol_func = [&cdata, &data, Bpp](int offset) {
- return bicubic_interpol(cdata.buf, cdata.pitch, data.pos_pixel,
- data.u_w, data.v_w, data.res_x, data.res_y, Bpp,
- offset);
- };
- WriteColorResult(bicubic_interpol_func, bHasAlpha, format, dest);
- };
- DoBicubicLoop(cdata, m_result, m_StretchClip, destBpp, func);
- } else {
- auto func = [&cdata, format, bHasAlpha, Bpp](const DownSampleData& data,
- uint8_t* dest) {
- const uint8_t* src_pos =
- cdata.buf + data.src_row * cdata.pitch + data.src_col * Bpp;
- auto sample_func = [src_pos](int offset) { return src_pos[offset]; };
- WriteColorResult(sample_func, bHasAlpha, format, dest);
- };
- DoDownSampleLoop(cdata, m_result, m_StretchClip, destBpp, func);
- }
-}
-
-bool CFX_ImageTransformer::IsBilinear() const {
- return !IsBiCubic();
-}
-
-bool CFX_ImageTransformer::IsBiCubic() const {
- return m_ResampleOptions.bInterpolateBicubic;
+ WriteColorResult(bilinear_interpol_func, bHasAlpha, format, dest);
+ };
+ DoBilinearLoop(cdata, m_result, m_StretchClip, destBpp, func);
}
diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h
index 88af9e5..2b06d37 100644
--- a/core/fxge/dib/cfx_imagetransformer.h
+++ b/core/fxge/dib/cfx_imagetransformer.h
@@ -31,23 +31,6 @@
int row_offset_r;
};
- struct BicubicData {
- int res_x;
- int res_y;
- int src_col_l;
- int src_row_l;
- int src_col_r;
- int src_row_r;
- int pos_pixel[8];
- int u_w[4];
- int v_w[4];
- };
-
- struct DownSampleData {
- int src_col;
- int src_row;
- };
-
struct CalcData {
CFX_DIBitmap* bitmap;
const CFX_Matrix& matrix;
@@ -82,9 +65,6 @@
void CalcMono(const CalcData& cdata);
void CalcColor(const CalcData& cdata, FXDIB_Format format, int Bpp);
- bool IsBilinear() const;
- bool IsBiCubic() const;
-
RetainPtr<CFX_DIBBase> const m_pSrc;
const CFX_Matrix m_matrix;
FX_RECT m_StretchClip;
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index 5e107cc..b1ea7f6 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -18,8 +18,6 @@
namespace {
-constexpr int kMaxDestValue = 16711680;
-
int GetPitchRoundUpTo4Bytes(int bits_per_pixel) {
return (bits_per_pixel + 31) / 32 * 4;
}
@@ -43,17 +41,14 @@
const FXDIB_ResampleOptions& options) {
// Help the compiler realize that these can't change during a loop iteration:
const bool bilinear = options.bInterpolateBilinear;
- const bool bicubic = options.bInterpolateBicubic;
m_WeightTables.clear();
m_dwWeightTablesSize = 0;
const double scale = static_cast<float>(src_len) / dest_len;
const double base = dest_len < 0 ? src_len : 0;
- const int ext_size = bicubic ? 3 : 1;
- m_ItemSize =
- sizeof(int) * 2 +
- static_cast<int>(sizeof(int) *
- (ceil(fabs(static_cast<float>(scale))) + ext_size));
+ m_ItemSize = sizeof(int) * 2 +
+ static_cast<int>(sizeof(int) *
+ (ceil(fabs(static_cast<float>(scale))) + 1));
m_DestMin = dest_min;
if (dest_max - dest_min > static_cast<int>((1U << 30) - 4) / m_ItemSize)
@@ -81,85 +76,6 @@
65536);
pixel_weights.m_Weights[0] = 65536 - pixel_weights.m_Weights[1];
}
- } else if (bicubic) {
- pixel_weights.m_SrcStart =
- static_cast<int>(floor(static_cast<float>(src_pos) - 1.0f / 2));
- pixel_weights.m_SrcEnd =
- static_cast<int>(floor(static_cast<float>(src_pos) + 1.0f / 2));
- int start = pixel_weights.m_SrcStart - 1;
- int end = pixel_weights.m_SrcEnd + 1;
- start = std::max(start, src_min);
- end = std::min(end, src_max - 1);
- if (pixel_weights.m_SrcStart < src_min) {
- src_pos += src_min - pixel_weights.m_SrcStart;
- pixel_weights.m_SrcStart = src_min;
- }
- pixel_weights.m_SrcEnd = std::min(pixel_weights.m_SrcEnd, src_max - 1);
- int weight = FXSYS_roundf(
- static_cast<float>(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) *
- 256);
- if (start == end) {
- pixel_weights.m_Weights[0] =
- (SDP_Table[256 + weight] + SDP_Table[weight] +
- SDP_Table[256 - weight] + SDP_Table[512 - weight])
- << 8;
- } else if ((start == pixel_weights.m_SrcStart &&
- (pixel_weights.m_SrcStart == pixel_weights.m_SrcEnd ||
- end == pixel_weights.m_SrcEnd) &&
- start < end) ||
- (start < pixel_weights.m_SrcStart &&
- pixel_weights.m_SrcStart == pixel_weights.m_SrcEnd &&
- end == pixel_weights.m_SrcEnd)) {
- if (start < pixel_weights.m_SrcStart) {
- pixel_weights.m_Weights[0] = SDP_Table[256 + weight] << 8;
- pixel_weights.m_Weights[1] =
- (SDP_Table[weight] + SDP_Table[256 - weight] +
- SDP_Table[512 - weight])
- << 8;
- } else {
- if (pixel_weights.m_SrcStart == pixel_weights.m_SrcEnd) {
- pixel_weights.m_Weights[0] =
- (SDP_Table[256 + weight] + SDP_Table[weight] +
- SDP_Table[256 - weight])
- << 8;
- pixel_weights.m_Weights[1] = SDP_Table[512 - weight] << 8;
- } else {
- pixel_weights.m_Weights[0] =
- (SDP_Table[256 + weight] + SDP_Table[weight]) << 8;
- pixel_weights.m_Weights[1] =
- (SDP_Table[256 - weight] + SDP_Table[512 - weight]) << 8;
- }
- }
- if (pixel_weights.m_SrcStart == pixel_weights.m_SrcEnd) {
- pixel_weights.m_SrcEnd = end;
- }
- if (start < pixel_weights.m_SrcStart) {
- pixel_weights.m_SrcStart = start;
- }
- } else if (start == pixel_weights.m_SrcStart &&
- start < pixel_weights.m_SrcEnd &&
- pixel_weights.m_SrcEnd < end) {
- pixel_weights.m_Weights[0] =
- (SDP_Table[256 + weight] + SDP_Table[weight]) << 8;
- pixel_weights.m_Weights[1] = SDP_Table[256 - weight] << 8;
- pixel_weights.m_Weights[2] = SDP_Table[512 - weight] << 8;
- pixel_weights.m_SrcEnd = end;
- } else if (start < pixel_weights.m_SrcStart &&
- pixel_weights.m_SrcStart < pixel_weights.m_SrcEnd &&
- pixel_weights.m_SrcEnd == end) {
- pixel_weights.m_Weights[0] = SDP_Table[256 + weight] << 8;
- pixel_weights.m_Weights[1] = SDP_Table[weight] << 8;
- pixel_weights.m_Weights[2] =
- (SDP_Table[256 - weight] + SDP_Table[512 - weight]) << 8;
- pixel_weights.m_SrcStart = start;
- } else {
- pixel_weights.m_Weights[0] = SDP_Table[256 + weight] << 8;
- pixel_weights.m_Weights[1] = SDP_Table[weight] << 8;
- pixel_weights.m_Weights[2] = SDP_Table[256 - weight] << 8;
- pixel_weights.m_Weights[3] = SDP_Table[512 - weight] << 8;
- pixel_weights.m_SrcStart = start;
- pixel_weights.m_SrcEnd = end;
- }
} else {
int pixel_pos = static_cast<int>(floor(static_cast<float>(src_pos)));
pixel_weights.m_SrcStart = std::max(pixel_pos, src_min);
@@ -260,9 +176,7 @@
if (options.bNoSmoothing) {
m_ResampleOptions.bNoSmoothing = true;
} else {
- bool bInterpol =
- options.bInterpolateBilinear || options.bInterpolateBicubic;
- if (!bInterpol && abs(dest_width) != 0 &&
+ if (!options.bInterpolateBilinear && abs(dest_width) != 0 &&
abs(dest_height) / 8 < static_cast<long long>(m_SrcWidth) *
m_SrcHeight / abs(dest_width)) {
m_ResampleOptions.bInterpolateBilinear = true;
@@ -354,9 +268,6 @@
if (m_pSource->SkipToScanline(m_CurRow, pPause))
return true;
- // Help the compiler realize that this can't change during a loop iteration:
- const bool bicubic = m_ResampleOptions.bInterpolateBicubic;
-
int Bpp = m_DestBpp / 8;
static const int kStrechPauseRows = 10;
int rows_to_go = kStrechPauseRows;
@@ -394,8 +305,6 @@
if (src_scan[j / 8] & (1 << (7 - j % 8)))
dest_a += pixel_weight * 255;
}
- if (bicubic)
- dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
*dest_scan++ = static_cast<uint8_t>(dest_a >> 16);
}
break;
@@ -412,8 +321,6 @@
int pixel_weight = *pWeight;
dest_a += pixel_weight * src_scan[j];
}
- if (bicubic)
- dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
*dest_scan++ = static_cast<uint8_t>(dest_a >> 16);
}
break;
@@ -433,10 +340,6 @@
dest_r += pixel_weight * src_scan[j];
dest_a += pixel_weight;
}
- if (bicubic) {
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- dest_a = pdfium::clamp(dest_a, 0, 65536);
- }
*dest_scan++ = static_cast<uint8_t>(dest_r >> 16);
*dest_scan_mask++ = static_cast<uint8_t>((dest_a * 255) >> 16);
}
@@ -465,11 +368,6 @@
dest_r += pixel_weight * static_cast<uint8_t>(argb >> 8);
}
}
- if (bicubic) {
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- dest_g = pdfium::clamp(dest_g, 0, kMaxDestValue);
- dest_b = pdfium::clamp(dest_b, 0, kMaxDestValue);
- }
*dest_scan++ = static_cast<uint8_t>(dest_b >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_g >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_r >> 16);
@@ -496,12 +394,6 @@
dest_r += pixel_weight * static_cast<uint8_t>(argb >> 8);
dest_a += pixel_weight;
}
- if (bicubic) {
- dest_b = pdfium::clamp(dest_b, 0, kMaxDestValue);
- dest_g = pdfium::clamp(dest_g, 0, kMaxDestValue);
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- dest_a = pdfium::clamp(dest_a, 0, 65536);
- }
*dest_scan++ = static_cast<uint8_t>(dest_b >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_g >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_r >> 16);
@@ -526,11 +418,6 @@
dest_g += pixel_weight * (*src_pixel++);
dest_r += pixel_weight * (*src_pixel);
}
- if (bicubic) {
- dest_b = pdfium::clamp(dest_b, 0, kMaxDestValue);
- dest_g = pdfium::clamp(dest_g, 0, kMaxDestValue);
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- }
*dest_scan++ = static_cast<uint8_t>(dest_b >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_g >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_r >> 16);
@@ -562,12 +449,6 @@
dest_r += pixel_weight * (*src_pixel);
dest_a += pixel_weight;
}
- if (bicubic) {
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- dest_g = pdfium::clamp(dest_g, 0, kMaxDestValue);
- dest_b = pdfium::clamp(dest_b, 0, kMaxDestValue);
- dest_a = pdfium::clamp(dest_a, 0, 65536);
- }
*dest_scan++ = static_cast<uint8_t>(dest_b >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_g >> 16);
*dest_scan++ = static_cast<uint8_t>(dest_r >> 16);
@@ -596,9 +477,6 @@
if (!ret)
return;
- // Help the compiler realize that this can't change during a loop iteration:
- const bool bicubic = m_ResampleOptions.bInterpolateBicubic;
-
const int DestBpp = m_DestBpp / 8;
for (int row = m_DestClip.top; row < m_DestClip.bottom; ++row) {
unsigned char* dest_scan = m_DestScanline.data();
@@ -621,8 +499,6 @@
dest_a +=
pixel_weight * src_scan[(j - m_SrcClip.top) * m_InterPitch];
}
- if (bicubic)
- dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
*dest_scan = static_cast<uint8_t>(dest_a >> 16);
dest_scan += DestBpp;
}
@@ -647,10 +523,6 @@
dest_a += pixel_weight *
src_scan_mask[(j - m_SrcClip.top) * m_ExtraMaskPitch];
}
- if (bicubic) {
- dest_k = pdfium::clamp(dest_k, 0, kMaxDestValue);
- dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
- }
*dest_scan = static_cast<uint8_t>(dest_k >> 16);
dest_scan += DestBpp;
*dest_scan_mask++ = static_cast<uint8_t>(dest_a >> 16);
@@ -677,11 +549,6 @@
dest_g += pixel_weight * (*src_pixel++);
dest_r += pixel_weight * (*src_pixel);
}
- if (bicubic) {
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- dest_g = pdfium::clamp(dest_g, 0, kMaxDestValue);
- dest_b = pdfium::clamp(dest_b, 0, kMaxDestValue);
- }
dest_scan[0] = static_cast<uint8_t>(dest_b >> 16);
dest_scan[1] = static_cast<uint8_t>(dest_g >> 16);
dest_scan[2] = static_cast<uint8_t>(dest_r >> 16);
@@ -720,12 +587,6 @@
else
dest_a += pixel_weight * mask_v;
}
- if (bicubic) {
- dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
- dest_g = pdfium::clamp(dest_g, 0, kMaxDestValue);
- dest_b = pdfium::clamp(dest_b, 0, kMaxDestValue);
- dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
- }
if (dest_a) {
int r = static_cast<uint32_t>(dest_r) * 255 / dest_a;
int g = static_cast<uint32_t>(dest_g) * 255 / dest_a;
diff --git a/core/fxge/dib/cstretchengine_unittest.cpp b/core/fxge/dib/cstretchengine_unittest.cpp
index f6f6c3d..055ed25 100644
--- a/core/fxge/dib/cstretchengine_unittest.cpp
+++ b/core/fxge/dib/cstretchengine_unittest.cpp
@@ -26,7 +26,6 @@
CStretchEngine engine(nullptr, FXDIB_Format::k8bppRgb, 500, 500, clip_rect,
dib_source, FXDIB_ResampleOptions());
EXPECT_TRUE(engine.m_ResampleOptions.bInterpolateBilinear);
- EXPECT_FALSE(engine.m_ResampleOptions.bInterpolateBicubic);
EXPECT_FALSE(engine.m_ResampleOptions.bHalftone);
EXPECT_FALSE(engine.m_ResampleOptions.bNoSmoothing);
EXPECT_FALSE(engine.m_ResampleOptions.bLossy);
diff --git a/core/fxge/dib/fx_dib.cpp b/core/fxge/dib/fx_dib.cpp
index 2bff739..76077c3 100644
--- a/core/fxge/dib/fx_dib.cpp
+++ b/core/fxge/dib/fx_dib.cpp
@@ -17,44 +17,6 @@
"FX_COLORREF vs. COLORREF mismatch");
#endif
-const int16_t SDP_Table[513] = {
- 256, 256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255, 255, 255, 255,
- 254, 254, 254, 254, 253, 253, 253, 252, 252, 252, 251, 251, 251, 250, 250,
- 249, 249, 249, 248, 248, 247, 247, 246, 246, 245, 244, 244, 243, 243, 242,
- 242, 241, 240, 240, 239, 238, 238, 237, 236, 236, 235, 234, 233, 233, 232,
- 231, 230, 230, 229, 228, 227, 226, 226, 225, 224, 223, 222, 221, 220, 219,
- 218, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205,
- 204, 203, 202, 201, 200, 199, 198, 196, 195, 194, 193, 192, 191, 190, 189,
- 188, 186, 185, 184, 183, 182, 181, 179, 178, 177, 176, 175, 173, 172, 171,
- 170, 169, 167, 166, 165, 164, 162, 161, 160, 159, 157, 156, 155, 154, 152,
- 151, 150, 149, 147, 146, 145, 143, 142, 141, 140, 138, 137, 136, 134, 133,
- 132, 130, 129, 128, 126, 125, 124, 122, 121, 120, 119, 117, 116, 115, 113,
- 112, 111, 109, 108, 107, 105, 104, 103, 101, 100, 99, 97, 96, 95, 93,
- 92, 91, 89, 88, 87, 85, 84, 83, 81, 80, 79, 77, 76, 75, 73,
- 72, 71, 69, 68, 67, 66, 64, 63, 62, 60, 59, 58, 57, 55, 54,
- 53, 52, 50, 49, 48, 47, 45, 44, 43, 42, 40, 39, 38, 37, 36,
- 34, 33, 32, 31, 30, 28, 27, 26, 25, 24, 23, 21, 20, 19, 18,
- 17, 16, 15, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
- 1, 0, 0, -1, -2, -3, -4, -5, -6, -7, -7, -8, -9, -10, -11,
- -12, -12, -13, -14, -15, -15, -16, -17, -17, -18, -19, -19, -20, -21, -21,
- -22, -22, -23, -24, -24, -25, -25, -26, -26, -27, -27, -27, -28, -28, -29,
- -29, -30, -30, -30, -31, -31, -31, -32, -32, -32, -33, -33, -33, -33, -34,
- -34, -34, -34, -35, -35, -35, -35, -35, -36, -36, -36, -36, -36, -36, -36,
- -36, -36, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37,
- -37, -37, -37, -37, -37, -37, -37, -37, -36, -36, -36, -36, -36, -36, -36,
- -36, -36, -35, -35, -35, -35, -35, -35, -34, -34, -34, -34, -34, -33, -33,
- -33, -33, -33, -32, -32, -32, -32, -31, -31, -31, -31, -30, -30, -30, -30,
- -29, -29, -29, -29, -28, -28, -28, -27, -27, -27, -27, -26, -26, -26, -25,
- -25, -25, -24, -24, -24, -23, -23, -23, -22, -22, -22, -22, -21, -21, -21,
- -20, -20, -20, -19, -19, -19, -18, -18, -18, -17, -17, -17, -16, -16, -16,
- -15, -15, -15, -14, -14, -14, -13, -13, -13, -12, -12, -12, -11, -11, -11,
- -10, -10, -10, -9, -9, -9, -9, -8, -8, -8, -7, -7, -7, -7, -6,
- -6, -6, -6, -5, -5, -5, -5, -4, -4, -4, -4, -3, -3, -3, -3,
- -3, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0,
-};
-
FXDIB_Format MakeRGBFormat(int bpp) {
switch (bpp) {
case 1:
@@ -73,8 +35,7 @@
FXDIB_ResampleOptions::FXDIB_ResampleOptions() = default;
bool FXDIB_ResampleOptions::HasAnyOptions() const {
- return bInterpolateBilinear || bInterpolateBicubic || bHalftone ||
- bNoSmoothing || bLossy;
+ return bInterpolateBilinear || bHalftone || bNoSmoothing || bLossy;
}
FX_RECT FXDIB_SwapClipBox(const FX_RECT& clip,
diff --git a/core/fxge/dib/fx_dib.h b/core/fxge/dib/fx_dib.h
index 772409d..2cfdd49 100644
--- a/core/fxge/dib/fx_dib.h
+++ b/core/fxge/dib/fx_dib.h
@@ -36,15 +36,12 @@
// FX_COLORREF, like win32 COLORREF, is BGR.
using FX_COLORREF = uint32_t;
-extern const int16_t SDP_Table[513];
-
struct FXDIB_ResampleOptions {
FXDIB_ResampleOptions();
bool HasAnyOptions() const;
bool bInterpolateBilinear = false;
- bool bInterpolateBicubic = false;
bool bHalftone = false;
bool bNoSmoothing = false;
bool bLossy = false;
diff --git a/core/fxge/win32/cgdi_device_driver.cpp b/core/fxge/win32/cgdi_device_driver.cpp
index 1a49aca..d349bd1 100644
--- a/core/fxge/win32/cgdi_device_driver.cpp
+++ b/core/fxge/win32/cgdi_device_driver.cpp
@@ -363,7 +363,7 @@
ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
if ((int64_t)abs(dest_width) * abs(dest_height) <
(int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 ||
- options.bInterpolateBilinear || options.bInterpolateBicubic) {
+ options.bInterpolateBilinear) {
SetStretchBltMode(m_hDC, HALFTONE);
} else {
SetStretchBltMode(m_hDC, COLORONCOLOR);