From f22d4206c768856efdfbf0ec38af4386a706de3a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 17 Jan 2018 15:13:38 +0000 Subject: Fold CXFA_ImageRenderer::Start into constructor This CL moves the code to initialize the variables into the constructor and changes the Start command into the StartDIB command. Change-Id: Iba3c1dcd9a872b4e2a1eadf87050f39c73b8e704 Reviewed-on: https://pdfium-review.googlesource.com/23050 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffwidget.cpp | 6 +++--- xfa/fxfa/cxfa_imagerenderer.cpp | 39 +++++++++++++++++---------------------- xfa/fxfa/cxfa_imagerenderer.h | 22 ++++++++++------------ 3 files changed, 30 insertions(+), 37 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 6aa6fd61b8..def2ee3139 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -1091,9 +1091,9 @@ void XFA_DrawImage(CXFA_Graphics* pGS, CFX_Matrix(rtFit.width, 0, 0, rtFit.height, rtFit.left, rtFit.top)); mtImage.Concat(matrix); - CXFA_ImageRenderer imageRender; - if (!imageRender.Start(pRenderDevice, pDIBitmap, 0, 255, &mtImage, - FXDIB_INTERPOL)) { + CXFA_ImageRenderer imageRender(pRenderDevice, pDIBitmap, 0, 255, &mtImage, + FXDIB_INTERPOL); + if (!imageRender.Start()) { return; } while (imageRender.Continue()) diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp index 14f8b25af1..7423037cb5 100644 --- a/xfa/fxfa/cxfa_imagerenderer.cpp +++ b/xfa/fxfa/cxfa_imagerenderer.cpp @@ -13,28 +13,23 @@ #include "core/fxge/dib/cfx_imagetransformer.h" #include "third_party/base/ptr_util.h" -CXFA_ImageRenderer::CXFA_ImageRenderer() : m_pDevice(nullptr) {} +CXFA_ImageRenderer::CXFA_ImageRenderer( + CFX_RenderDevice* pDevice, + const RetainPtr& pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + uint32_t flags) + : m_pDevice(pDevice), + m_ImageMatrix(*pImage2Device), + m_pDIBSource(pDIBSource), + m_BitmapAlpha(bitmap_alpha), + m_FillArgb(bitmap_argb), + m_Flags(flags) {} CXFA_ImageRenderer::~CXFA_ImageRenderer() {} -bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, - const RetainPtr& pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - uint32_t flags, - int blendType) { - m_pDevice = pDevice; - m_pDIBSource = pDIBSource; - m_FillArgb = bitmap_argb; - m_BitmapAlpha = bitmap_alpha; - m_ImageMatrix = *pImage2Device; - m_Flags = flags; - m_BlendType = blendType; - return StartDIBSource(); -} - -bool CXFA_ImageRenderer::StartDIBSource() { +bool CXFA_ImageRenderer::Start() { if (m_pDevice->StartDIBitsWithBlend(m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, &m_DeviceHandle, m_BlendType)) { @@ -228,9 +223,9 @@ void CXFA_ImageRenderer::CompositeDIBitmap( if (!pCloneConvert) return; - CXFA_ImageRenderer imageRender; - if (!imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb, m_BitmapAlpha, - &m_ImageMatrix, m_Flags)) { + CXFA_ImageRenderer imageRender(m_pDevice, pCloneConvert, m_FillArgb, + m_BitmapAlpha, &m_ImageMatrix, m_Flags); + if (!imageRender.Start()) { return; } while (imageRender.Continue()) diff --git a/xfa/fxfa/cxfa_imagerenderer.h b/xfa/fxfa/cxfa_imagerenderer.h index ca53bf639e..6a165b53e4 100644 --- a/xfa/fxfa/cxfa_imagerenderer.h +++ b/xfa/fxfa/cxfa_imagerenderer.h @@ -21,20 +21,18 @@ class CFX_ImageRenderer; class CXFA_ImageRenderer { public: - CXFA_ImageRenderer(); + CXFA_ImageRenderer(CFX_RenderDevice* pDevice, + const RetainPtr& pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + uint32_t flags); ~CXFA_ImageRenderer(); - bool Start(CFX_RenderDevice* pDevice, - const RetainPtr& pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - uint32_t flags, - int blendType = FXDIB_BLEND_NORMAL); + bool Start(); bool Continue(); protected: - bool StartDIBSource(); void CompositeDIBitmap(const RetainPtr& pDIBitmap, int left, int top, @@ -48,9 +46,9 @@ class CXFA_ImageRenderer { CFX_Matrix m_ImageMatrix; RetainPtr m_pDIBSource; RetainPtr m_pCloneConvert; - int m_BitmapAlpha = 255; - FX_ARGB m_FillArgb = 0; - uint32_t m_Flags = 0; + int m_BitmapAlpha; + FX_ARGB m_FillArgb; + uint32_t m_Flags; std::unique_ptr m_pTransformer; std::unique_ptr m_DeviceHandle; int32_t m_BlendType = FXDIB_BLEND_NORMAL; -- cgit v1.2.3