From caf6d61fbb38083f213a9d3441e12c5082d3ad3a Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Thu, 29 Jun 2017 17:02:48 -0400 Subject: Move Start to constructor in CFX_Image(Renderer|Transformer) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bool returned by Start was not being used and the method was always called right after the constructor, so it should be in the constructor. Change-Id: I98abf9f7c11fbe42b3aa15ec5e46731198aa23d5 Reviewed-on: https://pdfium-review.googlesource.com/7151 Commit-Queue: Nicolás Peña Reviewed-by: Lei Zhang --- core/fxge/dib/cfx_imagetransformer.cpp | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'core/fxge/dib/cfx_imagetransformer.cpp') diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index 2fb21e4c33..7a097ced12 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -186,19 +186,14 @@ CFX_ImageTransformer::CFX_ImageTransformer( m_pMatrix(pMatrix), m_pClip(pClip), m_Flags(flags), - m_Status(0) {} - -CFX_ImageTransformer::~CFX_ImageTransformer() {} - -bool CFX_ImageTransformer::Start() { - CFX_FloatRect unit_rect = m_pMatrix->GetUnitRect(); - FX_RECT result_rect = unit_rect.GetClosestRect(); + m_Status(0) { + FX_RECT result_rect = m_pMatrix->GetUnitRect().GetClosestRect(); FX_RECT result_clip = result_rect; if (m_pClip) result_clip.Intersect(*m_pClip); if (result_clip.IsEmpty()) - return false; + return; m_result = result_clip; if (fabs(m_pMatrix->a) < fabs(m_pMatrix->b) / 20 && @@ -213,29 +208,29 @@ bool CFX_ImageTransformer::Start() { &m_Storer, m_pSrc, dest_height, dest_width, result_clip, m_Flags); m_Stretcher->Start(); m_Status = 1; - return true; + return; } if (fabs(m_pMatrix->b) < FIX16_005 && fabs(m_pMatrix->c) < FIX16_005) { - int dest_width = - m_pMatrix->a > 0 ? (int)ceil(m_pMatrix->a) : (int)floor(m_pMatrix->a); - int dest_height = - m_pMatrix->d > 0 ? (int)-ceil(m_pMatrix->d) : (int)-floor(m_pMatrix->d); + int dest_width = static_cast(m_pMatrix->a > 0 ? ceil(m_pMatrix->a) + : floor(m_pMatrix->a)); + int dest_height = static_cast(m_pMatrix->d > 0 ? -ceil(m_pMatrix->d) + : -floor(m_pMatrix->d)); result_clip.Offset(-result_rect.left, -result_rect.top); m_Stretcher = pdfium::MakeUnique( &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags); m_Stretcher->Start(); m_Status = 2; - return true; + return; } - int stretch_width = (int)ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b)); - int stretch_height = (int)ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d)); - CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, - (float)(stretch_height)); + int stretch_width = + static_cast(ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b))); + int stretch_height = + static_cast(ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d))); + CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, stretch_height); stretch2dest.Concat( CFX_Matrix(m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width, m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height, m_pMatrix->e, m_pMatrix->f)); - ASSERT(m_dest2stretch.IsIdentity()); m_dest2stretch = stretch2dest.GetInverse(); CFX_FloatRect clip_rect_f(result_clip); @@ -246,9 +241,10 @@ bool CFX_ImageTransformer::Start() { &m_Storer, m_pSrc, stretch_width, stretch_height, m_StretchClip, m_Flags); m_Stretcher->Start(); m_Status = 3; - return true; } +CFX_ImageTransformer::~CFX_ImageTransformer() {} + bool CFX_ImageTransformer::Continue(IFX_Pause* pPause) { if (m_Status == 1) { if (m_Stretcher->Continue(pPause)) -- cgit v1.2.3