summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-26 22:52:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-26 22:52:48 +0000
commit5883300439287ab46559231ce8aed11e92bbc97c (patch)
tree2c3499da9df5a2c4e2fb9d13f99bde13b7bebb42
parent9590dee526c514d87dc1f47569d1136ffcf539ad (diff)
downloadpdfium-5883300439287ab46559231ce8aed11e92bbc97c.tar.xz
Replace int flags with struct FXDIB_ResampleOptions.
Using bit values in an int may not be reliable, since different parts of the code can interpret the bits differently. e.g. FXDIB_DOWNSAMPLE and RENDER_FORCE_DOWNSAMPLE are defined in different places, but can be used interchangeably because they just happen to have the same value. It works but is rather fragile. Instead, use a struct of bools to explicitly define what different bits mean. Remove FXDIB_DOWNSAMPLE and friends. Change-Id: I9cf0c8f94d1ed27edf8dba22b0ab0ee67f2722cc Reviewed-on: https://pdfium-review.googlesource.com/c/44650 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp48
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.h4
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp3
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.cpp4
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp10
-rw-r--r--core/fxge/agg/fx_agg_driver.h4
-rw-r--r--core/fxge/cfx_renderdevice.cpp14
-rw-r--r--core/fxge/cfx_renderdevice.h13
-rw-r--r--core/fxge/dib/cfx_dibbase.cpp14
-rw-r--r--core/fxge/dib/cfx_dibbase.h2
-rw-r--r--core/fxge/dib/cfx_dibitmap.cpp10
-rw-r--r--core/fxge/dib/cfx_imagerenderer.cpp9
-rw-r--r--core/fxge/dib/cfx_imagerenderer.h2
-rw-r--r--core/fxge/dib/cfx_imagestretcher.cpp11
-rw-r--r--core/fxge/dib/cfx_imagestretcher.h4
-rw-r--r--core/fxge/dib/cfx_imagetransformer.cpp21
-rw-r--r--core/fxge/dib/cfx_imagetransformer.h10
-rw-r--r--core/fxge/dib/cstretchengine.cpp62
-rw-r--r--core/fxge/dib/cstretchengine.h6
-rw-r--r--core/fxge/dib/cstretchengine_unittest.cpp9
-rw-r--r--core/fxge/dib/fx_dib_main.cpp23
-rw-r--r--core/fxge/fx_dib.h26
-rw-r--r--core/fxge/renderdevicedriver_iface.h4
-rw-r--r--core/fxge/skia/fx_skia_device.cpp16
-rw-r--r--core/fxge/skia/fx_skia_device.h4
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp11
-rw-r--r--core/fxge/win32/cfx_psrenderer.h5
-rw-r--r--core/fxge/win32/fx_win32_device.cpp38
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp4
-rw-r--r--core/fxge/win32/fx_win32_print.cpp30
-rw-r--r--core/fxge/win32/win32_int.h22
-rw-r--r--xfa/fxfa/cxfa_imagerenderer.cpp10
33 files changed, 266 insertions, 196 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index c937ee68bb..4ab3e25a3e 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -97,19 +97,19 @@ bool CPDF_ImageRenderer::StartRenderDIBBase() {
pClone->ConvertColorScale(0xffffff, 0);
m_pDIBBase = pClone;
}
- m_Flags = 0;
+ m_ResampleOptions = FXDIB_ResampleOptions();
if (GetRenderOptions().HasFlag(RENDER_FORCE_DOWNSAMPLE))
- m_Flags |= RENDER_FORCE_DOWNSAMPLE;
+ m_ResampleOptions.bInterpolateDownsample = true;
else if (GetRenderOptions().HasFlag(RENDER_FORCE_HALFTONE))
- m_Flags |= RENDER_FORCE_HALFTONE;
+ m_ResampleOptions.bHalftone = true;
if (m_pRenderStatus->GetRenderDevice()->GetDeviceClass() != FXDC_DISPLAY)
HandleFilters();
if (GetRenderOptions().HasFlag(RENDER_NOIMAGESMOOTH))
- m_Flags |= FXDIB_NOSMOOTH;
+ m_ResampleOptions.bNoSmoothing = true;
else if (m_pImageObject->GetImage()->IsInterpol())
- m_Flags |= FXDIB_INTERPOL;
+ m_ResampleOptions.bInterpolateBilinear = true;
if (m_Loader.GetMask())
return DrawMaskedImage();
@@ -176,7 +176,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus,
FX_ARGB bitmap_argb,
int bitmap_alpha,
const CFX_Matrix* pImage2Device,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
bool bStdCS,
BlendMode blendType) {
m_pRenderStatus = pStatus;
@@ -184,7 +184,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus,
m_FillArgb = bitmap_argb;
m_BitmapAlpha = bitmap_alpha;
m_ImageMatrix = *pImage2Device;
- m_Flags = flags;
+ m_ResampleOptions = options;
m_bStdCS = bStdCS;
m_BlendType = blendType;
return StartDIBBase();
@@ -222,7 +222,7 @@ void CPDF_ImageRenderer::CalculateDrawImage(
CPDF_ImageRenderer image_render;
if (image_render.Start(&bitmap_render, pDIBBase, 0xffffffff, 255, pNewMatrix,
- m_Flags, true, BlendMode::kNormal)) {
+ m_ResampleOptions, true, BlendMode::kNormal)) {
image_render.Continue(nullptr);
}
if (m_Loader.MatteColor() == 0xffffffff)
@@ -333,7 +333,7 @@ bool CPDF_ImageRenderer::DrawMaskedImage() {
bitmap_render.Initialize(nullptr, nullptr);
CPDF_ImageRenderer image_render;
if (image_render.Start(&bitmap_render, m_pDIBBase, 0, 255, &new_matrix,
- m_Flags, true, BlendMode::kNormal)) {
+ m_ResampleOptions, true, BlendMode::kNormal)) {
image_render.Continue(nullptr);
}
CFX_DefaultRenderDevice bitmap_device2;
@@ -364,7 +364,7 @@ bool CPDF_ImageRenderer::DrawMaskedImage() {
}
bool CPDF_ImageRenderer::StartDIBBase() {
- if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBBase->GetBPP() > 1) {
+ if (!m_ResampleOptions.bInterpolateDownsample && m_pDIBBase->GetBPP() > 1) {
FX_SAFE_SIZE_T image_size = m_pDIBBase->GetBPP();
image_size /= 8;
image_size *= m_pDIBBase->GetWidth();
@@ -373,8 +373,8 @@ bool CPDF_ImageRenderer::StartDIBBase() {
return false;
if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE &&
- !(m_Flags & RENDER_FORCE_HALFTONE)) {
- m_Flags |= RENDER_FORCE_DOWNSAMPLE;
+ !m_ResampleOptions.bHalftone) {
+ m_ResampleOptions.bInterpolateDownsample = true;
}
}
#ifdef _SKIA_SUPPORT_
@@ -382,8 +382,8 @@ bool CPDF_ImageRenderer::StartDIBBase() {
if (m_pDIBBase->HasAlpha())
CFX_SkiaDeviceDriver::PreMultiply(premultiplied);
if (m_pRenderStatus->GetRenderDevice()->StartDIBitsWithBlend(
- premultiplied, m_BitmapAlpha, m_FillArgb, m_ImageMatrix, m_Flags,
- &m_DeviceHandle, m_BlendType)) {
+ premultiplied, m_BitmapAlpha, m_FillArgb, m_ImageMatrix,
+ m_ResampleOptions, &m_DeviceHandle, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return true;
@@ -392,8 +392,8 @@ bool CPDF_ImageRenderer::StartDIBBase() {
}
#else
if (m_pRenderStatus->GetRenderDevice()->StartDIBitsWithBlend(
- m_pDIBBase, m_BitmapAlpha, m_FillArgb, m_ImageMatrix, m_Flags,
- &m_DeviceHandle, m_BlendType)) {
+ m_pDIBBase, m_BitmapAlpha, m_FillArgb, m_ImageMatrix,
+ m_ResampleOptions, &m_DeviceHandle, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return true;
@@ -416,7 +416,7 @@ bool CPDF_ImageRenderer::StartDIBBase() {
clip_box.Intersect(image_rect);
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- m_pDIBBase, m_ImageMatrix, m_Flags, &clip_box);
+ m_pDIBBase, m_ImageMatrix, m_ResampleOptions, &clip_box);
return true;
}
if (m_ImageMatrix.a < 0)
@@ -429,8 +429,8 @@ bool CPDF_ImageRenderer::StartDIBBase() {
int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
if (m_pDIBBase->IsOpaqueImage() && m_BitmapAlpha == 255) {
if (m_pRenderStatus->GetRenderDevice()->StretchDIBitsWithFlagsAndBlend(
- m_pDIBBase, dest_left, dest_top, dest_width, dest_height, m_Flags,
- m_BlendType)) {
+ m_pDIBBase, dest_left, dest_top, dest_width, dest_height,
+ m_ResampleOptions, m_BlendType)) {
return false;
}
}
@@ -439,7 +439,7 @@ bool CPDF_ImageRenderer::StartDIBBase() {
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
if (m_pRenderStatus->GetRenderDevice()->StretchBitMaskWithFlags(
m_pDIBBase, dest_left, dest_top, dest_width, dest_height,
- m_FillArgb, m_Flags)) {
+ m_FillArgb, m_ResampleOptions)) {
return false;
}
}
@@ -454,8 +454,8 @@ bool CPDF_ImageRenderer::StartDIBBase() {
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, m_Flags, &dest_clip);
+ RetainPtr<CFX_DIBitmap> pStretched = m_pDIBBase->StretchTo(
+ dest_width, dest_height, m_ResampleOptions, &dest_clip);
if (pStretched) {
m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left,
dest_rect.top, m_FillArgb, m_BitmapAlpha,
@@ -557,7 +557,7 @@ void CPDF_ImageRenderer::HandleFilters() {
if (pFilters->IsName()) {
ByteString bsDecodeType = pFilters->GetString();
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode")
- m_Flags |= FXRENDER_IMAGE_LOSSY;
+ m_ResampleOptions.bLossy = true;
return;
}
@@ -568,7 +568,7 @@ void CPDF_ImageRenderer::HandleFilters() {
for (size_t i = 0; i < pArray->size(); i++) {
ByteString bsDecodeType = pArray->GetStringAt(i);
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
- m_Flags |= FXRENDER_IMAGE_LOSSY;
+ m_ResampleOptions.bLossy = true;
break;
}
}
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h
index 6df412f2c0..6befaf9b5f 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.h
+++ b/core/fpdfapi/render/cpdf_imagerenderer.h
@@ -41,7 +41,7 @@ class CPDF_ImageRenderer {
FX_ARGB bitmap_argb,
int bitmap_alpha,
const CFX_Matrix* pImage2Device,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
bool bStdCS,
BlendMode blendType);
@@ -79,7 +79,7 @@ class CPDF_ImageRenderer {
int m_BitmapAlpha = 0;
BlendMode m_BlendType = BlendMode::kNormal;
FX_ARGB m_FillArgb = 0;
- uint32_t m_Flags = 0;
+ FXDIB_ResampleOptions m_ResampleOptions;
bool m_bPatternColor = false;
bool m_bStdCS = false;
bool m_Result = true;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 3f7b4923dc..9bbd298f18 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1911,7 +1911,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
image_matrix.Concat(matrix);
CPDF_ImageRenderer renderer;
if (renderer.Start(this, pType3Char->GetBitmap(), fill_argb, 255,
- &image_matrix, 0, false, BlendMode::kNormal)) {
+ &image_matrix, FXDIB_ResampleOptions(), false,
+ BlendMode::kNormal)) {
renderer.Continue(nullptr);
}
if (!renderer.GetResult())
@@ -2257,7 +2258,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
RetainPtr<CFX_DIBitmap> pEnlargedBitmap =
DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(),
pPattern, mtObj2Device, 8, 8, m_Options.GetFlags());
- pPatternBitmap = pEnlargedBitmap->StretchTo(width, height, 0, nullptr);
+ pPatternBitmap = pEnlargedBitmap->StretchTo(
+ width, height, FXDIB_ResampleOptions(), nullptr);
} else {
pPatternBitmap = DrawPatternBitmap(
m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern,
@@ -2393,7 +2395,8 @@ void CPDF_RenderStatus::CompositeDIBitmap(
std::unique_ptr<CFX_ImageRenderer> dummy;
CFX_Matrix m = CFX_RenderDevice::GetFlipMatrix(
pDIBitmap->GetWidth(), pDIBitmap->GetHeight(), left, top);
- m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, m, 0, &dummy);
+ m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, m,
+ FXDIB_ResampleOptions(), &dummy);
return;
#else
pDIBitmap->MultiplyAlpha(bitmap_alpha);
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index 11e5946e05..4638fccb92 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -146,7 +146,8 @@ std::unique_ptr<CFX_GlyphBitmap> CPDF_Type3Cache::RenderGlyph(
return nullptr;
pResBitmap = pBitmap->StretchTo(static_cast<int>(image_matrix.a),
- safe_height.ValueOrDie(), 0, nullptr);
+ safe_height.ValueOrDie(),
+ FXDIB_ResampleOptions(), nullptr);
top = top_line;
if (image_matrix.a < 0)
left = FXSYS_round(image_matrix.e + image_matrix.a);
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.cpp b/core/fxcodec/codec/ccodec_progressivedecoder.cpp
index 04dda05157..fc703d8ca4 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.cpp
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.cpp
@@ -1523,8 +1523,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TiffContinueDecode() {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return m_status;
}
- RetainPtr<CFX_DIBitmap> pStrechBitmap =
- pFormatBitmap->StretchTo(m_sizeX, m_sizeY, FXDIB_INTERPOL, nullptr);
+ RetainPtr<CFX_DIBitmap> pStrechBitmap = pFormatBitmap->StretchTo(
+ m_sizeX, m_sizeY, kBilinearInterpolation, nullptr);
pFormatBitmap = nullptr;
if (!pStrechBitmap) {
m_pDeviceBitmap = nullptr;
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 10293d865c..ff2b387d46 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1519,7 +1519,7 @@ bool CFX_AggDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) {
if (!m_pBitmap->GetBuffer())
return true;
@@ -1539,7 +1539,7 @@ bool CFX_AggDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
false, false, m_bRgbByteOrder, 0, blend_type);
dest_clip.Offset(-dest_rect.left, -dest_rect.top);
CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height,
- dest_clip, flags);
+ dest_clip, options);
if (stretcher.Start())
stretcher.Continue(nullptr);
return true;
@@ -1550,15 +1550,15 @@ bool CFX_AggDeviceDriver::StartDIBits(
int bitmap_alpha,
uint32_t argb,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) {
if (!m_pBitmap->GetBuffer())
return true;
*handle = pdfium::MakeUnique<CFX_ImageRenderer>(
- m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, matrix,
- render_flags, m_bRgbByteOrder);
+ m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, matrix, options,
+ m_bRgbByteOrder);
return true;
}
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 00cae08be6..4983dc07d5 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -80,13 +80,13 @@ class CFX_AggDeviceDriver final : public RenderDeviceDriverIface {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) override;
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
bool ContinueDIBits(CFX_ImageRenderer* handle,
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 8fe1f6b3b0..e1bea7d611 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -774,14 +774,14 @@ bool CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend(
int top,
int dest_width,
int dest_height,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_mode) {
FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
FX_RECT clip_box = m_ClipBox;
clip_box.Intersect(dest_rect);
return clip_box.IsEmpty() || m_pDeviceDriver->StretchDIBits(
pBitmap, 0, left, top, dest_width,
- dest_height, &clip_box, flags, blend_mode);
+ dest_height, &clip_box, options, blend_mode);
}
bool CFX_RenderDevice::SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
@@ -800,7 +800,7 @@ bool CFX_RenderDevice::StretchBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
int dest_height,
uint32_t color) {
return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height,
- color, 0);
+ color, FXDIB_ResampleOptions());
}
bool CFX_RenderDevice::StretchBitMaskWithFlags(
@@ -810,12 +810,12 @@ bool CFX_RenderDevice::StretchBitMaskWithFlags(
int dest_width,
int dest_height,
uint32_t argb,
- uint32_t flags) {
+ const FXDIB_ResampleOptions& options) {
FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
FX_RECT clip_box = m_ClipBox;
clip_box.Intersect(dest_rect);
return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width,
- dest_height, &clip_box, flags,
+ dest_height, &clip_box, options,
BlendMode::kNormal);
}
@@ -824,11 +824,11 @@ bool CFX_RenderDevice::StartDIBitsWithBlend(
int bitmap_alpha,
uint32_t argb,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_mode) {
return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, matrix,
- flags, handle, blend_mode);
+ options, handle, blend_mode);
}
bool CFX_RenderDevice::ContinueDIBits(CFX_ImageRenderer* handle,
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 4f802af3d7..d16188b611 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -171,14 +171,15 @@ class CFX_RenderDevice {
int dest_width,
int dest_height) {
return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width,
- dest_height, 0, BlendMode::kNormal);
+ dest_height, FXDIB_ResampleOptions(),
+ BlendMode::kNormal);
}
bool StretchDIBitsWithFlagsAndBlend(const RetainPtr<CFX_DIBBase>& pBitmap,
int left,
int top,
int dest_width,
int dest_height,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type);
bool SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
int left,
@@ -196,21 +197,21 @@ class CFX_RenderDevice {
int dest_width,
int dest_height,
uint32_t color,
- uint32_t flags);
+ const FXDIB_ResampleOptions& options);
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle) {
- return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, matrix, flags,
+ return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, matrix, options,
handle, BlendMode::kNormal);
}
bool StartDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type);
bool ContinueDIBits(CFX_ImageRenderer* handle, PauseIndicatorIface* pPause);
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index 7fc9bef9cb..1dcbcf9e17 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -1171,17 +1171,19 @@ RetainPtr<CFX_DIBitmap> CFX_DIBBase::TransformTo(const CFX_Matrix& mtDest,
int* result_left,
int* result_top) {
RetainPtr<CFX_DIBBase> holder(this);
- CFX_ImageTransformer transformer(holder, mtDest, 0, nullptr);
+ CFX_ImageTransformer transformer(holder, mtDest, FXDIB_ResampleOptions(),
+ nullptr);
transformer.Continue(nullptr);
*result_left = transformer.result().left;
*result_top = transformer.result().top;
return transformer.DetachBitmap();
}
-RetainPtr<CFX_DIBitmap> CFX_DIBBase::StretchTo(int dest_width,
- int dest_height,
- uint32_t flags,
- const FX_RECT* pClip) {
+RetainPtr<CFX_DIBitmap> CFX_DIBBase::StretchTo(
+ int dest_width,
+ int dest_height,
+ const FXDIB_ResampleOptions& options,
+ const FX_RECT* pClip) {
RetainPtr<CFX_DIBBase> holder(this);
FX_RECT clip_rect(0, 0, abs(dest_width), abs(dest_height));
if (pClip)
@@ -1195,7 +1197,7 @@ RetainPtr<CFX_DIBitmap> CFX_DIBBase::StretchTo(int dest_width,
CFX_BitmapStorer storer;
CFX_ImageStretcher stretcher(&storer, holder, dest_width, dest_height,
- clip_rect, flags);
+ clip_rect, options);
if (stretcher.Start())
stretcher.Continue(nullptr);
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index 81b0691563..23d65a3cda 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -80,7 +80,7 @@ class CFX_DIBBase : public Retainable {
RetainPtr<CFX_DIBitmap> CloneConvert(FXDIB_Format format);
RetainPtr<CFX_DIBitmap> StretchTo(int dest_width,
int dest_height,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
const FX_RECT* pClip);
RetainPtr<CFX_DIBitmap> TransformTo(const CFX_Matrix& mtDest,
int* left,
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index dcf5fdc7ab..011270494c 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -329,7 +329,8 @@ bool CFX_DIBitmap::LoadChannelFromAlpha(
if (pSrcClone->GetWidth() != m_Width ||
pSrcClone->GetHeight() != m_Height) {
if (pAlphaMask) {
- pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height, 0, nullptr);
+ pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height,
+ FXDIB_ResampleOptions(), nullptr);
if (!pAlphaMask)
return false;
}
@@ -338,8 +339,8 @@ bool CFX_DIBitmap::LoadChannelFromAlpha(
srcOffset = 0;
} else if (pSrcClone->GetWidth() != m_Width ||
pSrcClone->GetHeight() != m_Height) {
- RetainPtr<CFX_DIBitmap> pSrcMatched =
- pSrcClone->StretchTo(m_Width, m_Height, 0, nullptr);
+ RetainPtr<CFX_DIBitmap> pSrcMatched = pSrcClone->StretchTo(
+ m_Width, m_Height, FXDIB_ResampleOptions(), nullptr);
if (!pSrcMatched)
return false;
@@ -437,7 +438,8 @@ bool CFX_DIBitmap::MultiplyAlpha(const RetainPtr<CFX_DIBBase>& pSrcBitmap) {
RetainPtr<CFX_DIBitmap> pSrcClone = pSrcBitmap.As<CFX_DIBitmap>();
if (pSrcBitmap->GetWidth() != m_Width ||
pSrcBitmap->GetHeight() != m_Height) {
- pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height, 0, nullptr);
+ pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height,
+ FXDIB_ResampleOptions(), nullptr);
if (!pSrcClone)
return false;
}
diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp
index 6eadb05997..408bec1a09 100644
--- a/core/fxge/dib/cfx_imagerenderer.cpp
+++ b/core/fxge/dib/cfx_imagerenderer.cpp
@@ -20,7 +20,7 @@ CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr<CFX_DIBitmap>& pDevice,
int bitmap_alpha,
uint32_t mask_color,
const CFX_Matrix& matrix,
- uint32_t dib_flags,
+ const FXDIB_ResampleOptions& options,
bool bRgbByteOrder)
: m_pDevice(pDevice),
m_pClipRgn(pClipRgn),
@@ -50,15 +50,14 @@ CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr<CFX_DIBitmap>& pDevice,
true, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder,
0, BlendMode::kNormal);
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
- &m_Composer, pSource, dest_height, dest_width, bitmap_clip,
- dib_flags);
+ &m_Composer, pSource, dest_height, dest_width, bitmap_clip, options);
if (m_Stretcher->Start())
m_Status = 1;
return;
}
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- pSource, m_Matrix, dib_flags, &m_ClipBox);
+ pSource, m_Matrix, options, &m_ClipBox);
return;
}
@@ -80,7 +79,7 @@ CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr<CFX_DIBitmap>& pDevice,
BlendMode::kNormal);
m_Status = 1;
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
- &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags);
+ &m_Composer, pSource, dest_width, dest_height, bitmap_clip, options);
m_Stretcher->Start();
}
diff --git a/core/fxge/dib/cfx_imagerenderer.h b/core/fxge/dib/cfx_imagerenderer.h
index 01eec3a947..d97c01843f 100644
--- a/core/fxge/dib/cfx_imagerenderer.h
+++ b/core/fxge/dib/cfx_imagerenderer.h
@@ -28,7 +28,7 @@ class CFX_ImageRenderer {
int bitmap_alpha,
uint32_t mask_color,
const CFX_Matrix& matrix,
- uint32_t dib_flags,
+ const FXDIB_ResampleOptions& options,
bool bRgbByteOrder);
~CFX_ImageRenderer();
diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp
index 763c1db5d2..54d14f7d9d 100644
--- a/core/fxge/dib/cfx_imagestretcher.cpp
+++ b/core/fxge/dib/cfx_imagestretcher.cpp
@@ -48,10 +48,10 @@ CFX_ImageStretcher::CFX_ImageStretcher(ScanlineComposerIface* pDest,
int dest_width,
int dest_height,
const FX_RECT& bitmap_rect,
- uint32_t flags)
+ const FXDIB_ResampleOptions& options)
: m_pDest(pDest),
m_pSource(pSource),
- m_Flags(flags),
+ m_ResampleOptions(options),
m_bFlipX(false),
m_bFlipY(false),
m_DestWidth(dest_width),
@@ -119,14 +119,13 @@ bool CFX_ImageStretcher::Start() {
return false;
}
- if (m_Flags & FXDIB_DOWNSAMPLE)
+ if (m_ResampleOptions.bInterpolateDownsample)
return StartQuickStretch();
-
return StartStretch();
}
bool CFX_ImageStretcher::Continue(PauseIndicatorIface* pPause) {
- if (m_Flags & FXDIB_DOWNSAMPLE)
+ if (m_ResampleOptions.bInterpolateDownsample)
return ContinueQuickStretch(pPause);
return ContinueStretch(pPause);
}
@@ -138,7 +137,7 @@ RetainPtr<CFX_DIBBase> CFX_ImageStretcher::source() {
bool CFX_ImageStretcher::StartStretch() {
m_pStretchEngine = pdfium::MakeUnique<CStretchEngine>(
m_pDest.Get(), m_DestFormat, m_DestWidth, m_DestHeight, m_ClipRect,
- m_pSource, m_Flags);
+ m_pSource, m_ResampleOptions);
m_pStretchEngine->StartStretchHorz();
if (SourceSizeWithinLimit(m_pSource->GetWidth(), m_pSource->GetHeight())) {
m_pStretchEngine->Continue(nullptr);
diff --git a/core/fxge/dib/cfx_imagestretcher.h b/core/fxge/dib/cfx_imagestretcher.h
index 9f4e44b0d0..45544cbfbc 100644
--- a/core/fxge/dib/cfx_imagestretcher.h
+++ b/core/fxge/dib/cfx_imagestretcher.h
@@ -27,7 +27,7 @@ class CFX_ImageStretcher {
int dest_width,
int dest_height,
const FX_RECT& bitmap_rect,
- uint32_t flags);
+ const FXDIB_ResampleOptions& options);
~CFX_ImageStretcher();
bool Start();
@@ -46,7 +46,7 @@ class CFX_ImageStretcher {
std::unique_ptr<CStretchEngine> m_pStretchEngine;
std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline;
std::unique_ptr<uint8_t, FxFreeDeleter> m_pMaskScanline;
- const uint32_t m_Flags;
+ const FXDIB_ResampleOptions m_ResampleOptions;
bool m_bFlipX;
bool m_bFlipY;
int m_DestWidth;
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 29d22f4f77..9bbbaa644c 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -204,9 +204,9 @@ class CFX_BilinearMatrix final : public CPDF_FixedMatrix {
CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
const FX_RECT* pClip)
- : m_pSrc(pSrc), m_matrix(matrix), m_Flags(flags) {
+ : m_pSrc(pSrc), m_matrix(matrix), m_ResampleOptions(options) {
FX_RECT result_rect = m_matrix.GetUnitRect().GetClosestRect();
FX_RECT result_clip = result_rect;
if (pClip)
@@ -225,7 +225,8 @@ CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height,
m_matrix.c > 0, m_matrix.b < 0);
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
- &m_Storer, m_pSrc, dest_height, dest_width, result_clip, m_Flags);
+ &m_Storer, m_pSrc, dest_height, dest_width, result_clip,
+ m_ResampleOptions);
m_Stretcher->Start();
m_Status = 1;
return;
@@ -237,7 +238,8 @@ CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
: -floor(m_matrix.d));
result_clip.Offset(-result_rect.left, -result_rect.top);
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
- &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags);
+ &m_Storer, m_pSrc, dest_width, dest_height, result_clip,
+ m_ResampleOptions);
m_Stretcher->Start();
m_Status = 2;
return;
@@ -257,7 +259,8 @@ CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
m_dest2stretch.TransformRect(CFX_FloatRect(result_clip)).GetOuterRect();
m_StretchClip.Intersect(0, 0, stretch_width, stretch_height);
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
- &m_Storer, m_pSrc, stretch_width, stretch_height, m_StretchClip, m_Flags);
+ &m_Storer, m_pSrc, stretch_width, stretch_height, m_StretchClip,
+ m_ResampleOptions);
m_Stretcher->Start();
m_Status = 3;
}
@@ -463,6 +466,14 @@ void CFX_ImageTransformer::CalcColor(const CalcData& cdata,
}
}
+bool CFX_ImageTransformer::IsBilinear() const {
+ return !m_ResampleOptions.bInterpolateDownsample && !IsBiCubic();
+}
+
+bool CFX_ImageTransformer::IsBiCubic() const {
+ return m_ResampleOptions.bInterpolateBicubic;
+}
+
void CFX_ImageTransformer::AdjustCoords(int* col, int* row) const {
int& src_col = *col;
int& src_row = *row;
diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h
index 052df941d4..b0b854c333 100644
--- a/core/fxge/dib/cfx_imagetransformer.h
+++ b/core/fxge/dib/cfx_imagetransformer.h
@@ -23,7 +23,7 @@ class CFX_ImageTransformer {
public:
CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
const FX_RECT* pClip);
~CFX_ImageTransformer();
@@ -73,10 +73,8 @@ class CFX_ImageTransformer {
void CalcMono(const CalcData& cdata, FXDIB_Format format);
void CalcColor(const CalcData& cdata, FXDIB_Format format, int Bpp);
- bool IsBilinear() const {
- return !(m_Flags & FXDIB_DOWNSAMPLE) && !IsBiCubic();
- }
- bool IsBiCubic() const { return !!(m_Flags & FXDIB_BICUBIC_INTERPOL); }
+ bool IsBilinear() const;
+ bool IsBiCubic() const;
int stretch_width() const { return m_StretchClip.Width(); }
int stretch_height() const { return m_StretchClip.Height(); }
@@ -106,7 +104,7 @@ class CFX_ImageTransformer {
CFX_Matrix m_dest2stretch;
std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
CFX_BitmapStorer m_Storer;
- const uint32_t m_Flags;
+ const FXDIB_ResampleOptions m_ResampleOptions;
int m_Status = 0;
};
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index 969ab03667..7a582b537f 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -43,12 +43,12 @@ bool CStretchEngine::CWeightTable::Calc(int dest_len,
int src_len,
int src_min,
int src_max,
- int flags) {
+ const FXDIB_ResampleOptions& options) {
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 = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1;
+ const int ext_size = options.bInterpolateBicubic ? 3 : 1;
m_ItemSize =
sizeof(int) * 2 +
static_cast<int>(sizeof(int) *
@@ -60,11 +60,11 @@ bool CStretchEngine::CWeightTable::Calc(int dest_len,
m_dwWeightTablesSize = (dest_max - dest_min) * m_ItemSize + 4;
m_WeightTables.resize(m_dwWeightTablesSize);
- if ((flags & FXDIB_NOSMOOTH) != 0 || fabs(static_cast<float>(scale)) < 1.0f) {
+ if (options.bNoSmoothing || fabs(static_cast<float>(scale)) < 1.0f) {
for (int dest_pixel = dest_min; dest_pixel < dest_max; ++dest_pixel) {
PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel);
double src_pos = dest_pixel * scale + scale / 2 + base;
- if (flags & FXDIB_INTERPOL) {
+ if (options.bInterpolateBilinear) {
pixel_weights.m_SrcStart =
static_cast<int>(floor(static_cast<float>(src_pos) - 1.0f / 2));
pixel_weights.m_SrcEnd =
@@ -80,7 +80,7 @@ bool CStretchEngine::CWeightTable::Calc(int dest_len,
65536);
pixel_weights.m_Weights[0] = 65536 - pixel_weights.m_Weights[1];
}
- } else if (flags & FXDIB_BICUBIC_INTERPOL) {
+ } else if (options.bInterpolateBicubic) {
pixel_weights.m_SrcStart =
static_cast<int>(floor(static_cast<float>(src_pos) - 1.0f / 2));
pixel_weights.m_SrcEnd =
@@ -229,7 +229,7 @@ CStretchEngine::CStretchEngine(ScanlineComposerIface* pDestBitmap,
int dest_height,
const FX_RECT& clip_rect,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
- int flags)
+ const FXDIB_ResampleOptions& options)
: m_DestFormat(dest_format),
m_DestBpp(GetBppFromFormat(dest_format)),
m_SrcBpp(GetBppFromFormat(pSrcBitmap->GetFormat())),
@@ -256,18 +256,19 @@ CStretchEngine::CStretchEngine(ScanlineComposerIface* pDestBitmap,
std::fill(m_DestScanline.begin(), m_DestScanline.end(), 255);
m_InterPitch = GetPitchRoundUpTo4Bytes(m_DestClip.Width() * m_DestBpp);
m_ExtraMaskPitch = GetPitchRoundUpTo4Bytes(m_DestClip.Width() * 8);
- if ((flags & FXDIB_NOSMOOTH) == 0) {
- bool bInterpol = flags & FXDIB_INTERPOL || flags & FXDIB_BICUBIC_INTERPOL;
+ if (options.bNoSmoothing) {
+ m_ResampleOptions.bNoSmoothing = true;
+ m_ResampleOptions.bInterpolateDownsample = options.bInterpolateDownsample;
+ } else {
+ bool bInterpol =
+ options.bInterpolateBilinear || options.bInterpolateBicubic;
if (!bInterpol && abs(dest_width) != 0 &&
abs(dest_height) / 8 < static_cast<long long>(m_SrcWidth) *
m_SrcHeight / abs(dest_width)) {
- flags = FXDIB_INTERPOL;
+ m_ResampleOptions.bInterpolateBilinear = true;
+ } else {
+ m_ResampleOptions = options;
}
- m_Flags = flags;
- } else {
- m_Flags = FXDIB_NOSMOOTH;
- if (flags & FXDIB_DOWNSAMPLE)
- m_Flags |= FXDIB_DOWNSAMPLE;
}
double scale_x = static_cast<float>(m_SrcWidth) / m_DestWidth;
double scale_y = static_cast<float>(m_SrcHeight) / m_DestHeight;
@@ -336,9 +337,9 @@ bool CStretchEngine::StartStretchHorz() {
m_ExtraAlphaBuf.resize(m_SrcClip.Height(), m_ExtraMaskPitch);
m_DestMaskScanline.resize(m_ExtraMaskPitch);
}
- bool ret =
- m_WeightTable.Calc(m_DestWidth, m_DestClip.left, m_DestClip.right,
- m_SrcWidth, m_SrcClip.left, m_SrcClip.right, m_Flags);
+ bool ret = m_WeightTable.Calc(m_DestWidth, m_DestClip.left, m_DestClip.right,
+ m_SrcWidth, m_SrcClip.left, m_SrcClip.right,
+ m_ResampleOptions);
if (!ret)
return false;
@@ -390,7 +391,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
if (src_scan[j / 8] & (1 << (7 - j % 8)))
dest_a += pixel_weight * 255;
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL)
+ if (m_ResampleOptions.bInterpolateBicubic)
dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
*dest_scan++ = static_cast<uint8_t>(dest_a >> 16);
}
@@ -408,7 +409,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
int pixel_weight = *pWeight;
dest_a += pixel_weight * src_scan[j];
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL)
+ if (m_ResampleOptions.bInterpolateBicubic)
dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
*dest_scan++ = static_cast<uint8_t>(dest_a >> 16);
}
@@ -429,7 +430,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
dest_r += pixel_weight * src_scan[j];
dest_a += pixel_weight;
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_r = pdfium::clamp(dest_r, 0, kMaxDestValue);
dest_a = pdfium::clamp(dest_a, 0, 65536);
}
@@ -461,7 +462,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
dest_r_y += pixel_weight * static_cast<uint8_t>(argb_cmyk >> 8);
}
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_r_y = pdfium::clamp(dest_r_y, 0, kMaxDestValue);
dest_g_m = pdfium::clamp(dest_g_m, 0, kMaxDestValue);
dest_b_c = pdfium::clamp(dest_b_c, 0, kMaxDestValue);
@@ -498,7 +499,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
}
dest_a += pixel_weight;
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_b_c = pdfium::clamp(dest_b_c, 0, kMaxDestValue);
dest_g_m = pdfium::clamp(dest_g_m, 0, kMaxDestValue);
dest_r_y = pdfium::clamp(dest_r_y, 0, kMaxDestValue);
@@ -528,7 +529,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
dest_g_m += pixel_weight * (*src_pixel++);
dest_r_y += pixel_weight * (*src_pixel);
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_b_c = pdfium::clamp(dest_b_c, 0, kMaxDestValue);
dest_g_m = pdfium::clamp(dest_g_m, 0, kMaxDestValue);
dest_r_y = pdfium::clamp(dest_r_y, 0, kMaxDestValue);
@@ -564,7 +565,7 @@ bool CStretchEngine::ContinueStretchHorz(PauseIndicatorIface* pPause) {
dest_r_y += pixel_weight * (*src_pixel);
dest_a += pixel_weight;
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_r_y = pdfium::clamp(dest_r_y, 0, kMaxDestValue);
dest_g_m = pdfium::clamp(dest_g_m, 0, kMaxDestValue);
dest_b_c = pdfium::clamp(dest_b_c, 0, kMaxDestValue);
@@ -592,8 +593,9 @@ void CStretchEngine::StretchVert() {
return;
CWeightTable table;
- bool ret = table.Calc(m_DestHeight, m_DestClip.top, m_DestClip.bottom,
- m_SrcHeight, m_SrcClip.top, m_SrcClip.bottom, m_Flags);
+ bool ret =
+ table.Calc(m_DestHeight, m_DestClip.top, m_DestClip.bottom, m_SrcHeight,
+ m_SrcClip.top, m_SrcClip.bottom, m_ResampleOptions);
if (!ret)
return;
@@ -619,7 +621,7 @@ void CStretchEngine::StretchVert() {
dest_a +=
pixel_weight * src_scan[(j - m_SrcClip.top) * m_InterPitch];
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL)
+ if (m_ResampleOptions.bInterpolateBicubic)
dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
*dest_scan = static_cast<uint8_t>(dest_a >> 16);
dest_scan += DestBpp;
@@ -645,7 +647,7 @@ void CStretchEngine::StretchVert() {
dest_a += pixel_weight *
src_scan_mask[(j - m_SrcClip.top) * m_ExtraMaskPitch];
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_k = pdfium::clamp(dest_k, 0, kMaxDestValue);
dest_a = pdfium::clamp(dest_a, 0, kMaxDestValue);
}
@@ -675,7 +677,7 @@ void CStretchEngine::StretchVert() {
dest_g_m += pixel_weight * (*src_pixel++);
dest_r_y += pixel_weight * (*src_pixel);
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_r_y = pdfium::clamp(dest_r_y, 0, kMaxDestValue);
dest_g_m = pdfium::clamp(dest_g_m, 0, kMaxDestValue);
dest_b_c = pdfium::clamp(dest_b_c, 0, kMaxDestValue);
@@ -718,7 +720,7 @@ void CStretchEngine::StretchVert() {
else
dest_a += pixel_weight * mask_v;
}
- if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
+ if (m_ResampleOptions.bInterpolateBicubic) {
dest_r_y = pdfium::clamp(dest_r_y, 0, kMaxDestValue);
dest_g_m = pdfium::clamp(dest_g_m, 0, kMaxDestValue);
dest_b_c = pdfium::clamp(dest_b_c, 0, kMaxDestValue);
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 6bb07c662c..c2aaca687f 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -26,7 +26,7 @@ class CStretchEngine {
int dest_height,
const FX_RECT& clip_rect,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
- int flags);
+ const FXDIB_ResampleOptions& options);
~CStretchEngine();
bool Continue(PauseIndicatorIface* pPause);
@@ -46,7 +46,7 @@ class CStretchEngine {
int src_len,
int src_min,
int src_max,
- int flags);
+ const FXDIB_ResampleOptions& options);
const PixelWeight* GetPixelWeight(int pixel) const;
PixelWeight* GetPixelWeight(int pixel) {
@@ -96,7 +96,7 @@ class CStretchEngine {
FX_RECT m_SrcClip;
int m_InterPitch;
int m_ExtraMaskPitch;
- int m_Flags;
+ FXDIB_ResampleOptions m_ResampleOptions;
TransformMethod m_TransMethod;
State m_State = State::kInitial;
int m_CurRow;
diff --git a/core/fxge/dib/cstretchengine_unittest.cpp b/core/fxge/dib/cstretchengine_unittest.cpp
index 8169cae328..a79945c67d 100644
--- a/core/fxge/dib/cstretchengine_unittest.cpp
+++ b/core/fxge/dib/cstretchengine_unittest.cpp
@@ -27,6 +27,11 @@ TEST(CStretchEngine, OverflowInCtor) {
auto dib_source = pdfium::MakeRetain<CPDF_DIBBase>();
dib_source->Load(nullptr, stream.get());
CStretchEngine engine(nullptr, FXDIB_8bppRgb, 500, 500, clip_rect, dib_source,
- 0);
- EXPECT_EQ(FXDIB_INTERPOL, engine.m_Flags);
+ FXDIB_ResampleOptions());
+ EXPECT_FALSE(engine.m_ResampleOptions.bInterpolateDownsample);
+ 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_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index 8df1322e97..dfdf7ec909 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -54,6 +54,29 @@ const int16_t SDP_Table[513] = {
0, 0, 0,
};
+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 221a05278f..8cb7040f5a 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -46,10 +46,28 @@ using FX_CMYK = uint32_t;
extern const int16_t SDP_Table[513];
-#define FXDIB_DOWNSAMPLE 0x04
-#define FXDIB_INTERPOL 0x20
-#define FXDIB_BICUBIC_INTERPOL 0x80
-#define FXDIB_NOSMOOTH 0x100
+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;
+
+ bool bInterpolateDownsample = false;
+ bool bInterpolateBilinear = false;
+ bool bInterpolateBicubic = false;
+ bool bHalftone = false;
+ bool bNoSmoothing = false;
+ 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.
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index 8513f31428..5282cbe28b 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -77,13 +77,13 @@ class RenderDeviceDriverIface {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) = 0;
virtual bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) = 0;
virtual bool ContinueDIBits(CFX_ImageRenderer* handle,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 1cda61f4fe..fd3010af8c 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2250,7 +2250,8 @@ bool CFX_SkiaDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
CFX_Matrix m = CFX_RenderDevice::GetFlipMatrix(
pBitmap->GetWidth(), pBitmap->GetHeight(), left, top);
std::unique_ptr<CFX_ImageRenderer> dummy;
- return StartDIBits(pBitmap, 0xFF, argb, m, 0, &dummy, blend_type);
+ return StartDIBits(pBitmap, 0xFF, argb, m, FXDIB_ResampleOptions(), &dummy,
+ blend_type);
#endif // _SKIA_SUPPORT_
#ifdef _SKIA_SUPPORT_PATHS_
@@ -2274,7 +2275,7 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) {
#ifdef _SKIA_SUPPORT_
m_pCache->FlushForDraw();
@@ -2288,7 +2289,8 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
pClipRect->right, pClipRect->top);
m_pCanvas->clipRect(skClipRect, SkClipOp::kIntersect, true);
std::unique_ptr<CFX_ImageRenderer> dummy;
- bool result = StartDIBits(pSource, 0xFF, argb, m, 0, &dummy, blend_type);
+ bool result = StartDIBits(pSource, 0xFF, argb, m, FXDIB_ResampleOptions(),
+ &dummy, blend_type);
m_pCanvas->restore();
return result;
@@ -2311,7 +2313,7 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
false, false, m_bRgbByteOrder, 0, blend_type);
dest_clip.Offset(-dest_rect.left, -dest_rect.top);
CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height,
- dest_clip, flags);
+ dest_clip, options);
if (stretcher.Start())
stretcher.Continue(nullptr);
return true;
@@ -2323,7 +2325,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits(
int bitmap_alpha,
uint32_t argb,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) {
#ifdef _SKIA_SUPPORT_
@@ -2371,8 +2373,8 @@ bool CFX_SkiaDeviceDriver::StartDIBits(
return true;
m_pBitmap->UnPreMultiply();
*handle = pdfium::MakeUnique<CFX_ImageRenderer>(
- m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, matrix,
- render_flags, m_bRgbByteOrder);
+ m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, matrix, options,
+ m_bRgbByteOrder);
#endif // _SKIA_SUPPORT_PATHS_
return true;
}
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index ea3477882d..968e8c09aa 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -110,14 +110,14 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) override;
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 9f5a7cd139..13c1abacb1 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -25,6 +25,7 @@
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/cfx_dibextractor.h"
#include "core/fxge/dib/cfx_dibitmap.h"
+#include "core/fxge/fx_dib.h"
#include "core/fxge/win32/cpsoutput.h"
#include "third_party/base/ptr_util.h"
@@ -348,7 +349,7 @@ bool CFX_PSRenderer::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
StartRendering();
CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(
pSource->GetWidth(), pSource->GetHeight(), left, top);
- return DrawDIBits(pSource, color, matrix, 0);
+ return DrawDIBits(pSource, color, matrix, FXDIB_ResampleOptions());
}
bool CFX_PSRenderer::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
@@ -357,17 +358,17 @@ bool CFX_PSRenderer::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
int dest_top,
int dest_width,
int dest_height,
- uint32_t flags) {
+ const FXDIB_ResampleOptions& options) {
StartRendering();
CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(dest_width, dest_height,
dest_left, dest_top);
- return DrawDIBits(pSource, color, matrix, flags);
+ return DrawDIBits(pSource, color, matrix, options);
}
bool CFX_PSRenderer::DrawDIBits(const RetainPtr<CFX_DIBBase>& pSource,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags) {
+ const FXDIB_ResampleOptions& options) {
StartRendering();
if ((matrix.a == 0 && matrix.b == 0) || (matrix.c == 0 && matrix.d == 0))
return true;
@@ -459,7 +460,7 @@ bool CFX_PSRenderer::DrawDIBits(const RetainPtr<CFX_DIBBase>& pSource,
uint8_t* output_buf = nullptr;
size_t output_size = 0;
const char* filter = nullptr;
- if ((m_PSLevel == 2 || flags & FXRENDER_IMAGE_LOSSY) &&
+ if ((m_PSLevel == 2 || options.bLossy) &&
CCodec_JpegModule::JpegEncode(pConverted, &output_buf, &output_size)) {
filter = "/DCTDecode filter ";
}
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h
index b5107d9ab1..9b1d86b8fc 100644
--- a/core/fxge/win32/cfx_psrenderer.h
+++ b/core/fxge/win32/cfx_psrenderer.h
@@ -24,6 +24,7 @@ class CFX_Matrix;
class CFX_PathData;
class CPSFont;
class FXTEXT_CHARPOS;
+struct FXDIB_ResampleOptions;
class CFX_PSRenderer {
public:
@@ -62,11 +63,11 @@ class CFX_PSRenderer {
int dest_top,
int dest_width,
int dest_height,
- uint32_t flags);
+ const FXDIB_ResampleOptions& options);
bool DrawDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t flags);
+ const FXDIB_ResampleOptions& options);
bool DrawText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index a4452e7faa..4f2abae882 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -812,7 +812,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits(
int dest_top,
int dest_width,
int dest_height,
- uint32_t flags) {
+ const FXDIB_ResampleOptions& options) {
RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1;
if (!pBitmap || dest_width == 0 || dest_height == 0)
return false;
@@ -823,7 +823,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits(
ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
if ((int64_t)abs(dest_width) * abs(dest_height) <
(int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 ||
- (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) {
+ options.bInterpolateBilinear || options.bInterpolateBicubic) {
SetStretchBltMode(m_hDC, HALFTONE);
} else {
SetStretchBltMode(m_hDC, COLORONCOLOR);
@@ -832,7 +832,8 @@ bool CGdiDeviceDriver::GDI_StretchDIBits(
if (m_DeviceClass == FXDC_PRINTER &&
((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() >
(int64_t)abs(dest_width) * abs(dest_height))) {
- pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height, 0, nullptr);
+ pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height,
+ FXDIB_ResampleOptions(), nullptr);
}
ByteString toStrechBitmapInfo =
CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap);
@@ -1209,8 +1210,8 @@ bool CGdiDisplayDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
FX_RECT clip_rect(left, top, left + src_rect.Width(),
top + src_rect.Height());
return StretchDIBits(pSource, color, left - src_rect.left,
- top - src_rect.top, width, height, &clip_rect, 0,
- BlendMode::kNormal);
+ top - src_rect.top, width, height, &clip_rect,
+ FXDIB_ResampleOptions(), BlendMode::kNormal);
}
int width = src_rect.Width();
int height = src_rect.Height();
@@ -1241,7 +1242,7 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine(
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- int render_flags) {
+ const FXDIB_ResampleOptions& options) {
FX_RECT bitmap_clip = *pClipRect;
if (dest_width < 0)
dest_left += dest_width;
@@ -1251,7 +1252,7 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine(
bitmap_clip.Offset(-dest_left, -dest_top);
RetainPtr<CFX_DIBitmap> pStretched =
- pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip);
+ pSource->StretchTo(dest_width, dest_height, options, &bitmap_clip);
if (!pStretched)
return true;
@@ -1267,13 +1268,13 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) {
ASSERT(pSource && pClipRect);
- if (flags || dest_width > 10000 || dest_width < -10000 ||
+ if (options.HasAnyOptions() || dest_width > 10000 || dest_width < -10000 ||
dest_height > 10000 || dest_height < -10000) {
return UseFoxitStretchEngine(pSource, color, dest_left, dest_top,
- dest_width, dest_height, pClipRect, flags);
+ dest_width, dest_height, pClipRect, options);
}
if (pSource->IsAlphaMask()) {
FX_RECT image_rect;
@@ -1285,8 +1286,8 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
clip_rect.Intersect(*pClipRect);
clip_rect.Offset(-image_rect.left, -image_rect.top);
int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
- RetainPtr<CFX_DIBitmap> pStretched(
- pSource->StretchTo(dest_width, dest_height, 0, &clip_rect));
+ RetainPtr<CFX_DIBitmap> pStretched(pSource->StretchTo(
+ dest_width, dest_height, FXDIB_ResampleOptions(), &clip_rect));
if (!pStretched)
return true;
@@ -1312,26 +1313,27 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap();
if (!pBitmap)
return false;
- return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_left,
- dest_top, dest_width,
- dest_height, pClipRect, 0);
+ return pPlatform->m_GdiplusExt.StretchDIBits(
+ m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height,
+ pClipRect, FXDIB_ResampleOptions());
}
return UseFoxitStretchEngine(pSource, color, dest_left, dest_top,
- dest_width, dest_height, pClipRect, 0);
+ dest_width, dest_height, pClipRect,
+ FXDIB_ResampleOptions());
}
CFX_DIBExtractor temp(pSource);
RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap();
if (!pBitmap)
return false;
return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
- dest_height, 0);
+ dest_height, FXDIB_ResampleOptions());
}
bool CGdiDisplayDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) {
return false;
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index f93ce8f9ad..8e80b50fbc 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -778,12 +778,12 @@ bool CGdiplusExt::StretchDIBits(HDC hDC,
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- int flags) {
+ const FXDIB_ResampleOptions& options) {
Gdiplus::GpGraphics* pGraphics;
const CGdiplusExt& GdiplusExt = GetGdiplusExt();
CallFunc(GdipCreateFromHDC)(hDC, &pGraphics);
CallFunc(GdipSetPageUnit)(pGraphics, Gdiplus::UnitPixel);
- if (flags & FXDIB_NOSMOOTH) {
+ if (options.bNoSmoothing) {
CallFunc(GdipSetInterpolationMode)(
pGraphics, Gdiplus::InterpolationModeNearestNeighbor);
} else if (pBitmap->GetWidth() > abs(dest_width) / 2 ||
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index 2f99f88e68..f2d3a9c482 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -80,8 +80,8 @@ bool CGdiPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
top + src_rect.Height());
return StretchDIBits(pSource, color, left - src_rect.left,
top - src_rect.top, pSource->GetWidth(),
- pSource->GetHeight(), &clip_rect, 0,
- BlendMode::kNormal);
+ pSource->GetHeight(), &clip_rect,
+ FXDIB_ResampleOptions(), BlendMode::kNormal);
}
ASSERT(pSource && !pSource->IsAlphaMask());
ASSERT(blend_type == BlendMode::kNormal);
@@ -103,7 +103,7 @@ bool CGdiPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) {
if (pSource->IsAlphaMask()) {
int alpha = FXARGB_A(color);
@@ -148,7 +148,7 @@ bool CGdiPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
dest_top += dest_height;
return GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest_width),
- abs(dest_height), flags);
+ abs(dest_height), options);
}
CFX_DIBExtractor temp(pSource);
@@ -156,14 +156,14 @@ bool CGdiPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
if (!pBitmap)
return false;
return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
- dest_height, flags);
+ dest_height, options);
}
bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) {
if (bitmap_alpha < 255 || pSource->HasAlpha() ||
@@ -181,7 +181,7 @@ bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource,
bFlipY ? full_rect.bottom : full_rect.top,
bFlipX ? -full_rect.Width() : full_rect.Width(),
bFlipY ? -full_rect.Height() : full_rect.Height(),
- nullptr, 0, blend_type);
+ nullptr, FXDIB_ResampleOptions(), blend_type);
}
if (fabs(matrix.a) >= 0.5f || fabs(matrix.d) >= 0.5f)
return false;
@@ -192,8 +192,8 @@ bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource,
return false;
return StretchDIBits(pTransformed, color, full_rect.left, full_rect.top,
- full_rect.Width(), full_rect.Height(), nullptr, 0,
- blend_type);
+ full_rect.Width(), full_rect.Height(), nullptr,
+ FXDIB_ResampleOptions(), blend_type);
}
bool CGdiPrinterDriver::DrawDeviceText(int nChars,
@@ -472,19 +472,19 @@ bool CPSPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) {
if (blend_type != BlendMode::kNormal)
return false;
return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top,
- dest_width, dest_height, flags);
+ dest_width, dest_height, options);
}
bool CPSPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) {
if (blend_type != BlendMode::kNormal)
@@ -494,7 +494,7 @@ bool CPSPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
return false;
*handle = nullptr;
- return m_PSRenderer.DrawDIBits(pBitmap, color, matrix, render_flags);
+ return m_PSRenderer.DrawDIBits(pBitmap, color, matrix, options);
}
bool CPSPrinterDriver::DrawDeviceText(int nChars,
@@ -590,7 +590,7 @@ bool CTextOnlyPrinterDriver::StretchDIBits(
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) {
return false;
}
@@ -600,7 +600,7 @@ bool CTextOnlyPrinterDriver::StartDIBits(
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) {
return false;
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index db0e3894c5..44c3c8beae 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -40,7 +40,7 @@ class CGdiplusExt {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- int flags);
+ const FXDIB_ResampleOptions& options);
bool DrawPath(HDC hDC,
const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
@@ -106,7 +106,7 @@ class CGdiDeviceDriver : public RenderDeviceDriverIface {
int dest_top,
int dest_width,
int dest_height,
- uint32_t flags);
+ const FXDIB_ResampleOptions& options);
bool GDI_StretchBitMask(const RetainPtr<CFX_DIBitmap>& pBitmap,
int dest_left,
int dest_top,
@@ -145,13 +145,13 @@ class CGdiDisplayDriver final : public CGdiDeviceDriver {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) override;
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
bool UseFoxitStretchEngine(const RetainPtr<CFX_DIBBase>& pSource,
@@ -161,7 +161,7 @@ class CGdiDisplayDriver final : public CGdiDeviceDriver {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- int render_flags);
+ const FXDIB_ResampleOptions& options);
};
class CGdiPrinterDriver final : public CGdiDeviceDriver {
@@ -184,13 +184,13 @@ class CGdiPrinterDriver final : public CGdiDeviceDriver {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) override;
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
bool DrawDeviceText(int nChars,
@@ -243,13 +243,13 @@ class CPSPrinterDriver final : public RenderDeviceDriverIface {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) override;
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
bool DrawDeviceText(int nChars,
@@ -306,13 +306,13 @@ class CTextOnlyPrinterDriver final : public RenderDeviceDriverIface {
int dest_width,
int dest_height,
const FX_RECT* pClipRect,
- uint32_t flags,
+ const FXDIB_ResampleOptions& options,
BlendMode blend_type) override;
bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix& matrix,
- uint32_t render_flags,
+ const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
bool DrawDeviceText(int nChars,
diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp
index 164d056f00..6baa2eb418 100644
--- a/xfa/fxfa/cxfa_imagerenderer.cpp
+++ b/xfa/fxfa/cxfa_imagerenderer.cpp
@@ -22,7 +22,7 @@ CXFA_ImageRenderer::~CXFA_ImageRenderer() {}
bool CXFA_ImageRenderer::Start() {
if (m_pDevice->StartDIBitsWithBlend(m_pDIBBase, 255, 0, m_ImageMatrix,
- FXDIB_INTERPOL, &m_DeviceHandle,
+ kBilinearInterpolation, &m_DeviceHandle,
BlendMode::kNormal)) {
if (m_DeviceHandle) {
m_Status = 3;
@@ -50,7 +50,7 @@ bool CXFA_ImageRenderer::Start() {
clip_box.Intersect(image_rect);
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- pDib, m_ImageMatrix, FXDIB_INTERPOL, &clip_box);
+ pDib, m_ImageMatrix, kBilinearInterpolation, &clip_box);
return true;
}
if (m_ImageMatrix.a < 0)
@@ -63,14 +63,14 @@ bool CXFA_ImageRenderer::Start() {
if (m_pDIBBase->IsOpaqueImage()) {
if (m_pDevice->StretchDIBitsWithFlagsAndBlend(
m_pDIBBase, dest_left, dest_top, dest_width, dest_height,
- FXDIB_INTERPOL, BlendMode::kNormal)) {
+ kBilinearInterpolation, BlendMode::kNormal)) {
return false;
}
}
if (m_pDIBBase->IsAlphaMask()) {
if (m_pDevice->StretchBitMaskWithFlags(m_pDIBBase, dest_left, dest_top,
dest_width, dest_height, 0,
- FXDIB_INTERPOL)) {
+ kBilinearInterpolation)) {
return false;
}
}
@@ -82,7 +82,7 @@ bool CXFA_ImageRenderer::Start() {
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, FXDIB_INTERPOL, &dest_clip);
+ dest_width, dest_height, kBilinearInterpolation, &dest_clip);
if (pStretched)
CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top);