| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/include/fxcrt/fx_system.h" | 7 #include "core/include/fxcrt/fx_system.h" |
| 8 #include "core/include/fxge/fx_ge.h" | 8 #include "core/include/fxge/fx_ge.h" |
| 9 #include "third_party/base/numerics/safe_math.h" | 9 #include "third_party/base/numerics/safe_math.h" |
| 10 | 10 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 SetPointCount(nPoints); | 150 SetPointCount(nPoints); |
| 151 } | 151 } |
| 152 void CFX_PathData::AddPointCount(int addPoints) { | 152 void CFX_PathData::AddPointCount(int addPoints) { |
| 153 pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount; | 153 pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount; |
| 154 safe_new_count += addPoints; | 154 safe_new_count += addPoints; |
| 155 int new_count = safe_new_count.ValueOrDie(); | 155 int new_count = safe_new_count.ValueOrDie(); |
| 156 AllocPointCount(new_count); | 156 AllocPointCount(new_count); |
| 157 m_PointCount = new_count; | 157 m_PointCount = new_count; |
| 158 } | 158 } |
| 159 void CFX_PathData::Append(const CFX_PathData* pSrc, | 159 void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) { |
| 160 const CFX_AffineMatrix* pMatrix) { | |
| 161 int old_count = m_PointCount; | 160 int old_count = m_PointCount; |
| 162 AddPointCount(pSrc->m_PointCount); | 161 AddPointCount(pSrc->m_PointCount); |
| 163 FXSYS_memcpy(m_pPoints + old_count, pSrc->m_pPoints, | 162 FXSYS_memcpy(m_pPoints + old_count, pSrc->m_pPoints, |
| 164 pSrc->m_PointCount * sizeof(FX_PATHPOINT)); | 163 pSrc->m_PointCount * sizeof(FX_PATHPOINT)); |
| 165 if (pMatrix) { | 164 if (pMatrix) { |
| 166 for (int i = 0; i < pSrc->m_PointCount; i++) { | 165 for (int i = 0; i < pSrc->m_PointCount; i++) { |
| 167 pMatrix->Transform(m_pPoints[old_count + i].m_PointX, | 166 pMatrix->Transform(m_pPoints[old_count + i].m_PointX, |
| 168 m_pPoints[old_count + i].m_PointY); | 167 m_pPoints[old_count + i].m_PointY); |
| 169 } | 168 } |
| 170 } | 169 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 FX_FLOAT middle_y = m_pPoints[iMiddlePoint].m_PointY; | 376 FX_FLOAT middle_y = m_pPoints[iMiddlePoint].m_PointY; |
| 378 _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, end_x, | 377 _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, end_x, |
| 379 end_y, half_width, miter_limit); | 378 end_y, half_width, miter_limit); |
| 380 } else { | 379 } else { |
| 381 _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_width); | 380 _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_width); |
| 382 } | 381 } |
| 383 iPoint++; | 382 iPoint++; |
| 384 } | 383 } |
| 385 return rect; | 384 return rect; |
| 386 } | 385 } |
| 387 void CFX_PathData::Transform(const CFX_AffineMatrix* pMatrix) { | 386 void CFX_PathData::Transform(const CFX_Matrix* pMatrix) { |
| 388 if (pMatrix == NULL) { | 387 if (pMatrix == NULL) { |
| 389 return; | 388 return; |
| 390 } | 389 } |
| 391 for (int i = 0; i < m_PointCount; i++) { | 390 for (int i = 0; i < m_PointCount; i++) { |
| 392 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); | 391 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); |
| 393 } | 392 } |
| 394 } | 393 } |
| 395 FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, | 394 FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, |
| 396 CFX_AffineMatrix* pMatrix, | 395 CFX_Matrix* pMatrix, |
| 397 FX_BOOL& bThin, | 396 FX_BOOL& bThin, |
| 398 FX_BOOL bAdjust) const { | 397 FX_BOOL bAdjust) const { |
| 399 if (m_PointCount < 3) { | 398 if (m_PointCount < 3) { |
| 400 return FALSE; | 399 return FALSE; |
| 401 } | 400 } |
| 402 if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO && | 401 if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO && |
| 403 (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && | 402 (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && |
| 404 (m_pPoints[2].m_Flag & FXPT_TYPE) == FXPT_LINETO && | 403 (m_pPoints[2].m_Flag & FXPT_TYPE) == FXPT_LINETO && |
| 405 m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && | 404 m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && |
| 406 m_pPoints[0].m_PointY == m_pPoints[2].m_PointY) { | 405 m_pPoints[0].m_PointY == m_pPoints[2].m_PointY) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { | 555 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { |
| 557 return FALSE; | 556 return FALSE; |
| 558 } | 557 } |
| 559 if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && | 558 if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && |
| 560 m_pPoints[i].m_PointY != m_pPoints[i - 1].m_PointY) { | 559 m_pPoints[i].m_PointY != m_pPoints[i - 1].m_PointY) { |
| 561 return FALSE; | 560 return FALSE; |
| 562 } | 561 } |
| 563 } | 562 } |
| 564 return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE); | 563 return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE); |
| 565 } | 564 } |
| 566 FX_BOOL CFX_PathData::IsRect(const CFX_AffineMatrix* pMatrix, | 565 FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix, |
| 567 CFX_FloatRect* pRect) const { | 566 CFX_FloatRect* pRect) const { |
| 568 if (pMatrix == NULL) { | 567 if (pMatrix == NULL) { |
| 569 if (!IsRect()) { | 568 if (!IsRect()) { |
| 570 return FALSE; | 569 return FALSE; |
| 571 } | 570 } |
| 572 if (pRect) { | 571 if (pRect) { |
| 573 pRect->left = m_pPoints[0].m_PointX; | 572 pRect->left = m_pPoints[0].m_PointX; |
| 574 pRect->right = m_pPoints[2].m_PointX; | 573 pRect->right = m_pPoints[2].m_PointX; |
| 575 pRect->bottom = m_pPoints[0].m_PointY; | 574 pRect->bottom = m_pPoints[0].m_PointY; |
| 576 pRect->top = m_pPoints[2].m_PointY; | 575 pRect->top = m_pPoints[2].m_PointY; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 } | 648 } |
| 650 void CFX_GraphStateData::SetDashCount(int count) { | 649 void CFX_GraphStateData::SetDashCount(int count) { |
| 651 FX_Free(m_DashArray); | 650 FX_Free(m_DashArray); |
| 652 m_DashArray = NULL; | 651 m_DashArray = NULL; |
| 653 m_DashCount = count; | 652 m_DashCount = count; |
| 654 if (count == 0) { | 653 if (count == 0) { |
| 655 return; | 654 return; |
| 656 } | 655 } |
| 657 m_DashArray = FX_Alloc(FX_FLOAT, count); | 656 m_DashArray = FX_Alloc(FX_FLOAT, count); |
| 658 } | 657 } |
| OLD | NEW |