From 5883300439287ab46559231ce8aed11e92bbc97c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 26 Oct 2018 22:52:48 +0000 Subject: 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 Reviewed-by: Tom Sepez --- core/fxge/dib/cfx_imagestretcher.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/fxge/dib/cfx_imagestretcher.cpp') 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_ImageStretcher::source() { bool CFX_ImageStretcher::StartStretch() { m_pStretchEngine = pdfium::MakeUnique( 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); -- cgit v1.2.3