diff options
author | weili <weili@chromium.org> | 2016-08-09 10:33:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 10:33:10 -0700 |
commit | 16fccc51456dbab7e392c3952cc367723f9694f6 (patch) | |
tree | 0bd44bec6b81213db9d1dc487237164cdcaa43a4 /xfa/fxgraphics/cfx_path_generator.cpp | |
parent | af7ab33c73f58f18d0db0c90d93fa0aab0bc83f3 (diff) | |
download | pdfium-16fccc51456dbab7e392c3952cc367723f9694f6.tar.xz |
Use smart pointers for class owned pointers
For classes under xfa/fxfa/fm2js, and xfa/fxgraphics, use smart
pointers instead of raw pointer to make memory management easier.
Also fix some styling issues along the changes.
BUG=pdfium:518
Review-Url: https://codereview.chromium.org/2222203002
Diffstat (limited to 'xfa/fxgraphics/cfx_path_generator.cpp')
-rw-r--r-- | xfa/fxgraphics/cfx_path_generator.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index f2dc182b55..aadaa85ad0 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -8,15 +8,9 @@ #include "core/fxge/include/cfx_pathdata.h" -CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(nullptr) {} +CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(new CFX_PathData) {} -void CFX_PathGenerator::Create() { - m_pPathData = new CFX_PathData; -} - -CFX_PathGenerator::~CFX_PathGenerator() { - delete m_pPathData; -} +CFX_PathGenerator::~CFX_PathGenerator() {} void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { if (pPathData && pPathData->GetPointCount() > 0) { @@ -25,6 +19,7 @@ void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { AddPathData(pPoints, nCount); } } + void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { if (pPoints && nCount > 0) { int nOldCount = m_pPathData->GetPointCount(); @@ -34,14 +29,17 @@ void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { sizeof(FX_PATHPOINT) * nCount); } } + void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); } + void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); } + void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, FX_FLOAT ctrl_y1, FX_FLOAT ctrl_x2, @@ -54,6 +52,7 @@ void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::Close() { if (m_pPathData->GetPointCount() > 0) { int index = m_pPathData->GetPointCount() - 1; @@ -61,6 +60,7 @@ void CFX_PathGenerator::Close() { pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; } } + void CFX_PathGenerator::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, @@ -70,6 +70,7 @@ void CFX_PathGenerator::AddLine(FX_FLOAT x1, m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); } + void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, FX_FLOAT start_y, FX_FLOAT ctrl_x1, @@ -85,18 +86,21 @@ void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); } + 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(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height) { AddArc(x, y, width, height, 0, FX_PI * 2); } + void CFX_PathGenerator::ArcTo(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, @@ -127,6 +131,7 @@ void CFX_PathGenerator::ArcTo(FX_FLOAT x, bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::AddArc(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, @@ -178,6 +183,7 @@ void CFX_PathGenerator::AddArc(FX_FLOAT x, start_angle += local_sweep; } while (!done); } + void CFX_PathGenerator::AddPie(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, |