From 878b27de2fa8e5bdc3b910c98846f4b43185d4aa Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Tue, 22 Aug 2017 10:50:06 -0400 Subject: 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 Commit-Queue: Jane Liu --- core/fpdfapi/font/cpdf_cidfont.cpp | 4 +- core/fpdfapi/font/cpdf_type3font.cpp | 2 +- core/fpdfapi/page/cpdf_contentparser.cpp | 4 +- core/fpdfapi/page/cpdf_formobject.cpp | 4 +- core/fpdfapi/page/cpdf_imageobject.cpp | 7 +-- core/fpdfapi/page/cpdf_pageobject.cpp | 6 +-- core/fpdfapi/page/cpdf_pathobject.cpp | 2 +- core/fpdfapi/page/cpdf_shadingobject.cpp | 3 +- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 3 +- core/fpdfapi/page/cpdf_textobject.cpp | 8 +--- core/fpdfapi/render/cpdf_devicebuffer.cpp | 6 +-- core/fpdfapi/render/cpdf_progressiverenderer.cpp | 4 +- core/fpdfapi/render/cpdf_renderstatus.cpp | 32 ++++++------- core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp | 5 +- core/fpdfdoc/cpdf_annot.cpp | 4 +- core/fpdfdoc/cpdf_annotlist.cpp | 7 ++- core/fpdfdoc/cpdf_formcontrol.cpp | 4 +- core/fpdftext/cpdf_textpage.cpp | 2 +- core/fxcrt/fx_coordinates.cpp | 58 ++++++++++++++---------- core/fxcrt/fx_coordinates.h | 16 +++---- core/fxge/cfx_renderdevice.cpp | 2 +- core/fxge/dib/cfx_imagetransformer.cpp | 5 +- core/fxge/win32/cfx_psrenderer.cpp | 5 +- core/fxge/win32/fx_win32_device.cpp | 2 +- 24 files changed, 93 insertions(+), 102 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 9a2261caa9..a67abd29ac 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -499,9 +499,7 @@ FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode) { CIDTransformToFloat(pTransform[3]), CIDTransformToFloat(pTransform[4]) * 1000, CIDTransformToFloat(pTransform[5]) * 1000); - CFX_FloatRect rect_f(rect); - matrix.TransformRect(rect_f); - rect = rect_f.GetOuterRect(); + rect = matrix.TransformRect(CFX_FloatRect(rect)).GetOuterRect(); } } if (charcode < 256) diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp index b22551a26a..e13deaa56b 100644 --- a/core/fpdfapi/font/cpdf_type3font.cpp +++ b/core/fpdfapi/font/cpdf_type3font.cpp @@ -130,7 +130,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) { if (rcBBox.right <= rcBBox.left || rcBBox.bottom >= rcBBox.top) char_rect = pNewChar->m_pForm->CalcBoundingBox(); - m_FontMatrix.TransformRect(char_rect); + char_rect = m_FontMatrix.TransformRect(char_rect); rcBBox.left = FXSYS_round(char_rect.left * 1000); rcBBox.right = FXSYS_round(char_rect.right * 1000); rcBBox.top = FXSYS_round(char_rect.top * 1000); diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index 4f4036f078..36dea17572 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -91,9 +91,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, if (pParentMatrix) ClipPath.Transform(pParentMatrix); - form_matrix.TransformRect(form_bbox); + form_bbox = form_matrix.TransformRect(form_bbox); if (pParentMatrix) - pParentMatrix->TransformRect(form_bbox); + form_bbox = pParentMatrix->TransformRect(form_bbox); } CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources"); diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp index 5642a5dd01..c0cdd3e950 100644 --- a/core/fpdfapi/page/cpdf_formobject.cpp +++ b/core/fpdfapi/page/cpdf_formobject.cpp @@ -34,8 +34,8 @@ CPDF_PageObject::Type CPDF_FormObject::GetType() const { } void CPDF_FormObject::CalcBoundingBox() { - CFX_FloatRect form_rect = m_pForm->CalcBoundingBox(); - m_FormMatrix.TransformRect(form_rect); + CFX_FloatRect form_rect = + m_FormMatrix.TransformRect(m_pForm->CalcBoundingBox()); m_Left = form_rect.left; m_Bottom = form_rect.bottom; m_Right = form_rect.right; diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp index a74ac4802c..dd07385db4 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -41,11 +41,8 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const { } void CPDF_ImageObject::CalcBoundingBox() { - m_Left = 0; - m_Bottom = 0; - m_Right = 1.0f; - m_Top = 1.0f; - m_Matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); + std::tie(m_Left, m_Right, m_Top, m_Bottom) = + m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f); } void CPDF_ImageObject::SetImage(const CFX_RetainPtr& pImage) { diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp index 79d9bbc540..8bb5bf5978 100644 --- a/core/fpdfapi/page/cpdf_pageobject.cpp +++ b/core/fpdfapi/page/cpdf_pageobject.cpp @@ -95,8 +95,8 @@ void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) { FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const { CFX_FloatRect rect(m_Left, m_Bottom, m_Right, m_Top); - if (pMatrix) { - pMatrix->TransformRect(rect); - } + if (pMatrix) + rect = pMatrix->TransformRect(rect); + return rect.GetOuterRect(); } diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index 7dd91598c6..d8c2cb8741 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -42,7 +42,7 @@ void CPDF_PathObject::CalcBoundingBox() { } else { rect = m_Path.GetBoundingBox(); } - m_Matrix.TransformRect(rect); + rect = m_Matrix.TransformRect(rect); if (width == 0 && m_bStroke) { rect.left += -0.5f; diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp index 8a61161f17..df3fbd17cd 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.cpp +++ b/core/fpdfapi/page/cpdf_shadingobject.cpp @@ -25,7 +25,8 @@ void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { if (m_ClipPath.HasRef()) { CalcBoundingBox(); } else { - matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); + std::tie(m_Left, m_Right, m_Top, m_Bottom) = + matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); } } diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index ca92b9efdf..1d5ddaeed2 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -130,8 +130,7 @@ CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading, if (bGouraud) stream.BitStream()->ByteAlign(); } - matrix.TransformRect(rect); - return rect; + return matrix.TransformRect(rect); } struct AbbrPair { diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 7a70101789..a4d714ff72 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -261,12 +261,8 @@ CFX_PointF CPDF_TextObject::CalcPositionData(float horz_scale) { min_y = min_y * fontsize / 1000; max_y = max_y * fontsize / 1000; } - - m_Left = min_x; - m_Right = max_x; - m_Bottom = min_y; - m_Top = max_y; - GetTextMatrix().TransformRect(m_Left, m_Right, m_Top, m_Bottom); + std::tie(m_Left, m_Right, m_Top, m_Bottom) = + GetTextMatrix().TransformRect(min_x, max_x, max_y, min_y); if (!TextRenderingModeIsStrokeMode(m_TextState.GetTextMode())) return ret; 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(); 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 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(ceil(cell_bbox.Width())); int height = static_cast(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; diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index e43a7353b6..f2b54e81fe 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -52,9 +52,9 @@ CPDF_Form* AnnotGetMatrix(const CPDF_Page* pPage, if (!pForm) return nullptr; - CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectFor("BBox"); CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix"); - form_matrix.TransformRect(form_bbox); + CFX_FloatRect form_bbox = + form_matrix.TransformRect(pForm->m_pFormDict->GetRectFor("BBox")); matrix->MatchRect(pAnnot->GetRect(), form_bbox); matrix->Concat(*pUser2Device); return pForm; diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index e4ecf466f5..9f6f79a02c 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -148,12 +148,11 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, continue; } } - CFX_FloatRect annot_rect_f = pAnnot->GetRect(); + CFX_Matrix matrix = *pMatrix; if (clip_rect) { - matrix.TransformRect(annot_rect_f); - - FX_RECT annot_rect = annot_rect_f.GetOuterRect(); + FX_RECT annot_rect = + matrix.TransformRect(pAnnot->GetRect()).GetOuterRect(); annot_rect.Intersect(*clip_rect); if (annot_rect.IsEmpty()) continue; diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index 54524a64e2..322abc0eb1 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -173,9 +173,9 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, if (!pStream) return; - CFX_FloatRect form_bbox = pStream->GetDict()->GetRectFor("BBox"); CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixFor("Matrix"); - form_matrix.TransformRect(form_bbox); + CFX_FloatRect form_bbox = + form_matrix.TransformRect(pStream->GetDict()->GetRectFor("BBox")); CFX_FloatRect arect = m_pWidgetDict->GetRectFor("Rect"); CFX_Matrix matrix; matrix.MatchRect(arect, form_bbox); diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index a4c8b8fba0..223b59f4e8 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -1136,7 +1136,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_CharBox.right = charinfo.m_CharBox.left + pTextObj->GetCharWidth(charinfo.m_CharCode); } - matrix.TransformRect(charinfo.m_CharBox); + charinfo.m_CharBox = matrix.TransformRect(charinfo.m_CharBox); charinfo.m_Matrix = matrix; if (wstrItem.IsEmpty()) { charinfo.m_Unicode = 0; diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp index 26c9169fd9..b3d0432e1c 100644 --- a/core/fxcrt/fx_coordinates.cpp +++ b/core/fxcrt/fx_coordinates.cpp @@ -313,9 +313,7 @@ float CFX_Matrix::GetYUnit() const { } CFX_FloatRect CFX_Matrix::GetUnitRect() const { - CFX_FloatRect rect(0, 0, 1, 1); - TransformRect(rect); - return rect; + return TransformRect(CFX_FloatRect(0.f, 0.f, 1.f, 1.f)); } float CFX_Matrix::TransformXDistance(float dx) const { @@ -338,33 +336,47 @@ CFX_PointF CFX_Matrix::Transform(const CFX_PointF& point) const { return CFX_PointF(a * point.x + c * point.y + e, b * point.x + d * point.y + f); } - -void CFX_Matrix::TransformRect(CFX_RectF& rect) const { - float right = rect.right(), bottom = rect.bottom(); - TransformRect(rect.left, right, bottom, rect.top); - rect.width = right - rect.left; - rect.height = bottom - rect.top; -} - -void CFX_Matrix::TransformRect(float& left, - float& right, - float& top, - float& bottom) const { +std::tuple CFX_Matrix::TransformRect( + const float& left, + const float& right, + const float& top, + const float& bottom) const { CFX_PointF points[] = { {left, top}, {left, bottom}, {right, top}, {right, bottom}}; for (int i = 0; i < 4; i++) points[i] = Transform(points[i]); - right = points[0].x; - left = points[0].x; - top = points[0].y; - bottom = points[0].y; + float new_right = points[0].x; + float new_left = points[0].x; + float new_top = points[0].y; + float new_bottom = points[0].y; for (int i = 1; i < 4; i++) { - right = std::max(right, points[i].x); - left = std::min(left, points[i].x); - top = std::max(top, points[i].y); - bottom = std::min(bottom, points[i].y); + new_right = std::max(new_right, points[i].x); + new_left = std::min(new_left, points[i].x); + new_top = std::max(new_top, points[i].y); + new_bottom = std::min(new_bottom, points[i].y); } + return std::make_tuple(new_left, new_right, new_top, new_bottom); +} + +CFX_RectF CFX_Matrix::TransformRect(const CFX_RectF& rect) const { + float left; + float right; + float bottom; + float top; + std::tie(left, right, bottom, top) = + TransformRect(rect.left, rect.right(), rect.bottom(), rect.top); + return CFX_RectF(left, top, right - left, bottom - top); +} + +CFX_FloatRect CFX_Matrix::TransformRect(const CFX_FloatRect& rect) const { + float left; + float right; + float top; + float bottom; + std::tie(left, right, top, bottom) = + TransformRect(rect.left, rect.right, rect.top, rect.bottom); + return CFX_FloatRect(left, bottom, right, top); } void CFX_Matrix::ConcatInternal(const CFX_Matrix& other, bool prepend) { diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index cc14508d70..a4074a4afa 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -8,6 +8,7 @@ #define CORE_FXCRT_FX_COORDINATES_H_ #include +#include #include "core/fxcrt/fx_basic.h" @@ -672,14 +673,13 @@ class CFX_Matrix { CFX_PointF Transform(const CFX_PointF& point) const; - void TransformRect(CFX_RectF& rect) const; - void TransformRect(float& left, - float& right, - float& top, - float& bottom) const; - void TransformRect(CFX_FloatRect& rect) const { - TransformRect(rect.left, rect.right, rect.top, rect.bottom); - } + std::tuple TransformRect( + const float& left, + const float& right, + const float& top, + const float& bottom) const; + CFX_RectF TransformRect(const CFX_RectF& rect) const; + CFX_FloatRect TransformRect(const CFX_FloatRect& rect) const; float a; float b; diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index 8f35dce2da..e088bc4f9a 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -622,7 +622,7 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData, bbox = pPathData->GetBoundingBox(); } if (pObject2Device) - pObject2Device->TransformRect(bbox); + bbox = pObject2Device->TransformRect(bbox); CFX_Matrix ctm = GetCTM(); float fScaleX = fabs(ctm.a); diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index 7a097ced12..c05dd795b5 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -233,9 +233,8 @@ CFX_ImageTransformer::CFX_ImageTransformer( m_pMatrix->e, m_pMatrix->f)); m_dest2stretch = stretch2dest.GetInverse(); - CFX_FloatRect clip_rect_f(result_clip); - m_dest2stretch.TransformRect(clip_rect_f); - m_StretchClip = clip_rect_f.GetOuterRect(); + m_StretchClip = + m_dest2stretch.TransformRect(CFX_FloatRect(result_clip)).GetOuterRect(); m_StretchClip.Intersect(0, 0, stretch_width, stretch_height); m_Stretcher = pdfium::MakeUnique( &m_Storer, m_pSrc, stretch_width, stretch_height, m_StretchClip, m_Flags); diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 72ee731d56..c02058d1dd 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -213,7 +213,7 @@ void CFX_PSRenderer::SetClip_PathFill(const CFX_PathData* pPathData, OutputPath(pPathData, pObject2Device); CFX_FloatRect rect = pPathData->GetBoundingBox(); if (pObject2Device) - pObject2Device->TransformRect(rect); + rect = pObject2Device->TransformRect(rect); m_ClipBox.left = static_cast(rect.left); m_ClipBox.right = static_cast(rect.left + rect.right); @@ -242,8 +242,7 @@ void CFX_PSRenderer::SetClip_PathStroke(const CFX_PathData* pPathData, OutputPath(pPathData, nullptr); CFX_FloatRect rect = pPathData->GetBoundingBox(pGraphState->m_LineWidth, pGraphState->m_MiterLimit); - pObject2Device->TransformRect(rect); - m_ClipBox.Intersect(rect.GetOuterRect()); + m_ClipBox.Intersect(pObject2Device->TransformRect(rect).GetOuterRect()); m_pStream->WriteString("strokepath W n"); if (pObject2Device) diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 5f778f8965..fd1944a1b4 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -994,7 +994,7 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, !pPlatform->m_GdiplusExt.IsAvailable()) { CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); if (pMatrix) - pMatrix->TransformRect(bbox_f); + bbox_f = pMatrix->TransformRect(bbox_f); FX_RECT bbox = bbox_f.GetInnerRect(); if (bbox.Width() <= 0) { -- cgit v1.2.3