From 6296f2d501e2749d98e890ed722f923ee584c9ca Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 2 Sep 2016 16:56:21 -0700 Subject: Remove CFX_Matrix::Copy() in favor of assignment The default assignment operator will suffice and allows us to write matrix1 = matrix2; Review-Url: https://codereview.chromium.org/2307953003 --- core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 6 +++--- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 3 +-- core/fpdfapi/fpdf_render/fpdf_render_text.cpp | 2 +- core/fpdftext/cpdf_textpage.cpp | 20 ++++++++++---------- core/fxcrt/include/fx_coordinates.h | 12 +----------- 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp index b92f10b095..2883c26309 100644 --- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp @@ -30,9 +30,9 @@ CPDF_AllStates::~CPDF_AllStates() {} void CPDF_AllStates::Copy(const CPDF_AllStates& src) { CopyStates(src); - m_TextMatrix.Copy(src.m_TextMatrix); - m_ParentMatrix.Copy(src.m_ParentMatrix); - m_CTM.Copy(src.m_CTM); + m_TextMatrix = src.m_TextMatrix; + m_ParentMatrix = src.m_ParentMatrix; + m_CTM = src.m_CTM; m_TextX = src.m_TextX; m_TextY = src.m_TextY; m_TextLineX = src.m_TextLineX; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 83e66eae61..d7f1f3c3e0 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -777,8 +777,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, if (!pStream && !pImage) return nullptr; - CFX_Matrix ImageMatrix; - ImageMatrix.Copy(m_pCurStates->m_CTM); + CFX_Matrix ImageMatrix = m_pCurStates->m_CTM; ImageMatrix.Concat(m_mtContentToUser); std::unique_ptr pImageObj(new CPDF_ImageObject); diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index 7bfed906ea..fef0bcdb79 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -118,7 +118,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, if (pCTM[0] != 1.0f || pCTM[3] != 1.0f) { CFX_Matrix ctm(pCTM[0], pCTM[1], pCTM[2], pCTM[3], 0, 0); text_matrix.ConcatInverse(ctm); - device_matrix.Copy(ctm); + device_matrix = ctm; device_matrix.Concat(*pObj2Device); pDeviceMatrix = &device_matrix; } diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 7512453093..cb60c452bf 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -387,7 +387,7 @@ void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { info->m_FontSize = charinfo.m_pTextObj->GetFontSize(); else info->m_FontSize = kDefaultFontSize; - info->m_Matrix.Copy(charinfo.m_Matrix); + info->m_Matrix = charinfo.m_Matrix; } void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, @@ -565,7 +565,7 @@ void CPDF_TextPage::AppendGeneratedCharacter(FX_WCHAR unicode, m_TextBuf.AppendChar(unicode); if (!formMatrix.IsIdentity()) - generateChar.m_Matrix.Copy(formMatrix); + generateChar.m_Matrix = formMatrix; m_CharList.push_back(generateChar); } @@ -600,7 +600,7 @@ void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj, return; CFX_Matrix curFormMatrix; - curFormMatrix.Copy(pFormObj->m_FormMatrix); + curFormMatrix = pFormObj->m_FormMatrix; curFormMatrix.Concat(formMatrix); for (auto it = pObjectList->begin(); it != pObjectList->end(); ++it) { @@ -921,7 +921,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { charinfo.m_CharBox.left = charBox.left; charinfo.m_CharBox.right = charBox.right; charinfo.m_CharBox.bottom = charBox.bottom; - charinfo.m_Matrix.Copy(matrix); + charinfo.m_Matrix = matrix; m_TempTextBuf.AppendChar(wChar); m_TempCharList.push_back(charinfo); } @@ -984,7 +984,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { FPDFText_MarkedContent ePreMKC = PreMarkedContent(Obj); if (ePreMKC == FPDFText_MarkedContent::Done) { m_pPreTextObj = pTextObj; - m_perMatrix.Copy(formMatrix); + m_perMatrix = formMatrix; return; } GenerateCharacter result = GenerateCharacter::None; @@ -1006,7 +1006,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { PAGECHAR_INFO generateChar; if (GenerateCharInfo(TEXT_SPACE_CHAR, generateChar)) { if (!formMatrix.IsIdentity()) - generateChar.m_Matrix.Copy(formMatrix); + generateChar.m_Matrix = formMatrix; m_TempTextBuf.AppendChar(TEXT_SPACE_CHAR); m_TempCharList.push_back(generateChar); } @@ -1052,11 +1052,11 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { if (ePreMKC == FPDFText_MarkedContent::Delay) { ProcessMarkedContent(Obj); m_pPreTextObj = pTextObj; - m_perMatrix.Copy(formMatrix); + m_perMatrix = formMatrix; return; } m_pPreTextObj = pTextObj; - m_perMatrix.Copy(formMatrix); + m_perMatrix = formMatrix; int nItems = pTextObj->CountItems(); FX_FLOAT baseSpace = CalculateBaseSpace(pTextObj, matrix); @@ -1117,7 +1117,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_Index = m_TextBuf.GetLength(); m_TempTextBuf.AppendChar(TEXT_SPACE_CHAR); charinfo.m_CharCode = CPDF_Font::kInvalidCharCode; - charinfo.m_Matrix.Copy(formMatrix); + charinfo.m_Matrix = formMatrix; matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_OriginX, charinfo.m_OriginY); charinfo.m_CharBox = @@ -1168,7 +1168,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_CharBox.left + pTextObj->GetCharWidth(charinfo.m_CharCode); } matrix.TransformRect(charinfo.m_CharBox); - charinfo.m_Matrix.Copy(matrix); + charinfo.m_Matrix = matrix; if (wstrItem.IsEmpty()) { charinfo.m_Unicode = 0; m_TempCharList.push_back(charinfo); diff --git a/core/fxcrt/include/fx_coordinates.h b/core/fxcrt/include/fx_coordinates.h index 49f6a19859..7da6057ed4 100644 --- a/core/fxcrt/include/fx_coordinates.h +++ b/core/fxcrt/include/fx_coordinates.h @@ -582,27 +582,21 @@ class CFX_Matrix { void Concat(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); - void Copy(const CFX_Matrix& m) { *this = m; } - FX_BOOL IsIdentity() const { return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; } - FX_BOOL IsInvertible() const; + FX_BOOL IsInvertible() const; FX_BOOL Is90Rotated() const; - FX_BOOL IsScaled() const; void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE); - void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE) { Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); } void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE); - void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE); - void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, @@ -613,12 +607,9 @@ class CFX_Matrix { FX_BOOL bPrepended = FALSE); void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src); - FX_FLOAT GetXUnit() const; - FX_FLOAT GetYUnit() const; void GetUnitRect(CFX_RectF& rect) const; - CFX_FloatRect GetUnitRect() const; FX_FLOAT GetUnitArea() const; @@ -643,7 +634,6 @@ class CFX_Matrix { void TransformVector(CFX_Vector& v) const; void TransformRect(CFX_RectF& rect) const; void TransformRect(CFX_Rect& rect) const; - void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, -- cgit v1.2.3