summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn2
-rw-r--r--core/fxge/cfx_pathdata.h1
-rw-r--r--xfa/fwl/cfwl_edit.cpp6
-rw-r--r--xfa/fwl/theme/cfwl_carettp.cpp1
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.cpp12
-rw-r--r--xfa/fwl/theme/cfwl_comboboxtp.cpp2
-rw-r--r--xfa/fwl/theme/cfwl_edittp.cpp1
-rw-r--r--xfa/fwl/theme/cfwl_listboxtp.cpp1
-rw-r--r--xfa/fwl/theme/cfwl_monthcalendartp.cpp14
-rw-r--r--xfa/fwl/theme/cfwl_pushbuttontp.cpp2
-rw-r--r--xfa/fwl/theme/cfwl_scrollbartp.cpp3
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp6
-rw-r--r--xfa/fxfa/app/xfa_fffield.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffpath.cpp1
-rw-r--r--xfa/fxfa/app/xfa_ffpushbutton.cpp5
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp22
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp1
-rw-r--r--xfa/fxgraphics/cfx_path.cpp267
-rw-r--r--xfa/fxgraphics/cfx_path.h78
-rw-r--r--xfa/fxgraphics/cfx_path_generator.cpp164
-rw-r--r--xfa/fxgraphics/cfx_path_generator.h54
21 files changed, 176 insertions, 475 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 830aa04869..d8da9decde 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1712,8 +1712,6 @@ if (pdf_enable_xfa) {
"xfa/fxgraphics/cfx_graphics.h",
"xfa/fxgraphics/cfx_path.cpp",
"xfa/fxgraphics/cfx_path.h",
- "xfa/fxgraphics/cfx_path_generator.cpp",
- "xfa/fxgraphics/cfx_path_generator.h",
"xfa/fxgraphics/cfx_pattern.cpp",
"xfa/fxgraphics/cfx_pattern.h",
"xfa/fxgraphics/cfx_shading.cpp",
diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h
index 68939bfeb2..b0e30e32ad 100644
--- a/core/fxge/cfx_pathdata.h
+++ b/core/fxge/cfx_pathdata.h
@@ -58,7 +58,6 @@ class CFX_PathData {
bool* setIdentity) const;
bool IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const;
- void Append(const CFX_PathData& data);
void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix);
void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure);
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index d343090647..d36e28ab56 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -192,15 +192,11 @@ void CFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics,
CFX_Color crLine(0xFFFF0000);
CFWL_EventCheckWord checkWordEvent(this);
-
CFX_ByteString sLatinWord;
CFX_Path pathSpell;
- pathSpell.Create();
-
int32_t nStart = 0;
FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
-
CFX_WideString wsSpell = GetText();
int32_t nContentLen = wsSpell.GetLength();
for (int i = 0; i < nContentLen; i++) {
@@ -550,7 +546,6 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics,
}
CFX_Path path;
- path.Create();
for (auto& rect : rectArr) {
rect.left += fOffSetX;
rect.top += fOffSetY;
@@ -581,7 +576,6 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics,
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
pGraphics->RestoreGraphState();
CFX_Path path;
- path.Create();
int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1;
FX_FLOAT fStep = m_rtEngine.width / iLimit;
FX_FLOAT fLeft = m_rtEngine.left + 1;
diff --git a/xfa/fwl/theme/cfwl_carettp.cpp b/xfa/fwl/theme/cfwl_carettp.cpp
index 06df3f51e4..4a04f869f4 100644
--- a/xfa/fwl/theme/cfwl_carettp.cpp
+++ b/xfa/fwl/theme/cfwl_carettp.cpp
@@ -40,7 +40,6 @@ void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics,
CFX_Color* crFill,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
CFX_RectF rect = *pRect;
path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
if (crFill) {
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp
index 7876b71db5..1d185b4c33 100644
--- a/xfa/fwl/theme/cfwl_checkboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -79,7 +79,6 @@ void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics* pGraphics,
FX_ARGB argbFill,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
path.AddEllipse(*pRtSign);
CFX_Color crFill(argbFill);
pGraphics->SaveGraphState();
@@ -93,8 +92,6 @@ void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics,
FX_ARGB argbFill,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
FX_FLOAT fRight = pRtSign->right();
FX_FLOAT fBottom = pRtSign->bottom();
path.AddLine(pRtSign->TopLeft(), CFX_PointF(fRight, fBottom));
@@ -114,8 +111,6 @@ void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics,
FX_ARGB argbFill,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
FX_FLOAT fWidth = pRtSign->width;
FX_FLOAT fHeight = pRtSign->height;
FX_FLOAT fBottom = pRtSign->bottom();
@@ -137,7 +132,6 @@ void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics* pGraphics,
FX_ARGB argbFill,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width,
pRtSign->height);
CFX_Color crFill(argbFill);
@@ -152,8 +146,6 @@ void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics,
FX_ARGB argbFill,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
FX_FLOAT fBottom = pRtSign->bottom();
FX_FLOAT fRadius =
(pRtSign->top - fBottom) / (1 + static_cast<FX_FLOAT>(cos(FX_PI / 5.0f)));
@@ -227,7 +219,6 @@ void CFWL_CheckBoxTP::SetThemeData() {
void CFWL_CheckBoxTP::InitCheckPath(FX_FLOAT fCheckLen) {
if (!m_pCheckPath) {
m_pCheckPath = pdfium::MakeUnique<CFX_Path>();
- m_pCheckPath->Create();
FX_FLOAT fWidth = kSignPath;
FX_FLOAT fHeight = -kSignPath;
@@ -275,8 +266,7 @@ void CFWL_CheckBoxTP::InitCheckPath(FX_FLOAT fCheckLen) {
CFX_Matrix mt(1, 0, 0, 1, 0, 0);
mt.Scale(fScale, fScale);
- CFX_PathData* pData = m_pCheckPath->GetPathData();
- pData->Transform(&mt);
+ m_pCheckPath->TransformBy(mt);
}
}
diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp
index 567cb2ec2b..53a6eae722 100644
--- a/xfa/fwl/theme/cfwl_comboboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp
@@ -28,7 +28,6 @@ void CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
case CFWL_Part::Background: {
CFX_Path path;
- path.Create();
CFX_RectF& rect = pParams->m_rtPart;
path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
FX_ARGB argb_color;
@@ -66,7 +65,6 @@ void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams,
uint32_t dwStates,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top,
pParams->m_rtPart.width - 1, pParams->m_rtPart.height);
CFX_Color cr(ArgbEncode(0xff, 0xff, 0, 0));
diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp
index eee5423201..43160177d7 100644
--- a/xfa/fwl/theme/cfwl_edittp.cpp
+++ b/xfa/fwl/theme/cfwl_edittp.cpp
@@ -53,7 +53,6 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
pGraphics->RestoreGraphState();
} else {
CFX_Path path;
- path.Create();
path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top,
pParams->m_rtPart.width, pParams->m_rtPart.height);
CFX_Color cr(FWLTHEME_COLOR_Background);
diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp
index 7a9ba92bee..4e00420df5 100644
--- a/xfa/fwl/theme/cfwl_listboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_listboxtp.cpp
@@ -70,7 +70,6 @@ void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics,
pGraphics->SetFillColor(&crFill);
CFX_RectF rt(*prtItem);
CFX_Path path;
- path.Create();
#if (_FX_OS_ == _FX_MACOSX_)
path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1);
#else
diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp
index cf6306a53f..b14109d013 100644
--- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp
+++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp
@@ -105,8 +105,6 @@ void CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) {
void CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
CFX_RectF rtTotal(pParams->m_rtPart);
path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height);
pParams->m_pGraphics->SaveGraphState();
@@ -120,8 +118,6 @@ void CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
CFX_RectF rtHead = pParams->m_rtPart;
path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height);
pParams->m_pGraphics->SaveGraphState();
@@ -135,8 +131,6 @@ void CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
CFX_RectF rtLBtn = pParams->m_rtPart;
path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height);
pParams->m_pGraphics->SaveGraphState();
@@ -171,8 +165,6 @@ void CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
CFX_RectF rtRBtn = pParams->m_rtPart;
path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height);
pParams->m_pGraphics->SaveGraphState();
@@ -207,7 +199,6 @@ void CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
CFX_RectF rtHSep = pParams->m_rtPart;
path.MoveTo(CFX_PointF(rtHSep.left, rtHSep.top + rtHSep.height / 2));
path.LineTo(CFX_PointF(rtHSep.right(), rtHSep.top + rtHSep.height / 2));
@@ -222,7 +213,6 @@ void CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
CFX_RectF rtWeekSep = pParams->m_rtPart;
path.MoveTo(rtWeekSep.TopLeft());
path.LineTo(rtWeekSep.BottomLeft());
@@ -239,7 +229,6 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams,
pParams->m_pGraphics->SaveGraphState();
if (pParams->m_dwStates & CFWL_PartState_Selected) {
CFX_Path path;
- path.Create();
CFX_RectF rtSelDay = pParams->m_rtPart;
path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
rtSelDay.height);
@@ -248,7 +237,6 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams,
pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
} else if (pParams->m_dwStates & CFWL_PartState_Hovered) {
CFX_Path path;
- path.Create();
CFX_RectF rtSelDay = pParams->m_rtPart;
path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
rtSelDay.height);
@@ -262,7 +250,6 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
CFX_RectF rtSelDay = pParams->m_rtPart;
path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
rtSelDay.height);
@@ -276,7 +263,6 @@ void CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams,
void CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
CFX_RectF rtTodayCircle = pParams->m_rtPart;
path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width,
rtTodayCircle.height);
diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp
index ba7b2ca506..56268a8507 100644
--- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp
+++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp
@@ -33,7 +33,6 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
FX_FLOAT fBottom = rect.bottom();
CFX_Path strokePath;
- strokePath.Create();
strokePath.MoveTo(
CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, rect.top));
strokePath.LineTo(CFX_PointF(fRight - PUSHBUTTON_SIZE_Corner, rect.top));
@@ -50,7 +49,6 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, rect.top));
CFX_Path fillPath;
- fillPath.Create();
fillPath.AddSubpath(&strokePath);
CFX_Graphics* pGraphics = pParams->m_pGraphics;
diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp
index 5f8f7dcd49..121d4dea34 100644
--- a/xfa/fwl/theme/cfwl_scrollbartp.cpp
+++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp
@@ -81,7 +81,6 @@ void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics,
return;
CFX_Path path;
- path.Create();
CFX_RectF rect(*pRect);
if (bVert) {
rect.Deflate(1, 0);
@@ -124,7 +123,6 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics,
FWLTHEME_STATE eState,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
if (bVert) {
FX_FLOAT fPawLen = kPawLength;
if (pRect->width / 2 <= fPawLen) {
@@ -214,7 +212,6 @@ void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics,
pGraphics->SaveGraphState();
CFX_Color colorLine(ArgbEncode(255, 238, 237, 229));
CFX_Path path;
- path.Create();
FX_FLOAT fRight = pRect->right();
FX_FLOAT fBottom = pRect->bottom();
if (bVert) {
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index d7d98cd76f..fbcbcffb85 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -104,7 +104,6 @@ void CFWL_WidgetTP::DrawBorder(CFX_Graphics* pGraphics,
if (!pRect)
return;
CFX_Path path;
- path.Create();
path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2,
pRect->height - 2);
@@ -133,7 +132,6 @@ void CFWL_WidgetTP::FillSoildRect(CFX_Graphics* pGraphics,
CFX_Color crFill(fillColor);
pGraphics->SetFillColor(&crFill);
CFX_Path path;
- path.Create();
path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
pGraphics->RestoreGraphState();
@@ -175,7 +173,6 @@ void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics,
FX_FLOAT DashPattern[2] = {1, 1};
pGraphics->SetLineDash(0.0f, DashPattern, 2);
CFX_Path path;
- path.Create();
path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
pGraphics->StrokePath(&path, pMatrix);
pGraphics->RestoreGraphState();
@@ -193,7 +190,6 @@ void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics,
FX_FLOAT fTop =
(FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5);
CFX_Path path;
- path.Create();
switch (eDict) {
case FWLTHEME_DIRECTION_Down: {
path.MoveTo(CFX_PointF(fLeft, fTop + 1));
@@ -242,8 +238,6 @@ void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics,
FWLTHEME_STATE eState,
CFX_Matrix* pMatrix) {
CFX_Path path;
- path.Create();
-
InitializeArrowColorData();
FX_FLOAT fRight = pRect->right();
diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp
index 0c8d8c1b5f..630d04311f 100644
--- a/xfa/fxfa/app/xfa_fffield.cpp
+++ b/xfa/fxfa/app/xfa_fffield.cpp
@@ -82,12 +82,11 @@ void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS,
CFX_Color crHighlight(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc));
pGS->SetFillColor(&crHighlight);
CFX_Path path;
- path.Create();
- if (bEllipse) {
+ if (bEllipse)
path.AddEllipse(m_rtUI);
- } else {
+ else
path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height);
- }
+
pGS->FillPath(&path, FXFILL_WINDING, pMatrix);
}
}
@@ -100,7 +99,6 @@ void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) {
pGS->SetLineWidth(0, false);
CFX_Path path;
- path.Create();
path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height);
pGS->StrokePath(&path, pMatrix);
}
diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp
index feea7bf00b..43016fe5c6 100644
--- a/xfa/fxfa/app/xfa_ffpath.cpp
+++ b/xfa/fxfa/app/xfa_ffpath.cpp
@@ -87,7 +87,6 @@ void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS,
GetRectFromHand(rtLine, lineObj.GetHand(), fLineWidth);
CFX_Path linePath;
- linePath.Create();
if (lineObj.GetSlope() && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f)
linePath.AddLine(rtLine.TopRight(), rtLine.BottomLeft());
else
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index 9c05083bb0..7b6be82035 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -214,8 +214,8 @@ void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics,
rtFill.Deflate(fLineWith, fLineWith);
CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255));
pGraphics->SetFillColor(&cr);
+
CFX_Path path;
- path.Create();
path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height);
pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix);
}
@@ -227,9 +227,8 @@ void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics,
CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255));
pGraphics->SetStrokeColor(&cr);
pGraphics->SetLineWidth(fLineWidth);
- CFX_Path path;
- path.Create();
+ CFX_Path path;
CFX_RectF rect = m_pNormalWidget->GetWidgetRect();
path.AddRectangle(0, 0, rect.width, rect.height);
pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix);
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 0f47dffa22..e0c70a51e5 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -1635,12 +1635,11 @@ static void XFA_BOX_Fill(CXFA_Box box,
CFX_Matrix* pMatrix,
uint32_t dwFlags) {
CXFA_Fill fill = box.GetFill();
- if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) {
+ if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
return;
- }
+
pGS->SaveGraphState();
CFX_Path fillPath;
- fillPath.Create();
XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath,
(dwFlags & XFA_DRAWBOX_ForceRound) != 0);
fillPath.Close();
@@ -1729,11 +1728,10 @@ static void XFA_BOX_StrokeArc(CXFA_Box box,
}
if ((dwFlags & XFA_DRAWBOX_ForceRound) == 0 ||
(dwFlags & XFA_DRAWBOX_Lowered3D) == 0) {
- if (fHalf < 0.001f) {
+ if (fHalf < 0.001f)
return;
- }
+
CFX_Path arcPath;
- arcPath.Create();
XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags);
XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix);
return;
@@ -1760,7 +1758,6 @@ static void XFA_BOX_StrokeArc(CXFA_Box box,
sweepAngle = -sweepAngle * FX_PI / 180.0f;
CFX_Path arcPath;
- arcPath.Create();
arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f,
FX_PI);
@@ -1802,7 +1799,6 @@ static void XFA_Draw3DRect(CFX_Graphics* pGraphic,
FX_FLOAT fBottom = rt.bottom();
FX_FLOAT fRight = rt.right();
CFX_Path pathLT;
- pathLT.Create();
pathLT.MoveTo(CFX_PointF(rt.left, fBottom));
pathLT.LineTo(CFX_PointF(rt.left, rt.top));
pathLT.LineTo(CFX_PointF(fRight, rt.top));
@@ -1816,7 +1812,6 @@ static void XFA_Draw3DRect(CFX_Graphics* pGraphic,
pGraphic->SetFillColor(&crRB);
CFX_Path pathRB;
- pathRB.Create();
pathRB.MoveTo(CFX_PointF(fRight, rt.top));
pathRB.LineTo(CFX_PointF(fRight, fBottom));
pathRB.LineTo(CFX_PointF(rt.left, fBottom));
@@ -1836,7 +1831,6 @@ static void XFA_BOX_Stroke_3DRect_Lowered(CFX_Graphics* pGS,
CFX_Color cr(0xFF000000);
pGS->SetFillColor(&cr);
CFX_Path path;
- path.Create();
path.AddRectangle(rt.left, rt.top, rt.width, rt.height);
path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
@@ -1852,7 +1846,6 @@ static void XFA_BOX_Stroke_3DRect_Raised(CFX_Graphics* pGS,
CFX_Color cr(0xFF000000);
pGS->SetFillColor(&cr);
CFX_Path path;
- path.Create();
path.AddRectangle(rt.left, rt.top, rt.width, rt.height);
path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
@@ -1931,17 +1924,14 @@ static void XFA_BOX_Stroke_Rect(CXFA_Box box,
}
if (bSameStyles) {
stroke1 = strokes[0];
- if (stroke1.IsInverted()) {
+ if (stroke1.IsInverted())
bSameStyles = false;
- }
- if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) {
+ if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square)
bSameStyles = false;
- }
}
}
bool bStart = true;
CFX_Path path;
- path.Create();
for (int32_t i = 0; i < 8; i++) {
CXFA_Stroke stroke = strokes[i];
if ((i % 1) == 0 && stroke.GetRadius() < 0) {
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 2b8bd17aad..d47c261868 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -16,7 +16,6 @@
#include "xfa/fxgraphics/cagg_graphics.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#include "xfa/fxgraphics/cfx_path_generator.h"
#include "xfa/fxgraphics/cfx_pattern.h"
#include "xfa/fxgraphics/cfx_shading.h"
diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp
index 3072df2475..d56eb13f67 100644
--- a/xfa/fxgraphics/cfx_path.cpp
+++ b/xfa/fxgraphics/cfx_path.cpp
@@ -8,155 +8,144 @@
#include "core/fxge/cfx_pathdata.h"
#include "third_party/base/ptr_util.h"
-#include "xfa/fxgraphics/cfx_path_generator.h"
CFX_Path::CFX_Path() {}
-FWL_Error CFX_Path::Create() {
- if (m_generator)
- return FWL_Error::PropertyInvalid;
-
- m_generator = pdfium::MakeUnique<CFX_PathGenerator>();
- return FWL_Error::Succeeded;
-}
-
CFX_Path::~CFX_Path() {}
-FWL_Error CFX_Path::MoveTo(const CFX_PointF& point) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->MoveTo(point);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::LineTo(const CFX_PointF& point) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->LineTo(point);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->BezierTo(c1, c2, to);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::ArcTo(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2.0f;
- m_generator->ArcTo(CFX_PointF(pos.x + newSize.width, pos.y + newSize.height),
- newSize, startAngle, sweepAngle);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::Close() {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->Close();
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddLine(p1, p2);
- return FWL_Error::Succeeded;
+void CFX_Path::Clear() {
+ data_.Clear();
}
-FWL_Error CFX_Path::AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddBezier(p1, c1, c2, p2);
- return FWL_Error::Succeeded;
+void CFX_Path::Close() {
+ data_.ClosePath();
}
-FWL_Error CFX_Path::AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddRectangle(left, top, left + width, top + height);
- return FWL_Error::Succeeded;
+void CFX_Path::MoveTo(const CFX_PointF& point) {
+ data_.AppendPoint(point, FXPT_TYPE::MoveTo, false);
}
-FWL_Error CFX_Path::AddEllipse(const CFX_PointF& pos, const CFX_SizeF& size) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2.0f;
- m_generator->AddEllipse(
- CFX_PointF(pos.x + newSize.width, pos.y + newSize.height), newSize);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddEllipse(const CFX_RectF& rect) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddEllipse(
- CFX_PointF(rect.left + rect.Width() / 2, rect.top + rect.Height() / 2),
- CFX_SizeF(rect.Width() / 2, rect.Height() / 2));
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddArc(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2;
- m_generator->AddArc(CFX_PointF(pos.x + newSize.width, pos.y + newSize.height),
- newSize, startAngle, sweepAngle);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddPie(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2;
- m_generator->AddPie(CFX_PointF(pos.x + newSize.width, pos.y + newSize.height),
- newSize, startAngle, sweepAngle);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddSubpath(CFX_Path* path) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddPathData(path->GetPathData());
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::Clear() {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->GetPathData()->Clear();
- return FWL_Error::Succeeded;
-}
-
-bool CFX_Path::IsEmpty() const {
- if (!m_generator)
- return false;
- if (m_generator->GetPathData()->GetPoints().empty())
- return true;
- return false;
-}
+void CFX_Path::LineTo(const CFX_PointF& point) {
+ data_.AppendPoint(point, FXPT_TYPE::LineTo, false);
+}
+
+void CFX_Path::BezierTo(const CFX_PointF& c1,
+ const CFX_PointF& c2,
+ const CFX_PointF& to) {
+ data_.AppendPoint(c1, FXPT_TYPE::BezierTo, false);
+ data_.AppendPoint(c2, FXPT_TYPE::BezierTo, false);
+ data_.AppendPoint(to, FXPT_TYPE::BezierTo, false);
+}
+
+void CFX_Path::ArcTo(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle) {
+ CFX_SizeF new_size = size / 2.0f;
+ ArcToInternal(CFX_PointF(pos.x + new_size.width, pos.y + new_size.height),
+ new_size, start_angle, sweep_angle);
+}
-CFX_PathData* CFX_Path::GetPathData() const {
- if (!m_generator)
- return nullptr;
- return m_generator->GetPathData();
+void CFX_Path::ArcToInternal(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle) {
+ FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2);
+ FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2);
+ FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f);
+ FX_FLOAT ty = y0 - ((tx * x0) / y0);
+
+ CFX_PointF points[] = {CFX_PointF(x0 + tx, -ty), CFX_PointF(x0 + tx, ty)};
+ FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2);
+ FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2);
+
+ CFX_PointF bezier;
+ bezier.x = pos.x + (size.width * ((points[0].x * cs) - (points[0].y * sn)));
+ bezier.y = pos.y + (size.height * ((points[0].x * sn) + (points[0].y * cs)));
+ data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
+
+ bezier.x = pos.x + (size.width * ((points[1].x * cs) - (points[1].y * sn)));
+ bezier.y = pos.y + (size.height * ((points[1].x * sn) + (points[1].y * cs)));
+ data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
+
+ bezier.x = pos.x + (size.width * FXSYS_cos(start_angle + sweep_angle));
+ bezier.y = pos.y + (size.height * FXSYS_sin(start_angle + sweep_angle));
+ data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
+}
+
+void CFX_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
+ data_.AppendPoint(p1, FXPT_TYPE::MoveTo, false);
+ data_.AppendPoint(p2, FXPT_TYPE::LineTo, false);
+}
+
+void CFX_Path::AddRectangle(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height) {
+ data_.AppendRect(left, top, left + width, top + height);
+}
+
+void CFX_Path::AddEllipse(const CFX_RectF& rect) {
+ AddArc(rect.TopLeft(), rect.Size(), 0, FX_PI * 2);
+}
+
+void CFX_Path::AddArc(const CFX_PointF& original_pos,
+ const CFX_SizeF& original_size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle) {
+ if (sweep_angle == 0)
+ return;
+
+ const FX_FLOAT bezier_arc_angle_epsilon = 0.01f;
+ while (start_angle > FX_PI * 2)
+ start_angle -= FX_PI * 2;
+ while (start_angle < 0)
+ start_angle += FX_PI * 2;
+ if (sweep_angle >= FX_PI * 2)
+ sweep_angle = FX_PI * 2;
+ if (sweep_angle <= -FX_PI * 2)
+ sweep_angle = -FX_PI * 2;
+
+ CFX_SizeF size = original_size / 2;
+ CFX_PointF pos(original_pos.x + size.width, original_pos.y + size.height);
+ data_.AppendPoint(pos + CFX_PointF(size.width * FXSYS_cos(start_angle),
+ size.height * FXSYS_sin(start_angle)),
+ FXPT_TYPE::MoveTo, false);
+
+ FX_FLOAT total_sweep = 0;
+ FX_FLOAT local_sweep = 0;
+ FX_FLOAT prev_sweep = 0;
+ bool done = false;
+ do {
+ if (sweep_angle < 0) {
+ prev_sweep = total_sweep;
+ local_sweep = -FX_PI / 2;
+ total_sweep -= FX_PI / 2;
+ if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) {
+ local_sweep = sweep_angle - prev_sweep;
+ done = true;
+ }
+ } else {
+ prev_sweep = total_sweep;
+ local_sweep = FX_PI / 2;
+ total_sweep += FX_PI / 2;
+ if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) {
+ local_sweep = sweep_angle - prev_sweep;
+ done = true;
+ }
+ }
+
+ ArcToInternal(pos, size, start_angle, local_sweep);
+ start_angle += local_sweep;
+ } while (!done);
+}
+
+void CFX_Path::AddSubpath(CFX_Path* path) {
+ if (!path)
+ return;
+ data_.Append(&path->data_, nullptr);
+}
+
+void CFX_Path::TransformBy(const CFX_Matrix& mt) {
+ data_.Transform(&mt);
}
diff --git a/xfa/fxgraphics/cfx_path.h b/xfa/fxgraphics/cfx_path.h
index 1dee566788..267831603a 100644
--- a/xfa/fxgraphics/cfx_path.h
+++ b/xfa/fxgraphics/cfx_path.h
@@ -7,58 +7,52 @@
#ifndef XFA_FXGRAPHICS_CFX_PATH_H_
#define XFA_FXGRAPHICS_CFX_PATH_H_
-#include <memory>
-
#include "core/fxcrt/fx_system.h"
+#include "core/fxge/cfx_pathdata.h"
#include "xfa/fxgraphics/cfx_graphics.h"
-class CFX_PathData;
-class CFX_PathGenerator;
-
class CFX_Path final {
public:
CFX_Path();
~CFX_Path();
- FWL_Error Create();
- FWL_Error MoveTo(const CFX_PointF& point);
- FWL_Error LineTo(const CFX_PointF& point);
- FWL_Error BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to);
- FWL_Error ArcTo(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FWL_Error Close();
-
- FWL_Error AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
- FWL_Error AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2);
- FWL_Error AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height);
- FWL_Error AddEllipse(const CFX_PointF& pos, const CFX_SizeF& size);
- FWL_Error AddEllipse(const CFX_RectF& rect);
- FWL_Error AddArc(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FWL_Error AddPie(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FWL_Error AddSubpath(CFX_Path* path);
- FWL_Error Clear();
-
- bool IsEmpty() const;
- CFX_PathData* GetPathData() const;
+ const CFX_PathData* GetPathData() const { return &data_; }
+
+ void Clear();
+ bool IsEmpty() const { return data_.GetPoints().empty(); }
+ void TransformBy(const CFX_Matrix& mt);
+
+ void Close();
+ void MoveTo(const CFX_PointF& point);
+ void LineTo(const CFX_PointF& point);
+ void BezierTo(const CFX_PointF& c1,
+ const CFX_PointF& c2,
+ const CFX_PointF& to);
+ void ArcTo(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+
+ void AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
+ void AddRectangle(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height);
+ void AddEllipse(const CFX_RectF& rect);
+ void AddArc(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+
+ void AddSubpath(CFX_Path* path);
private:
- std::unique_ptr<CFX_PathGenerator> m_generator;
+ void ArcToInternal(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle);
+
+ CFX_PathData data_;
};
#endif // XFA_FXGRAPHICS_CFX_PATH_H_
diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp
deleted file mode 100644
index ab3d9d631a..0000000000
--- a/xfa/fxgraphics/cfx_path_generator.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxgraphics/cfx_path_generator.h"
-
-#include "core/fxge/cfx_pathdata.h"
-#include "core/fxge/cfx_renderdevice.h"
-
-CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(new CFX_PathData) {}
-
-CFX_PathGenerator::~CFX_PathGenerator() {}
-
-void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) {
- if (!pPathData)
- return;
- m_pPathData->Append(pPathData, nullptr);
-}
-
-void CFX_PathGenerator::MoveTo(const CFX_PointF& point) {
- m_pPathData->AppendPoint(point, FXPT_TYPE::MoveTo, false);
-}
-
-void CFX_PathGenerator::LineTo(const CFX_PointF& point) {
- m_pPathData->AppendPoint(point, FXPT_TYPE::LineTo, false);
-}
-
-void CFX_PathGenerator::BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to) {
- m_pPathData->AppendPoint(c1, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(c2, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(to, FXPT_TYPE::BezierTo, false);
-}
-
-void CFX_PathGenerator::Close() {
- m_pPathData->ClosePath();
-}
-
-void CFX_PathGenerator::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
- m_pPathData->AppendPoint(p1, FXPT_TYPE::MoveTo, false);
- m_pPathData->AppendPoint(p2, FXPT_TYPE::LineTo, false);
-}
-
-void CFX_PathGenerator::AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2) {
- m_pPathData->AppendPoint(p1, FXPT_TYPE::MoveTo, false);
- m_pPathData->AppendPoint(c1, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(c2, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(p2, FXPT_TYPE::BezierTo, false);
-}
-
-void CFX_PathGenerator::AddRectangle(FX_FLOAT x1,
- FX_FLOAT y1,
- FX_FLOAT x2,
- FX_FLOAT y2) {
- m_pPathData->AppendRect(x1, y1, x2, y2);
-}
-
-void CFX_PathGenerator::AddEllipse(const CFX_PointF& pos,
- const CFX_SizeF& size) {
- AddArc(pos, size, 0, FX_PI * 2);
-}
-
-void CFX_PathGenerator::ArcTo(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2);
- FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2);
- FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f);
- FX_FLOAT ty = y0 - ((tx * x0) / y0);
- FX_FLOAT px[3], py[3];
- px[0] = x0 + tx;
- py[0] = -ty;
- px[1] = x0 + tx;
- py[1] = ty;
- FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2);
- FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2);
-
- CFX_PointF bezier;
- bezier.x = pos.x + (size.width * ((px[0] * cs) - (py[0] * sn)));
- bezier.y = pos.y + (size.height * ((px[0] * sn) + (py[0] * cs)));
- m_pPathData->AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
-
- bezier.x = pos.x + (size.width * ((px[1] * cs) - (py[1] * sn)));
- bezier.y = pos.y + (size.height * ((px[1] * sn) + (py[1] * cs)));
- m_pPathData->AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
-
- bezier.x = pos.x + (size.width * FXSYS_cos(start_angle + sweep_angle));
- bezier.y = pos.y + (size.height * FXSYS_sin(start_angle + sweep_angle));
- m_pPathData->AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
-}
-
-void CFX_PathGenerator::AddArc(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- if (sweep_angle == 0)
- return;
-
- const FX_FLOAT bezier_arc_angle_epsilon = 0.01f;
- while (start_angle > FX_PI * 2)
- start_angle -= FX_PI * 2;
- while (start_angle < 0)
- start_angle += FX_PI * 2;
- if (sweep_angle >= FX_PI * 2)
- sweep_angle = FX_PI * 2;
- if (sweep_angle <= -FX_PI * 2)
- sweep_angle = -FX_PI * 2;
-
- m_pPathData->AppendPoint(
- pos + CFX_PointF(size.width * FXSYS_cos(start_angle),
- size.height * FXSYS_sin(start_angle)),
- FXPT_TYPE::MoveTo, false);
-
- FX_FLOAT total_sweep = 0;
- FX_FLOAT local_sweep = 0;
- FX_FLOAT prev_sweep = 0;
- bool done = false;
- do {
- if (sweep_angle < 0) {
- prev_sweep = total_sweep;
- local_sweep = -FX_PI / 2;
- total_sweep -= FX_PI / 2;
- if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) {
- local_sweep = sweep_angle - prev_sweep;
- done = true;
- }
- } else {
- prev_sweep = total_sweep;
- local_sweep = FX_PI / 2;
- total_sweep += FX_PI / 2;
- if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) {
- local_sweep = sweep_angle - prev_sweep;
- done = true;
- }
- }
-
- ArcTo(pos, size, start_angle, local_sweep);
- start_angle += local_sweep;
- } while (!done);
-}
-
-void CFX_PathGenerator::AddPie(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- if (sweep_angle == 0) {
- m_pPathData->AppendPoint(pos, FXPT_TYPE::MoveTo, false);
- m_pPathData->AppendPoint(
- pos + CFX_PointF(size.width * FXSYS_cos(start_angle),
- size.height * FXSYS_sin(start_angle)),
- FXPT_TYPE::LineTo, false);
- return;
- }
-
- AddArc(pos, size, start_angle, sweep_angle);
- m_pPathData->AppendPoint(pos, FXPT_TYPE::LineTo, true);
-}
diff --git a/xfa/fxgraphics/cfx_path_generator.h b/xfa/fxgraphics/cfx_path_generator.h
deleted file mode 100644
index d3ba290f1c..0000000000
--- a/xfa/fxgraphics/cfx_path_generator.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_
-#define XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_
-
-#include <memory>
-
-#include "core/fxge/cfx_pathdata.h"
-
-class CFX_PathGenerator {
- public:
- CFX_PathGenerator();
- ~CFX_PathGenerator();
-
- CFX_PathData* GetPathData() const { return m_pPathData.get(); }
-
- void AddPathData(CFX_PathData* path_data);
-
- void MoveTo(const CFX_PointF& point);
- void LineTo(const CFX_PointF& point);
- void BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to);
- void Close();
- void ArcTo(const CFX_PointF& point,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
-
- void AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
- void AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2);
- void AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
- void AddEllipse(const CFX_PointF& point, const CFX_SizeF& size);
- void AddArc(const CFX_PointF& point,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
- void AddPie(const CFX_PointF& point,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
-
- protected:
- std::unique_ptr<CFX_PathData> m_pPathData;
-};
-
-#endif // XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_