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/win32/cfx_psrenderer.cpp | |
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/win32/cfx_psrenderer.cpp')
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 9f5a7cd139..13c1abacb1 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -25,6 +25,7 @@ #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/dib/cfx_dibextractor.h" #include "core/fxge/dib/cfx_dibitmap.h" +#include "core/fxge/fx_dib.h" #include "core/fxge/win32/cpsoutput.h" #include "third_party/base/ptr_util.h" @@ -348,7 +349,7 @@ bool CFX_PSRenderer::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource, StartRendering(); CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix( pSource->GetWidth(), pSource->GetHeight(), left, top); - return DrawDIBits(pSource, color, matrix, 0); + return DrawDIBits(pSource, color, matrix, FXDIB_ResampleOptions()); } bool CFX_PSRenderer::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, @@ -357,17 +358,17 @@ bool CFX_PSRenderer::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, int dest_top, int dest_width, int dest_height, - uint32_t flags) { + const FXDIB_ResampleOptions& options) { StartRendering(); CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(dest_width, dest_height, dest_left, dest_top); - return DrawDIBits(pSource, color, matrix, flags); + return DrawDIBits(pSource, color, matrix, options); } bool CFX_PSRenderer::DrawDIBits(const RetainPtr<CFX_DIBBase>& pSource, uint32_t color, const CFX_Matrix& matrix, - uint32_t flags) { + const FXDIB_ResampleOptions& options) { StartRendering(); if ((matrix.a == 0 && matrix.b == 0) || (matrix.c == 0 && matrix.d == 0)) return true; @@ -459,7 +460,7 @@ bool CFX_PSRenderer::DrawDIBits(const RetainPtr<CFX_DIBBase>& pSource, uint8_t* output_buf = nullptr; size_t output_size = 0; const char* filter = nullptr; - if ((m_PSLevel == 2 || flags & FXRENDER_IMAGE_LOSSY) && + if ((m_PSLevel == 2 || options.bLossy) && CCodec_JpegModule::JpegEncode(pConverted, &output_buf, &output_size)) { filter = "/DCTDecode filter "; } |