diff options
author | Jane Liu <janeliulwq@google.com> | 2017-08-22 10:50:06 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-22 16:42:55 +0000 |
commit | 878b27de2fa8e5bdc3b910c98846f4b43185d4aa (patch) | |
tree | f21a9528354ebf533a637f5ea0e8edaa44be7427 /core/fpdfapi/render | |
parent | aac59a0e59052366e260396165a759b5b0e80188 (diff) | |
download | pdfium-878b27de2fa8e5bdc3b910c98846f4b43185d4aa.tar.xz |
Converted CFX_Matrix::TransformRect() to take in consts
Currently, all three of CFX_Matrix::TransformRect() take in rect values
and modify them in place.
This CL converts them to take in constant values and return the
transformed values instead, and fixes all the call sites.
Bug=pdfium:874
Change-Id: I9c274df3b14e9d88c100ba0530068e06e8fec32b
Reviewed-on: https://pdfium-review.googlesource.com/11550
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Jane Liu <janeliulwq@google.com>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r-- | core/fpdfapi/render/cpdf_devicebuffer.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_progressiverenderer.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 32 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp | 5 |
4 files changed, 19 insertions, 28 deletions
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp index 8125ea5df1..b632dee49d 100644 --- a/core/fpdfapi/render/cpdf_devicebuffer.cpp +++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp @@ -45,10 +45,8 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Matrix ctm = m_pDevice->GetCTM(); m_Matrix.Concat(CFX_Matrix(fabs(ctm.a), 0, 0, fabs(ctm.d), 0, 0)); - CFX_FloatRect rect(*pRect); - m_Matrix.TransformRect(rect); - - FX_RECT bitmap_rect = rect.GetOuterRect(); + FX_RECT bitmap_rect = + m_Matrix.TransformRect(CFX_FloatRect(*pRect)).GetOuterRect(); m_pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); return true; diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp index c61902cda7..3c6be3ba34 100644 --- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp +++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp @@ -59,8 +59,8 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { m_pOptions, m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr); m_pDevice->SaveState(); - m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); - m_pCurrentLayer->m_Matrix.GetInverse().TransformRect(m_ClipRect); + m_ClipRect = m_pCurrentLayer->m_Matrix.GetInverse().TransformRect( + CFX_FloatRect(m_pDevice->GetClipBox())); } CPDF_PageObjectList::iterator iter; CPDF_PageObjectList::iterator iterEnd = diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 439ad4e5f0..01deab0bea 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -925,9 +925,9 @@ CFX_RetainPtr<CFX_DIBitmap> DrawPatternBitmap(CPDF_Document* pDoc, CFX_DefaultRenderDevice bitmap_device; bitmap_device.Attach(pBitmap, false, nullptr, false); pBitmap->Clear(0); - CFX_FloatRect cell_bbox = pPattern->bbox(); - pPattern->pattern_to_form()->TransformRect(cell_bbox); - pObject2Device->TransformRect(cell_bbox); + CFX_FloatRect cell_bbox = + pPattern->pattern_to_form()->TransformRect(pPattern->bbox()); + cell_bbox = pObject2Device->TransformRect(cell_bbox); CFX_FloatRect bitmap_rect(0.0f, 0.0f, (float)width, (float)height); CFX_Matrix mtAdjust; mtAdjust.MatchRect(bitmap_rect, cell_bbox); @@ -1048,9 +1048,8 @@ void CPDF_RenderStatus::RenderObjectList( #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - CFX_FloatRect clip_rect(m_pDevice->GetClipBox()); - pObj2Device->GetInverse().TransformRect(clip_rect); - + CFX_FloatRect clip_rect = pObj2Device->GetInverse().TransformRect( + CFX_FloatRect(m_pDevice->GetClipBox())); for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) { if (pCurObj.get() == m_pStopObj) { m_bStopped = true; @@ -1899,10 +1898,9 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, CFX_RenderDevice::StateRestorer restorer(m_pDevice); status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); } else { - CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox(); - matrix.TransformRect(rect_f); - - FX_RECT rect = rect_f.GetOuterRect(); + FX_RECT rect = + matrix.TransformRect(pType3Char->m_pForm->CalcBoundingBox()) + .GetOuterRect(); CFX_DefaultRenderDevice bitmap_device; if (!bitmap_device.Create((int)(rect.Width() * sa), (int)(rect.Height() * sd), FXDIB_Argb, @@ -2075,9 +2073,8 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, } } if (pDict->KeyExist("BBox")) { - CFX_FloatRect rect = pDict->GetRectFor("BBox"); - pMatrix->TransformRect(rect); - clip_rect.Intersect(rect.GetOuterRect()); + clip_rect.Intersect( + pMatrix->TransformRect(pDict->GetRectFor("BBox")).GetOuterRect()); } if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SHADING && m_pDevice->GetDeviceDriver()->DrawShading(pPattern, pMatrix, clip_rect, @@ -2224,9 +2221,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, pPattern->bbox().top == pPattern->y_step() && (mtPattern2Device.IsScaled() || mtPattern2Device.Is90Rotated()); - CFX_FloatRect cell_bbox = pPattern->bbox(); - mtPattern2Device.TransformRect(cell_bbox); - + CFX_FloatRect cell_bbox = mtPattern2Device.TransformRect(pPattern->bbox()); int width = static_cast<int>(ceil(cell_bbox.Width())); int height = static_cast<int>(ceil(cell_bbox.Height())); if (width == 0) @@ -2234,9 +2229,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, if (height == 0) height = 1; - CFX_FloatRect clip_box_p(clip_box); - mtPattern2Device.GetInverse().TransformRect(clip_box_p); - + CFX_FloatRect clip_box_p = + mtPattern2Device.GetInverse().TransformRect(CFX_FloatRect(clip_box)); int min_col = (int)ceil((clip_box_p.left - pPattern->bbox().right) / pPattern->x_step()); int max_col = (int)floor((clip_box_p.right - pPattern->bbox().left) / diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp index 17e33af3b1..82970e5e60 100644 --- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp +++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp @@ -52,9 +52,8 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, bpp = 32; } while (1) { - CFX_FloatRect rect(pRect); - m_Matrix.TransformRect(rect); - FX_RECT bitmap_rect = rect.GetOuterRect(); + FX_RECT bitmap_rect = + m_Matrix.TransformRect(CFX_FloatRect(pRect)).GetOuterRect(); int32_t iWidth = bitmap_rect.Width(); int32_t iHeight = bitmap_rect.Height(); int32_t iPitch = (iWidth * bpp + 31) / 32 * 4; |