Remove a static initializer in fx_dib_main.cpp.
Instead of initializing a global |kBilinearInterpolation| constant
there, add two non-global variables in the two functions that use it.
Change-Id: Ib3d74f1355e6e11294be1fbe749dbc2eafe86ed1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54291
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.cpp b/core/fxcodec/codec/ccodec_progressivedecoder.cpp
index 30d7616..9462a4f 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.cpp
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.cpp
@@ -1523,8 +1523,11 @@
m_status = FXCODEC_STATUS_ERR_MEMORY;
return m_status;
}
- RetainPtr<CFX_DIBitmap> pStrechBitmap = pFormatBitmap->StretchTo(
- m_sizeX, m_sizeY, kBilinearInterpolation, nullptr);
+
+ FXDIB_ResampleOptions options;
+ options.bInterpolateBilinear = true;
+ RetainPtr<CFX_DIBitmap> pStrechBitmap =
+ pFormatBitmap->StretchTo(m_sizeX, m_sizeY, options, nullptr);
pFormatBitmap = nullptr;
if (!pStrechBitmap) {
m_pDeviceBitmap = nullptr;
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index 742c016..d24be39 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -57,27 +57,11 @@
FXDIB_ResampleOptions::FXDIB_ResampleOptions() = default;
-FXDIB_ResampleOptions::FXDIB_ResampleOptions(bool downsample,
- bool bilinear,
- bool bicubic,
- bool halftone,
- bool no_smoothing,
- bool lossy)
- : bInterpolateDownsample(downsample),
- bInterpolateBilinear(bilinear),
- bInterpolateBicubic(bicubic),
- bHalftone(halftone),
- bNoSmoothing(no_smoothing),
- bLossy(lossy) {}
-
bool FXDIB_ResampleOptions::HasAnyOptions() const {
return bInterpolateDownsample || bInterpolateBilinear ||
bInterpolateBicubic || bHalftone || bNoSmoothing || bLossy;
}
-const FXDIB_ResampleOptions kBilinearInterpolation = {
- false, /*bilinear=*/true, false, false, false, false};
-
FX_RECT FXDIB_SwapClipBox(const FX_RECT& clip,
int width,
int height,
diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h
index 5bc621f..f61d1f2 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -48,14 +48,6 @@
struct FXDIB_ResampleOptions {
FXDIB_ResampleOptions();
- // TODO(thestig): Remove this ctor once C++14 can be used for more flexible
- // constexpr initialization.
- FXDIB_ResampleOptions(bool downsample,
- bool bilinear,
- bool bicubic,
- bool halftone,
- bool no_smoothing,
- bool lossy);
bool HasAnyOptions() const;
@@ -67,8 +59,6 @@
bool bLossy = false;
};
-extern const FXDIB_ResampleOptions kBilinearInterpolation;
-
// See PDF 1.7 spec, table 7.2 and 7.3. The enum values need to be in the same
// order as listed in the spec.
enum class BlendMode {
diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp
index b46f05f..d3b66c8 100644
--- a/xfa/fxfa/cxfa_imagerenderer.cpp
+++ b/xfa/fxfa/cxfa_imagerenderer.cpp
@@ -21,8 +21,10 @@
CXFA_ImageRenderer::~CXFA_ImageRenderer() = default;
bool CXFA_ImageRenderer::Start() {
- if (m_pDevice->StartDIBits(m_pDIBBase, 255, 0, m_ImageMatrix,
- kBilinearInterpolation, &m_DeviceHandle)) {
+ FXDIB_ResampleOptions options;
+ options.bInterpolateBilinear = true;
+ if (m_pDevice->StartDIBits(m_pDIBBase, 255, 0, m_ImageMatrix, options,
+ &m_DeviceHandle)) {
if (m_DeviceHandle) {
m_Status = 3;
return true;
@@ -49,7 +51,7 @@
clip_box.Intersect(image_rect);
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- pDib, m_ImageMatrix, kBilinearInterpolation, &clip_box);
+ pDib, m_ImageMatrix, options, &clip_box);
return true;
}
if (m_ImageMatrix.a < 0)
@@ -61,15 +63,15 @@
dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
if (m_pDIBBase->IsOpaqueImage()) {
if (m_pDevice->StretchDIBitsWithFlagsAndBlend(
- m_pDIBBase, dest_left, dest_top, dest_width, dest_height,
- kBilinearInterpolation, BlendMode::kNormal)) {
+ m_pDIBBase, dest_left, dest_top, dest_width, dest_height, options,
+ BlendMode::kNormal)) {
return false;
}
}
if (m_pDIBBase->IsAlphaMask()) {
if (m_pDevice->StretchBitMaskWithFlags(m_pDIBBase, dest_left, dest_top,
dest_width, dest_height, 0,
- kBilinearInterpolation)) {
+ options)) {
return false;
}
}
@@ -80,8 +82,8 @@
FX_RECT dest_clip(
dest_rect.left - image_rect.left, dest_rect.top - image_rect.top,
dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top);
- RetainPtr<CFX_DIBitmap> pStretched = m_pDIBBase->StretchTo(
- dest_width, dest_height, kBilinearInterpolation, &dest_clip);
+ RetainPtr<CFX_DIBitmap> pStretched =
+ m_pDIBBase->StretchTo(dest_width, dest_height, options, &dest_clip);
if (pStretched)
CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top);