diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-26 22:52:48 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-26 22:52:48 +0000 |
commit | 5883300439287ab46559231ce8aed11e92bbc97c (patch) | |
tree | 2c3499da9df5a2c4e2fb9d13f99bde13b7bebb42 /core/fxge/skia | |
parent | 9590dee526c514d87dc1f47569d1136ffcf539ad (diff) | |
download | pdfium-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>
Diffstat (limited to 'core/fxge/skia')
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 16 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.h | 4 |
2 files changed, 11 insertions, 9 deletions
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; |