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/fx_dib_main.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'core/fxge/dib/fx_dib_main.cpp') 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, -- cgit v1.2.3