summaryrefslogtreecommitdiff
path: root/xfa/fxgraphics
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxgraphics')
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp1
-rw-r--r--xfa/fxgraphics/cfx_path.cpp267
-rw-r--r--xfa/fxgraphics/cfx_path.h78
-rw-r--r--xfa/fxgraphics/cfx_path_generator.cpp164
-rw-r--r--xfa/fxgraphics/cfx_path_generator.h54
5 files changed, 164 insertions, 400 deletions
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 2b8bd17aad..d47c261868 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -16,7 +16,6 @@
#include "xfa/fxgraphics/cagg_graphics.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#include "xfa/fxgraphics/cfx_path_generator.h"
#include "xfa/fxgraphics/cfx_pattern.h"
#include "xfa/fxgraphics/cfx_shading.h"
diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp
index 3072df2475..d56eb13f67 100644
--- a/xfa/fxgraphics/cfx_path.cpp
+++ b/xfa/fxgraphics/cfx_path.cpp
@@ -8,155 +8,144 @@
#include "core/fxge/cfx_pathdata.h"
#include "third_party/base/ptr_util.h"
-#include "xfa/fxgraphics/cfx_path_generator.h"
CFX_Path::CFX_Path() {}
-FWL_Error CFX_Path::Create() {
- if (m_generator)
- return FWL_Error::PropertyInvalid;
-
- m_generator = pdfium::MakeUnique<CFX_PathGenerator>();
- return FWL_Error::Succeeded;
-}
-
CFX_Path::~CFX_Path() {}
-FWL_Error CFX_Path::MoveTo(const CFX_PointF& point) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->MoveTo(point);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::LineTo(const CFX_PointF& point) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->LineTo(point);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->BezierTo(c1, c2, to);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::ArcTo(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2.0f;
- m_generator->ArcTo(CFX_PointF(pos.x + newSize.width, pos.y + newSize.height),
- newSize, startAngle, sweepAngle);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::Close() {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->Close();
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddLine(p1, p2);
- return FWL_Error::Succeeded;
+void CFX_Path::Clear() {
+ data_.Clear();
}
-FWL_Error CFX_Path::AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddBezier(p1, c1, c2, p2);
- return FWL_Error::Succeeded;
+void CFX_Path::Close() {
+ data_.ClosePath();
}
-FWL_Error CFX_Path::AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddRectangle(left, top, left + width, top + height);
- return FWL_Error::Succeeded;
+void CFX_Path::MoveTo(const CFX_PointF& point) {
+ data_.AppendPoint(point, FXPT_TYPE::MoveTo, false);
}
-FWL_Error CFX_Path::AddEllipse(const CFX_PointF& pos, const CFX_SizeF& size) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2.0f;
- m_generator->AddEllipse(
- CFX_PointF(pos.x + newSize.width, pos.y + newSize.height), newSize);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddEllipse(const CFX_RectF& rect) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddEllipse(
- CFX_PointF(rect.left + rect.Width() / 2, rect.top + rect.Height() / 2),
- CFX_SizeF(rect.Width() / 2, rect.Height() / 2));
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddArc(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2;
- m_generator->AddArc(CFX_PointF(pos.x + newSize.width, pos.y + newSize.height),
- newSize, startAngle, sweepAngle);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddPie(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- CFX_SizeF newSize = size / 2;
- m_generator->AddPie(CFX_PointF(pos.x + newSize.width, pos.y + newSize.height),
- newSize, startAngle, sweepAngle);
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::AddSubpath(CFX_Path* path) {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->AddPathData(path->GetPathData());
- return FWL_Error::Succeeded;
-}
-
-FWL_Error CFX_Path::Clear() {
- if (!m_generator)
- return FWL_Error::PropertyInvalid;
- m_generator->GetPathData()->Clear();
- return FWL_Error::Succeeded;
-}
-
-bool CFX_Path::IsEmpty() const {
- if (!m_generator)
- return false;
- if (m_generator->GetPathData()->GetPoints().empty())
- return true;
- return false;
-}
+void CFX_Path::LineTo(const CFX_PointF& point) {
+ data_.AppendPoint(point, FXPT_TYPE::LineTo, false);
+}
+
+void CFX_Path::BezierTo(const CFX_PointF& c1,
+ const CFX_PointF& c2,
+ const CFX_PointF& to) {
+ data_.AppendPoint(c1, FXPT_TYPE::BezierTo, false);
+ data_.AppendPoint(c2, FXPT_TYPE::BezierTo, false);
+ data_.AppendPoint(to, FXPT_TYPE::BezierTo, false);
+}
+
+void CFX_Path::ArcTo(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle) {
+ CFX_SizeF new_size = size / 2.0f;
+ ArcToInternal(CFX_PointF(pos.x + new_size.width, pos.y + new_size.height),
+ new_size, start_angle, sweep_angle);
+}
-CFX_PathData* CFX_Path::GetPathData() const {
- if (!m_generator)
- return nullptr;
- return m_generator->GetPathData();
+void CFX_Path::ArcToInternal(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle) {
+ FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2);
+ FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2);
+ FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f);
+ FX_FLOAT ty = y0 - ((tx * x0) / y0);
+
+ CFX_PointF points[] = {CFX_PointF(x0 + tx, -ty), CFX_PointF(x0 + tx, ty)};
+ FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2);
+ FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2);
+
+ CFX_PointF bezier;
+ bezier.x = pos.x + (size.width * ((points[0].x * cs) - (points[0].y * sn)));
+ bezier.y = pos.y + (size.height * ((points[0].x * sn) + (points[0].y * cs)));
+ data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
+
+ bezier.x = pos.x + (size.width * ((points[1].x * cs) - (points[1].y * sn)));
+ bezier.y = pos.y + (size.height * ((points[1].x * sn) + (points[1].y * cs)));
+ data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
+
+ bezier.x = pos.x + (size.width * FXSYS_cos(start_angle + sweep_angle));
+ bezier.y = pos.y + (size.height * FXSYS_sin(start_angle + sweep_angle));
+ data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
+}
+
+void CFX_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
+ data_.AppendPoint(p1, FXPT_TYPE::MoveTo, false);
+ data_.AppendPoint(p2, FXPT_TYPE::LineTo, false);
+}
+
+void CFX_Path::AddRectangle(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height) {
+ data_.AppendRect(left, top, left + width, top + height);
+}
+
+void CFX_Path::AddEllipse(const CFX_RectF& rect) {
+ AddArc(rect.TopLeft(), rect.Size(), 0, FX_PI * 2);
+}
+
+void CFX_Path::AddArc(const CFX_PointF& original_pos,
+ const CFX_SizeF& original_size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle) {
+ if (sweep_angle == 0)
+ return;
+
+ const FX_FLOAT bezier_arc_angle_epsilon = 0.01f;
+ while (start_angle > FX_PI * 2)
+ start_angle -= FX_PI * 2;
+ while (start_angle < 0)
+ start_angle += FX_PI * 2;
+ if (sweep_angle >= FX_PI * 2)
+ sweep_angle = FX_PI * 2;
+ if (sweep_angle <= -FX_PI * 2)
+ sweep_angle = -FX_PI * 2;
+
+ CFX_SizeF size = original_size / 2;
+ CFX_PointF pos(original_pos.x + size.width, original_pos.y + size.height);
+ data_.AppendPoint(pos + CFX_PointF(size.width * FXSYS_cos(start_angle),
+ size.height * FXSYS_sin(start_angle)),
+ FXPT_TYPE::MoveTo, false);
+
+ FX_FLOAT total_sweep = 0;
+ FX_FLOAT local_sweep = 0;
+ FX_FLOAT prev_sweep = 0;
+ bool done = false;
+ do {
+ if (sweep_angle < 0) {
+ prev_sweep = total_sweep;
+ local_sweep = -FX_PI / 2;
+ total_sweep -= FX_PI / 2;
+ if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) {
+ local_sweep = sweep_angle - prev_sweep;
+ done = true;
+ }
+ } else {
+ prev_sweep = total_sweep;
+ local_sweep = FX_PI / 2;
+ total_sweep += FX_PI / 2;
+ if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) {
+ local_sweep = sweep_angle - prev_sweep;
+ done = true;
+ }
+ }
+
+ ArcToInternal(pos, size, start_angle, local_sweep);
+ start_angle += local_sweep;
+ } while (!done);
+}
+
+void CFX_Path::AddSubpath(CFX_Path* path) {
+ if (!path)
+ return;
+ data_.Append(&path->data_, nullptr);
+}
+
+void CFX_Path::TransformBy(const CFX_Matrix& mt) {
+ data_.Transform(&mt);
}
diff --git a/xfa/fxgraphics/cfx_path.h b/xfa/fxgraphics/cfx_path.h
index 1dee566788..267831603a 100644
--- a/xfa/fxgraphics/cfx_path.h
+++ b/xfa/fxgraphics/cfx_path.h
@@ -7,58 +7,52 @@
#ifndef XFA_FXGRAPHICS_CFX_PATH_H_
#define XFA_FXGRAPHICS_CFX_PATH_H_
-#include <memory>
-
#include "core/fxcrt/fx_system.h"
+#include "core/fxge/cfx_pathdata.h"
#include "xfa/fxgraphics/cfx_graphics.h"
-class CFX_PathData;
-class CFX_PathGenerator;
-
class CFX_Path final {
public:
CFX_Path();
~CFX_Path();
- FWL_Error Create();
- FWL_Error MoveTo(const CFX_PointF& point);
- FWL_Error LineTo(const CFX_PointF& point);
- FWL_Error BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to);
- FWL_Error ArcTo(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FWL_Error Close();
-
- FWL_Error AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
- FWL_Error AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2);
- FWL_Error AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height);
- FWL_Error AddEllipse(const CFX_PointF& pos, const CFX_SizeF& size);
- FWL_Error AddEllipse(const CFX_RectF& rect);
- FWL_Error AddArc(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FWL_Error AddPie(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FWL_Error AddSubpath(CFX_Path* path);
- FWL_Error Clear();
-
- bool IsEmpty() const;
- CFX_PathData* GetPathData() const;
+ const CFX_PathData* GetPathData() const { return &data_; }
+
+ void Clear();
+ bool IsEmpty() const { return data_.GetPoints().empty(); }
+ void TransformBy(const CFX_Matrix& mt);
+
+ void Close();
+ void MoveTo(const CFX_PointF& point);
+ void LineTo(const CFX_PointF& point);
+ void BezierTo(const CFX_PointF& c1,
+ const CFX_PointF& c2,
+ const CFX_PointF& to);
+ void ArcTo(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+
+ void AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
+ void AddRectangle(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height);
+ void AddEllipse(const CFX_RectF& rect);
+ void AddArc(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+
+ void AddSubpath(CFX_Path* path);
private:
- std::unique_ptr<CFX_PathGenerator> m_generator;
+ void ArcToInternal(const CFX_PointF& pos,
+ const CFX_SizeF& size,
+ FX_FLOAT start_angle,
+ FX_FLOAT sweep_angle);
+
+ CFX_PathData data_;
};
#endif // XFA_FXGRAPHICS_CFX_PATH_H_
diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp
deleted file mode 100644
index ab3d9d631a..0000000000
--- a/xfa/fxgraphics/cfx_path_generator.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxgraphics/cfx_path_generator.h"
-
-#include "core/fxge/cfx_pathdata.h"
-#include "core/fxge/cfx_renderdevice.h"
-
-CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(new CFX_PathData) {}
-
-CFX_PathGenerator::~CFX_PathGenerator() {}
-
-void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) {
- if (!pPathData)
- return;
- m_pPathData->Append(pPathData, nullptr);
-}
-
-void CFX_PathGenerator::MoveTo(const CFX_PointF& point) {
- m_pPathData->AppendPoint(point, FXPT_TYPE::MoveTo, false);
-}
-
-void CFX_PathGenerator::LineTo(const CFX_PointF& point) {
- m_pPathData->AppendPoint(point, FXPT_TYPE::LineTo, false);
-}
-
-void CFX_PathGenerator::BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to) {
- m_pPathData->AppendPoint(c1, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(c2, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(to, FXPT_TYPE::BezierTo, false);
-}
-
-void CFX_PathGenerator::Close() {
- m_pPathData->ClosePath();
-}
-
-void CFX_PathGenerator::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
- m_pPathData->AppendPoint(p1, FXPT_TYPE::MoveTo, false);
- m_pPathData->AppendPoint(p2, FXPT_TYPE::LineTo, false);
-}
-
-void CFX_PathGenerator::AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2) {
- m_pPathData->AppendPoint(p1, FXPT_TYPE::MoveTo, false);
- m_pPathData->AppendPoint(c1, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(c2, FXPT_TYPE::BezierTo, false);
- m_pPathData->AppendPoint(p2, FXPT_TYPE::BezierTo, false);
-}
-
-void CFX_PathGenerator::AddRectangle(FX_FLOAT x1,
- FX_FLOAT y1,
- FX_FLOAT x2,
- FX_FLOAT y2) {
- m_pPathData->AppendRect(x1, y1, x2, y2);
-}
-
-void CFX_PathGenerator::AddEllipse(const CFX_PointF& pos,
- const CFX_SizeF& size) {
- AddArc(pos, size, 0, FX_PI * 2);
-}
-
-void CFX_PathGenerator::ArcTo(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2);
- FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2);
- FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f);
- FX_FLOAT ty = y0 - ((tx * x0) / y0);
- FX_FLOAT px[3], py[3];
- px[0] = x0 + tx;
- py[0] = -ty;
- px[1] = x0 + tx;
- py[1] = ty;
- FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2);
- FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2);
-
- CFX_PointF bezier;
- bezier.x = pos.x + (size.width * ((px[0] * cs) - (py[0] * sn)));
- bezier.y = pos.y + (size.height * ((px[0] * sn) + (py[0] * cs)));
- m_pPathData->AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
-
- bezier.x = pos.x + (size.width * ((px[1] * cs) - (py[1] * sn)));
- bezier.y = pos.y + (size.height * ((px[1] * sn) + (py[1] * cs)));
- m_pPathData->AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
-
- bezier.x = pos.x + (size.width * FXSYS_cos(start_angle + sweep_angle));
- bezier.y = pos.y + (size.height * FXSYS_sin(start_angle + sweep_angle));
- m_pPathData->AppendPoint(bezier, FXPT_TYPE::BezierTo, false);
-}
-
-void CFX_PathGenerator::AddArc(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- if (sweep_angle == 0)
- return;
-
- const FX_FLOAT bezier_arc_angle_epsilon = 0.01f;
- while (start_angle > FX_PI * 2)
- start_angle -= FX_PI * 2;
- while (start_angle < 0)
- start_angle += FX_PI * 2;
- if (sweep_angle >= FX_PI * 2)
- sweep_angle = FX_PI * 2;
- if (sweep_angle <= -FX_PI * 2)
- sweep_angle = -FX_PI * 2;
-
- m_pPathData->AppendPoint(
- pos + CFX_PointF(size.width * FXSYS_cos(start_angle),
- size.height * FXSYS_sin(start_angle)),
- FXPT_TYPE::MoveTo, false);
-
- FX_FLOAT total_sweep = 0;
- FX_FLOAT local_sweep = 0;
- FX_FLOAT prev_sweep = 0;
- bool done = false;
- do {
- if (sweep_angle < 0) {
- prev_sweep = total_sweep;
- local_sweep = -FX_PI / 2;
- total_sweep -= FX_PI / 2;
- if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) {
- local_sweep = sweep_angle - prev_sweep;
- done = true;
- }
- } else {
- prev_sweep = total_sweep;
- local_sweep = FX_PI / 2;
- total_sweep += FX_PI / 2;
- if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) {
- local_sweep = sweep_angle - prev_sweep;
- done = true;
- }
- }
-
- ArcTo(pos, size, start_angle, local_sweep);
- start_angle += local_sweep;
- } while (!done);
-}
-
-void CFX_PathGenerator::AddPie(const CFX_PointF& pos,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- if (sweep_angle == 0) {
- m_pPathData->AppendPoint(pos, FXPT_TYPE::MoveTo, false);
- m_pPathData->AppendPoint(
- pos + CFX_PointF(size.width * FXSYS_cos(start_angle),
- size.height * FXSYS_sin(start_angle)),
- FXPT_TYPE::LineTo, false);
- return;
- }
-
- AddArc(pos, size, start_angle, sweep_angle);
- m_pPathData->AppendPoint(pos, FXPT_TYPE::LineTo, true);
-}
diff --git a/xfa/fxgraphics/cfx_path_generator.h b/xfa/fxgraphics/cfx_path_generator.h
deleted file mode 100644
index d3ba290f1c..0000000000
--- a/xfa/fxgraphics/cfx_path_generator.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_
-#define XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_
-
-#include <memory>
-
-#include "core/fxge/cfx_pathdata.h"
-
-class CFX_PathGenerator {
- public:
- CFX_PathGenerator();
- ~CFX_PathGenerator();
-
- CFX_PathData* GetPathData() const { return m_pPathData.get(); }
-
- void AddPathData(CFX_PathData* path_data);
-
- void MoveTo(const CFX_PointF& point);
- void LineTo(const CFX_PointF& point);
- void BezierTo(const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& to);
- void Close();
- void ArcTo(const CFX_PointF& point,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
-
- void AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
- void AddBezier(const CFX_PointF& p1,
- const CFX_PointF& c1,
- const CFX_PointF& c2,
- const CFX_PointF& p2);
- void AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
- void AddEllipse(const CFX_PointF& point, const CFX_SizeF& size);
- void AddArc(const CFX_PointF& point,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
- void AddPie(const CFX_PointF& point,
- const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
-
- protected:
- std::unique_ptr<CFX_PathData> m_pPathData;
-};
-
-#endif // XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_