Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: xfa/fxgraphics/cfx_path.cpp

Issue 1943413002: Convert FWL_ERR into an enum class. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@bcdattribute
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxgraphics/cfx_path.h ('k') | xfa/fxgraphics/include/cfx_graphics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxgraphics/cfx_path.h" 7 #include "xfa/fxgraphics/cfx_path.h"
8 8
9 #include "xfa/fxgraphics/cfx_path_generator.h" 9 #include "xfa/fxgraphics/cfx_path_generator.h"
10 10
11 CFX_Path::CFX_Path() { 11 CFX_Path::CFX_Path() {
12 m_generator = nullptr; 12 m_generator = nullptr;
13 } 13 }
14 14
15 FX_ERR CFX_Path::Create() { 15 FWL_Error CFX_Path::Create() {
16 if (m_generator) 16 if (m_generator)
17 return FX_ERR_Property_Invalid; 17 return FWL_Error::PropertyInvalid;
18 18
19 m_generator = new CFX_PathGenerator; 19 m_generator = new CFX_PathGenerator;
20 m_generator->Create(); 20 m_generator->Create();
21 return FX_ERR_Succeeded; 21 return FWL_Error::Succeeded;
22 } 22 }
23 23
24 CFX_Path::~CFX_Path() { 24 CFX_Path::~CFX_Path() {
25 delete m_generator; 25 delete m_generator;
26 } 26 }
27 27
28 FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { 28 FWL_Error CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) {
29 if (!m_generator) 29 if (!m_generator)
30 return FX_ERR_Property_Invalid; 30 return FWL_Error::PropertyInvalid;
31 m_generator->MoveTo(x, y); 31 m_generator->MoveTo(x, y);
32 return FX_ERR_Succeeded; 32 return FWL_Error::Succeeded;
33 } 33 }
34 34
35 FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { 35 FWL_Error CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) {
36 if (!m_generator) 36 if (!m_generator)
37 return FX_ERR_Property_Invalid; 37 return FWL_Error::PropertyInvalid;
38 m_generator->LineTo(x, y); 38 m_generator->LineTo(x, y);
39 return FX_ERR_Succeeded; 39 return FWL_Error::Succeeded;
40 } 40 }
41 41
42 FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, 42 FWL_Error CFX_Path::BezierTo(FX_FLOAT ctrlX1,
43 FX_FLOAT ctrlY1, 43 FX_FLOAT ctrlY1,
44 FX_FLOAT ctrlX2, 44 FX_FLOAT ctrlX2,
45 FX_FLOAT ctrlY2, 45 FX_FLOAT ctrlY2,
46 FX_FLOAT toX, 46 FX_FLOAT toX,
47 FX_FLOAT toY) { 47 FX_FLOAT toY) {
48 if (!m_generator) 48 if (!m_generator)
49 return FX_ERR_Property_Invalid; 49 return FWL_Error::PropertyInvalid;
50 m_generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); 50 m_generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY);
51 return FX_ERR_Succeeded; 51 return FWL_Error::Succeeded;
52 } 52 }
53 53
54 FX_ERR CFX_Path::ArcTo(FX_FLOAT left, 54 FWL_Error CFX_Path::ArcTo(FX_FLOAT left,
55 FX_FLOAT top, 55 FX_FLOAT top,
56 FX_FLOAT width, 56 FX_FLOAT width,
57 FX_FLOAT height, 57 FX_FLOAT height,
58 FX_FLOAT startAngle, 58 FX_FLOAT startAngle,
59 FX_FLOAT sweepAngle) { 59 FX_FLOAT sweepAngle) {
60 if (!m_generator) 60 if (!m_generator)
61 return FX_ERR_Property_Invalid; 61 return FWL_Error::PropertyInvalid;
62 m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, 62 m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2,
63 startAngle, sweepAngle); 63 startAngle, sweepAngle);
64 return FX_ERR_Succeeded; 64 return FWL_Error::Succeeded;
65 } 65 }
66 66
67 FX_ERR CFX_Path::Close() { 67 FWL_Error CFX_Path::Close() {
68 if (!m_generator) 68 if (!m_generator)
69 return FX_ERR_Property_Invalid; 69 return FWL_Error::PropertyInvalid;
70 m_generator->Close(); 70 m_generator->Close();
71 return FX_ERR_Succeeded; 71 return FWL_Error::Succeeded;
72 } 72 }
73 73
74 FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { 74 FWL_Error CFX_Path::AddLine(FX_FLOAT x1,
75 FX_FLOAT y1,
76 FX_FLOAT x2,
77 FX_FLOAT y2) {
75 if (!m_generator) 78 if (!m_generator)
76 return FX_ERR_Property_Invalid; 79 return FWL_Error::PropertyInvalid;
77 m_generator->AddLine(x1, y1, x2, y2); 80 m_generator->AddLine(x1, y1, x2, y2);
78 return FX_ERR_Succeeded; 81 return FWL_Error::Succeeded;
79 } 82 }
80 83
81 FX_ERR CFX_Path::AddBezier(FX_FLOAT startX, 84 FWL_Error CFX_Path::AddBezier(FX_FLOAT startX,
82 FX_FLOAT startY, 85 FX_FLOAT startY,
83 FX_FLOAT ctrlX1, 86 FX_FLOAT ctrlX1,
84 FX_FLOAT ctrlY1, 87 FX_FLOAT ctrlY1,
85 FX_FLOAT ctrlX2, 88 FX_FLOAT ctrlX2,
86 FX_FLOAT ctrlY2, 89 FX_FLOAT ctrlY2,
87 FX_FLOAT endX, 90 FX_FLOAT endX,
88 FX_FLOAT endY) { 91 FX_FLOAT endY) {
89 if (!m_generator) 92 if (!m_generator)
90 return FX_ERR_Property_Invalid; 93 return FWL_Error::PropertyInvalid;
91 m_generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, 94 m_generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX,
92 endY); 95 endY);
93 return FX_ERR_Succeeded; 96 return FWL_Error::Succeeded;
94 } 97 }
95 98
96 FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, 99 FWL_Error CFX_Path::AddRectangle(FX_FLOAT left,
97 FX_FLOAT top, 100 FX_FLOAT top,
98 FX_FLOAT width, 101 FX_FLOAT width,
99 FX_FLOAT height) { 102 FX_FLOAT height) {
100 if (!m_generator) 103 if (!m_generator)
101 return FX_ERR_Property_Invalid; 104 return FWL_Error::PropertyInvalid;
102 m_generator->AddRectangle(left, top, left + width, top + height); 105 m_generator->AddRectangle(left, top, left + width, top + height);
103 return FX_ERR_Succeeded; 106 return FWL_Error::Succeeded;
104 } 107 }
105 108
106 FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, 109 FWL_Error CFX_Path::AddEllipse(FX_FLOAT left,
107 FX_FLOAT top, 110 FX_FLOAT top,
108 FX_FLOAT width, 111 FX_FLOAT width,
109 FX_FLOAT height) { 112 FX_FLOAT height) {
110 if (!m_generator) 113 if (!m_generator)
111 return FX_ERR_Property_Invalid; 114 return FWL_Error::PropertyInvalid;
112 m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2, 115 m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2,
113 height / 2); 116 height / 2);
114 return FX_ERR_Succeeded; 117 return FWL_Error::Succeeded;
115 } 118 }
116 119
117 FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { 120 FWL_Error CFX_Path::AddEllipse(const CFX_RectF& rect) {
118 if (!m_generator) 121 if (!m_generator)
119 return FX_ERR_Property_Invalid; 122 return FWL_Error::PropertyInvalid;
120 m_generator->AddEllipse(rect.left + rect.Width() / 2, 123 m_generator->AddEllipse(rect.left + rect.Width() / 2,
121 rect.top + rect.Height() / 2, rect.Width() / 2, 124 rect.top + rect.Height() / 2, rect.Width() / 2,
122 rect.Height() / 2); 125 rect.Height() / 2);
123 return FX_ERR_Succeeded; 126 return FWL_Error::Succeeded;
124 } 127 }
125 128
126 FX_ERR CFX_Path::AddArc(FX_FLOAT left, 129 FWL_Error CFX_Path::AddArc(FX_FLOAT left,
127 FX_FLOAT top, 130 FX_FLOAT top,
128 FX_FLOAT width, 131 FX_FLOAT width,
129 FX_FLOAT height, 132 FX_FLOAT height,
130 FX_FLOAT startAngle, 133 FX_FLOAT startAngle,
131 FX_FLOAT sweepAngle) { 134 FX_FLOAT sweepAngle) {
132 if (!m_generator) 135 if (!m_generator)
133 return FX_ERR_Property_Invalid; 136 return FWL_Error::PropertyInvalid;
134 m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, 137 m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2,
135 startAngle, sweepAngle); 138 startAngle, sweepAngle);
136 return FX_ERR_Succeeded; 139 return FWL_Error::Succeeded;
137 } 140 }
138 141
139 FX_ERR CFX_Path::AddPie(FX_FLOAT left, 142 FWL_Error CFX_Path::AddPie(FX_FLOAT left,
140 FX_FLOAT top, 143 FX_FLOAT top,
141 FX_FLOAT width, 144 FX_FLOAT width,
142 FX_FLOAT height, 145 FX_FLOAT height,
143 FX_FLOAT startAngle, 146 FX_FLOAT startAngle,
144 FX_FLOAT sweepAngle) { 147 FX_FLOAT sweepAngle) {
145 if (!m_generator) 148 if (!m_generator)
146 return FX_ERR_Property_Invalid; 149 return FWL_Error::PropertyInvalid;
147 m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, 150 m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2,
148 startAngle, sweepAngle); 151 startAngle, sweepAngle);
149 return FX_ERR_Succeeded; 152 return FWL_Error::Succeeded;
150 } 153 }
151 154
152 FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { 155 FWL_Error CFX_Path::AddSubpath(CFX_Path* path) {
153 if (!m_generator) 156 if (!m_generator)
154 return FX_ERR_Property_Invalid; 157 return FWL_Error::PropertyInvalid;
155 m_generator->AddPathData(path->GetPathData()); 158 m_generator->AddPathData(path->GetPathData());
156 return FX_ERR_Succeeded; 159 return FWL_Error::Succeeded;
157 } 160 }
158 161
159 FX_ERR CFX_Path::Clear() { 162 FWL_Error CFX_Path::Clear() {
160 if (!m_generator) 163 if (!m_generator)
161 return FX_ERR_Property_Invalid; 164 return FWL_Error::PropertyInvalid;
162 m_generator->GetPathData()->SetPointCount(0); 165 m_generator->GetPathData()->SetPointCount(0);
163 return FX_ERR_Succeeded; 166 return FWL_Error::Succeeded;
164 } 167 }
165 168
166 FX_BOOL CFX_Path::IsEmpty() { 169 FX_BOOL CFX_Path::IsEmpty() {
167 if (!m_generator) 170 if (!m_generator)
168 return FX_ERR_Property_Invalid; 171 return FALSE;
169 if (m_generator->GetPathData()->GetPointCount() == 0) { 172 if (m_generator->GetPathData()->GetPointCount() == 0)
170 return TRUE; 173 return TRUE;
171 }
172 return FALSE; 174 return FALSE;
173 } 175 }
174 176
175 CFX_PathData* CFX_Path::GetPathData() { 177 CFX_PathData* CFX_Path::GetPathData() {
176 if (!m_generator) 178 if (!m_generator)
177 return nullptr; 179 return nullptr;
178 return m_generator->GetPathData(); 180 return m_generator->GetPathData();
179 } 181 }
OLDNEW
« no previous file with comments | « xfa/fxgraphics/cfx_path.h ('k') | xfa/fxgraphics/include/cfx_graphics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698