diff options
author | dan sinclair <dsinclair@chromium.org> | 2017-02-22 19:56:15 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-23 01:17:40 +0000 |
commit | b147e07ee36be10ca0796a6566be107077c21a03 (patch) | |
tree | 637b1b206000a88fb3e198f648e86a9ee5178f1b /xfa | |
parent | e3f237740fd8bea50b4a6f37f56455dfa0328546 (diff) | |
download | pdfium-b147e07ee36be10ca0796a6566be107077c21a03.tar.xz |
Convert point x,y into CFX_PointF
This Cl converts the PointX,PointY pairs into a CFX_PointF.
Change-Id: I46897832077c317a5bffb4e568550705decbc40c
Reviewed-on: https://pdfium-review.googlesource.com/2821
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fde/cfde_path.cpp | 21 | ||||
-rw-r--r-- | xfa/fde/cfde_path.h | 6 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 7 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_checkboxtp.cpp | 100 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_monthcalendartp.cpp | 44 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_pushbuttontp.cpp | 31 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_scrollbartp.cpp | 72 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_widgettp.cpp | 48 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffpath.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidget.cpp | 131 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path.cpp | 90 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path.h | 50 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path_generator.cpp | 144 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path_generator.h | 47 |
14 files changed, 392 insertions, 403 deletions
diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp index 0418513972..5e6cf5cf56 100644 --- a/xfa/fde/cfde_path.cpp +++ b/xfa/fde/cfde_path.cpp @@ -18,20 +18,20 @@ bool CFDE_Path::FigureClosed() const { return points.empty() ? true : points.back().m_CloseFigure; } -void CFDE_Path::MoveTo(FX_FLOAT fx, FX_FLOAT fy) { - m_Path.AppendPoint(fx, fy, FXPT_TYPE::MoveTo, false); +void CFDE_Path::MoveTo(const CFX_PointF& point) { + m_Path.AppendPoint(point, FXPT_TYPE::MoveTo, false); } -void CFDE_Path::LineTo(FX_FLOAT fx, FX_FLOAT fy) { - m_Path.AppendPoint(fx, fy, FXPT_TYPE::LineTo, false); +void CFDE_Path::LineTo(const CFX_PointF& point) { + m_Path.AppendPoint(point, FXPT_TYPE::LineTo, false); } void CFDE_Path::BezierTo(const CFX_PointF& p1, const CFX_PointF& p2, const CFX_PointF& p3) { - m_Path.AppendPoint(p1.x, p1.y, FXPT_TYPE::BezierTo, false); - m_Path.AppendPoint(p2.x, p2.y, FXPT_TYPE::BezierTo, false); - m_Path.AppendPoint(p3.x, p3.y, FXPT_TYPE::BezierTo, false); + m_Path.AppendPoint(p1, FXPT_TYPE::BezierTo, false); + m_Path.AppendPoint(p2, FXPT_TYPE::BezierTo, false); + m_Path.AppendPoint(p3, FXPT_TYPE::BezierTo, false); } void CFDE_Path::ArcTo(bool bStart, @@ -52,6 +52,7 @@ void CFDE_Path::ArcTo(bool bStart, else alpha -= 2 * FX_PI; } + FX_FLOAT half_delta = (beta - alpha) / 2; FX_FLOAT bcp = 4.0f / 3 * (1 - FXSYS_cos(half_delta)) / FXSYS_sin(half_delta); FX_FLOAT sin_alpha = FXSYS_sin(alpha); @@ -155,8 +156,8 @@ void CFDE_Path::AddEllipse(const CFX_RectF& rect) { void CFDE_Path::AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) { std::vector<FX_PATHPOINT>& points = m_Path.GetPoints(); - if (points.empty() || FXSYS_fabs(points.back().m_PointX - pt1.x) > 0.001 || - FXSYS_fabs(points.back().m_PointY - pt1.y) > 0.001) { + if (points.empty() || FXSYS_fabs(points.back().m_Point.x - pt1.x) > 0.001 || + FXSYS_fabs(points.back().m_Point.y - pt1.y) > 0.001) { MoveTo(pt1); } LineTo(pt2); @@ -169,7 +170,7 @@ void CFDE_Path::AddPath(const CFDE_Path* pSrc, bool bConnect) { if (pSrc->m_Path.GetPoints().empty()) return; if (bConnect) - LineTo(pSrc->m_Path.GetPointX(0), pSrc->m_Path.GetPointY(0)); + LineTo(pSrc->m_Path.GetPoint(0)); m_Path.Append(&pSrc->m_Path, nullptr); } diff --git a/xfa/fde/cfde_path.h b/xfa/fde/cfde_path.h index a3a81805bf..99ff4d3680 100644 --- a/xfa/fde/cfde_path.h +++ b/xfa/fde/cfde_path.h @@ -32,8 +32,6 @@ class CFDE_Path { CFX_RectF GetBBox(FX_FLOAT fLineWidth, FX_FLOAT fMiterLimit) const; bool FigureClosed() const; - void MoveTo(FX_FLOAT fx, FX_FLOAT fy); - void LineTo(FX_FLOAT fx, FX_FLOAT fy); void BezierTo(const CFX_PointF& p1, const CFX_PointF& p2, const CFX_PointF& p3); @@ -41,8 +39,8 @@ class CFDE_Path { const CFX_RectF& rect, FX_FLOAT startAngle, FX_FLOAT endAngle); - void MoveTo(const CFX_PointF& p0) { MoveTo(p0.x, p0.y); } - void LineTo(const CFX_PointF& p1) { LineTo(p1.x, p1.y); } + void MoveTo(const CFX_PointF& p); + void LineTo(const CFX_PointF& p); void GetCurveTangents(const std::vector<CFX_PointF>& points, std::vector<CFX_PointF>* tangents, diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 35a83f9da5..d343090647 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -49,10 +49,10 @@ void AddSquigglyPath(CFX_Path* pPathData, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep) { - pPathData->MoveTo(fStartX, fY); + pPathData->MoveTo(CFX_PointF(fStartX, fY)); int i = 1; for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) - pPathData->LineTo(fx, fY + (i & 1) * fStep); + pPathData->LineTo(CFX_PointF(fx, fY + (i & 1) * fStep)); } } // namespace @@ -587,7 +587,8 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics, FX_FLOAT fLeft = m_rtEngine.left + 1; for (int32_t i = 1; i < iLimit; i++) { fLeft += fStep; - path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom()); + path.AddLine(CFX_PointF(fLeft, m_rtClient.top), + CFX_PointF(fLeft, m_rtClient.bottom())); } CFWL_ThemeBackground param; diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index 052b9c1638..7876b71db5 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -94,10 +94,13 @@ void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); + FX_FLOAT fRight = pRtSign->right(); FX_FLOAT fBottom = pRtSign->bottom(); - path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom); - path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top); + path.AddLine(pRtSign->TopLeft(), CFX_PointF(fRight, fBottom)); + path.AddLine(CFX_PointF(pRtSign->left, fBottom), + CFX_PointF(fRight, pRtSign->top)); + CFX_Color crFill(argbFill); pGraphics->SaveGraphState(); pGraphics->SetStrokeColor(&crFill); @@ -112,14 +115,16 @@ void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); + FX_FLOAT fWidth = pRtSign->width; FX_FLOAT fHeight = pRtSign->height; FX_FLOAT fBottom = pRtSign->bottom(); - path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top); - path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2); - path.LineTo(pRtSign->left + fWidth / 2, fBottom); - path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2); - path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top); + path.MoveTo(CFX_PointF(pRtSign->left + fWidth / 2, pRtSign->top)); + path.LineTo(CFX_PointF(pRtSign->left, pRtSign->top + fHeight / 2)); + path.LineTo(CFX_PointF(pRtSign->left + fWidth / 2, fBottom)); + path.LineTo(CFX_PointF(pRtSign->right(), pRtSign->top + fHeight / 2)); + path.LineTo(CFX_PointF(pRtSign->left + fWidth / 2, pRtSign->top)); + CFX_Color crFill(argbFill); pGraphics->SaveGraphState(); pGraphics->SetFillColor(&crFill); @@ -148,27 +153,32 @@ void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); + FX_FLOAT fBottom = pRtSign->bottom(); FX_FLOAT fRadius = - (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); + (pRtSign->top - fBottom) / (1 + static_cast<FX_FLOAT>(cos(FX_PI / 5.0f))); CFX_PointF ptCenter((pRtSign->left + pRtSign->right()) / 2.0f, (pRtSign->top + fBottom) / 2.0f); - FX_FLOAT px[5], py[5]; + + CFX_PointF points[5]; FX_FLOAT fAngel = FX_PI / 10.0f; for (int32_t i = 0; i < 5; i++) { - px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); - py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); + points[i] = + ptCenter + CFX_PointF(fRadius * static_cast<FX_FLOAT>(cos(fAngel)), + fRadius * static_cast<FX_FLOAT>(sin(fAngel))); fAngel += FX_PI * 2 / 5.0f; } - path.MoveTo(px[0], py[0]); + + path.MoveTo(points[0]); int32_t nNext = 0; for (int32_t j = 0; j < 5; j++) { nNext += 2; - if (nNext >= 5) { + if (nNext >= 5) nNext -= 5; - } - path.LineTo(px[nNext], py[nNext]); + + path.LineTo(points[nNext]); } + CFX_Color crFill(argbFill); pGraphics->SaveGraphState(); pGraphics->SetFillColor(&crFill); @@ -218,6 +228,7 @@ 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; FX_FLOAT fBottom = kSignPath; @@ -238,45 +249,32 @@ void CFWL_CheckBoxTP::InitCheckPath(FX_FLOAT fCheckLen) { CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f); CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f); CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f); - m_pCheckPath->MoveTo(pt1.x, pt1.y); - FX_FLOAT px1 = pt12.x - pt1.x; - FX_FLOAT py1 = pt12.y - pt1.y; - FX_FLOAT px2 = pt21.x - pt2.x; - FX_FLOAT py2 = pt21.y - pt2.y; - m_pCheckPath->BezierTo(pt1.x + px1 * FX_BEZIER, pt1.y + py1 * FX_BEZIER, - pt2.x + px2 * FX_BEZIER, pt2.y + py2 * FX_BEZIER, - pt2.x, pt2.y); - px1 = pt23.x - pt2.x; - py1 = pt23.y - pt2.y; - px2 = pt32.x - pt3.x; - py2 = pt32.y - pt3.y; - m_pCheckPath->BezierTo(pt2.x + px1 * FX_BEZIER, pt2.y + py1 * FX_BEZIER, - pt3.x + px2 * FX_BEZIER, pt3.y + py2 * FX_BEZIER, - pt3.x, pt3.y); - px1 = pt34.x - pt3.x; - py1 = pt34.y - pt3.y; - px2 = pt43.x - pt4.x; - py2 = pt43.y - pt4.y; - m_pCheckPath->BezierTo(pt3.x + px1 * FX_BEZIER, pt3.y + py1 * FX_BEZIER, - pt4.x + px2 * FX_BEZIER, pt4.y + py2 * FX_BEZIER, - pt4.x, pt4.y); - px1 = pt45.x - pt4.x; - py1 = pt45.y - pt4.y; - px2 = pt54.x - pt5.x; - py2 = pt54.y - pt5.y; - m_pCheckPath->BezierTo(pt4.x + px1 * FX_BEZIER, pt4.y + py1 * FX_BEZIER, - pt5.x + px2 * FX_BEZIER, pt5.y + py2 * FX_BEZIER, - pt5.x, pt5.y); - px1 = pt51.x - pt5.x; - py1 = pt51.y - pt5.y; - px2 = pt15.x - pt1.x; - py2 = pt15.y - pt1.y; - m_pCheckPath->BezierTo(pt5.x + px1 * FX_BEZIER, pt5.y + py1 * FX_BEZIER, - pt1.x + px2 * FX_BEZIER, pt1.y + py2 * FX_BEZIER, - pt1.x, pt1.y); + m_pCheckPath->MoveTo(pt1); + + CFX_PointF p1 = CFX_PointF(pt12.x - pt1.x, pt12.y - pt1.y) * FX_BEZIER; + CFX_PointF p2 = CFX_PointF(pt21.x - pt2.x, pt21.y - pt2.y) * FX_BEZIER; + m_pCheckPath->BezierTo(pt1 + p1, pt2 + p2, pt2); + + p1 = CFX_PointF(pt23.x - pt2.x, pt23.y - pt2.y) * FX_BEZIER; + p2 = CFX_PointF(pt32.x - pt3.x, pt32.y - pt3.y) * FX_BEZIER; + m_pCheckPath->BezierTo(pt2 + p1, pt3 + p2, pt3); + + p1 = CFX_PointF(pt34.x - pt3.x, pt34.y - pt3.y) * FX_BEZIER; + p2 = CFX_PointF(pt43.x - pt4.x, pt43.y - pt4.y) * FX_BEZIER; + m_pCheckPath->BezierTo(pt3 + p1, pt4 + p2, pt4); + + p1 = CFX_PointF(pt45.x - pt4.x, pt45.y - pt4.y) * FX_BEZIER; + p2 = CFX_PointF(pt54.x - pt5.x, pt54.y - pt5.y) * FX_BEZIER; + m_pCheckPath->BezierTo(pt4 + p1, pt5 + p2, pt5); + + p1 = CFX_PointF(pt51.x - pt5.x, pt51.y - pt5.y) * FX_BEZIER; + p2 = CFX_PointF(pt15.x - pt1.x, pt15.y - pt1.y) * FX_BEZIER; + m_pCheckPath->BezierTo(pt5 + p1, pt1 + p2, pt1); + FX_FLOAT fScale = fCheckLen / kSignPath; CFX_Matrix mt(1, 0, 0, 1, 0, 0); mt.Scale(fScale, fScale); + CFX_PathData* pData = m_pCheckPath->GetPathData(); pData->Transform(&mt); } diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp index 476135fa44..cf6306a53f 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -106,9 +106,11 @@ 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(); + CFX_Color clrBK(m_pThemeData->clrBK); pParams->m_pGraphics->SetFillColor(&clrBK); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); @@ -119,9 +121,11 @@ 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(); + CFX_Color clrHeadBK(m_pThemeData->clrBK); pParams->m_pGraphics->SetFillColor(&clrHeadBK); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); @@ -132,9 +136,11 @@ 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(); + CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243)); pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge); pParams->m_pGraphics->StrokePath(&path, pMatrix); @@ -147,12 +153,15 @@ void CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, pParams->m_pGraphics->SetFillColor(&clrLBtnFill); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } + path.Clear(); - path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, - rtLBtn.top + rtLBtn.height / 4); - path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2); - path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, - rtLBtn.bottom() - rtLBtn.height / 4); + path.MoveTo(CFX_PointF(rtLBtn.left + rtLBtn.Width() / 3 * 2, + rtLBtn.top + rtLBtn.height / 4)); + path.LineTo(CFX_PointF(rtLBtn.left + rtLBtn.Width() / 3, + rtLBtn.top + rtLBtn.height / 2)); + path.LineTo(CFX_PointF(rtLBtn.left + rtLBtn.Width() / 3 * 2, + rtLBtn.bottom() - rtLBtn.height / 4)); + CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); pParams->m_pGraphics->SetStrokeColor(&clrFlag); pParams->m_pGraphics->StrokePath(&path, pMatrix); @@ -163,9 +172,11 @@ 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(); + CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243)); pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge); pParams->m_pGraphics->StrokePath(&path, pMatrix); @@ -178,12 +189,15 @@ void CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, pParams->m_pGraphics->SetFillColor(&clrRBtnFill); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } + path.Clear(); - path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4); - path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, - rtRBtn.top + rtRBtn.height / 2); - path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, - rtRBtn.bottom() - rtRBtn.height / 4); + path.MoveTo(CFX_PointF(rtRBtn.left + rtRBtn.Width() / 3, + rtRBtn.top + rtRBtn.height / 4)); + path.LineTo(CFX_PointF(rtRBtn.left + rtRBtn.Width() / 3 * 2, + rtRBtn.top + rtRBtn.height / 2)); + path.LineTo(CFX_PointF(rtRBtn.left + rtRBtn.Width() / 3, + rtRBtn.bottom() - rtRBtn.height / 4)); + CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); pParams->m_pGraphics->SetStrokeColor(&clrFlag); pParams->m_pGraphics->StrokePath(&path, pMatrix); @@ -195,9 +209,10 @@ void CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, CFX_Path path; path.Create(); CFX_RectF rtHSep = pParams->m_rtPart; - path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2); - path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2); + path.MoveTo(CFX_PointF(rtHSep.left, rtHSep.top + rtHSep.height / 2)); + path.LineTo(CFX_PointF(rtHSep.right(), rtHSep.top + rtHSep.height / 2)); pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHSep(m_pThemeData->clrSeperator); pParams->m_pGraphics->SetStrokeColor(&clrHSep); pParams->m_pGraphics->StrokePath(&path, pMatrix); @@ -209,9 +224,10 @@ void CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Path path; path.Create(); CFX_RectF rtWeekSep = pParams->m_rtPart; - path.MoveTo(rtWeekSep.left, rtWeekSep.top); - path.LineTo(rtWeekSep.left, rtWeekSep.bottom()); + path.MoveTo(rtWeekSep.TopLeft()); + path.LineTo(rtWeekSep.BottomLeft()); pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHSep(m_pThemeData->clrSeperator); pParams->m_pGraphics->SetStrokeColor(&clrHSep); pParams->m_pGraphics->StrokePath(&path, pMatrix); diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp index a1e57836fa..ba7b2ca506 100644 --- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp +++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp @@ -31,39 +31,52 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { CFX_RectF& rect = pParams->m_rtPart; FX_FLOAT fRight = rect.right(); FX_FLOAT fBottom = rect.bottom(); + CFX_Path strokePath; strokePath.Create(); - strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); - strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top); - strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom); - strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom); - strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); + strokePath.MoveTo( + CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, rect.top)); + strokePath.LineTo(CFX_PointF(fRight - PUSHBUTTON_SIZE_Corner, rect.top)); + strokePath.LineTo(CFX_PointF(fRight, rect.top + PUSHBUTTON_SIZE_Corner)); + strokePath.LineTo(CFX_PointF(fRight, fBottom - PUSHBUTTON_SIZE_Corner)); + strokePath.LineTo(CFX_PointF(fRight - PUSHBUTTON_SIZE_Corner, fBottom)); + strokePath.LineTo( + CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, fBottom)); + strokePath.LineTo( + CFX_PointF(rect.left, fBottom - PUSHBUTTON_SIZE_Corner)); + strokePath.LineTo( + CFX_PointF(rect.left, rect.top + PUSHBUTTON_SIZE_Corner)); + strokePath.LineTo( + CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, rect.top)); + CFX_Path fillPath; fillPath.Create(); fillPath.AddSubpath(&strokePath); + CFX_Graphics* pGraphics = pParams->m_pGraphics; pGraphics->SaveGraphState(); + CFX_RectF rtInner(rect); rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner); fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + int32_t iColor = GetColorID(pParams->m_dwStates); DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top, rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(), m_pThemeData->clrStart[iColor], m_pThemeData->clrEnd[iColor], &fillPath, FXFILL_ALTERNATE, &pParams->m_matrix); + CFX_Color crStroke(m_pThemeData->clrBorder[iColor]); pGraphics->SetStrokeColor(&crStroke); pGraphics->StrokePath(&strokePath, &pParams->m_matrix); + fillPath.Clear(); fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + CFX_Color crFill(m_pThemeData->clrFill[iColor]); pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 4cd2fb376d..5f8f7dcd49 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -130,30 +130,34 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, if (pRect->width / 2 <= fPawLen) { fPawLen = (pRect->width - 6) / 2; } + FX_FLOAT fX = pRect->left + pRect->width / 4; FX_FLOAT fY = pRect->top + pRect->height / 2; - path.MoveTo(fX, fY - 4); - path.LineTo(fX + fPawLen, fY - 4); - path.MoveTo(fX, fY - 2); - path.LineTo(fX + fPawLen, fY - 2); - path.MoveTo(fX, fY); - path.LineTo(fX + fPawLen, fY); - path.MoveTo(fX, fY + 2); - path.LineTo(fX + fPawLen, fY + 2); + path.MoveTo(CFX_PointF(fX, fY - 4)); + path.LineTo(CFX_PointF(fX + fPawLen, fY - 4)); + path.MoveTo(CFX_PointF(fX, fY - 2)); + path.LineTo(CFX_PointF(fX + fPawLen, fY - 2)); + path.MoveTo(CFX_PointF(fX, fY)); + path.LineTo(CFX_PointF(fX + fPawLen, fY)); + path.MoveTo(CFX_PointF(fX, fY + 2)); + path.LineTo(CFX_PointF(fX + fPawLen, fY + 2)); + CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrLight); pGraphics->StrokePath(&path); fX++; + path.Clear(); - path.MoveTo(fX, fY - 3); - path.LineTo(fX + fPawLen, fY - 3); - path.MoveTo(fX, fY - 1); - path.LineTo(fX + fPawLen, fY - 1); - path.MoveTo(fX, fY + 1); - path.LineTo(fX + fPawLen, fY + 1); - path.MoveTo(fX, fY + 3); - path.LineTo(fX + fPawLen, fY + 3); + path.MoveTo(CFX_PointF(fX, fY - 3)); + path.LineTo(CFX_PointF(fX + fPawLen, fY - 3)); + path.MoveTo(CFX_PointF(fX, fY - 1)); + path.LineTo(CFX_PointF(fX + fPawLen, fY - 1)); + path.MoveTo(CFX_PointF(fX, fY + 1)); + path.LineTo(CFX_PointF(fX + fPawLen, fY + 1)); + path.MoveTo(CFX_PointF(fX, fY + 3)); + path.LineTo(CFX_PointF(fX + fPawLen, fY + 3)); + CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrDark); @@ -163,30 +167,34 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, if (pRect->height / 2 <= fPawLen) { fPawLen = (pRect->height - 6) / 2; } + FX_FLOAT fX = pRect->left + pRect->width / 2; FX_FLOAT fY = pRect->top + pRect->height / 4; - path.MoveTo(fX - 4, fY); - path.LineTo(fX - 4, fY + fPawLen); - path.MoveTo(fX - 2, fY); - path.LineTo(fX - 2, fY + fPawLen); - path.MoveTo(fX, fY); - path.LineTo(fX, fY + fPawLen); - path.MoveTo(fX + 2, fY); - path.LineTo(fX + 2, fY + fPawLen); + path.MoveTo(CFX_PointF(fX - 4, fY)); + path.LineTo(CFX_PointF(fX - 4, fY + fPawLen)); + path.MoveTo(CFX_PointF(fX - 2, fY)); + path.LineTo(CFX_PointF(fX - 2, fY + fPawLen)); + path.MoveTo(CFX_PointF(fX, fY)); + path.LineTo(CFX_PointF(fX, fY + fPawLen)); + path.MoveTo(CFX_PointF(fX + 2, fY)); + path.LineTo(CFX_PointF(fX + 2, fY + fPawLen)); + CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrLight); pGraphics->StrokePath(&path, pMatrix); fY++; + path.Clear(); - path.MoveTo(fX - 3, fY); - path.LineTo(fX - 3, fY + fPawLen); - path.MoveTo(fX - 1, fY); - path.LineTo(fX - 1, fY + fPawLen); - path.MoveTo(fX + 1, fY); - path.LineTo(fX + 1, fY + fPawLen); - path.MoveTo(fX + 3, fY); - path.LineTo(fX + 3, fY + fPawLen); + path.MoveTo(CFX_PointF(fX - 3, fY)); + path.LineTo(CFX_PointF(fX - 3, fY + fPawLen)); + path.MoveTo(CFX_PointF(fX - 1, fY)); + path.LineTo(CFX_PointF(fX - 1, fY + fPawLen)); + path.MoveTo(CFX_PointF(fX + 1, fY)); + path.LineTo(CFX_PointF(fX + 1, fY + fPawLen)); + path.MoveTo(CFX_PointF(fX + 3, fY)); + path.LineTo(CFX_PointF(fX + 3, fY + fPawLen)); + CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrDark); diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index ad5beef858..d7d98cd76f 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -196,39 +196,39 @@ void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, path.Create(); switch (eDict) { case FWLTHEME_DIRECTION_Down: { - path.MoveTo(fLeft, fTop + 1); - path.LineTo(fLeft + 4, fTop + 5); - path.LineTo(fLeft + 8, fTop + 1); - path.LineTo(fLeft + 7, fTop); - path.LineTo(fLeft + 4, fTop + 3); - path.LineTo(fLeft + 1, fTop); + path.MoveTo(CFX_PointF(fLeft, fTop + 1)); + path.LineTo(CFX_PointF(fLeft + 4, fTop + 5)); + path.LineTo(CFX_PointF(fLeft + 8, fTop + 1)); + path.LineTo(CFX_PointF(fLeft + 7, fTop)); + path.LineTo(CFX_PointF(fLeft + 4, fTop + 3)); + path.LineTo(CFX_PointF(fLeft + 1, fTop)); break; } case FWLTHEME_DIRECTION_Up: { - path.MoveTo(fLeft, fTop + 4); - path.LineTo(fLeft + 4, fTop); - path.LineTo(fLeft + 8, fTop + 4); - path.LineTo(fLeft + 7, fTop + 5); - path.LineTo(fLeft + 4, fTop + 2); - path.LineTo(fLeft + 1, fTop + 5); + path.MoveTo(CFX_PointF(fLeft, fTop + 4)); + path.LineTo(CFX_PointF(fLeft + 4, fTop)); + path.LineTo(CFX_PointF(fLeft + 8, fTop + 4)); + path.LineTo(CFX_PointF(fLeft + 7, fTop + 5)); + path.LineTo(CFX_PointF(fLeft + 4, fTop + 2)); + path.LineTo(CFX_PointF(fLeft + 1, fTop + 5)); break; } case FWLTHEME_DIRECTION_Right: { - path.MoveTo(fLeft + 1, fTop); - path.LineTo(fLeft + 5, fTop + 4); - path.LineTo(fLeft + 1, fTop + 8); - path.LineTo(fLeft, fTop + 7); - path.LineTo(fLeft + 3, fTop + 4); - path.LineTo(fLeft, fTop + 1); + path.MoveTo(CFX_PointF(fLeft + 1, fTop)); + path.LineTo(CFX_PointF(fLeft + 5, fTop + 4)); + path.LineTo(CFX_PointF(fLeft + 1, fTop + 8)); + path.LineTo(CFX_PointF(fLeft, fTop + 7)); + path.LineTo(CFX_PointF(fLeft + 3, fTop + 4)); + path.LineTo(CFX_PointF(fLeft, fTop + 1)); break; } case FWLTHEME_DIRECTION_Left: { - path.MoveTo(fLeft, fTop + 4); - path.LineTo(fLeft + 4, fTop); - path.LineTo(fLeft + 5, fTop + 1); - path.LineTo(fLeft + 2, fTop + 4); - path.LineTo(fLeft + 5, fTop + 7); - path.LineTo(fLeft + 4, fTop + 8); + path.MoveTo(CFX_PointF(fLeft, fTop + 4)); + path.LineTo(CFX_PointF(fLeft + 4, fTop)); + path.LineTo(CFX_PointF(fLeft + 5, fTop + 1)); + path.LineTo(CFX_PointF(fLeft + 2, fTop + 4)); + path.LineTo(CFX_PointF(fLeft + 5, fTop + 7)); + path.LineTo(CFX_PointF(fLeft + 4, fTop + 8)); break; } } diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp index c4e6554c1a..feea7bf00b 100644 --- a/xfa/fxfa/app/xfa_ffpath.cpp +++ b/xfa/fxfa/app/xfa_ffpath.cpp @@ -89,9 +89,9 @@ void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS, CFX_Path linePath; linePath.Create(); if (lineObj.GetSlope() && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) - linePath.AddLine(rtLine.right(), rtLine.top, rtLine.left, rtLine.bottom()); + linePath.AddLine(rtLine.TopRight(), rtLine.BottomLeft()); else - linePath.AddLine(rtLine.left, rtLine.top, rtLine.right(), rtLine.bottom()); + linePath.AddLine(rtLine.TopLeft(), rtLine.BottomRight()); CFX_Color color(lineColor); pGS->SaveGraphState(); diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index c917697948..0f47dffa22 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -1211,9 +1211,9 @@ static void XFA_BOX_GetPath_Arc(CXFA_Box box, } startAngle = -startAngle * FX_PI / 180.0f; sweepAngle = -sweepAngle * FX_PI / 180.0f; - fillPath.AddArc(rtDraw.left, rtDraw.top, rtDraw.width, rtDraw.height, - startAngle, sweepAngle); + fillPath.AddArc(rtDraw.TopLeft(), rtDraw.Size(), startAngle, sweepAngle); } + static void XFA_BOX_GetPath(CXFA_Box box, const std::vector<CXFA_Stroke>& strokes, CFX_RectF rtWidget, @@ -1336,49 +1336,51 @@ static void XFA_BOX_GetPath(CXFA_Box box, cpStart.x = cp1.x, cpStart.y = cp1.y - fRadius1 + halfBefore, offsetEY = -halfAfter; } - vx = 1, vy = -1; - nx = 0, ny = 1; + vx = 1; + vy = -1; + nx = 0; + ny = 1; if (bRound) { sx = bInverted ? 0 : FX_PI / 2; } else { - sx = 0, sy = -1; + sx = 0; + sy = -1; } break; } if (bStart) { - path.MoveTo(cpStart.x, cpStart.y); + path.MoveTo(cpStart); } if (nIndex & 1) { - path.LineTo(cp2.x + fRadius2 * nx + offsetEX, - cp2.y + fRadius2 * ny + offsetEY); + path.LineTo(CFX_PointF(cp2.x + fRadius2 * nx + offsetEX, + cp2.y + fRadius2 * ny + offsetEY)); return; } if (bRound) { - if (fRadius1 < 0) { + if (fRadius1 < 0) sx -= FX_PI; - } - if (bInverted) { + if (bInverted) sy *= -1; - } + CFX_RectF rtRadius(cp1.x + offsetX * 2, cp1.y + offsetY * 2, fRadius1 * 2 * vx - offsetX * 2, fRadius1 * 2 * vy - offsetY * 2); rtRadius.Normalize(); - if (bInverted) { + if (bInverted) rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); - } - path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx, - sy); + + path.ArcTo(rtRadius.TopLeft(), rtRadius.Size(), sx, sy); } else { CFX_PointF cp; if (bInverted) { - cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; + cp.x = cp1.x + fRadius1 * vx; + cp.y = cp1.y + fRadius1 * vy; } else { cp = cp1; } - path.LineTo(cp.x, cp.y); - path.LineTo(cp1.x + fRadius1 * sx + offsetX, - cp1.y + fRadius1 * sy + offsetY); + path.LineTo(cp); + path.LineTo(CFX_PointF(cp1.x + fRadius1 * sx + offsetX, + cp1.y + fRadius1 * sy + offsetY)); } } static void XFA_BOX_GetFillPath(CXFA_Box box, @@ -1498,38 +1500,38 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, if (bRound) { sx = bInverted ? 0 : FX_PI / 2; } else { - sx = 0, sy = -1; + sx = 0; + sy = -1; } break; } - if (i == 0) { - fillPath.MoveTo(cp1.x, cp1.y + fRadius1); - } + if (i == 0) + fillPath.MoveTo(CFX_PointF(cp1.x, cp1.y + fRadius1)); + if (bRound) { - if (fRadius1 < 0) { + if (fRadius1 < 0) sx -= FX_PI; - } - if (bInverted) { + if (bInverted) sy *= -1; - } + CFX_RectF rtRadius(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); rtRadius.Normalize(); - if (bInverted) { + if (bInverted) rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); - } - fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, - rtRadius.height, sx, sy); + + fillPath.ArcTo(rtRadius.TopLeft(), rtRadius.Size(), sx, sy); } else { CFX_PointF cp; if (bInverted) { - cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; + cp.x = cp1.x + fRadius1 * vx; + cp.y = cp1.y + fRadius1 * vy; } else { cp = cp1; } - fillPath.LineTo(cp.x, cp.y); - fillPath.LineTo(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy); + fillPath.LineTo(cp); + fillPath.LineTo(CFX_PointF(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy)); } - fillPath.LineTo(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny); + fillPath.LineTo(CFX_PointF(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny)); } } static void XFA_BOX_Fill_Radial(CXFA_Box box, @@ -1738,43 +1740,52 @@ static void XFA_BOX_StrokeArc(CXFA_Box box, } pGS->SaveGraphState(); pGS->SetLineWidth(fHalf); + FX_FLOAT a, b; a = rtWidget.width / 2.0f; b = rtWidget.height / 2.0f; if (dwFlags & XFA_DRAWBOX_ForceRound) { - a = b = std::min(a, b); + a = std::min(a, b); + b = a; } + CFX_PointF center = rtWidget.Center(); rtWidget.left = center.x - a; rtWidget.top = center.y - b; rtWidget.width = a + a; rtWidget.height = b + b; + FX_FLOAT startAngle = 0, sweepAngle = 360; startAngle = startAngle * FX_PI / 180.0f; sweepAngle = -sweepAngle * FX_PI / 180.0f; + CFX_Path arcPath; arcPath.Create(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - 3.0f * FX_PI / 4.0f, FX_PI); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, + FX_PI); + CFX_Color cr(0xFF808080); pGS->SetStrokeColor(&cr); pGS->StrokePath(&arcPath, pMatrix); arcPath.Clear(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - -1.0f * FX_PI / 4.0f, FX_PI); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, + FX_PI); + cr.Set(0xFFFFFFFF); pGS->SetStrokeColor(&cr); pGS->StrokePath(&arcPath, pMatrix); rtWidget.Deflate(fHalf, fHalf); arcPath.Clear(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - 3.0f * FX_PI / 4.0f, FX_PI); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, + FX_PI); + cr.Set(0xFF404040); pGS->SetStrokeColor(&cr); pGS->StrokePath(&arcPath, pMatrix); arcPath.Clear(); - arcPath.AddArc(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height, - -1.0f * FX_PI / 4.0f, FX_PI); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, + FX_PI); + cr.Set(0xFFC0C0C0); pGS->SetStrokeColor(&cr); pGS->StrokePath(&arcPath, pMatrix); @@ -1792,25 +1803,27 @@ static void XFA_Draw3DRect(CFX_Graphics* pGraphic, FX_FLOAT fRight = rt.right(); CFX_Path pathLT; pathLT.Create(); - pathLT.MoveTo(rt.left, fBottom); - pathLT.LineTo(rt.left, rt.top); - pathLT.LineTo(fRight, rt.top); - pathLT.LineTo(fRight - fLineWidth, rt.top + fLineWidth); - pathLT.LineTo(rt.left + fLineWidth, rt.top + fLineWidth); - pathLT.LineTo(rt.left + fLineWidth, fBottom - fLineWidth); - pathLT.LineTo(rt.left, fBottom); + pathLT.MoveTo(CFX_PointF(rt.left, fBottom)); + pathLT.LineTo(CFX_PointF(rt.left, rt.top)); + pathLT.LineTo(CFX_PointF(fRight, rt.top)); + pathLT.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); + pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, rt.top + fLineWidth)); + pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); + pathLT.LineTo(CFX_PointF(rt.left, fBottom)); pGraphic->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + CFX_Color crRB(argbBottomRight); pGraphic->SetFillColor(&crRB); + CFX_Path pathRB; pathRB.Create(); - pathRB.MoveTo(fRight, rt.top); - pathRB.LineTo(fRight, fBottom); - pathRB.LineTo(rt.left, fBottom); - pathRB.LineTo(rt.left + fLineWidth, fBottom - fLineWidth); - pathRB.LineTo(fRight - fLineWidth, fBottom - fLineWidth); - pathRB.LineTo(fRight - fLineWidth, rt.top + fLineWidth); - pathRB.LineTo(fRight, rt.top); + pathRB.MoveTo(CFX_PointF(fRight, rt.top)); + pathRB.LineTo(CFX_PointF(fRight, fBottom)); + pathRB.LineTo(CFX_PointF(rt.left, fBottom)); + pathRB.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); + pathRB.LineTo(CFX_PointF(fRight - fLineWidth, fBottom - fLineWidth)); + pathRB.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); + pathRB.LineTo(CFX_PointF(fRight, rt.top)); pGraphic->FillPath(&pathRB, FXFILL_WINDING, pMatrix); } static void XFA_BOX_Stroke_3DRect_Lowered(CFX_Graphics* pGS, diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp index d2e8f94638..3072df2475 100644 --- a/xfa/fxgraphics/cfx_path.cpp +++ b/xfa/fxgraphics/cfx_path.cpp @@ -22,42 +22,38 @@ FWL_Error CFX_Path::Create() { CFX_Path::~CFX_Path() {} -FWL_Error CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { +FWL_Error CFX_Path::MoveTo(const CFX_PointF& point) { if (!m_generator) return FWL_Error::PropertyInvalid; - m_generator->MoveTo(x, y); + m_generator->MoveTo(point); return FWL_Error::Succeeded; } -FWL_Error CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { +FWL_Error CFX_Path::LineTo(const CFX_PointF& point) { if (!m_generator) return FWL_Error::PropertyInvalid; - m_generator->LineTo(x, y); + m_generator->LineTo(point); return FWL_Error::Succeeded; } -FWL_Error CFX_Path::BezierTo(FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT toX, - FX_FLOAT toY) { +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(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); + m_generator->BezierTo(c1, c2, to); return FWL_Error::Succeeded; } -FWL_Error CFX_Path::ArcTo(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, +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; - m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); + 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; } @@ -68,28 +64,20 @@ FWL_Error CFX_Path::Close() { return FWL_Error::Succeeded; } -FWL_Error CFX_Path::AddLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { +FWL_Error CFX_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) { if (!m_generator) return FWL_Error::PropertyInvalid; - m_generator->AddLine(x1, y1, x2, y2); + m_generator->AddLine(p1, p2); return FWL_Error::Succeeded; } -FWL_Error CFX_Path::AddBezier(FX_FLOAT startX, - FX_FLOAT startY, - FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT endX, - FX_FLOAT endY) { +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(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, - endY); + m_generator->AddBezier(p1, c1, c2, p2); return FWL_Error::Succeeded; } @@ -103,49 +91,45 @@ FWL_Error CFX_Path::AddRectangle(FX_FLOAT left, return FWL_Error::Succeeded; } -FWL_Error CFX_Path::AddEllipse(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height) { +FWL_Error CFX_Path::AddEllipse(const CFX_PointF& pos, const CFX_SizeF& size) { if (!m_generator) return FWL_Error::PropertyInvalid; - m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2, - height / 2); + 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(rect.left + rect.Width() / 2, - rect.top + rect.Height() / 2, rect.Width() / 2, - rect.Height() / 2); + 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(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, +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; - m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); + 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(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, +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; - m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); + 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; } diff --git a/xfa/fxgraphics/cfx_path.h b/xfa/fxgraphics/cfx_path.h index 9171a91a00..1dee566788 100644 --- a/xfa/fxgraphics/cfx_path.h +++ b/xfa/fxgraphics/cfx_path.h @@ -21,50 +21,34 @@ class CFX_Path final { ~CFX_Path(); FWL_Error Create(); - FWL_Error MoveTo(FX_FLOAT x, FX_FLOAT y); - FWL_Error LineTo(FX_FLOAT x, FX_FLOAT y); - FWL_Error BezierTo(FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT toX, - FX_FLOAT toY); - FWL_Error ArcTo(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, + 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(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - FWL_Error AddBezier(FX_FLOAT startX, - FX_FLOAT startY, - FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT endX, - FX_FLOAT endY); + 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(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(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, + FWL_Error AddArc(const CFX_PointF& pos, + const CFX_SizeF& size, FX_FLOAT startAngle, FX_FLOAT sweepAngle); - FWL_Error AddPie(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, + FWL_Error AddPie(const CFX_PointF& pos, + const CFX_SizeF& size, FX_FLOAT startAngle, FX_FLOAT sweepAngle); FWL_Error AddSubpath(CFX_Path* path); diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index 8da1b4fe15..ab3d9d631a 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -19,49 +19,39 @@ void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { m_pPathData->Append(pPathData, nullptr); } -void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { - m_pPathData->AppendPoint(x, y, FXPT_TYPE::MoveTo, false); +void CFX_PathGenerator::MoveTo(const CFX_PointF& point) { + m_pPathData->AppendPoint(point, FXPT_TYPE::MoveTo, false); } -void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { - m_pPathData->AppendPoint(x, y, FXPT_TYPE::LineTo, false); +void CFX_PathGenerator::LineTo(const CFX_PointF& point) { + m_pPathData->AppendPoint(point, FXPT_TYPE::LineTo, false); } -void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT to_x, - FX_FLOAT to_y) { - m_pPathData->AppendPoint(ctrl_x1, ctrl_y1, FXPT_TYPE::BezierTo, false); - m_pPathData->AppendPoint(ctrl_x2, ctrl_y2, FXPT_TYPE::BezierTo, false); - m_pPathData->AppendPoint(to_x, to_y, FXPT_TYPE::BezierTo, 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(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { - m_pPathData->AppendPoint(x1, y1, FXPT_TYPE::MoveTo, false); - m_pPathData->AppendPoint(x2, y2, FXPT_TYPE::LineTo, false); +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(FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT end_x, - FX_FLOAT end_y) { - m_pPathData->AppendPoint(start_x, start_y, FXPT_TYPE::MoveTo, false); - m_pPathData->AppendPoint(ctrl_x1, ctrl_y1, FXPT_TYPE::BezierTo, false); - m_pPathData->AppendPoint(ctrl_x2, ctrl_y2, FXPT_TYPE::BezierTo, false); - m_pPathData->AppendPoint(end_x, end_y, FXPT_TYPE::BezierTo, 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, @@ -71,17 +61,13 @@ void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, m_pPathData->AppendRect(x1, y1, x2, y2); } -void CFX_PathGenerator::AddEllipse(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height) { - AddArc(x, y, width, height, 0, FX_PI * 2); +void CFX_PathGenerator::AddEllipse(const CFX_PointF& pos, + const CFX_SizeF& size) { + AddArc(pos, size, 0, FX_PI * 2); } -void CFX_PathGenerator::ArcTo(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, +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); @@ -96,46 +82,45 @@ void CFX_PathGenerator::ArcTo(FX_FLOAT x, FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2); FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2); - FX_FLOAT bezier_x, bezier_y; - bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn))); - bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs))); - m_pPathData->AppendPoint(bezier_x, bezier_y, FXPT_TYPE::BezierTo, false); - bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn))); - bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs))); - m_pPathData->AppendPoint(bezier_x, bezier_y, FXPT_TYPE::BezierTo, false); - bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle)); - bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); - m_pPathData->AppendPoint(bezier_x, bezier_y, FXPT_TYPE::BezierTo, false); + 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(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, +void CFX_PathGenerator::AddArc(const CFX_PointF& pos, + const CFX_SizeF& size, FX_FLOAT start_angle, FX_FLOAT sweep_angle) { - if (sweep_angle == 0) { + if (sweep_angle == 0) return; - } const FX_FLOAT bezier_arc_angle_epsilon = 0.01f; - while (start_angle > FX_PI * 2) { + while (start_angle > FX_PI * 2) start_angle -= FX_PI * 2; - } - while (start_angle < 0) { + while (start_angle < 0) start_angle += FX_PI * 2; - } - if (sweep_angle >= FX_PI * 2) { + if (sweep_angle >= FX_PI * 2) sweep_angle = FX_PI * 2; - } - if (sweep_angle <= -FX_PI * 2) { + if (sweep_angle <= -FX_PI * 2) sweep_angle = -FX_PI * 2; - } - m_pPathData->AppendPoint(x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), - FXPT_TYPE::MoveTo, false); - FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; + 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) { @@ -155,24 +140,25 @@ void CFX_PathGenerator::AddArc(FX_FLOAT x, done = true; } } - ArcTo(x, y, width, height, start_angle, local_sweep); + + ArcTo(pos, size, start_angle, local_sweep); start_angle += local_sweep; } while (!done); } -void CFX_PathGenerator::AddPie(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, +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(x, y, FXPT_TYPE::MoveTo, false); - m_pPathData->AppendPoint(x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), - FXPT_TYPE::LineTo, false); + 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(x, y, width, height, start_angle, sweep_angle); - m_pPathData->AppendPoint(x, y, FXPT_TYPE::LineTo, true); + + 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 index 916400d529..d3ba290f1c 100644 --- a/xfa/fxgraphics/cfx_path_generator.h +++ b/xfa/fxgraphics/cfx_path_generator.h @@ -20,43 +20,30 @@ class CFX_PathGenerator { void AddPathData(CFX_PathData* path_data); - void MoveTo(FX_FLOAT x, FX_FLOAT y); - void LineTo(FX_FLOAT x, FX_FLOAT y); - void BezierTo(FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT to_x, - FX_FLOAT to_y); + 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(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, + void ArcTo(const CFX_PointF& point, + const CFX_SizeF& size, FX_FLOAT start_angle, FX_FLOAT sweep_angle); - void AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - void AddBezier(FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT end_x, - FX_FLOAT end_y); + 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(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height); - void AddArc(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, + 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(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, + void AddPie(const CFX_PointF& point, + const CFX_SizeF& size, FX_FLOAT start_angle, FX_FLOAT sweep_angle); |