From b21f174ad87e46c823c2ef8c11682167e2d12864 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Thu, 29 Jun 2017 12:02:06 -0400 Subject: Change SetReverse to GetInverse in CFX_Matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CFX_Matrix::GetInverse is much clearer. Change-Id: Id10ab1723735332e1a78de853f28415ec3a4d834 Reviewed-on: https://pdfium-review.googlesource.com/7090 Reviewed-by: Lei Zhang Commit-Queue: Nicolás Peña --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 7 ++----- core/fpdfapi/render/cpdf_progressiverenderer.cpp | 4 +--- core/fpdfapi/render/cpdf_renderstatus.cpp | 23 ++++++----------------- core/fpdftext/cpdf_textpage.cpp | 8 ++------ core/fxcrt/fx_coordinates.cpp | 24 ++++++++++++------------ core/fxcrt/fx_coordinates.h | 2 +- core/fxcrt/fx_coordinates_unittest.cpp | 14 +++++--------- core/fxge/agg/fx_agg_driver.cpp | 4 +--- core/fxge/dib/cfx_imagetransformer.cpp | 3 ++- fpdfsdk/cfx_systemhandler.cpp | 3 +-- fpdfsdk/formfiller/cffl_formfiller.cpp | 15 +++------------ fpdfsdk/fpdfview.cpp | 4 +--- fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 10 ++++------ fpdfsdk/pdfwindow/cpwl_icon.cpp | 3 +-- fpdfsdk/pdfwindow/cpwl_wnd.cpp | 8 ++++++-- xfa/fde/cfde_rendercontext.cpp | 4 +--- xfa/fde/cfde_textout.cpp | 4 +--- xfa/fwl/cfwl_widget.cpp | 5 ++--- xfa/fwl/cfwl_widgetmgr.cpp | 7 +------ xfa/fxfa/cxfa_ffwidget.cpp | 4 +--- xfa/fxfa/cxfa_rendercontext.cpp | 4 +--- 21 files changed, 55 insertions(+), 105 deletions(-) diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 10b3933742..369c2a81ff 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -68,11 +68,8 @@ void CPDF_PageContentGenerator::GenerateContent() { // Set the default graphic state values buf << "q\n"; - if (!m_pObjHolder->GetLastCTM().IsIdentity()) { - CFX_Matrix reverse; - reverse.SetReverse(m_pObjHolder->GetLastCTM()); - buf << reverse << " cm\n"; - } + if (!m_pObjHolder->GetLastCTM().IsIdentity()) + buf << m_pObjHolder->GetLastCTM().GetInverse() << " cm\n"; ProcessDefaultGraphics(&buf); // Process the page objects diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp index 984ad75834..4ddc528342 100644 --- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp +++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp @@ -60,9 +60,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { nullptr); m_pDevice->SaveState(); m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); - CFX_Matrix device2object; - device2object.SetReverse(m_pCurrentLayer->m_Matrix); - device2object.TransformRect(m_ClipRect); + m_pCurrentLayer->m_Matrix.GetInverse().TransformRect(m_ClipRect); } 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 beeca3febe..a3b1bb8567 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -133,8 +133,6 @@ void DrawAxialShading(const CFX_RetainPtr& pBitmap, float x_span = end_x - start_x; float y_span = end_y - start_y; float axis_len_square = (x_span * x_span) + (y_span * y_span); - CFX_Matrix matrix; - matrix.SetReverse(*pObject2Bitmap); uint32_t total_results = std::max(CountOutputs(funcs), pCS->CountComponents()); CFX_FixedBufGrow result_array(total_results); @@ -160,6 +158,7 @@ void DrawAxialShading(const CFX_RetainPtr& pBitmap, FXSYS_round(G * 255), FXSYS_round(B * 255))); } int pitch = pBitmap->GetPitch(); + CFX_Matrix matrix = pObject2Bitmap->GetInverse(); for (int row = 0; row < height; row++) { uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); for (int column = 0; column < width; column++) { @@ -202,8 +201,6 @@ void DrawRadialShading(const CFX_RetainPtr& pBitmap, float end_x = pCoords->GetNumberAt(3); float end_y = pCoords->GetNumberAt(4); float end_r = pCoords->GetNumberAt(5); - CFX_Matrix matrix; - matrix.SetReverse(*pObject2Bitmap); float t_min = 0; float t_max = 1.0f; CPDF_Array* pArray = pDict->GetArrayFor("Domain"); @@ -256,6 +253,7 @@ void DrawRadialShading(const CFX_RetainPtr& pBitmap, bDecreasing = true; } } + CFX_Matrix matrix = pObject2Bitmap->GetInverse(); for (int row = 0; row < height; row++) { uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); for (int column = 0; column < width; column++) { @@ -334,12 +332,8 @@ void DrawFuncShading(const CFX_RetainPtr& pBitmap, ymax = pDomain->GetNumberAt(3); } CFX_Matrix mtDomain2Target = pDict->GetMatrixFor("Matrix"); - CFX_Matrix matrix; - matrix.SetReverse(*pObject2Bitmap); - - CFX_Matrix reverse_matrix; - reverse_matrix.SetReverse(mtDomain2Target); - matrix.Concat(reverse_matrix); + CFX_Matrix matrix = pObject2Bitmap->GetInverse(); + matrix.Concat(mtDomain2Target.GetInverse()); int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); @@ -1056,9 +1050,7 @@ void CPDF_RenderStatus::RenderObjectList( DebugVerifyDeviceIsPreMultiplied(); #endif CFX_FloatRect clip_rect(m_pDevice->GetClipBox()); - CFX_Matrix device2object; - device2object.SetReverse(*pObj2Device); - device2object.TransformRect(clip_rect); + pObj2Device->GetInverse().TransformRect(clip_rect); for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) { if (pCurObj.get() == m_pStopObj) { @@ -2243,11 +2235,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, if (height == 0) height = 1; - CFX_Matrix mtDevice2Pattern; - mtDevice2Pattern.SetReverse(mtPattern2Device); - CFX_FloatRect clip_box_p(clip_box); - mtDevice2Pattern.TransformRect(clip_box_p); + mtPattern2Device.GetInverse().TransformRect(clip_box_p); int min_col = (int)ceil((clip_box_p.left - pPattern->bbox().right) / pPattern->x_step()); diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index b8860122f1..b6b3a0dbce 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -264,10 +264,7 @@ std::vector CPDF_TextPage::GetRectArray(int start, CFX_Matrix matrix = info_curchar.m_pTextObj->GetTextMatrix(); matrix.Concat(info_curchar.m_Matrix); - CFX_Matrix matrix_reverse; - matrix_reverse.SetReverse(matrix); - - CFX_PointF origin = matrix_reverse.Transform(info_curchar.m_Origin); + CFX_PointF origin = matrix.GetInverse().Transform(info_curchar.m_Origin); rect.left = info_curchar.m_CharBox.left; rect.right = info_curchar.m_CharBox.right; if (pCurObj->GetFont()->GetTypeDescent()) { @@ -1306,8 +1303,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( CFX_Matrix prev_matrix = m_pPreTextObj->GetTextMatrix(); prev_matrix.Concat(m_perMatrix); - CFX_Matrix prev_reverse; - prev_reverse.SetReverse(prev_matrix); + CFX_Matrix prev_reverse = prev_matrix.GetInverse(); CFX_PointF pos = prev_reverse.Transform(formMatrix.Transform(pObj->GetPos())); if (last_width < this_width) diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp index 27c0a95ee4..0b6aed44cc 100644 --- a/core/fxcrt/fx_coordinates.cpp +++ b/core/fxcrt/fx_coordinates.cpp @@ -197,18 +197,20 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) { return CFX_FloatRect(min_x, min_y, max_x, max_y); } -void CFX_Matrix::SetReverse(const CFX_Matrix& m) { - float i = m.a * m.d - m.b * m.c; +CFX_Matrix CFX_Matrix::GetInverse() const { + CFX_Matrix inverse; + float i = a * d - b * c; if (fabs(i) == 0) - return; + return inverse; float j = -i; - a = m.d / i; - b = m.b / j; - c = m.c / j; - d = m.a / i; - e = (m.c * m.f - m.d * m.e) / i; - f = (m.a * m.f - m.b * m.e) / j; + inverse.a = d / i; + inverse.b = b / j; + inverse.c = c / j; + inverse.d = a / i; + inverse.e = (c * f - d * e) / i; + inverse.f = (a * f - b * e) / j; + return inverse; } void CFX_Matrix::Concat(const CFX_Matrix& m, bool bPrepended) { @@ -216,9 +218,7 @@ void CFX_Matrix::Concat(const CFX_Matrix& m, bool bPrepended) { } void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, bool bPrepended) { - CFX_Matrix m; - m.SetReverse(src); - Concat(m, bPrepended); + Concat(src.GetInverse(), bPrepended); } bool CFX_Matrix::Is90Rotated() const { diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index fc51c458a0..25923f7290 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -608,7 +608,7 @@ class CFX_Matrix { f = 0; } - void SetReverse(const CFX_Matrix& m); + CFX_Matrix GetInverse() const; void Concat(const CFX_Matrix& m, bool bPrepended = false); void ConcatInverse(const CFX_Matrix& m, bool bPrepended = false); diff --git a/core/fxcrt/fx_coordinates_unittest.cpp b/core/fxcrt/fx_coordinates_unittest.cpp index 12ddb97330..e998b440f5 100644 --- a/core/fxcrt/fx_coordinates_unittest.cpp +++ b/core/fxcrt/fx_coordinates_unittest.cpp @@ -8,10 +8,9 @@ TEST(CFX_Matrix, ReverseIdentity) { CFX_Matrix m; - CFX_Matrix rev; - m.SetIdentity(); - rev.SetReverse(m); + CFX_Matrix rev = m.GetInverse(); + EXPECT_FLOAT_EQ(1.0, rev.a); EXPECT_FLOAT_EQ(0.0, rev.b); EXPECT_FLOAT_EQ(0.0, rev.c); @@ -28,9 +27,8 @@ TEST(CFX_Matrix, ReverseIdentity) { TEST(CFX_Matrix, Reverse) { float data[6] = {3, 0, 2, 3, 1, 4}; CFX_Matrix m(data); - CFX_Matrix rev; + CFX_Matrix rev = m.GetInverse(); - rev.SetReverse(m); EXPECT_FLOAT_EQ(0.33333334f, rev.a); EXPECT_FLOAT_EQ(0.0f, rev.b); EXPECT_FLOAT_EQ(-0.22222222f, rev.c); @@ -50,9 +48,8 @@ TEST(CFX_Matrix, ReverseCR702041) { float data[6] = {0.947368443f, -0.108947366f, -0.923076928f, 0.106153846f, 18.0f, 787.929993f}; CFX_Matrix m(data); - CFX_Matrix rev; + CFX_Matrix rev = m.GetInverse(); - rev.SetReverse(m); EXPECT_FLOAT_EQ(14247728.0f, rev.a); EXPECT_FLOAT_EQ(14622668.0f, rev.b); EXPECT_FLOAT_EQ(1.2389329e+08f, rev.c); @@ -71,9 +68,8 @@ TEST(CFX_Matrix, ReverseCR714187) { // The determinate is < std::numeric_limits::epsilon() float data[6] = {0.000037f, 0.0f, 0.0f, -0.000037f, 182.413101f, 136.977646f}; CFX_Matrix m(data); - CFX_Matrix rev; + CFX_Matrix rev = m.GetInverse(); - rev.SetReverse(m); EXPECT_FLOAT_EQ(27027.025f, rev.a); EXPECT_FLOAT_EQ(0.0f, rev.b); EXPECT_FLOAT_EQ(0.0f, rev.c); diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 22d80071a9..91272d4427 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -1349,10 +1349,8 @@ bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0, 0); - CFX_Matrix mtRervese; - mtRervese.SetReverse(matrix2); matrix1 = *pObject2Device; - matrix1.Concat(mtRervese); + matrix1.Concat(matrix2.GetInverse()); } CAgg_PathData path_data; diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index 6174a51c29..2fb21e4c33 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -235,7 +235,8 @@ bool CFX_ImageTransformer::Start() { 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)); - m_dest2stretch.SetReverse(stretch2dest); + ASSERT(m_dest2stretch.IsIdentity()); + m_dest2stretch = stretch2dest.GetInverse(); CFX_FloatRect clip_rect_f(result_clip); m_dest2stretch.TransformRect(clip_rect_f); diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp index d38c6270f7..882351145e 100644 --- a/fpdfsdk/cfx_systemhandler.cpp +++ b/fpdfsdk/cfx_systemhandler.cpp @@ -49,8 +49,7 @@ void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget, FX_RECT rect) { CFX_Matrix page2device; pPageView->GetCurrentMatrix(page2device); - CFX_Matrix device2page; - device2page.SetReverse(page2device); + CFX_Matrix device2page = page2device.GetInverse(); CFX_PointF left_top = device2page.Transform( CFX_PointF(static_cast(rect.left), static_cast(rect.top))); diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 526f4b947d..565d2babdd 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -459,28 +459,19 @@ CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { } CFX_FloatRect CFFL_FormFiller::FFLtoPWL(const CFX_FloatRect& rect) { - CFX_Matrix mt; - mt.SetReverse(GetCurMatrix()); - CFX_FloatRect temp = rect; - mt.TransformRect(temp); - + GetCurMatrix().GetInverse().TransformRect(temp); return temp; } CFX_FloatRect CFFL_FormFiller::PWLtoFFL(const CFX_FloatRect& rect) { - CFX_Matrix mt = GetCurMatrix(); - CFX_FloatRect temp = rect; - mt.TransformRect(temp); - + GetCurMatrix().TransformRect(temp); return temp; } CFX_PointF CFFL_FormFiller::FFLtoPWL(const CFX_PointF& point) { - CFX_Matrix mt; - mt.SetReverse(GetCurMatrix()); - return mt.Transform(point); + return GetCurMatrix().GetInverse().Transform(point); } CFX_PointF CFFL_FormFiller::PWLtoFFL(const CFX_PointF& point) { diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 68ef377dc8..ccd487aa4d 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -1031,10 +1031,8 @@ DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, #else // PDF_ENABLE_XFA CFX_Matrix page2device = pPage->GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate); - CFX_Matrix device2page; - device2page.SetReverse(page2device); - CFX_PointF pos = device2page.Transform( + CFX_PointF pos = page2device.GetInverse().Transform( CFX_PointF(static_cast(device_x), static_cast(device_y))); *page_x = pos.x; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 24858f2f1a..87e003e147 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -143,12 +143,10 @@ void CPDFXFA_Page::DeviceToPage(int start_x, if (!m_pPDFPage && !m_pXFAPageView) return; - CFX_Matrix device2page; - device2page.SetReverse( - GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate)); - - CFX_PointF pos = device2page.Transform( - CFX_PointF(static_cast(device_x), static_cast(device_y))); + CFX_PointF pos = GetDisplayMatrix(start_x, start_y, size_x, size_y, rotate) + .GetInverse() + .Transform(CFX_PointF(static_cast(device_x), + static_cast(device_y))); *page_x = pos.x; *page_y = pos.y; diff --git a/fpdfsdk/pdfwindow/cpwl_icon.cpp b/fpdfsdk/pdfwindow/cpwl_icon.cpp index 6650311915..ebf3b4fc12 100644 --- a/fpdfsdk/pdfwindow/cpwl_icon.cpp +++ b/fpdfsdk/pdfwindow/cpwl_icon.cpp @@ -23,8 +23,7 @@ CFX_ByteString CPWL_Image::GetImageAppStream() { CFX_ByteString sAlias = GetImageAlias(); CFX_FloatRect rcPlate = GetClientRect(); - CFX_Matrix mt; - mt.SetReverse(GetImageMatrix()); + CFX_Matrix mt = GetImageMatrix().GetInverse(); float fHScale = 1.0f; float fVScale = 1.0f; diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp index a8b5c31254..85a610eea5 100644 --- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp +++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp @@ -765,7 +765,9 @@ CFX_PointF CPWL_Wnd::ParentToChild(const CFX_PointF& point) const { if (mt.IsIdentity()) return point; - mt.SetReverse(mt); + CFX_Matrix inverse = mt.GetInverse(); + if (!inverse.IsIdentity()) + mt = inverse; return mt.Transform(point); } @@ -774,7 +776,9 @@ CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const { if (mt.IsIdentity()) return rect; - mt.SetReverse(mt); + CFX_Matrix inverse = mt.GetInverse(); + if (!inverse.IsIdentity()) + mt = inverse; CFX_FloatRect rc = rect; mt.TransformRect(rc); return rc; diff --git a/xfa/fde/cfde_rendercontext.cpp b/xfa/fde/cfde_rendercontext.cpp index 702f7ce295..dc2a628c23 100644 --- a/xfa/fde/cfde_rendercontext.cpp +++ b/xfa/fde/cfde_rendercontext.cpp @@ -40,15 +40,13 @@ void CFDE_RenderContext::DoRender() { if (!m_pRenderDevice || !m_pIterator) return; - CFX_Matrix rm; - rm.SetReverse(m_Transform); CFX_RectF rtDocClip = m_pRenderDevice->GetClipRect(); if (rtDocClip.IsEmpty()) { rtDocClip.left = rtDocClip.top = 0; rtDocClip.width = (float)m_pRenderDevice->GetWidth(); rtDocClip.height = (float)m_pRenderDevice->GetHeight(); } - rm.TransformRect(rtDocClip); + m_Transform.GetInverse().TransformRect(rtDocClip); IFDE_VisualSet* pVisualSet; FDE_TEXTEDITPIECE* pPiece; int32_t iCount = 0; diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp index 6d5ab2a980..5d84b6d12b 100644 --- a/xfa/fde/cfde_textout.cpp +++ b/xfa/fde/cfde_textout.cpp @@ -294,9 +294,7 @@ void CFDE_TextOut::DrawText(const wchar_t* pwsStr, int32_t iLength, const CFX_RectF& rect) { CFX_RectF rtText(rect.left, rect.top, rect.width, rect.height); - CFX_Matrix rm; - rm.SetReverse(m_Matrix); - rm.TransformRect(rtText); + m_Matrix.GetInverse().TransformRect(rtText); DrawText(pwsStr, iLength, rtText, m_rtClip); } diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index 172014da62..45ae9c0b0c 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -197,9 +197,8 @@ CFX_PointF CFWL_Widget::TransformTo(CFWL_Widget* pWidget, if (!parent) return ret; - CFX_Matrix m; - m.SetReverse(pWidget->GetMatrix()); - return m.Transform(ret) - pWidget->GetWidgetRect().TopLeft(); + return pWidget->GetMatrix().GetInverse().Transform(ret) - + pWidget->GetWidgetRect().TopLeft(); } CFX_Matrix CFWL_Widget::GetMatrix() { diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index 67a63ba921..3abe14d89b 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -266,12 +266,7 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, CFWL_Widget* child = GetLastChildWidget(parent); while (child) { if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { - CFX_Matrix m; - m.SetIdentity(); - - CFX_Matrix matrixOnParent; - m.SetReverse(matrixOnParent); - pos = m.Transform(point); + pos = parent->GetMatrix().GetInverse().Transform(point); CFX_RectF bounds = child->GetWidgetRect(); if (bounds.Contains(pos)) { diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 9de99255ab..f72b29127a 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -348,9 +348,7 @@ CFX_PointF CXFA_FFWidget::Rotate2Normal(const CFX_PointF& point) { if (mt.IsIdentity()) return point; - CFX_Matrix mtReverse; - mtReverse.SetReverse(mt); - return mtReverse.Transform(point); + return mt.GetInverse().Transform(point); } static void XFA_GetMatrix(CFX_Matrix& m, diff --git a/xfa/fxfa/cxfa_rendercontext.cpp b/xfa/fxfa/cxfa_rendercontext.cpp index 02c7cbb371..d709502ec8 100644 --- a/xfa/fxfa/cxfa_rendercontext.cpp +++ b/xfa/fxfa/cxfa_rendercontext.cpp @@ -14,9 +14,7 @@ CXFA_RenderContext::CXFA_RenderContext(CXFA_FFPageView* pPageView, const CFX_RectF& clipRect, const CFX_Matrix& matrix) : m_pWidget(nullptr), m_matrix(matrix), m_rtClipRect(clipRect) { - CFX_Matrix mtRes; - mtRes.SetReverse(matrix); - mtRes.TransformRect(m_rtClipRect); + matrix.GetInverse().TransformRect(m_rtClipRect); m_pWidgetIterator = pPageView->CreateWidgetIterator( XFA_TRAVERSEWAY_Form, -- cgit v1.2.3