summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp14
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp44
-rw-r--r--core/fpdfapi/page/cpdf_clippath.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_path.cpp13
-rw-r--r--core/fpdfapi/page/cpdf_path.h5
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp10
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp4
-rw-r--r--core/fxcrt/fx_coordinates.h97
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp47
-rw-r--r--core/fxge/cfx_pathdata.h16
-rw-r--r--core/fxge/ge/cfx_font.cpp56
-rw-r--r--core/fxge/ge/cfx_pathdata.cpp469
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp8
-rw-r--r--core/fxge/skia/fx_skia_device.cpp13
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp22
-rw-r--r--core/fxge/win32/fx_win32_device.cpp57
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp18
-rw-r--r--fpdfsdk/formfiller/cffl_interactiveformfiller.cpp18
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp26
-rw-r--r--fpdfsdk/fpdfeditpath.cpp12
-rw-r--r--fpdfsdk/pdfwindow/PWL_Caret.cpp18
-rw-r--r--fpdfsdk/pdfwindow/PWL_ComboBox.cpp8
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.cpp32
-rw-r--r--fpdfsdk/pdfwindow/PWL_ScrollBar.cpp16
-rw-r--r--fpdfsdk/pdfwindow/PWL_Utils.cpp98
-rw-r--r--xfa/fde/cfde_path.cpp21
-rw-r--r--xfa/fde/cfde_path.h6
-rw-r--r--xfa/fwl/cfwl_edit.cpp7
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.cpp100
-rw-r--r--xfa/fwl/theme/cfwl_monthcalendartp.cpp44
-rw-r--r--xfa/fwl/theme/cfwl_pushbuttontp.cpp31
-rw-r--r--xfa/fwl/theme/cfwl_scrollbartp.cpp72
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp48
-rw-r--r--xfa/fxfa/app/xfa_ffpath.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp131
-rw-r--r--xfa/fxgraphics/cfx_path.cpp90
-rw-r--r--xfa/fxgraphics/cfx_path.h50
-rw-r--r--xfa/fxgraphics/cfx_path_generator.cpp144
-rw-r--r--xfa/fxgraphics/cfx_path_generator.h47
41 files changed, 974 insertions, 962 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index b5fe4c0f35..35595b3e1f 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -150,14 +150,14 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf,
ProcessGraphics(buf, pPathObj);
auto& pPoints = pPathObj->m_Path.GetPoints();
if (pPathObj->m_Path.IsRect()) {
- *buf << pPoints[0].m_PointX << " " << pPoints[0].m_PointY << " "
- << (pPoints[2].m_PointX - pPoints[0].m_PointX) << " "
- << (pPoints[2].m_PointY - pPoints[0].m_PointY) << " re";
+ CFX_PointF diff = pPoints[2].m_Point - pPoints[0].m_Point;
+ *buf << pPoints[0].m_Point.x << " " << pPoints[0].m_Point.y << " " << diff.x
+ << " " << diff.y << " re";
} else {
for (size_t i = 0; i < pPoints.size(); i++) {
if (i > 0)
*buf << " ";
- *buf << pPoints[i].m_PointX << " " << pPoints[i].m_PointY;
+ *buf << pPoints[i].m_Point.x << " " << pPoints[i].m_Point.y;
FXPT_TYPE pointType = pPoints[i].m_Type;
if (pointType == FXPT_TYPE::MoveTo) {
*buf << " m";
@@ -172,9 +172,9 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf,
*buf << " h";
break;
}
- *buf << " " << pPoints[i + 1].m_PointX << " " << pPoints[i + 1].m_PointY
- << " " << pPoints[i + 2].m_PointX << " " << pPoints[i + 2].m_PointY
- << " c";
+ *buf << " " << pPoints[i + 1].m_Point.x << " "
+ << pPoints[i + 1].m_Point.y << " " << pPoints[i + 2].m_Point.x
+ << " " << pPoints[i + 2].m_Point.y << " c";
i += 2;
}
if (pPoints[i].m_CloseFigure)
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 42e6e2d843..d8813ba30f 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -52,10 +52,11 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
EXPECT_EQ("q 10 5 3 25 re B* Q\n", buf.MakeString());
pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
- pPathObj->m_Path.AppendPoint(0, 0, FXPT_TYPE::MoveTo, false);
- pPathObj->m_Path.AppendPoint(5.2f, 0, FXPT_TYPE::LineTo, false);
- pPathObj->m_Path.AppendPoint(5.2f, 3.78f, FXPT_TYPE::LineTo, false);
- pPathObj->m_Path.AppendPoint(0, 3.78f, FXPT_TYPE::LineTo, true);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(0, 0), FXPT_TYPE::MoveTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 0), FXPT_TYPE::LineTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 3.78f), FXPT_TYPE::LineTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(0, 3.78f), FXPT_TYPE::LineTo, true);
pPathObj->m_FillType = 0;
pPathObj->m_bStroke = false;
buf.Clear();
@@ -66,16 +67,25 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
- pPathObj->m_Path.AppendPoint(3.102f, 4.67f, FXPT_TYPE::MoveTo, false);
- pPathObj->m_Path.AppendPoint(5.45f, 0.29f, FXPT_TYPE::LineTo, false);
- pPathObj->m_Path.AppendPoint(4.24f, 3.15f, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(4.65f, 2.98f, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(3.456f, 0.24f, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(10.6f, 11.15f, FXPT_TYPE::LineTo, false);
- pPathObj->m_Path.AppendPoint(11, 12.5f, FXPT_TYPE::LineTo, false);
- pPathObj->m_Path.AppendPoint(11.46f, 12.67f, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(11.84f, 12.96f, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(12, 13.64f, FXPT_TYPE::BezierTo, true);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(3.102f, 4.67f), FXPT_TYPE::MoveTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(5.45f, 0.29f), FXPT_TYPE::LineTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(4.24f, 3.15f), FXPT_TYPE::BezierTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(4.65f, 2.98f), FXPT_TYPE::BezierTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(3.456f, 0.24f), FXPT_TYPE::BezierTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(10.6f, 11.15f), FXPT_TYPE::LineTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(11, 12.5f), FXPT_TYPE::LineTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(11.46f, 12.67f), FXPT_TYPE::BezierTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(11.84f, 12.96f), FXPT_TYPE::BezierTo,
+ false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(12, 13.64f), FXPT_TYPE::BezierTo,
+ true);
pPathObj->m_FillType = FXFILL_WINDING;
pPathObj->m_bStroke = false;
@@ -91,9 +101,9 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) {
auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
- pPathObj->m_Path.AppendPoint(1, 2, FXPT_TYPE::MoveTo, false);
- pPathObj->m_Path.AppendPoint(3, 4, FXPT_TYPE::LineTo, false);
- pPathObj->m_Path.AppendPoint(5, 6, FXPT_TYPE::LineTo, true);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(1, 2), FXPT_TYPE::MoveTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(3, 4), FXPT_TYPE::LineTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(5, 6), FXPT_TYPE::LineTo, true);
pPathObj->m_FillType = FXFILL_WINDING;
pPathObj->m_bStroke = true;
diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp
index cfcd9a1e64..714b56bff3 100644
--- a/core/fpdfapi/page/cpdf_clippath.cpp
+++ b/core/fpdfapi/page/cpdf_clippath.cpp
@@ -84,8 +84,9 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) {
if (!pData->m_PathAndTypeList.empty() && bAutoMerge) {
const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first;
if (old_path.IsRect()) {
- CFX_FloatRect old_rect(old_path.GetPointX(0), old_path.GetPointY(0),
- old_path.GetPointX(2), old_path.GetPointY(2));
+ CFX_PointF point0 = old_path.GetPoint(0);
+ CFX_PointF point2 = old_path.GetPoint(2);
+ CFX_FloatRect old_rect(point0.x, point0.y, point2.x, point2.y);
CFX_FloatRect new_rect = path.GetBoundingBox();
if (old_rect.Contains(new_rect))
pData->m_PathAndTypeList.pop_back();
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 7f00eabb86..7ceb509348 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -203,8 +203,10 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
CPDF_Path ClipPath = pObj->m_ClipPath.GetPath(0);
if (!ClipPath.IsRect() || pObj->IsShading())
continue;
- CFX_FloatRect old_rect(ClipPath.GetPointX(0), ClipPath.GetPointY(0),
- ClipPath.GetPointX(2), ClipPath.GetPointY(2));
+
+ CFX_PointF point0 = ClipPath.GetPoint(0);
+ CFX_PointF point2 = ClipPath.GetPoint(2);
+ CFX_FloatRect old_rect(point0.x, point0.y, point2.x, point2.y);
CFX_FloatRect obj_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right,
pObj->m_Top);
if (old_rect.Contains(obj_rect))
diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp
index a95ce1e5bc..ddc6bbd1d6 100644
--- a/core/fpdfapi/page/cpdf_path.cpp
+++ b/core/fpdfapi/page/cpdf_path.cpp
@@ -20,12 +20,8 @@ void CPDF_Path::ClosePath() {
m_Ref.GetPrivateCopy()->ClosePath();
}
-FX_FLOAT CPDF_Path::GetPointX(int index) const {
- return m_Ref.GetObject()->GetPointX(index);
-}
-
-FX_FLOAT CPDF_Path::GetPointY(int index) const {
- return m_Ref.GetObject()->GetPointY(index);
+CFX_PointF CPDF_Path::GetPoint(int index) const {
+ return m_Ref.GetObject()->GetPoint(index);
}
CFX_FloatRect CPDF_Path::GetBoundingBox() const {
@@ -60,11 +56,10 @@ void CPDF_Path::AppendRect(FX_FLOAT left,
m_Ref.GetPrivateCopy()->AppendRect(left, bottom, right, top);
}
-void CPDF_Path::AppendPoint(FX_FLOAT x,
- FX_FLOAT y,
+void CPDF_Path::AppendPoint(const CFX_PointF& point,
FXPT_TYPE type,
bool close) {
CFX_PathData data;
- data.AppendPoint(x, y, type, close);
+ data.AppendPoint(point, type, close);
Append(&data, nullptr);
}
diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h
index 97dd8fd8a9..b0c5a68a44 100644
--- a/core/fpdfapi/page/cpdf_path.h
+++ b/core/fpdfapi/page/cpdf_path.h
@@ -27,8 +27,7 @@ class CPDF_Path {
const std::vector<FX_PATHPOINT>& GetPoints() const;
void ClosePath();
- FX_FLOAT GetPointX(int index) const;
- FX_FLOAT GetPointY(int index) const;
+ CFX_PointF GetPoint(int index) const;
CFX_FloatRect GetBoundingBox() const;
CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const;
@@ -38,7 +37,7 @@ class CPDF_Path {
void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix);
void Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix);
void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
- void AppendPoint(FX_FLOAT x, FX_FLOAT y, FXPT_TYPE type, bool close);
+ void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool close);
// TODO(tsepez): Remove when all access thru this class.
const CFX_PathData* GetObject() const { return m_Ref.GetObject(); }
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index b8c9c4c6af..d8e1c1e15d 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1445,8 +1445,7 @@ void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x,
m_PathStartY = y;
if (m_PathPointCount &&
m_pPathPoints[m_PathPointCount - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) {
- m_pPathPoints[m_PathPointCount - 1].m_PointX = x;
- m_pPathPoints[m_PathPointCount - 1].m_PointY = y;
+ m_pPathPoints[m_PathPointCount - 1].m_Point = CFX_PointF(x, y);
return;
}
} else if (m_PathPointCount == 0) {
@@ -1466,8 +1465,7 @@ void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x,
}
m_pPathPoints[m_PathPointCount - 1].m_Type = type;
m_pPathPoints[m_PathPointCount - 1].m_CloseFigure = close;
- m_pPathPoints[m_PathPointCount - 1].m_PointX = x;
- m_pPathPoints[m_PathPointCount - 1].m_PointY = y;
+ m_pPathPoints[m_PathPointCount - 1].m_Point = CFX_PointF(x, y);
}
void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
@@ -1491,8 +1489,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
CPDF_Path Path;
for (int i = 0; i < PathPointCount; i++) {
FX_PATHPOINT& point = m_pPathPoints[i];
- Path.AppendPoint(point.m_PointX, point.m_PointY, point.m_Type,
- point.m_CloseFigure);
+ Path.AppendPoint(point.m_Point, point.m_Type, point.m_CloseFigure);
}
CFX_Matrix matrix = m_pCurStates->m_CTM;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index b041a72662..fe04174c28 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -639,11 +639,11 @@ struct Coon_Bezier {
int i;
x.GetPoints(p);
for (i = 0; i < 4; i++)
- pPoints[start_idx + i].m_PointX = p[i];
+ pPoints[start_idx + i].m_Point.x = p[i];
y.GetPoints(p);
for (i = 0; i < 4; i++)
- pPoints[start_idx + i].m_PointY = p[i];
+ pPoints[start_idx + i].m_Point.y = p[i];
}
void GetPointsReverse(std::vector<FX_PATHPOINT>& pPoints, size_t start_idx) {
@@ -651,11 +651,11 @@ struct Coon_Bezier {
int i;
x.GetPointsReverse(p);
for (i = 0; i < 4; i++)
- pPoints[i + start_idx].m_PointX = p[i];
+ pPoints[i + start_idx].m_Point.x = p[i];
y.GetPointsReverse(p);
for (i = 0; i < 4; i++)
- pPoints[i + start_idx].m_PointY = p[i];
+ pPoints[i + start_idx].m_Point.y = p[i];
}
float Distance() { return x.Distance() + y.Distance(); }
@@ -822,7 +822,7 @@ void DrawCoonPatchMeshes(
for (int i = 0; i < 13; i++) {
patch.path.AppendPoint(
- 0, 0, i == 0 ? FXPT_TYPE::MoveTo : FXPT_TYPE::BezierTo, false);
+ CFX_PointF(), i == 0 ? FXPT_TYPE::MoveTo : FXPT_TYPE::BezierTo, false);
}
CFX_PointF coords[16];
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 38e5b5fc8b..89c4785d98 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -500,8 +500,8 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
rect.top - width);
int fill_type = 0;
- if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
+ if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH))
fill_type |= FXFILL_NOPATHSMOOTH;
- }
+
pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
}
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index d1fa8115b7..a900506fe7 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -127,16 +127,16 @@ class CFX_STemplate {
height /= divisor;
return *this;
}
- CFX_STemplate operator+(const CFX_STemplate& other) {
+ CFX_STemplate operator+(const CFX_STemplate& other) const {
return CFX_STemplate(width + other.width, height + other.height);
}
- CFX_STemplate operator-(const CFX_STemplate& other) {
+ CFX_STemplate operator-(const CFX_STemplate& other) const {
return CFX_STemplate(width - other.width, height - other.height);
}
- CFX_STemplate operator*(BaseType factor) {
+ CFX_STemplate operator*(BaseType factor) const {
return CFX_STemplate(width * factor, height * factor);
}
- CFX_STemplate operator/(BaseType divisor) {
+ CFX_STemplate operator/(BaseType divisor) const {
return CFX_STemplate(width / divisor, height / divisor);
}
@@ -192,50 +192,6 @@ using CFX_VectorF = CFX_VTemplate<FX_FLOAT>;
// Rectangles.
// TODO(tsepez): Consolidate all these different rectangle classes.
-// LTRB rectangles (y-axis runs downwards).
-struct FX_RECT {
- FX_RECT() : left(0), top(0), right(0), bottom(0) {}
- FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
-
- int Width() const { return right - left; }
- int Height() const { return bottom - top; }
- bool IsEmpty() const { return right <= left || bottom <= top; }
-
- bool Valid() const {
- pdfium::base::CheckedNumeric<int> w = right;
- pdfium::base::CheckedNumeric<int> h = bottom;
- w -= left;
- h -= top;
- return w.IsValid() && h.IsValid();
- }
-
- void Normalize();
-
- void Intersect(const FX_RECT& src);
- void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); }
-
- void Offset(int dx, int dy) {
- left += dx;
- right += dx;
- top += dy;
- bottom += dy;
- }
-
- bool operator==(const FX_RECT& src) const {
- return left == src.left && right == src.right && top == src.top &&
- bottom == src.bottom;
- }
-
- bool Contains(int x, int y) const {
- return x >= left && x < right && y >= top && y < bottom;
- }
-
- int32_t left;
- int32_t top;
- int32_t right;
- int32_t bottom;
-};
-
// LTWH rectangles (y-axis runs downwards).
template <class BaseType>
class CFX_RTemplate {
@@ -450,6 +406,51 @@ class CFX_RTemplate {
using CFX_Rect = CFX_RTemplate<int32_t>;
using CFX_RectF = CFX_RTemplate<FX_FLOAT>;
+// LTRB rectangles (y-axis runs downwards).
+struct FX_RECT {
+ FX_RECT() : left(0), top(0), right(0), bottom(0) {}
+ FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
+
+ int Width() const { return right - left; }
+ int Height() const { return bottom - top; }
+ bool IsEmpty() const { return right <= left || bottom <= top; }
+
+ bool Valid() const {
+ pdfium::base::CheckedNumeric<int> w = right;
+ pdfium::base::CheckedNumeric<int> h = bottom;
+ w -= left;
+ h -= top;
+ return w.IsValid() && h.IsValid();
+ }
+
+ void Normalize();
+
+ void Intersect(const FX_RECT& src);
+ void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); }
+
+ void Offset(int dx, int dy) {
+ left += dx;
+ right += dx;
+ top += dy;
+ bottom += dy;
+ }
+
+ bool operator==(const FX_RECT& src) const {
+ return left == src.left && right == src.right && top == src.top &&
+ bottom == src.bottom;
+ }
+
+ bool Contains(int x, int y) const {
+ return x >= left && x < right && y >= top && y < bottom;
+ }
+
+ int32_t left;
+ int32_t top;
+ int32_t right;
+ int32_t bottom;
+};
+
+// LTRB rectangles (y-axis runs upwards).
class CFX_FloatRect {
public:
CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {}
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index e17f2df13a..8c7277752e 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -32,9 +32,9 @@
namespace {
-void HardClip(FX_FLOAT& x, FX_FLOAT& y) {
- x = std::max(std::min(x, 50000.0f), -50000.0f);
- y = std::max(std::min(y, 50000.0f), -50000.0f);
+CFX_PointF HardClip(const CFX_PointF& pos) {
+ return CFX_PointF(std::max(std::min(pos.x, 50000.0f), -50000.0f),
+ std::max(std::min(pos.y, 50000.0f), -50000.0f));
}
void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, uint32_t argb) {
@@ -275,45 +275,44 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device) {
const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints();
for (size_t i = 0; i < pPoints.size(); i++) {
- FX_FLOAT x = pPoints[i].m_PointX;
- FX_FLOAT y = pPoints[i].m_PointY;
+ CFX_PointF pos = pPoints[i].m_Point;
if (pObject2Device)
- pObject2Device->TransformPoint(x, y);
+ pos = pObject2Device->Transform(pos);
- HardClip(x, y);
+ pos = HardClip(pos);
FXPT_TYPE point_type = pPoints[i].m_Type;
if (point_type == FXPT_TYPE::MoveTo) {
- m_PathData.move_to(x, y);
+ m_PathData.move_to(pos.x, pos.y);
} else if (point_type == FXPT_TYPE::LineTo) {
if (pPoints[i - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo) &&
(i == pPoints.size() - 1 ||
pPoints[i + 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) &&
- pPoints[i].m_PointX == pPoints[i - 1].m_PointX &&
- pPoints[i].m_PointY == pPoints[i - 1].m_PointY) {
- x += 1;
+ pPoints[i].m_Point == pPoints[i - 1].m_Point) {
+ pos.x += 1;
}
- m_PathData.line_to(x, y);
+ m_PathData.line_to(pos.x, pos.y);
} else if (point_type == FXPT_TYPE::BezierTo) {
- FX_FLOAT x0 = pPoints[i - 1].m_PointX, y0 = pPoints[i - 1].m_PointY;
- FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY;
- FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY;
+ CFX_PointF pos0 = pPoints[i - 1].m_Point;
+ CFX_PointF pos2 = pPoints[i + 1].m_Point;
+ CFX_PointF pos3 = pPoints[i + 2].m_Point;
if (pObject2Device) {
- pObject2Device->TransformPoint(x0, y0);
- pObject2Device->TransformPoint(x2, y2);
- pObject2Device->TransformPoint(x3, y3);
+ pos0 = pObject2Device->Transform(pos0);
+ pos2 = pObject2Device->Transform(pos2);
+ pos3 = pObject2Device->Transform(pos3);
}
- HardClip(x0, y0);
- HardClip(x2, y2);
- HardClip(x3, y3);
- agg::curve4 curve(x0, y0, x, y, x2, y2, x3, y3);
+ pos0 = HardClip(pos0);
+ pos2 = HardClip(pos2);
+ pos3 = HardClip(pos3);
+ agg::curve4 curve(pos0.x, pos0.y, pos.x, pos.y, pos2.x, pos2.y, pos3.x,
+ pos3.y);
i += 2;
m_PathData.add_path_curve(curve);
}
- if (pPoints[i].m_CloseFigure) {
+ if (pPoints[i].m_CloseFigure)
m_PathData.end_poly();
- }
}
}
+
namespace agg {
template <class BaseRenderer>
diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h
index 14a8d992b9..68939bfeb2 100644
--- a/core/fxge/cfx_pathdata.h
+++ b/core/fxge/cfx_pathdata.h
@@ -13,13 +13,18 @@
#include "core/fxcrt/fx_system.h"
#include "core/fxge/cfx_renderdevice.h"
-struct FX_PATHPOINT {
+class FX_PATHPOINT {
+ public:
+ FX_PATHPOINT();
+ FX_PATHPOINT(const CFX_PointF& point, FXPT_TYPE type, bool close);
+ FX_PATHPOINT(const FX_PATHPOINT& other);
+ ~FX_PATHPOINT();
+
bool IsTypeAndOpen(FXPT_TYPE type) const {
return m_Type == type && !m_CloseFigure;
}
- FX_FLOAT m_PointX;
- FX_FLOAT m_PointY;
+ CFX_PointF m_Point;
FXPT_TYPE m_Type;
bool m_CloseFigure;
};
@@ -37,8 +42,7 @@ class CFX_PathData {
return m_Points[index].m_CloseFigure;
}
- FX_FLOAT GetPointX(int index) const { return m_Points[index].m_PointX; }
- FX_FLOAT GetPointY(int index) const { return m_Points[index].m_PointY; }
+ CFX_PointF GetPoint(int index) const { return m_Points[index].m_Point; }
const std::vector<FX_PATHPOINT>& GetPoints() const { return m_Points; }
std::vector<FX_PATHPOINT>& GetPoints() { return m_Points; }
@@ -57,7 +61,7 @@ class CFX_PathData {
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(FX_FLOAT x, FX_FLOAT y, FXPT_TYPE type, bool closeFigure);
+ void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure);
void ClosePath();
private:
diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp
index ef6960a3d7..87157b0101 100644
--- a/core/fxge/ge/cfx_font.cpp
+++ b/core/fxge/ge/cfx_font.cpp
@@ -88,18 +88,14 @@ void Outline_CheckEmptyContour(OUTLINE_PARAMS* param) {
size_t size = points.size();
if (size >= 2 && points[size - 2].IsTypeAndOpen(FXPT_TYPE::MoveTo) &&
- points[size - 2].m_PointX == points[size - 1].m_PointX &&
- points[size - 2].m_PointY == points[size - 1].m_PointY) {
+ points[size - 2].m_Point == points[size - 1].m_Point) {
size -= 2;
}
if (size >= 4 && points[size - 4].IsTypeAndOpen(FXPT_TYPE::MoveTo) &&
points[size - 3].IsTypeAndOpen(FXPT_TYPE::BezierTo) &&
- points[size - 3].m_PointX == points[size - 4].m_PointX &&
- points[size - 3].m_PointY == points[size - 4].m_PointY &&
- points[size - 2].m_PointX == points[size - 4].m_PointX &&
- points[size - 2].m_PointY == points[size - 4].m_PointY &&
- points[size - 1].m_PointX == points[size - 4].m_PointX &&
- points[size - 1].m_PointY == points[size - 4].m_PointY) {
+ points[size - 3].m_Point == points[size - 4].m_Point &&
+ points[size - 2].m_Point == points[size - 4].m_Point &&
+ points[size - 1].m_Point == points[size - 4].m_Point) {
size -= 4;
}
points.resize(size);
@@ -111,9 +107,9 @@ int Outline_MoveTo(const FXFT_Vector* to, void* user) {
Outline_CheckEmptyContour(param);
param->m_pPath->ClosePath();
- param->m_pPath->AppendPoint(to->x / param->m_CoordUnit,
- to->y / param->m_CoordUnit, FXPT_TYPE::MoveTo,
- false);
+ param->m_pPath->AppendPoint(
+ CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit),
+ FXPT_TYPE::MoveTo, false);
param->m_CurX = to->x;
param->m_CurY = to->y;
@@ -123,9 +119,9 @@ int Outline_MoveTo(const FXFT_Vector* to, void* user) {
int Outline_LineTo(const FXFT_Vector* to, void* user) {
OUTLINE_PARAMS* param = (OUTLINE_PARAMS*)user;
- param->m_pPath->AppendPoint(to->x / param->m_CoordUnit,
- to->y / param->m_CoordUnit, FXPT_TYPE::LineTo,
- false);
+ param->m_pPath->AppendPoint(
+ CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit),
+ FXPT_TYPE::LineTo, false);
param->m_CurX = to->x;
param->m_CurY = to->y;
@@ -138,20 +134,20 @@ int Outline_ConicTo(const FXFT_Vector* control,
OUTLINE_PARAMS* param = (OUTLINE_PARAMS*)user;
param->m_pPath->AppendPoint(
- (param->m_CurX + (control->x - param->m_CurX) * 2 / 3) /
- param->m_CoordUnit,
- (param->m_CurY + (control->y - param->m_CurY) * 2 / 3) /
- param->m_CoordUnit,
+ CFX_PointF((param->m_CurX + (control->x - param->m_CurX) * 2 / 3) /
+ param->m_CoordUnit,
+ (param->m_CurY + (control->y - param->m_CurY) * 2 / 3) /
+ param->m_CoordUnit),
FXPT_TYPE::BezierTo, false);
param->m_pPath->AppendPoint(
- (control->x + (to->x - control->x) / 3) / param->m_CoordUnit,
- (control->y + (to->y - control->y) / 3) / param->m_CoordUnit,
+ CFX_PointF((control->x + (to->x - control->x) / 3) / param->m_CoordUnit,
+ (control->y + (to->y - control->y) / 3) / param->m_CoordUnit),
FXPT_TYPE::BezierTo, false);
- param->m_pPath->AppendPoint(to->x / param->m_CoordUnit,
- to->y / param->m_CoordUnit, FXPT_TYPE::BezierTo,
- false);
+ param->m_pPath->AppendPoint(
+ CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit),
+ FXPT_TYPE::BezierTo, false);
param->m_CurX = to->x;
param->m_CurY = to->y;
@@ -164,17 +160,17 @@ int Outline_CubicTo(const FXFT_Vector* control1,
void* user) {
OUTLINE_PARAMS* param = (OUTLINE_PARAMS*)user;
- param->m_pPath->AppendPoint(control1->x / param->m_CoordUnit,
- control1->y / param->m_CoordUnit,
+ param->m_pPath->AppendPoint(CFX_PointF(control1->x / param->m_CoordUnit,
+ control1->y / param->m_CoordUnit),
FXPT_TYPE::BezierTo, false);
- param->m_pPath->AppendPoint(control2->x / param->m_CoordUnit,
- control2->y / param->m_CoordUnit,
+ param->m_pPath->AppendPoint(CFX_PointF(control2->x / param->m_CoordUnit,
+ control2->y / param->m_CoordUnit),
FXPT_TYPE::BezierTo, false);
- param->m_pPath->AppendPoint(to->x / param->m_CoordUnit,
- to->y / param->m_CoordUnit, FXPT_TYPE::BezierTo,
- false);
+ param->m_pPath->AppendPoint(
+ CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit),
+ FXPT_TYPE::BezierTo, false);
param->m_CurX = to->x;
param->m_CurY = to->y;
diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp
index e06eadd6ce..9fa2cd2aac 100644
--- a/core/fxge/ge/cfx_pathdata.cpp
+++ b/core/fxge/ge/cfx_pathdata.cpp
@@ -9,6 +9,164 @@
#include "core/fxcrt/fx_system.h"
#include "third_party/base/numerics/safe_math.h"
+namespace {
+
+void UpdateLineEndPoints(CFX_FloatRect* rect,
+ const CFX_PointF& start_pos,
+ const CFX_PointF& end_pos,
+ FX_FLOAT hw) {
+ if (start_pos.x == end_pos.x) {
+ if (start_pos.y == end_pos.y) {
+ rect->UpdateRect(end_pos.x + hw, end_pos.y + hw);
+ rect->UpdateRect(end_pos.x - hw, end_pos.y - hw);
+ return;
+ }
+
+ FX_FLOAT point_y;
+ if (end_pos.y < start_pos.y)
+ point_y = end_pos.y - hw;
+ else
+ point_y = end_pos.y + hw;
+
+ rect->UpdateRect(end_pos.x + hw, point_y);
+ rect->UpdateRect(end_pos.x - hw, point_y);
+ return;
+ }
+
+ if (start_pos.y == end_pos.y) {
+ FX_FLOAT point_x;
+ if (end_pos.x < start_pos.x)
+ point_x = end_pos.x - hw;
+ else
+ point_x = end_pos.x + hw;
+
+ rect->UpdateRect(point_x, end_pos.y + hw);
+ rect->UpdateRect(point_x, end_pos.y - hw);
+ return;
+ }
+
+ CFX_PointF diff = end_pos - start_pos;
+ FX_FLOAT ll = FXSYS_sqrt2(diff.x, diff.y);
+ FX_FLOAT mx = end_pos.x + hw * diff.x / ll;
+ FX_FLOAT my = end_pos.y + hw * diff.y / ll;
+ FX_FLOAT dx1 = hw * diff.y / ll;
+ FX_FLOAT dy1 = hw * diff.x / ll;
+ rect->UpdateRect(mx - dx1, my + dy1);
+ rect->UpdateRect(mx + dx1, my - dy1);
+}
+
+void UpdateLineJoinPoints(CFX_FloatRect* rect,
+ const CFX_PointF& start_pos,
+ const CFX_PointF& mid_pos,
+ const CFX_PointF& end_pos,
+ FX_FLOAT half_width,
+ FX_FLOAT miter_limit) {
+ FX_FLOAT start_k = 0;
+ FX_FLOAT start_c = 0;
+ FX_FLOAT end_k = 0;
+ FX_FLOAT end_c = 0;
+ FX_FLOAT start_len = 0;
+ FX_FLOAT start_dc = 0;
+ FX_FLOAT end_len = 0;
+ FX_FLOAT end_dc = 0;
+ FX_FLOAT one_twentieth = 1.0f / 20;
+
+ bool bStartVert = FXSYS_fabs(start_pos.x - mid_pos.x) < one_twentieth;
+ bool bEndVert = FXSYS_fabs(mid_pos.x - end_pos.x) < one_twentieth;
+ if (bStartVert && bEndVert) {
+ int start_dir = mid_pos.y > start_pos.y ? 1 : -1;
+ FX_FLOAT point_y = mid_pos.y + half_width * start_dir;
+ rect->UpdateRect(mid_pos.x + half_width, point_y);
+ rect->UpdateRect(mid_pos.x - half_width, point_y);
+ return;
+ }
+
+ if (!bStartVert) {
+ CFX_PointF start_to_mid = start_pos - mid_pos;
+ start_k = (mid_pos.y - start_pos.y) / (mid_pos.x - start_pos.x);
+ start_c = mid_pos.y - (start_k * mid_pos.x);
+ start_len = FXSYS_sqrt2(start_to_mid.x, start_to_mid.y);
+ start_dc = static_cast<FX_FLOAT>(
+ FXSYS_fabs(half_width * start_len / start_to_mid.x));
+ }
+ if (!bEndVert) {
+ CFX_PointF end_to_mid = end_pos - mid_pos;
+ end_k = end_to_mid.y / end_to_mid.x;
+ end_c = mid_pos.y - (end_k * mid_pos.x);
+ end_len = FXSYS_sqrt2(end_to_mid.x, end_to_mid.y);
+ end_dc =
+ static_cast<FX_FLOAT>(FXSYS_fabs(half_width * end_len / end_to_mid.x));
+ }
+ if (bStartVert) {
+ CFX_PointF outside(start_pos.x, 0);
+ if (end_pos.x < start_pos.x)
+ outside.x += half_width;
+ else
+ outside.x -= half_width;
+
+ if (start_pos.y < (end_k * start_pos.x) + end_c)
+ outside.y = (end_k * outside.x) + end_c + end_dc;
+ else
+ outside.y = (end_k * outside.x) + end_c - end_dc;
+
+ rect->UpdateRect(outside.x, outside.y);
+ return;
+ }
+
+ if (bEndVert) {
+ CFX_PointF outside(end_pos.x, 0);
+ if (start_pos.x < end_pos.x)
+ outside.x += half_width;
+ else
+ outside.x -= half_width;
+
+ if (end_pos.y < (start_k * end_pos.x) + start_c)
+ outside.y = (start_k * outside.x) + start_c + start_dc;
+ else
+ outside.y = (start_k * outside.x) + start_c - start_dc;
+
+ rect->UpdateRect(outside.x, outside.y);
+ return;
+ }
+
+ if (FXSYS_fabs(start_k - end_k) < one_twentieth) {
+ int start_dir = mid_pos.x > start_pos.x ? 1 : -1;
+ int end_dir = end_pos.x > mid_pos.x ? 1 : -1;
+ if (start_dir == end_dir)
+ UpdateLineEndPoints(rect, mid_pos, end_pos, half_width);
+ else
+ UpdateLineEndPoints(rect, start_pos, mid_pos, half_width);
+ return;
+ }
+
+ FX_FLOAT start_outside_c = start_c;
+ if (end_pos.y < (start_k * end_pos.x) + start_c)
+ start_outside_c += start_dc;
+ else
+ start_outside_c -= start_dc;
+
+ FX_FLOAT end_outside_c = end_c;
+ if (start_pos.y < (end_k * start_pos.x) + end_c)
+ end_outside_c += end_dc;
+ else
+ end_outside_c -= end_dc;
+
+ FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k);
+ FX_FLOAT join_y = start_k * join_x + start_outside_c;
+ rect->UpdateRect(join_x, join_y);
+}
+
+} // namespace
+
+FX_PATHPOINT::FX_PATHPOINT() = default;
+
+FX_PATHPOINT::FX_PATHPOINT(const CFX_PointF& point, FXPT_TYPE type, bool close)
+ : m_Point(point), m_Type(type), m_CloseFigure(close) {}
+
+FX_PATHPOINT::FX_PATHPOINT(const FX_PATHPOINT& other) = default;
+
+FX_PATHPOINT::~FX_PATHPOINT() = default;
+
CFX_PathData::CFX_PathData() {}
CFX_PathData::~CFX_PathData() {}
@@ -36,25 +194,29 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
return;
for (size_t i = cur_size; i < m_Points.size(); i++)
- pMatrix->TransformPoint(m_Points[i].m_PointX, m_Points[i].m_PointY);
+ m_Points[i].m_Point = pMatrix->Transform(m_Points[i].m_Point);
}
-void CFX_PathData::AppendPoint(FX_FLOAT x,
- FX_FLOAT y,
+void CFX_PathData::AppendPoint(const CFX_PointF& point,
FXPT_TYPE type,
bool closeFigure) {
- m_Points.push_back({x, y, type, closeFigure});
+ m_Points.push_back(FX_PATHPOINT(point, type, closeFigure));
}
void CFX_PathData::AppendRect(FX_FLOAT left,
FX_FLOAT bottom,
FX_FLOAT right,
FX_FLOAT top) {
- m_Points.push_back({left, bottom, FXPT_TYPE::MoveTo, false});
- m_Points.push_back({left, top, FXPT_TYPE::LineTo, false});
- m_Points.push_back({right, top, FXPT_TYPE::LineTo, false});
- m_Points.push_back({right, bottom, FXPT_TYPE::LineTo, false});
- m_Points.push_back({left, bottom, FXPT_TYPE::LineTo, true});
+ m_Points.push_back(
+ FX_PATHPOINT(CFX_PointF(left, bottom), FXPT_TYPE::MoveTo, false));
+ m_Points.push_back(
+ FX_PATHPOINT(CFX_PointF(left, top), FXPT_TYPE::LineTo, false));
+ m_Points.push_back(
+ FX_PATHPOINT(CFX_PointF(right, top), FXPT_TYPE::LineTo, false));
+ m_Points.push_back(
+ FX_PATHPOINT(CFX_PointF(right, bottom), FXPT_TYPE::LineTo, false));
+ m_Points.push_back(
+ FX_PATHPOINT(CFX_PointF(left, bottom), FXPT_TYPE::LineTo, true));
}
CFX_FloatRect CFX_PathData::GetBoundingBox() const {
@@ -62,153 +224,15 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const {
return CFX_FloatRect();
CFX_FloatRect rect;
- rect.InitRect(m_Points[0].m_PointX, m_Points[0].m_PointY);
+ rect.InitRect(m_Points[0].m_Point.x, m_Points[0].m_Point.y);
for (size_t i = 1; i < m_Points.size(); i++)
- rect.UpdateRect(m_Points[i].m_PointX, m_Points[i].m_PointY);
+ rect.UpdateRect(m_Points[i].m_Point.x, m_Points[i].m_Point.y);
return rect;
}
-static void _UpdateLineEndPoints(CFX_FloatRect& rect,
- FX_FLOAT start_x,
- FX_FLOAT start_y,
- FX_FLOAT end_x,
- FX_FLOAT end_y,
- FX_FLOAT hw) {
- if (start_x == end_x) {
- if (start_y == end_y) {
- rect.UpdateRect(end_x + hw, end_y + hw);
- rect.UpdateRect(end_x - hw, end_y - hw);
- return;
- }
- FX_FLOAT point_y;
- if (end_y < start_y) {
- point_y = end_y - hw;
- } else {
- point_y = end_y + hw;
- }
- rect.UpdateRect(end_x + hw, point_y);
- rect.UpdateRect(end_x - hw, point_y);
- return;
- }
- if (start_y == end_y) {
- FX_FLOAT point_x;
- if (end_x < start_x) {
- point_x = end_x - hw;
- } else {
- point_x = end_x + hw;
- }
- rect.UpdateRect(point_x, end_y + hw);
- rect.UpdateRect(point_x, end_y - hw);
- return;
- }
- FX_FLOAT dx = end_x - start_x;
- FX_FLOAT dy = end_y - start_y;
- FX_FLOAT ll = FXSYS_sqrt2(dx, dy);
- FX_FLOAT mx = end_x + hw * dx / ll;
- FX_FLOAT my = end_y + hw * dy / ll;
- FX_FLOAT dx1 = hw * dy / ll;
- FX_FLOAT dy1 = hw * dx / ll;
- rect.UpdateRect(mx - dx1, my + dy1);
- rect.UpdateRect(mx + dx1, my - dy1);
-}
-
-static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
- FX_FLOAT start_x,
- FX_FLOAT start_y,
- FX_FLOAT middle_x,
- FX_FLOAT middle_y,
- FX_FLOAT end_x,
- FX_FLOAT end_y,
- FX_FLOAT half_width,
- FX_FLOAT miter_limit) {
- FX_FLOAT start_k = 0, start_c = 0, end_k = 0, end_c = 0, start_len = 0,
- start_dc = 0, end_len = 0, end_dc = 0;
- bool bStartVert = FXSYS_fabs(start_x - middle_x) < 1.0f / 20;
- bool bEndVert = FXSYS_fabs(middle_x - end_x) < 1.0f / 20;
- if (bStartVert && bEndVert) {
- int start_dir = middle_y > start_y ? 1 : -1;
- FX_FLOAT point_y = middle_y + half_width * start_dir;
- rect.UpdateRect(middle_x + half_width, point_y);
- rect.UpdateRect(middle_x - half_width, point_y);
- return;
- }
- if (!bStartVert) {
- start_k = (middle_y - start_y) / (middle_x - start_x);
- start_c = middle_y - (start_k * middle_x);
- start_len = FXSYS_sqrt2(start_x - middle_x, start_y - middle_y);
- start_dc =
- (FX_FLOAT)FXSYS_fabs(half_width * start_len / (start_x - middle_x));
- }
- if (!bEndVert) {
- end_k = (end_y - middle_y) / (end_x - middle_x);
- end_c = middle_y - (end_k * middle_x);
- end_len = FXSYS_sqrt2(end_x - middle_x, end_y - middle_y);
- end_dc = (FX_FLOAT)FXSYS_fabs(half_width * end_len / (end_x - middle_x));
- }
- if (bStartVert) {
- FX_FLOAT outside_x = start_x;
- if (end_x < start_x) {
- outside_x += half_width;
- } else {
- outside_x -= half_width;
- }
- FX_FLOAT outside_y;
- if (start_y < (end_k * start_x) + end_c) {
- outside_y = (end_k * outside_x) + end_c + end_dc;
- } else {
- outside_y = (end_k * outside_x) + end_c - end_dc;
- }
- rect.UpdateRect(outside_x, outside_y);
- return;
- }
- if (bEndVert) {
- FX_FLOAT outside_x = end_x;
- if (start_x < end_x) {
- outside_x += half_width;
- } else {
- outside_x -= half_width;
- }
- FX_FLOAT outside_y;
- if (end_y < (start_k * end_x) + start_c) {
- outside_y = (start_k * outside_x) + start_c + start_dc;
- } else {
- outside_y = (start_k * outside_x) + start_c - start_dc;
- }
- rect.UpdateRect(outside_x, outside_y);
- return;
- }
- if (FXSYS_fabs(start_k - end_k) < 1.0f / 20) {
- int start_dir = middle_x > start_x ? 1 : -1;
- int end_dir = end_x > middle_x ? 1 : -1;
- if (start_dir == end_dir) {
- _UpdateLineEndPoints(rect, middle_x, middle_y, end_x, end_y, half_width);
- } else {
- _UpdateLineEndPoints(rect, start_x, start_y, middle_x, middle_y,
- half_width);
- }
- return;
- }
- FX_FLOAT start_outside_c = start_c;
- if (end_y < (start_k * end_x) + start_c) {
- start_outside_c += start_dc;
- } else {
- start_outside_c -= start_dc;
- }
- FX_FLOAT end_outside_c = end_c;
- if (start_y < (end_k * start_x) + end_c) {
- end_outside_c += end_dc;
- } else {
- end_outside_c -= end_dc;
- }
- FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k);
- FX_FLOAT join_y = (start_k * join_x) + start_outside_c;
- rect.UpdateRect(join_x, join_y);
-}
-
CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
FX_FLOAT miter_limit) const {
- CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f,
- -100000 * 1.0f);
+ CFX_FloatRect rect(100000.0f, 100000.0f, -100000.0f, -100000.0f);
size_t iPoint = 0;
FX_FLOAT half_width = line_width;
int iStartPoint = 0;
@@ -222,9 +246,9 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
bJoin = false;
} else {
if (m_Points[iPoint].IsTypeAndOpen(FXPT_TYPE::BezierTo)) {
- rect.UpdateRect(m_Points[iPoint].m_PointX, m_Points[iPoint].m_PointY);
- rect.UpdateRect(m_Points[iPoint + 1].m_PointX,
- m_Points[iPoint + 1].m_PointY);
+ rect.UpdateRect(m_Points[iPoint].m_Point.x, m_Points[iPoint].m_Point.y);
+ rect.UpdateRect(m_Points[iPoint + 1].m_Point.x,
+ m_Points[iPoint + 1].m_Point.y);
iPoint += 2;
}
if (iPoint == m_Points.size() - 1 ||
@@ -239,17 +263,15 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
bJoin = true;
}
}
- FX_FLOAT start_x = m_Points[iStartPoint].m_PointX;
- FX_FLOAT start_y = m_Points[iStartPoint].m_PointY;
- FX_FLOAT end_x = m_Points[iEndPoint].m_PointX;
- FX_FLOAT end_y = m_Points[iEndPoint].m_PointY;
+
+ CFX_PointF start_pos = m_Points[iStartPoint].m_Point;
+ CFX_PointF end_pos = m_Points[iEndPoint].m_Point;
if (bJoin) {
- FX_FLOAT middle_x = m_Points[iMiddlePoint].m_PointX;
- FX_FLOAT middle_y = m_Points[iMiddlePoint].m_PointY;
- _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, end_x,
- end_y, half_width, miter_limit);
+ CFX_PointF mid_pos = m_Points[iMiddlePoint].m_Point;
+ UpdateLineJoinPoints(&rect, start_pos, mid_pos, end_pos, half_width,
+ miter_limit);
} else {
- _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_width);
+ UpdateLineEndPoints(&rect, start_pos, end_pos, half_width);
}
iPoint++;
}
@@ -260,7 +282,7 @@ void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
if (!pMatrix)
return;
for (auto& point : m_Points)
- pMatrix->TransformPoint(point.m_PointX, point.m_PointY);
+ point.m_Point = pMatrix->Transform(point.m_Point);
}
bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix,
@@ -275,26 +297,25 @@ bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix,
if (m_Points.size() == 3 && m_Points[0].m_Type == FXPT_TYPE::MoveTo &&
m_Points[1].m_Type == FXPT_TYPE::LineTo &&
m_Points[2].m_Type == FXPT_TYPE::LineTo &&
- m_Points[0].m_PointX == m_Points[2].m_PointX &&
- m_Points[0].m_PointY == m_Points[2].m_PointY) {
+ m_Points[0].m_Point == m_Points[2].m_Point) {
for (size_t i = 0; i < 2; i++) {
- FX_FLOAT x = m_Points[i].m_PointX;
- FX_FLOAT y = m_Points[i].m_PointY;
+ CFX_PointF point = m_Points[i].m_Point;
if (bAdjust) {
if (pMatrix)
- pMatrix->TransformPoint(x, y);
+ point = pMatrix->Transform(point);
- x = static_cast<int>(x) + 0.5f;
- y = static_cast<int>(y) + 0.5f;
+ point = CFX_PointF(static_cast<int>(point.x) + 0.5f,
+ static_cast<int>(point.y) + 0.5f);
}
- NewPath->AppendPoint(x, y, i == 0 ? FXPT_TYPE::MoveTo : FXPT_TYPE::LineTo,
- false);
+ NewPath->AppendPoint(
+ point, i == 0 ? FXPT_TYPE::MoveTo : FXPT_TYPE::LineTo, false);
}
if (bAdjust && pMatrix)
*setIdentity = true;
- if (m_Points[0].m_PointX != m_Points[1].m_PointX &&
- m_Points[0].m_PointY != m_Points[1].m_PointY) {
+ // Note, they both have to be not equal.
+ if (m_Points[0].m_Point.x != m_Points[1].m_Point.x &&
+ m_Points[0].m_Point.y != m_Points[1].m_Point.y) {
*bThin = true;
}
return true;
@@ -305,18 +326,15 @@ bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix,
bool bZeroArea = false;
CFX_PathData t_path;
for (int i = 0; i < mid; i++) {
- if (!(m_Points[mid - i - 1].m_PointX == m_Points[mid + i + 1].m_PointX &&
- m_Points[mid - i - 1].m_PointY == m_Points[mid + i + 1].m_PointY &&
+ if (!(m_Points[mid - i - 1].m_Point == m_Points[mid + i + 1].m_Point &&
m_Points[mid - i - 1].m_Type != FXPT_TYPE::BezierTo &&
m_Points[mid + i + 1].m_Type != FXPT_TYPE::BezierTo)) {
bZeroArea = true;
break;
}
- t_path.AppendPoint(m_Points[mid - i].m_PointX, m_Points[mid - i].m_PointY,
- FXPT_TYPE::MoveTo, false);
- t_path.AppendPoint(m_Points[mid - i - 1].m_PointX,
- m_Points[mid - i - 1].m_PointY, FXPT_TYPE::LineTo,
+ t_path.AppendPoint(m_Points[mid - i].m_Point, FXPT_TYPE::MoveTo, false);
+ t_path.AppendPoint(m_Points[mid - i - 1].m_Point, FXPT_TYPE::LineTo,
false);
}
if (!bZeroArea) {
@@ -336,48 +354,43 @@ bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix,
next = (i + 1 - stratPoint) % (m_Points.size() - stratPoint) + stratPoint;
if (m_Points[next].m_Type != FXPT_TYPE::BezierTo &&
m_Points[next].m_Type != FXPT_TYPE::MoveTo) {
- if ((m_Points[i - 1].m_PointX == m_Points[i].m_PointX &&
- m_Points[i].m_PointX == m_Points[next].m_PointX) &&
- ((m_Points[i].m_PointY - m_Points[i - 1].m_PointY) *
- (m_Points[i].m_PointY - m_Points[next].m_PointY) >
+ if ((m_Points[i - 1].m_Point.x == m_Points[i].m_Point.x &&
+ m_Points[i].m_Point.x == m_Points[next].m_Point.x) &&
+ ((m_Points[i].m_Point.y - m_Points[i - 1].m_Point.y) *
+ (m_Points[i].m_Point.y - m_Points[next].m_Point.y) >
0)) {
int pre = i;
- if (FXSYS_fabs(m_Points[i].m_PointY - m_Points[i - 1].m_PointY) <
- FXSYS_fabs(m_Points[i].m_PointY - m_Points[next].m_PointY)) {
+ if (FXSYS_fabs(m_Points[i].m_Point.y - m_Points[i - 1].m_Point.y) <
+ FXSYS_fabs(m_Points[i].m_Point.y - m_Points[next].m_Point.y)) {
pre--;
next--;
}
- NewPath->AppendPoint(m_Points[pre].m_PointX, m_Points[pre].m_PointY,
- FXPT_TYPE::MoveTo, false);
- NewPath->AppendPoint(m_Points[next].m_PointX, m_Points[next].m_PointY,
- FXPT_TYPE::LineTo, false);
- } else if ((m_Points[i - 1].m_PointY == m_Points[i].m_PointY &&
- m_Points[i].m_PointY == m_Points[next].m_PointY) &&
- ((m_Points[i].m_PointX - m_Points[i - 1].m_PointX) *
- (m_Points[i].m_PointX - m_Points[next].m_PointX) >
+ NewPath->AppendPoint(m_Points[pre].m_Point, FXPT_TYPE::MoveTo, false);
+ NewPath->AppendPoint(m_Points[next].m_Point, FXPT_TYPE::LineTo,
+ false);
+ } else if ((m_Points[i - 1].m_Point.y == m_Points[i].m_Point.y &&
+ m_Points[i].m_Point.y == m_Points[next].m_Point.y) &&
+ ((m_Points[i].m_Point.x - m_Points[i - 1].m_Point.x) *
+ (m_Points[i].m_Point.x - m_Points[next].m_Point.x) >
0)) {
int pre = i;
- if (FXSYS_fabs(m_Points[i].m_PointX - m_Points[i - 1].m_PointX) <
- FXSYS_fabs(m_Points[i].m_PointX - m_Points[next].m_PointX)) {
+ if (FXSYS_fabs(m_Points[i].m_Point.x - m_Points[i - 1].m_Point.x) <
+ FXSYS_fabs(m_Points[i].m_Point.x - m_Points[next].m_Point.x)) {
pre--;
next--;
}
- NewPath->AppendPoint(m_Points[pre].m_PointX, m_Points[pre].m_PointY,
- FXPT_TYPE::MoveTo, false);
- NewPath->AppendPoint(m_Points[next].m_PointX, m_Points[next].m_PointY,
- FXPT_TYPE::LineTo, false);
+ NewPath->AppendPoint(m_Points[pre].m_Point, FXPT_TYPE::MoveTo, false);
+ NewPath->AppendPoint(m_Points[next].m_Point, FXPT_TYPE::LineTo,
+ false);
} else if (m_Points[i - 1].m_Type == FXPT_TYPE::MoveTo &&
m_Points[next].m_Type == FXPT_TYPE::LineTo &&
- m_Points[i - 1].m_PointX == m_Points[next].m_PointX &&
- m_Points[i - 1].m_PointY == m_Points[next].m_PointY &&
+ m_Points[i - 1].m_Point == m_Points[next].m_Point &&
m_Points[next].m_CloseFigure) {
- NewPath->AppendPoint(m_Points[i - 1].m_PointX,
- m_Points[i - 1].m_PointY, FXPT_TYPE::MoveTo,
+ NewPath->AppendPoint(m_Points[i - 1].m_Point, FXPT_TYPE::MoveTo,
false);
- NewPath->AppendPoint(m_Points[i].m_PointX, m_Points[i].m_PointY,
- FXPT_TYPE::LineTo, false);
+ NewPath->AppendPoint(m_Points[i].m_Point, FXPT_TYPE::LineTo, false);
*bThin = true;
}
}
@@ -397,24 +410,23 @@ bool CFX_PathData::IsRect() const {
if (m_Points.size() != 5 && m_Points.size() != 4)
return false;
- if ((m_Points.size() == 5 &&
- (m_Points[0].m_PointX != m_Points[4].m_PointX ||
- m_Points[0].m_PointY != m_Points[4].m_PointY)) ||
- (m_Points[0].m_PointX == m_Points[2].m_PointX &&
- m_Points[0].m_PointY == m_Points[2].m_PointY) ||
- (m_Points[1].m_PointX == m_Points[3].m_PointX &&
- m_Points[1].m_PointY == m_Points[3].m_PointY)) {
+ if ((m_Points.size() == 5 && m_Points[0].m_Point != m_Points[4].m_Point) ||
+ m_Points[0].m_Point == m_Points[2].m_Point ||
+ m_Points[1].m_Point == m_Points[3].m_Point) {
return false;
}
- if (m_Points[0].m_PointX != m_Points[3].m_PointX &&
- m_Points[0].m_PointY != m_Points[3].m_PointY) {
+ // Note, both x,y have to not equal.
+ if (m_Points[0].m_Point.x != m_Points[3].m_Point.x &&
+ m_Points[0].m_Point.y != m_Points[3].m_Point.y) {
return false;
}
+
for (int i = 1; i < 4; i++) {
if (m_Points[i].m_Type != FXPT_TYPE::LineTo)
return false;
- if (m_Points[i].m_PointX != m_Points[i - 1].m_PointX &&
- m_Points[i].m_PointY != m_Points[i - 1].m_PointY) {
+ // Note, both x,y have to not equal.
+ if (m_Points[i].m_Point.x != m_Points[i - 1].m_Point.x &&
+ m_Points[i].m_Point.y != m_Points[i - 1].m_Point.y) {
return false;
}
}
@@ -428,10 +440,10 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
return false;
if (pRect) {
- pRect->left = m_Points[0].m_PointX;
- pRect->right = m_Points[2].m_PointX;
- pRect->bottom = m_Points[0].m_PointY;
- pRect->top = m_Points[2].m_PointY;
+ pRect->left = m_Points[0].m_Point.x;
+ pRect->right = m_Points[2].m_Point.x;
+ pRect->bottom = m_Points[0].m_Point.y;
+ pRect->top = m_Points[2].m_Point.y;
pRect->Normalize();
}
return true;
@@ -440,22 +452,19 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
if (m_Points.size() != 5 && m_Points.size() != 4)
return false;
- if ((m_Points.size() == 5 &&
- (m_Points[0].m_PointX != m_Points[4].m_PointX ||
- m_Points[0].m_PointY != m_Points[4].m_PointY)) ||
- (m_Points[1].m_PointX == m_Points[3].m_PointX &&
- m_Points[1].m_PointY == m_Points[3].m_PointY)) {
+ if ((m_Points.size() == 5 && m_Points[0].m_Point != m_Points[4].m_Point) ||
+ m_Points[1].m_Point == m_Points[3].m_Point) {
return false;
}
- if (m_Points.size() == 4 && m_Points[0].m_PointX != m_Points[3].m_PointX &&
- m_Points[0].m_PointY != m_Points[3].m_PointY) {
+ // Note, both x,y not equal.
+ if (m_Points.size() == 4 && m_Points[0].m_Point.x != m_Points[3].m_Point.x &&
+ m_Points[0].m_Point.y != m_Points[3].m_Point.y) {
return false;
}
CFX_PointF points[5];
for (size_t i = 0; i < m_Points.size(); i++) {
- points[i] = pMatrix->Transform(
- CFX_PointF(m_Points[i].m_PointX, m_Points[i].m_PointY));
+ points[i] = pMatrix->Transform(m_Points[i].m_Point);
if (i == 0)
continue;
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 203fecf061..daa67ccc91 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -490,8 +490,8 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData,
uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0;
const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints();
if (stroke_alpha == 0 && pPoints.size() == 2) {
- CFX_PointF pos1(pPoints[0].m_PointX, pPoints[0].m_PointY);
- CFX_PointF pos2(pPoints[1].m_PointX, pPoints[1].m_PointY);
+ CFX_PointF pos1 = pPoints[0].m_Point;
+ CFX_PointF pos2 = pPoints[1].m_Point;
if (pObject2Device) {
pos1 = pObject2Device->Transform(pos1);
pos2 = pObject2Device->Transform(pos2);
@@ -692,8 +692,8 @@ bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1,
}
CFX_GraphStateData graph_state;
CFX_PathData path;
- path.AppendPoint(x1, y1, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(x2, y2, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(CFX_PointF(x2, y2), FXPT_TYPE::LineTo, false);
return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color,
fill_mode, blend_type);
}
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 431491d826..7e23f97287 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -280,17 +280,16 @@ SkPath BuildPath(const CFX_PathData* pPathData) {
const CFX_PathData* pFPath = pPathData;
const std::vector<FX_PATHPOINT>& pPoints = pFPath->GetPoints();
for (size_t i = 0; i < pPoints.size(); i++) {
- FX_FLOAT x = pPoints[i].m_PointX;
- FX_FLOAT y = pPoints[i].m_PointY;
+ CFX_PointF point = pPoints[i].m_Point;
FXPT_TYPE point_type = pPoints[i].m_Type;
if (point_type == FXPT_TYPE::MoveTo) {
- skPath.moveTo(x, y);
+ skPath.moveTo(point.x, point.y);
} else if (point_type == FXPT_TYPE::LineTo) {
- skPath.lineTo(x, y);
+ skPath.lineTo(point.x, point.y);
} else if (point_type == FXPT_TYPE::BezierTo) {
- FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY;
- FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY;
- skPath.cubicTo(x, y, x2, y2, x3, y3);
+ CFX_PointF point2 = pPoints[i + 1].m_Point;
+ CFX_PointF point3 = pPoints[i + 2].m_Point;
+ skPath.cubicTo(point.x, point.y, point2.x, point2.y, point3.x, point3.y);
i += 2;
}
if (pPoints[i].m_CloseFigure)
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index a0e675e23c..74fae088d9 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -116,7 +116,7 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
for (size_t i = 0; i < size; i++) {
FXPT_TYPE type = pPathData->GetType(i);
bool closing = pPathData->IsClosingFigure(i);
- CFX_PointF pos(pPathData->GetPointX(i), pPathData->GetPointY(i));
+ CFX_PointF pos = pPathData->GetPoint(i);
if (pObject2Device)
pos = pObject2Device->Transform(pos);
@@ -131,10 +131,8 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
buf << "h ";
break;
case FXPT_TYPE::BezierTo: {
- CFX_PointF pos1(pPathData->GetPointX(i + 1),
- pPathData->GetPointY(i + 1));
- CFX_PointF pos2(pPathData->GetPointX(i + 2),
- pPathData->GetPointY(i + 2));
+ CFX_PointF pos1 = pPathData->GetPoint(i + 1);
+ CFX_PointF pos2 = pPathData->GetPoint(i + 2);
if (pObject2Device) {
pos1 = pObject2Device->Transform(pos1);
pos2 = pObject2Device->Transform(pos2);
@@ -604,21 +602,21 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
buf << "/X" << *ps_fontnum << " Ff/CharProcs get begin/" << glyphindex
<< "{n ";
for (size_t p = 0; p < TransformedPath.GetPoints().size(); p++) {
- FX_FLOAT x = TransformedPath.GetPointX(p), y = TransformedPath.GetPointY(p);
+ CFX_PointF point = TransformedPath.GetPoint(p);
switch (TransformedPath.GetType(p)) {
case FXPT_TYPE::MoveTo: {
- buf << x << " " << y << " m\n";
+ buf << point.x << " " << point.y << " m\n";
break;
}
case FXPT_TYPE::LineTo: {
- buf << x << " " << y << " l\n";
+ buf << point.x << " " << point.y << " l\n";
break;
}
case FXPT_TYPE::BezierTo: {
- buf << x << " " << y << " " << TransformedPath.GetPointX(p + 1) << " "
- << TransformedPath.GetPointY(p + 1) << " "
- << TransformedPath.GetPointX(p + 2) << " "
- << TransformedPath.GetPointY(p + 2) << " c\n";
+ CFX_PointF point1 = TransformedPath.GetPoint(p + 1);
+ CFX_PointF point2 = TransformedPath.GetPoint(p + 2);
+ buf << point.x << " " << point.y << " " << point1.x << " " << point1.y
+ << " " << point2.x << " " << point2.y << " c\n";
p += 2;
break;
}
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index b5ce7345c6..92e9b41e06 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -169,45 +169,42 @@ void SetPathToDC(HDC hDC,
const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints();
for (size_t i = 0; i < pPoints.size(); i++) {
- FX_FLOAT posx = pPoints[i].m_PointX;
- FX_FLOAT posy = pPoints[i].m_PointY;
+ CFX_PointF pos = pPoints[i].m_Point;
if (pMatrix)
- pMatrix->TransformPoint(posx, posy);
+ pos = pMatrix->Transform(pos);
- int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy);
+ CFX_Point screen(FXSYS_round(pos.x), FXSYS_round(pos.y));
FXPT_TYPE point_type = pPoints[i].m_Type;
if (point_type == FXPT_TYPE::MoveTo) {
- MoveToEx(hDC, screen_x, screen_y, nullptr);
+ MoveToEx(hDC, screen.x, screen.y, nullptr);
} else if (point_type == FXPT_TYPE::LineTo) {
- if (pPoints[i].m_PointY == pPoints[i - 1].m_PointY &&
- pPoints[i].m_PointX == pPoints[i - 1].m_PointX) {
- screen_x++;
- }
- LineTo(hDC, screen_x, screen_y);
+ if (pPoints[i].m_Point == pPoints[i - 1].m_Point)
+ screen.x++;
+
+ LineTo(hDC, screen.x, screen.y);
} else if (point_type == FXPT_TYPE::BezierTo) {
POINT lppt[3];
- lppt[0].x = screen_x;
- lppt[0].y = screen_y;
- posx = pPoints[i + 1].m_PointX;
- posy = pPoints[i + 1].m_PointY;
+ lppt[0].x = screen.x;
+ lppt[0].y = screen.y;
+
+ pos = pPoints[i + 1].m_Point;
if (pMatrix)
- pMatrix->TransformPoint(posx, posy);
+ pos = pMatrix->Transform(pos);
- lppt[1].x = FXSYS_round(posx);
- lppt[1].y = FXSYS_round(posy);
- posx = pPoints[i + 2].m_PointX;
- posy = pPoints[i + 2].m_PointY;
+ lppt[1].x = FXSYS_round(pos.x);
+ lppt[1].y = FXSYS_round(pos.y);
+
+ pos = pPoints[i + 2].m_Point;
if (pMatrix)
- pMatrix->TransformPoint(posx, posy);
+ pos = pMatrix->Transform(pos);
- lppt[2].x = FXSYS_round(posx);
- lppt[2].y = FXSYS_round(posy);
+ lppt[2].x = FXSYS_round(pos.x);
+ lppt[2].y = FXSYS_round(pos.y);
PolyBezierTo(hDC, lppt, 3);
i += 2;
}
- if (pPoints[i].m_CloseFigure) {
+ if (pPoints[i].m_CloseFigure)
CloseFigure(hDC);
- }
}
EndPath(hDC);
}
@@ -1047,15 +1044,13 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
}
if (pPathData->GetPoints().size() == 2 && pGraphState &&
pGraphState->m_DashCount) {
- FX_FLOAT x1 = pPathData->GetPointX(0);
- FX_FLOAT y1 = pPathData->GetPointY(0);
- FX_FLOAT x2 = pPathData->GetPointX(1);
- FX_FLOAT y2 = pPathData->GetPointY(1);
+ CFX_PointF pos1 = pPathData->GetPoint(0);
+ CFX_PointF pos2 = pPathData->GetPoint(1);
if (pMatrix) {
- pMatrix->TransformPoint(x1, y1);
- pMatrix->TransformPoint(x2, y2);
+ pos1 = pMatrix->Transform(pos1);
+ pos2 = pMatrix->Transform(pos2);
}
- DrawLine(x1, y1, x2, y2);
+ DrawLine(pos1.x, pos1.y, pos2.x, pos2.y);
} else {
SetPathToDC(m_hDC, pPathData, pMatrix);
if (pGraphState && stroke_alpha) {
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index c766ac8f3b..54711ceef5 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -1129,20 +1129,20 @@ bool CGdiplusExt::DrawPath(HDC hDC,
bool bSmooth = false;
int startpoint = 0;
for (size_t i = 0; i < pPoints.size(); i++) {
- points[i].X = pPoints[i].m_PointX;
- points[i].Y = pPoints[i].m_PointY;
- FX_FLOAT x = pPoints[i].m_PointX;
- FX_FLOAT y = pPoints[i].m_PointY;
+ points[i].X = pPoints[i].m_Point.x;
+ points[i].Y = pPoints[i].m_Point.y;
+
+ CFX_PointF pos = pPoints[i].m_Point;
if (pObject2Device)
- pObject2Device->TransformPoint(x, y);
+ pos = pObject2Device->Transform(pos);
- if (x > 50000 * 1.0f)
+ if (pos.x > 50000 * 1.0f)
points[i].X = 50000 * 1.0f;
- if (x < -50000 * 1.0f)
+ if (pos.x < -50000 * 1.0f)
points[i].X = -50000 * 1.0f;
- if (y > 50000 * 1.0f)
+ if (pos.y > 50000 * 1.0f)
points[i].Y = 50000 * 1.0f;
- if (y < -50000 * 1.0f)
+ if (pos.y < -50000 * 1.0f)
points[i].Y = -50000 * 1.0f;
FXPT_TYPE point_type = pPoints[i].m_Type;
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 01d12c1687..a830d529cb 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -69,14 +69,16 @@ void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView,
CFX_FloatRect rcFocus = pFormFiller->GetFocusBox(pPageView);
if (!rcFocus.IsEmpty()) {
CFX_PathData path;
- path.AppendPoint(rcFocus.left, rcFocus.top, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(rcFocus.left, rcFocus.bottom, FXPT_TYPE::LineTo,
- false);
- path.AppendPoint(rcFocus.right, rcFocus.bottom, FXPT_TYPE::LineTo,
- false);
- path.AppendPoint(rcFocus.right, rcFocus.top, FXPT_TYPE::LineTo,
- false);
- path.AppendPoint(rcFocus.left, rcFocus.top, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(CFX_PointF(rcFocus.left, rcFocus.top),
+ FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(CFX_PointF(rcFocus.left, rcFocus.bottom),
+ FXPT_TYPE::LineTo, false);
+ path.AppendPoint(CFX_PointF(rcFocus.right, rcFocus.bottom),
+ FXPT_TYPE::LineTo, false);
+ path.AppendPoint(CFX_PointF(rcFocus.right, rcFocus.top),
+ FXPT_TYPE::LineTo, false);
+ path.AppendPoint(CFX_PointF(rcFocus.left, rcFocus.top),
+ FXPT_TYPE::LineTo, false);
CFX_GraphStateData gsd;
gsd.SetDashCount(1);
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 7e19505c26..3427f4ea58 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -239,32 +239,32 @@ void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) {
const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints();
if (path.IsRect()) {
- buf << (pPoints[0].m_PointX) << " " << (pPoints[0].m_PointY) << " "
- << (pPoints[2].m_PointX - pPoints[0].m_PointX) << " "
- << (pPoints[2].m_PointY - pPoints[0].m_PointY) << " re\n";
+ CFX_PointF diff = pPoints[2].m_Point - pPoints[0].m_Point;
+ buf << pPoints[0].m_Point.x << " " << pPoints[0].m_Point.y << " " << diff.x
+ << " " << diff.y << " re\n";
return;
}
CFX_ByteString temp;
for (size_t i = 0; i < pPoints.size(); i++) {
- buf << (pPoints[i].m_PointX) << " " << (pPoints[i].m_PointY);
+ buf << pPoints[i].m_Point.x << " " << pPoints[i].m_Point.y;
FXPT_TYPE point_type = pPoints[i].m_Type;
if (point_type == FXPT_TYPE::MoveTo) {
buf << " m\n";
} else if (point_type == FXPT_TYPE::BezierTo) {
- buf << " " << (pPoints[i + 1].m_PointX) << " "
- << (pPoints[i + 1].m_PointY) << " " << (pPoints[i + 2].m_PointX)
- << " " << (pPoints[i + 2].m_PointY);
+ buf << " " << pPoints[i + 1].m_Point.x << " " << pPoints[i + 1].m_Point.y
+ << " " << pPoints[i + 2].m_Point.x << " " << pPoints[i + 2].m_Point.y;
+ buf << " c";
if (pPoints[i + 2].m_CloseFigure)
- buf << " c h\n";
- else
- buf << " c\n";
+ buf << " h";
+ buf << "\n";
+
i += 2;
} else if (point_type == FXPT_TYPE::LineTo) {
+ buf << " l";
if (pPoints[i].m_CloseFigure)
- buf << " l h\n";
- else
- buf << " l\n";
+ buf << " h";
+ buf << "\n";
}
}
}
diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
index 63a887dc85..074f083bb1 100644
--- a/fpdfsdk/fpdfeditpath.cpp
+++ b/fpdfsdk/fpdfeditpath.cpp
@@ -10,7 +10,7 @@
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_CreateNewPath(float x, float y) {
CPDF_PathObject* pPathObj = new CPDF_PathObject;
- pPathObj->m_Path.AppendPoint(x, y, FXPT_TYPE::MoveTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::MoveTo, false);
pPathObj->DefaultStates();
return pPathObj;
}
@@ -71,7 +71,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y) {
return false;
auto pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
- pPathObj->m_Path.AppendPoint(x, y, FXPT_TYPE::MoveTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::MoveTo, false);
return true;
}
@@ -80,7 +80,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y) {
return false;
auto pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
- pPathObj->m_Path.AppendPoint(x, y, FXPT_TYPE::LineTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::LineTo, false);
return true;
}
@@ -95,9 +95,9 @@ DLLEXPORT FPDF_BOOL FPDFPath_BezierTo(FPDF_PAGEOBJECT path,
return false;
auto pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
- pPathObj->m_Path.AppendPoint(x1, y1, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(x2, y2, FXPT_TYPE::BezierTo, false);
- pPathObj->m_Path.AppendPoint(x3, y3, FXPT_TYPE::BezierTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::BezierTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(x2, y2), FXPT_TYPE::BezierTo, false);
+ pPathObj->m_Path.AppendPoint(CFX_PointF(x3, y3), FXPT_TYPE::BezierTo, false);
return true;
}
diff --git a/fpdfsdk/pdfwindow/PWL_Caret.cpp b/fpdfsdk/pdfwindow/PWL_Caret.cpp
index e263a79065..3360bbf62a 100644
--- a/fpdfsdk/pdfwindow/PWL_Caret.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Caret.cpp
@@ -40,19 +40,17 @@ void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
FX_FLOAT fCaretBottom = rcRect.bottom;
if (!rcClip.IsEmpty()) {
rcRect.Intersect(rcClip);
- if (!rcRect.IsEmpty()) {
- fCaretTop = rcRect.top;
- fCaretBottom = rcRect.bottom;
- path.AppendPoint(fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(fCaretX, fCaretTop, FXPT_TYPE::LineTo, false);
- } else {
+ if (rcRect.IsEmpty())
return;
- }
- } else {
- path.AppendPoint(fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(fCaretX, fCaretTop, FXPT_TYPE::LineTo, false);
+
+ fCaretTop = rcRect.top;
+ fCaretBottom = rcRect.bottom;
}
+ path.AppendPoint(CFX_PointF(fCaretX, fCaretBottom), FXPT_TYPE::MoveTo,
+ false);
+ path.AppendPoint(CFX_PointF(fCaretX, fCaretTop), FXPT_TYPE::LineTo, false);
+
CFX_GraphStateData gsd;
gsd.m_LineWidth = m_fWidth;
pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
index adab4e7998..b9e96b2bf1 100644
--- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
@@ -147,10 +147,10 @@ void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
IsFloatBigger(rectWnd.top - rectWnd.bottom,
PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
CFX_PathData path;
- path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(pt2.x, pt2.y, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt3.x, pt3.y, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
pDevice->DrawPath(&path, pUser2Device, nullptr,
CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp
index 5c22d21940..4aa3d927d7 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -326,13 +326,17 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
for (int32_t i = 0; i < nCharArray - 1; i++) {
path.AppendPoint(
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.bottom, FXPT_TYPE::MoveTo, false);
+ CFX_PointF(
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.bottom),
+ FXPT_TYPE::MoveTo, false);
path.AppendPoint(
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.top, FXPT_TYPE::LineTo, false);
+ CFX_PointF(
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.top),
+ FXPT_TYPE::LineTo, false);
}
if (!path.GetPoints().empty()) {
pDevice->DrawPath(
@@ -354,13 +358,17 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_PathData path;
for (int32_t i = 0; i < nCharArray - 1; i++) {
path.AppendPoint(
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.bottom, FXPT_TYPE::MoveTo, false);
+ CFX_PointF(
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.bottom),
+ FXPT_TYPE::MoveTo, false);
path.AppendPoint(
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.top, FXPT_TYPE::LineTo, false);
+ CFX_PointF(
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.top),
+ FXPT_TYPE::LineTo, false);
}
if (!path.GetPoints().empty()) {
pDevice->DrawPath(
diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp
index 652c8e1f45..23bd753761 100644
--- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp
+++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp
@@ -257,10 +257,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
CFX_PathData path;
- path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(pt2.x, pt2.y, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt3.x, pt3.y, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
pDevice->DrawPath(&path, pUser2Device, nullptr,
CPWL_Utils::PWLColorToFXColor(
@@ -278,10 +278,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
CFX_PathData path;
- path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(pt2.x, pt2.y, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt3.x, pt3.y, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt1.x, pt1.y, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
pDevice->DrawPath(&path, pUser2Device, nullptr,
CPWL_Utils::PWLColorToFXColor(
diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp
index 9f5e31f6fd..54e75db8fe 100644
--- a/fpdfsdk/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp
@@ -51,16 +51,13 @@ void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path,
for (int32_t i = 0; i < nCount; i++) {
switch (pPathData[i].type) {
case PWLPT_MOVETO:
- path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y,
- FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pPathData[i].point, FXPT_TYPE::MoveTo, false);
break;
case PWLPT_LINETO:
- path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y,
- FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pPathData[i].point, FXPT_TYPE::LineTo, false);
break;
case PWLPT_BEZIERTO:
- path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y,
- FXPT_TYPE::BezierTo, false);
+ path.AppendPoint(pPathData[i].point, FXPT_TYPE::BezierTo, false);
break;
default:
break;
@@ -1232,9 +1229,9 @@ void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice,
int32_t nCount,
const FX_COLORREF& color) {
CFX_PathData path;
- path.AppendPoint(pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pPts[0], FXPT_TYPE::MoveTo, false);
for (int32_t i = 1; i < nCount; i++)
- path.AppendPoint(pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pPts[i], FXPT_TYPE::LineTo, false);
pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE);
}
@@ -1261,8 +1258,8 @@ void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice,
const FX_COLORREF& color,
FX_FLOAT fWidth) {
CFX_PathData path;
- path.AppendPoint(ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(ptMoveTo, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(ptLineTo, FXPT_TYPE::LineTo, false);
CFX_GraphStateData gsd;
gsd.m_LineWidth = fWidth;
@@ -1345,16 +1342,21 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
}
case BorderStyle::DASH: {
CFX_PathData path;
- path.AppendPoint(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
- FXPT_TYPE::MoveTo, false);
- path.AppendPoint(fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f,
- FXPT_TYPE::LineTo, false);
- path.AppendPoint(fRight - fWidth / 2.0f, fTop - fWidth / 2.0f,
- FXPT_TYPE::LineTo, false);
- path.AppendPoint(fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f,
- FXPT_TYPE::LineTo, false);
- path.AppendPoint(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
- FXPT_TYPE::LineTo, false);
+ path.AppendPoint(
+ CFX_PointF(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f),
+ FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(
+ CFX_PointF(fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f),
+ FXPT_TYPE::LineTo, false);
+ path.AppendPoint(
+ CFX_PointF(fRight - fWidth / 2.0f, fTop - fWidth / 2.0f),
+ FXPT_TYPE::LineTo, false);
+ path.AppendPoint(
+ CFX_PointF(fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f),
+ FXPT_TYPE::LineTo, false);
+ path.AppendPoint(
+ CFX_PointF(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f),
+ FXPT_TYPE::LineTo, false);
CFX_GraphStateData gsd;
gsd.SetDashCount(2);
@@ -1375,19 +1377,22 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
CFX_PathData pathLT;
- pathLT.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth,
+ pathLT.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth),
FXPT_TYPE::MoveTo, false);
- pathLT.AppendPoint(fLeft + fHalfWidth, fTop - fHalfWidth,
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth,
+ pathLT.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fTop - fHalfWidth),
FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
+ pathLT.AppendPoint(CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth),
FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2,
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth,
+ pathLT.AppendPoint(
+ CFX_PointF(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2),
+ FXPT_TYPE::LineTo, false);
+ pathLT.AppendPoint(
+ CFX_PointF(fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2),
+ FXPT_TYPE::LineTo, false);
+ pathLT.AppendPoint(
+ CFX_PointF(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2),
+ FXPT_TYPE::LineTo, false);
+ pathLT.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth),
FXPT_TYPE::LineTo, false);
pDevice->DrawPath(&pathLT, pUser2Device, &gsd,
@@ -1395,19 +1400,23 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
FXFILL_ALTERNATE);
CFX_PathData pathRB;
- pathRB.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth,
+ pathRB.AppendPoint(CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth),
FXPT_TYPE::MoveTo, false);
- pathRB.AppendPoint(fRight - fHalfWidth, fBottom + fHalfWidth,
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth,
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
+ pathRB.AppendPoint(
+ CFX_PointF(fRight - fHalfWidth, fBottom + fHalfWidth),
+ FXPT_TYPE::LineTo, false);
+ pathRB.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth),
FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2,
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth,
+ pathRB.AppendPoint(
+ CFX_PointF(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2),
+ FXPT_TYPE::LineTo, false);
+ pathRB.AppendPoint(
+ CFX_PointF(fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2),
+ FXPT_TYPE::LineTo, false);
+ pathRB.AppendPoint(
+ CFX_PointF(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2),
+ FXPT_TYPE::LineTo, false);
+ pathRB.AppendPoint(CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth),
FXPT_TYPE::LineTo, false);
pDevice->DrawPath(&pathRB, pUser2Device, &gsd,
@@ -1427,9 +1436,10 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
}
case BorderStyle::UNDERLINE: {
CFX_PathData path;
- path.AppendPoint(fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo,
- false);
+ path.AppendPoint(CFX_PointF(fLeft, fBottom + fWidth / 2),
+ FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(CFX_PointF(fRight, fBottom + fWidth / 2),
+ FXPT_TYPE::LineTo, false);
CFX_GraphStateData gsd;
gsd.m_LineWidth = fWidth;
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);