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/skia/fx_skia_device.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'core/fxge/skia/fx_skia_device.cpp') 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& pBitmap, CFX_Matrix m = CFX_RenderDevice::GetFlipMatrix( pBitmap->GetWidth(), pBitmap->GetHeight(), left, top); std::unique_ptr 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& 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& pSource, pClipRect->right, pClipRect->top); m_pCanvas->clipRect(skClipRect, SkClipOp::kIntersect, true); std::unique_ptr 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& 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* handle, BlendMode blend_type) { #ifdef _SKIA_SUPPORT_ @@ -2371,8 +2373,8 @@ bool CFX_SkiaDeviceDriver::StartDIBits( return true; m_pBitmap->UnPreMultiply(); *handle = pdfium::MakeUnique( - 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; } -- cgit v1.2.3