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/fx_dib.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'core/fxge/fx_dib.h') 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. -- cgit v1.2.3