OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "xfa/src/fxgraphics/src/fx_path_generator.h" | 9 #include "xfa/src/fxgraphics/src/fx_path_generator.h" |
10 #include "xfa/src/fxgraphics/src/pre.h" | 10 #include "xfa/src/fxgraphics/src/pre.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 _info._fillColor = NULL; | 32 _info._fillColor = NULL; |
33 _info._font = NULL; | 33 _info._font = NULL; |
34 _info._fontSize = 40.0; | 34 _info._fontSize = 40.0; |
35 _info._fontHScale = 1.0; | 35 _info._fontHScale = 1.0; |
36 _info._fontSpacing = 0.0; | 36 _info._fontSpacing = 0.0; |
37 _renderDevice = NULL; | 37 _renderDevice = NULL; |
38 _aggGraphics = NULL; | 38 _aggGraphics = NULL; |
39 } | 39 } |
40 FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, | 40 FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, |
41 FX_BOOL isAntialiasing) { | 41 FX_BOOL isAntialiasing) { |
42 _FX_RETURN_VALUE_IF_FAIL(renderDevice, FX_ERR_Parameter_Invalid); | 42 if (!renderDevice) |
43 return FX_ERR_Parameter_Invalid; | |
43 if (_type != FX_CONTEXT_None) { | 44 if (_type != FX_CONTEXT_None) { |
44 return FX_ERR_Property_Invalid; | 45 return FX_ERR_Property_Invalid; |
45 } | 46 } |
46 _type = FX_CONTEXT_Device; | 47 _type = FX_CONTEXT_Device; |
47 _info._isAntialiasing = isAntialiasing; | 48 _info._isAntialiasing = isAntialiasing; |
48 _renderDevice = renderDevice; | 49 _renderDevice = renderDevice; |
49 if (_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) { | 50 if (_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) { |
50 return FX_ERR_Succeeded; | 51 return FX_ERR_Succeeded; |
51 } | 52 } |
52 return FX_ERR_Indefinite; | 53 return FX_ERR_Indefinite; |
(...skipping 18 matching lines...) Expand all Loading... | |
71 delete _aggGraphics; | 72 delete _aggGraphics; |
72 _aggGraphics = NULL; | 73 _aggGraphics = NULL; |
73 } | 74 } |
74 _renderDevice = NULL; | 75 _renderDevice = NULL; |
75 _info._graphState.SetDashCount(0); | 76 _info._graphState.SetDashCount(0); |
76 _type = FX_CONTEXT_None; | 77 _type = FX_CONTEXT_None; |
77 } | 78 } |
78 FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { | 79 FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { |
79 switch (_type) { | 80 switch (_type) { |
80 case FX_CONTEXT_Device: { | 81 case FX_CONTEXT_Device: { |
81 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 82 if (!_renderDevice) |
83 return FX_ERR_Property_Invalid; | |
82 capVal = _renderDevice->GetDeviceCaps(capID); | 84 capVal = _renderDevice->GetDeviceCaps(capID); |
83 return FX_ERR_Succeeded; | 85 return FX_ERR_Succeeded; |
84 } | 86 } |
85 default: { return FX_ERR_Property_Invalid; } | 87 default: { return FX_ERR_Property_Invalid; } |
86 } | 88 } |
87 } | 89 } |
88 FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { | 90 FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { |
89 switch (_type) { | 91 switch (_type) { |
90 case FX_CONTEXT_Device: { | 92 case FX_CONTEXT_Device: { |
91 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 93 if (!_renderDevice) |
94 return FX_ERR_Property_Invalid; | |
92 int32_t deviceClass = _renderDevice->GetDeviceClass(); | 95 int32_t deviceClass = _renderDevice->GetDeviceClass(); |
93 if (deviceClass == FXDC_PRINTER) { | 96 if (deviceClass == FXDC_PRINTER) { |
94 isPrinter = TRUE; | 97 isPrinter = TRUE; |
95 } else { | 98 } else { |
96 isPrinter = FALSE; | 99 isPrinter = FALSE; |
97 } | 100 } |
98 return FX_ERR_Succeeded; | 101 return FX_ERR_Succeeded; |
99 } | 102 } |
100 default: { return FX_ERR_Property_Invalid; } | 103 default: { return FX_ERR_Property_Invalid; } |
101 } | 104 } |
102 } | 105 } |
103 FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { | 106 FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { |
104 switch (_type) { | 107 switch (_type) { |
105 case FX_CONTEXT_Device: { | 108 case FX_CONTEXT_Device: { |
106 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 109 if (!_renderDevice) |
110 return FX_ERR_Property_Invalid; | |
107 _info._isAntialiasing = isAntialiasing; | 111 _info._isAntialiasing = isAntialiasing; |
108 return FX_ERR_Succeeded; | 112 return FX_ERR_Succeeded; |
109 } | 113 } |
110 default: { return FX_ERR_Property_Invalid; } | 114 default: { return FX_ERR_Property_Invalid; } |
111 } | 115 } |
112 } | 116 } |
113 FX_ERR CFX_Graphics::SaveGraphState() { | 117 FX_ERR CFX_Graphics::SaveGraphState() { |
114 switch (_type) { | 118 switch (_type) { |
115 case FX_CONTEXT_Device: { | 119 case FX_CONTEXT_Device: { |
116 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 120 if (!_renderDevice) |
121 return FX_ERR_Property_Invalid; | |
117 _renderDevice->SaveState(); | 122 _renderDevice->SaveState(); |
118 TInfo* info = new TInfo; | 123 TInfo* info = new TInfo; |
119 info->_graphState.Copy(_info._graphState); | 124 info->_graphState.Copy(_info._graphState); |
120 info->_isAntialiasing = _info._isAntialiasing; | 125 info->_isAntialiasing = _info._isAntialiasing; |
121 info->_strokeAlignment = _info._strokeAlignment; | 126 info->_strokeAlignment = _info._strokeAlignment; |
122 info->_CTM = _info._CTM; | 127 info->_CTM = _info._CTM; |
123 info->_isActOnDash = _info._isActOnDash; | 128 info->_isActOnDash = _info._isActOnDash; |
124 info->_strokeColor = _info._strokeColor; | 129 info->_strokeColor = _info._strokeColor; |
125 info->_fillColor = _info._fillColor; | 130 info->_fillColor = _info._fillColor; |
126 info->_font = _info._font; | 131 info->_font = _info._font; |
127 info->_fontSize = _info._fontSize; | 132 info->_fontSize = _info._fontSize; |
128 info->_fontHScale = _info._fontHScale; | 133 info->_fontHScale = _info._fontHScale; |
129 info->_fontSpacing = _info._fontSpacing; | 134 info->_fontSpacing = _info._fontSpacing; |
130 _infoStack.Add(info); | 135 _infoStack.Add(info); |
131 return FX_ERR_Succeeded; | 136 return FX_ERR_Succeeded; |
132 } | 137 } |
133 default: { return FX_ERR_Property_Invalid; } | 138 default: { return FX_ERR_Property_Invalid; } |
134 } | 139 } |
135 } | 140 } |
136 FX_ERR CFX_Graphics::RestoreGraphState() { | 141 FX_ERR CFX_Graphics::RestoreGraphState() { |
137 switch (_type) { | 142 switch (_type) { |
138 case FX_CONTEXT_Device: { | 143 case FX_CONTEXT_Device: { |
139 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 144 if (!_renderDevice) |
145 return FX_ERR_Property_Invalid; | |
140 _renderDevice->RestoreState(); | 146 _renderDevice->RestoreState(); |
141 int32_t size = _infoStack.GetSize(); | 147 int32_t size = _infoStack.GetSize(); |
142 if (size <= 0) { | 148 if (size <= 0) { |
143 return FX_ERR_Intermediate_Value_Invalid; | 149 return FX_ERR_Intermediate_Value_Invalid; |
144 } | 150 } |
145 int32_t topIndex = size - 1; | 151 int32_t topIndex = size - 1; |
146 TInfo* info = (TInfo*)_infoStack.GetAt(topIndex); | 152 TInfo* info = (TInfo*)_infoStack.GetAt(topIndex); |
147 _FX_RETURN_VALUE_IF_FAIL(info, FX_ERR_Intermediate_Value_Invalid); | 153 if (!info) |
154 return FX_ERR_Intermediate_Value_Invalid; | |
148 _info._graphState.Copy(info->_graphState); | 155 _info._graphState.Copy(info->_graphState); |
149 _info._isAntialiasing = info->_isAntialiasing; | 156 _info._isAntialiasing = info->_isAntialiasing; |
150 _info._strokeAlignment = info->_strokeAlignment; | 157 _info._strokeAlignment = info->_strokeAlignment; |
151 _info._CTM = info->_CTM; | 158 _info._CTM = info->_CTM; |
152 _info._isActOnDash = info->_isActOnDash; | 159 _info._isActOnDash = info->_isActOnDash; |
153 _info._strokeColor = info->_strokeColor; | 160 _info._strokeColor = info->_strokeColor; |
154 _info._fillColor = info->_fillColor; | 161 _info._fillColor = info->_fillColor; |
155 _info._font = info->_font; | 162 _info._font = info->_font; |
156 _info._fontSize = info->_fontSize; | 163 _info._fontSize = info->_fontSize; |
157 _info._fontHScale = info->_fontHScale; | 164 _info._fontHScale = info->_fontHScale; |
158 _info._fontSpacing = info->_fontSpacing; | 165 _info._fontSpacing = info->_fontSpacing; |
159 delete info; | 166 delete info; |
160 info = NULL; | 167 info = NULL; |
161 _infoStack.RemoveAt(topIndex); | 168 _infoStack.RemoveAt(topIndex); |
162 return FX_ERR_Succeeded; | 169 return FX_ERR_Succeeded; |
163 } | 170 } |
164 default: { return FX_ERR_Property_Invalid; } | 171 default: { return FX_ERR_Property_Invalid; } |
165 } | 172 } |
166 } | 173 } |
167 FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) { | 174 FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) { |
168 switch (_type) { | 175 switch (_type) { |
169 case FX_CONTEXT_Device: { | 176 case FX_CONTEXT_Device: { |
170 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 177 if (!_renderDevice) |
178 return FX_ERR_Property_Invalid; | |
171 lineCap = _info._graphState.m_LineCap; | 179 lineCap = _info._graphState.m_LineCap; |
172 return FX_ERR_Succeeded; | 180 return FX_ERR_Succeeded; |
173 } | 181 } |
174 default: { return FX_ERR_Property_Invalid; } | 182 default: { return FX_ERR_Property_Invalid; } |
175 } | 183 } |
176 } | 184 } |
177 FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { | 185 FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { |
178 switch (_type) { | 186 switch (_type) { |
179 case FX_CONTEXT_Device: { | 187 case FX_CONTEXT_Device: { |
180 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 188 if (!_renderDevice) |
189 return FX_ERR_Property_Invalid; | |
181 _info._graphState.m_LineCap = lineCap; | 190 _info._graphState.m_LineCap = lineCap; |
182 return FX_ERR_Succeeded; | 191 return FX_ERR_Succeeded; |
183 } | 192 } |
184 default: { return FX_ERR_Property_Invalid; } | 193 default: { return FX_ERR_Property_Invalid; } |
185 } | 194 } |
186 } | 195 } |
187 FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) { | 196 FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) { |
188 switch (_type) { | 197 switch (_type) { |
189 case FX_CONTEXT_Device: { | 198 case FX_CONTEXT_Device: { |
190 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 199 if (!_renderDevice) |
200 return FX_ERR_Property_Invalid; | |
191 dashCount = _info._graphState.m_DashCount; | 201 dashCount = _info._graphState.m_DashCount; |
192 return FX_ERR_Succeeded; | 202 return FX_ERR_Succeeded; |
193 } | 203 } |
194 default: { return FX_ERR_Property_Invalid; } | 204 default: { return FX_ERR_Property_Invalid; } |
195 } | 205 } |
196 } | 206 } |
197 FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) { | 207 FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) { |
198 _FX_RETURN_VALUE_IF_FAIL(dashArray, FX_ERR_Parameter_Invalid); | 208 if (!dashArray) |
209 return FX_ERR_Parameter_Invalid; | |
199 switch (_type) { | 210 switch (_type) { |
200 case FX_CONTEXT_Device: { | 211 case FX_CONTEXT_Device: { |
201 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 212 if (!_renderDevice) |
213 return FX_ERR_Property_Invalid; | |
202 dashPhase = _info._graphState.m_DashPhase; | 214 dashPhase = _info._graphState.m_DashPhase; |
203 FXSYS_memcpy(dashArray, _info._graphState.m_DashArray, | 215 FXSYS_memcpy(dashArray, _info._graphState.m_DashArray, |
204 _info._graphState.m_DashCount * sizeof(FX_FLOAT)); | 216 _info._graphState.m_DashCount * sizeof(FX_FLOAT)); |
205 return FX_ERR_Succeeded; | 217 return FX_ERR_Succeeded; |
206 } | 218 } |
207 default: { return FX_ERR_Property_Invalid; } | 219 default: { return FX_ERR_Property_Invalid; } |
208 } | 220 } |
209 } | 221 } |
210 FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, | 222 FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, |
211 FX_FLOAT* dashArray, | 223 FX_FLOAT* dashArray, |
212 int32_t dashCount) { | 224 int32_t dashCount) { |
213 if (dashCount > 0 && !dashArray) { | 225 if (dashCount > 0 && !dashArray) { |
214 return FX_ERR_Parameter_Invalid; | 226 return FX_ERR_Parameter_Invalid; |
215 } | 227 } |
216 dashCount = dashCount < 0 ? 0 : dashCount; | 228 dashCount = dashCount < 0 ? 0 : dashCount; |
217 switch (_type) { | 229 switch (_type) { |
218 case FX_CONTEXT_Device: { | 230 case FX_CONTEXT_Device: { |
219 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 231 if (!_renderDevice) |
232 return FX_ERR_Property_Invalid; | |
220 FX_FLOAT scale = 1.0; | 233 FX_FLOAT scale = 1.0; |
221 if (_info._isActOnDash) { | 234 if (_info._isActOnDash) { |
222 scale = _info._graphState.m_LineWidth; | 235 scale = _info._graphState.m_LineWidth; |
223 } | 236 } |
224 _info._graphState.m_DashPhase = dashPhase; | 237 _info._graphState.m_DashPhase = dashPhase; |
225 _info._graphState.SetDashCount(dashCount); | 238 _info._graphState.SetDashCount(dashCount); |
226 for (int32_t i = 0; i < dashCount; i++) { | 239 for (int32_t i = 0; i < dashCount; i++) { |
227 _info._graphState.m_DashArray[i] = dashArray[i] * scale; | 240 _info._graphState.m_DashArray[i] = dashArray[i] * scale; |
228 } | 241 } |
229 return FX_ERR_Succeeded; | 242 return FX_ERR_Succeeded; |
230 } | 243 } |
231 default: { return FX_ERR_Property_Invalid; } | 244 default: { return FX_ERR_Property_Invalid; } |
232 } | 245 } |
233 } | 246 } |
234 FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { | 247 FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { |
235 switch (_type) { | 248 switch (_type) { |
236 case FX_CONTEXT_Device: { | 249 case FX_CONTEXT_Device: { |
237 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 250 if (!_renderDevice) |
251 return FX_ERR_Property_Invalid; | |
238 return RenderDeviceSetLineDash(dashStyle); | 252 return RenderDeviceSetLineDash(dashStyle); |
239 } | 253 } |
240 default: { return FX_ERR_Property_Invalid; } | 254 default: { return FX_ERR_Property_Invalid; } |
241 } | 255 } |
242 } | 256 } |
243 FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) { | 257 FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) { |
244 switch (_type) { | 258 switch (_type) { |
245 case FX_CONTEXT_Device: { | 259 case FX_CONTEXT_Device: { |
246 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 260 if (!_renderDevice) |
261 return FX_ERR_Property_Invalid; | |
247 lineJoin = _info._graphState.m_LineJoin; | 262 lineJoin = _info._graphState.m_LineJoin; |
248 return FX_ERR_Succeeded; | 263 return FX_ERR_Succeeded; |
249 } | 264 } |
250 default: { return FX_ERR_Property_Invalid; } | 265 default: { return FX_ERR_Property_Invalid; } |
251 } | 266 } |
252 } | 267 } |
253 FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { | 268 FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { |
254 switch (_type) { | 269 switch (_type) { |
255 case FX_CONTEXT_Device: { | 270 case FX_CONTEXT_Device: { |
256 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 271 if (!_renderDevice) |
272 return FX_ERR_Property_Invalid; | |
257 _info._graphState.m_LineJoin = lineJoin; | 273 _info._graphState.m_LineJoin = lineJoin; |
258 return FX_ERR_Succeeded; | 274 return FX_ERR_Succeeded; |
259 } | 275 } |
260 default: { return FX_ERR_Property_Invalid; } | 276 default: { return FX_ERR_Property_Invalid; } |
261 } | 277 } |
262 } | 278 } |
263 FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) { | 279 FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) { |
264 switch (_type) { | 280 switch (_type) { |
265 case FX_CONTEXT_Device: { | 281 case FX_CONTEXT_Device: { |
266 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 282 if (!_renderDevice) |
283 return FX_ERR_Property_Invalid; | |
267 miterLimit = _info._graphState.m_MiterLimit; | 284 miterLimit = _info._graphState.m_MiterLimit; |
268 return FX_ERR_Succeeded; | 285 return FX_ERR_Succeeded; |
269 } | 286 } |
270 default: { return FX_ERR_Property_Invalid; } | 287 default: { return FX_ERR_Property_Invalid; } |
271 } | 288 } |
272 } | 289 } |
273 FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { | 290 FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { |
274 switch (_type) { | 291 switch (_type) { |
275 case FX_CONTEXT_Device: { | 292 case FX_CONTEXT_Device: { |
276 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 293 if (!_renderDevice) |
294 return FX_ERR_Property_Invalid; | |
277 _info._graphState.m_MiterLimit = miterLimit; | 295 _info._graphState.m_MiterLimit = miterLimit; |
278 return FX_ERR_Succeeded; | 296 return FX_ERR_Succeeded; |
279 } | 297 } |
280 default: { return FX_ERR_Property_Invalid; } | 298 default: { return FX_ERR_Property_Invalid; } |
281 } | 299 } |
282 } | 300 } |
283 FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) { | 301 FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) { |
284 switch (_type) { | 302 switch (_type) { |
285 case FX_CONTEXT_Device: { | 303 case FX_CONTEXT_Device: { |
286 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 304 if (!_renderDevice) |
305 return FX_ERR_Property_Invalid; | |
287 lineWidth = _info._graphState.m_LineWidth; | 306 lineWidth = _info._graphState.m_LineWidth; |
288 return FX_ERR_Succeeded; | 307 return FX_ERR_Succeeded; |
289 } | 308 } |
290 default: { return FX_ERR_Property_Invalid; } | 309 default: { return FX_ERR_Property_Invalid; } |
291 } | 310 } |
292 } | 311 } |
293 FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { | 312 FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { |
294 switch (_type) { | 313 switch (_type) { |
295 case FX_CONTEXT_Device: { | 314 case FX_CONTEXT_Device: { |
296 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 315 if (!_renderDevice) |
316 return FX_ERR_Property_Invalid; | |
297 _info._graphState.m_LineWidth = lineWidth; | 317 _info._graphState.m_LineWidth = lineWidth; |
298 _info._isActOnDash = isActOnDash; | 318 _info._isActOnDash = isActOnDash; |
299 return FX_ERR_Succeeded; | 319 return FX_ERR_Succeeded; |
300 } | 320 } |
301 default: { return FX_ERR_Property_Invalid; } | 321 default: { return FX_ERR_Property_Invalid; } |
302 } | 322 } |
303 } | 323 } |
304 FX_ERR CFX_Graphics::GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) { | 324 FX_ERR CFX_Graphics::GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) { |
305 switch (_type) { | 325 switch (_type) { |
306 case FX_CONTEXT_Device: { | 326 case FX_CONTEXT_Device: { |
307 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 327 if (!_renderDevice) |
328 return FX_ERR_Property_Invalid; | |
308 strokeAlignment = _info._strokeAlignment; | 329 strokeAlignment = _info._strokeAlignment; |
309 return FX_ERR_Succeeded; | 330 return FX_ERR_Succeeded; |
310 } | 331 } |
311 default: { return FX_ERR_Property_Invalid; } | 332 default: { return FX_ERR_Property_Invalid; } |
312 } | 333 } |
313 } | 334 } |
314 FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { | 335 FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { |
315 switch (_type) { | 336 switch (_type) { |
316 case FX_CONTEXT_Device: { | 337 case FX_CONTEXT_Device: { |
317 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 338 if (!_renderDevice) |
339 return FX_ERR_Property_Invalid; | |
318 _info._strokeAlignment = strokeAlignment; | 340 _info._strokeAlignment = strokeAlignment; |
319 return FX_ERR_Succeeded; | 341 return FX_ERR_Succeeded; |
320 } | 342 } |
321 default: { return FX_ERR_Property_Invalid; } | 343 default: { return FX_ERR_Property_Invalid; } |
322 } | 344 } |
323 } | 345 } |
324 FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { | 346 FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { |
325 _FX_RETURN_VALUE_IF_FAIL(color, FX_ERR_Parameter_Invalid); | 347 if (!color) |
348 return FX_ERR_Parameter_Invalid; | |
326 switch (_type) { | 349 switch (_type) { |
327 case FX_CONTEXT_Device: { | 350 case FX_CONTEXT_Device: { |
328 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 351 if (!_renderDevice) |
352 return FX_ERR_Property_Invalid; | |
329 _info._strokeColor = color; | 353 _info._strokeColor = color; |
330 return FX_ERR_Succeeded; | 354 return FX_ERR_Succeeded; |
331 } | 355 } |
332 default: { return FX_ERR_Property_Invalid; } | 356 default: { return FX_ERR_Property_Invalid; } |
333 } | 357 } |
334 } | 358 } |
335 FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { | 359 FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { |
336 _FX_RETURN_VALUE_IF_FAIL(color, FX_ERR_Parameter_Invalid); | 360 if (!color) |
361 return FX_ERR_Parameter_Invalid; | |
337 switch (_type) { | 362 switch (_type) { |
338 case FX_CONTEXT_Device: { | 363 case FX_CONTEXT_Device: { |
339 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 364 if (!_renderDevice) |
365 return FX_ERR_Property_Invalid; | |
340 _info._fillColor = color; | 366 _info._fillColor = color; |
341 return FX_ERR_Succeeded; | 367 return FX_ERR_Succeeded; |
342 } | 368 } |
343 default: { return FX_ERR_Property_Invalid; } | 369 default: { return FX_ERR_Property_Invalid; } |
344 } | 370 } |
345 } | 371 } |
346 FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { | 372 FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { |
347 _FX_RETURN_VALUE_IF_FAIL(path, FX_ERR_Parameter_Invalid); | 373 if (!path) |
374 return FX_ERR_Parameter_Invalid; | |
348 switch (_type) { | 375 switch (_type) { |
349 case FX_CONTEXT_Device: { | 376 case FX_CONTEXT_Device: { |
350 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 377 if (!_renderDevice) |
378 return FX_ERR_Property_Invalid; | |
351 return RenderDeviceStrokePath(path, matrix); | 379 return RenderDeviceStrokePath(path, matrix); |
352 } | 380 } |
353 default: { return FX_ERR_Property_Invalid; } | 381 default: { return FX_ERR_Property_Invalid; } |
354 } | 382 } |
355 } | 383 } |
356 FX_ERR CFX_Graphics::FillPath(CFX_Path* path, | 384 FX_ERR CFX_Graphics::FillPath(CFX_Path* path, |
357 FX_FillMode fillMode, | 385 FX_FillMode fillMode, |
358 CFX_Matrix* matrix) { | 386 CFX_Matrix* matrix) { |
359 _FX_RETURN_VALUE_IF_FAIL(path, FX_ERR_Parameter_Invalid); | 387 if (!path) |
388 return FX_ERR_Parameter_Invalid; | |
360 switch (_type) { | 389 switch (_type) { |
361 case FX_CONTEXT_Device: { | 390 case FX_CONTEXT_Device: { |
362 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 391 if (!_renderDevice) |
392 return FX_ERR_Property_Invalid; | |
363 return RenderDeviceFillPath(path, fillMode, matrix); | 393 return RenderDeviceFillPath(path, fillMode, matrix); |
364 } | 394 } |
365 default: { return FX_ERR_Property_Invalid; } | 395 default: { return FX_ERR_Property_Invalid; } |
366 } | 396 } |
367 } | 397 } |
368 FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, | 398 FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, |
369 FX_FillMode fillMode, | 399 FX_FillMode fillMode, |
370 CFX_Matrix* matrix) { | 400 CFX_Matrix* matrix) { |
371 _FX_RETURN_VALUE_IF_FAIL(path, FX_ERR_Parameter_Invalid); | 401 if (!path) |
402 return FX_ERR_Parameter_Invalid; | |
372 switch (_type) { | 403 switch (_type) { |
373 case FX_CONTEXT_Device: { | 404 case FX_CONTEXT_Device: { |
374 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 405 if (!_renderDevice) |
406 return FX_ERR_Property_Invalid; | |
375 FX_BOOL result = _renderDevice->SetClip_PathFill( | 407 FX_BOOL result = _renderDevice->SetClip_PathFill( |
376 path->GetPathData(), (CFX_Matrix*)matrix, fillMode); | 408 path->GetPathData(), (CFX_Matrix*)matrix, fillMode); |
377 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Indefinite); | 409 if (!result) |
410 return FX_ERR_Indefinite; | |
378 return FX_ERR_Succeeded; | 411 return FX_ERR_Succeeded; |
379 } | 412 } |
380 default: { return FX_ERR_Property_Invalid; } | 413 default: { return FX_ERR_Property_Invalid; } |
381 } | 414 } |
382 } | 415 } |
383 FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, | 416 FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, |
384 const CFX_PointF& point, | 417 const CFX_PointF& point, |
385 CFX_Matrix* matrix) { | 418 CFX_Matrix* matrix) { |
386 _FX_RETURN_VALUE_IF_FAIL(source, FX_ERR_Parameter_Invalid); | 419 if (!source) |
420 return FX_ERR_Parameter_Invalid; | |
387 switch (_type) { | 421 switch (_type) { |
388 case FX_CONTEXT_Device: { | 422 case FX_CONTEXT_Device: { |
389 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 423 if (!_renderDevice) |
424 return FX_ERR_Property_Invalid; | |
390 return RenderDeviceDrawImage(source, point, matrix); | 425 return RenderDeviceDrawImage(source, point, matrix); |
391 } | 426 } |
392 default: { return FX_ERR_Property_Invalid; } | 427 default: { return FX_ERR_Property_Invalid; } |
393 } | 428 } |
394 } | 429 } |
395 FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, | 430 FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, |
396 const CFX_RectF& rect, | 431 const CFX_RectF& rect, |
397 CFX_Matrix* matrix) { | 432 CFX_Matrix* matrix) { |
398 _FX_RETURN_VALUE_IF_FAIL(source, FX_ERR_Parameter_Invalid); | 433 if (!source) |
434 return FX_ERR_Parameter_Invalid; | |
399 switch (_type) { | 435 switch (_type) { |
400 case FX_CONTEXT_Device: { | 436 case FX_CONTEXT_Device: { |
401 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 437 if (!_renderDevice) |
438 return FX_ERR_Property_Invalid; | |
402 return RenderDeviceStretchImage(source, rect, matrix); | 439 return RenderDeviceStretchImage(source, rect, matrix); |
403 } | 440 } |
404 default: { return FX_ERR_Property_Invalid; } | 441 default: { return FX_ERR_Property_Invalid; } |
405 } | 442 } |
406 } | 443 } |
407 FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { | 444 FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { |
408 _FX_RETURN_VALUE_IF_FAIL(matrix, FX_ERR_Parameter_Invalid); | 445 if (!matrix) |
446 return FX_ERR_Parameter_Invalid; | |
409 switch (_type) { | 447 switch (_type) { |
410 case FX_CONTEXT_Device: { | 448 case FX_CONTEXT_Device: { |
411 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 449 if (!_renderDevice) |
450 return FX_ERR_Property_Invalid; | |
412 _info._CTM.Concat(*matrix); | 451 _info._CTM.Concat(*matrix); |
413 return FX_ERR_Succeeded; | 452 return FX_ERR_Succeeded; |
414 } | 453 } |
415 default: { return FX_ERR_Property_Invalid; } | 454 default: { return FX_ERR_Property_Invalid; } |
416 } | 455 } |
417 } | 456 } |
418 CFX_Matrix* CFX_Graphics::GetMatrix() { | 457 CFX_Matrix* CFX_Graphics::GetMatrix() { |
419 switch (_type) { | 458 switch (_type) { |
420 case FX_CONTEXT_Device: { | 459 case FX_CONTEXT_Device: { |
421 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, NULL); | 460 if (!_renderDevice) |
461 return NULL; | |
422 return &_info._CTM; | 462 return &_info._CTM; |
423 } | 463 } |
424 default: { return NULL; } | 464 default: { return NULL; } |
425 } | 465 } |
426 } | 466 } |
427 FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) { | 467 FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) { |
428 switch (_type) { | 468 switch (_type) { |
429 case FX_CONTEXT_Device: { | 469 case FX_CONTEXT_Device: { |
430 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 470 if (!_renderDevice) |
471 return FX_ERR_Property_Invalid; | |
431 FX_RECT r = _renderDevice->GetClipBox(); | 472 FX_RECT r = _renderDevice->GetClipBox(); |
432 rect.left = (FX_FLOAT)r.left; | 473 rect.left = (FX_FLOAT)r.left; |
433 rect.top = (FX_FLOAT)r.top; | 474 rect.top = (FX_FLOAT)r.top; |
434 rect.width = (FX_FLOAT)r.Width(); | 475 rect.width = (FX_FLOAT)r.Width(); |
435 rect.height = (FX_FLOAT)r.Height(); | 476 rect.height = (FX_FLOAT)r.Height(); |
436 return FX_ERR_Succeeded; | 477 return FX_ERR_Succeeded; |
437 } | 478 } |
438 default: { return FX_ERR_Property_Invalid; } | 479 default: { return FX_ERR_Property_Invalid; } |
439 } | 480 } |
440 } | 481 } |
441 FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { | 482 FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { |
442 switch (_type) { | 483 switch (_type) { |
443 case FX_CONTEXT_Device: { | 484 case FX_CONTEXT_Device: { |
444 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 485 if (!_renderDevice) |
486 return FX_ERR_Property_Invalid; | |
445 FX_RECT r(FXSYS_round(rect.left), FXSYS_round(rect.top), | 487 FX_RECT r(FXSYS_round(rect.left), FXSYS_round(rect.top), |
446 FXSYS_round(rect.right()), FXSYS_round(rect.bottom())); | 488 FXSYS_round(rect.right()), FXSYS_round(rect.bottom())); |
447 FX_BOOL result = _renderDevice->SetClip_Rect(&r); | 489 FX_BOOL result = _renderDevice->SetClip_Rect(&r); |
448 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Method_Not_Supported); | 490 if (!result) |
491 return FX_ERR_Method_Not_Supported; | |
449 return FX_ERR_Succeeded; | 492 return FX_ERR_Succeeded; |
450 } | 493 } |
451 default: { return FX_ERR_Property_Invalid; } | 494 default: { return FX_ERR_Property_Invalid; } |
452 } | 495 } |
453 } | 496 } |
454 FX_ERR CFX_Graphics::ClearClip() { | 497 FX_ERR CFX_Graphics::ClearClip() { |
455 switch (_type) { | 498 switch (_type) { |
456 case FX_CONTEXT_Device: { | 499 case FX_CONTEXT_Device: { |
457 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 500 if (!_renderDevice) |
501 return FX_ERR_Property_Invalid; | |
458 FX_BOOL result = FX_ERR_Succeeded; | 502 FX_BOOL result = FX_ERR_Succeeded; |
Lei Zhang
2016/02/26 19:40:55
uh
Tom Sepez
2016/02/26 19:50:09
Uh-oh. Probably Does the opposite of what the want
| |
459 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Method_Not_Supported); | 503 if (!result) |
504 return FX_ERR_Method_Not_Supported; | |
460 return FX_ERR_Succeeded; | 505 return FX_ERR_Succeeded; |
461 } | 506 } |
462 default: { return FX_ERR_Property_Invalid; } | 507 default: { return FX_ERR_Property_Invalid; } |
463 } | 508 } |
464 } | 509 } |
465 FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { | 510 FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { |
466 _FX_RETURN_VALUE_IF_FAIL(font, FX_ERR_Parameter_Invalid); | 511 if (!font) |
512 return FX_ERR_Parameter_Invalid; | |
467 switch (_type) { | 513 switch (_type) { |
468 case FX_CONTEXT_Device: { | 514 case FX_CONTEXT_Device: { |
469 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 515 if (!_renderDevice) |
516 return FX_ERR_Property_Invalid; | |
470 _info._font = font; | 517 _info._font = font; |
471 return FX_ERR_Succeeded; | 518 return FX_ERR_Succeeded; |
472 } | 519 } |
473 default: { return FX_ERR_Property_Invalid; } | 520 default: { return FX_ERR_Property_Invalid; } |
474 } | 521 } |
475 } | 522 } |
476 FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { | 523 FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { |
477 FX_FLOAT fontSize = size <= 0 ? 1.0f : size; | 524 FX_FLOAT fontSize = size <= 0 ? 1.0f : size; |
478 switch (_type) { | 525 switch (_type) { |
479 case FX_CONTEXT_Device: { | 526 case FX_CONTEXT_Device: { |
480 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 527 if (!_renderDevice) |
528 return FX_ERR_Property_Invalid; | |
481 _info._fontSize = fontSize; | 529 _info._fontSize = fontSize; |
482 return FX_ERR_Succeeded; | 530 return FX_ERR_Succeeded; |
483 } | 531 } |
484 default: { return FX_ERR_Property_Invalid; } | 532 default: { return FX_ERR_Property_Invalid; } |
485 } | 533 } |
486 } | 534 } |
487 FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { | 535 FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { |
488 FX_FLOAT fontHScale = scale <= 0 ? 1.0f : scale; | 536 FX_FLOAT fontHScale = scale <= 0 ? 1.0f : scale; |
489 switch (_type) { | 537 switch (_type) { |
490 case FX_CONTEXT_Device: { | 538 case FX_CONTEXT_Device: { |
491 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 539 if (!_renderDevice) |
540 return FX_ERR_Property_Invalid; | |
492 _info._fontHScale = fontHScale; | 541 _info._fontHScale = fontHScale; |
493 return FX_ERR_Succeeded; | 542 return FX_ERR_Succeeded; |
494 } | 543 } |
495 default: { return FX_ERR_Property_Invalid; } | 544 default: { return FX_ERR_Property_Invalid; } |
496 } | 545 } |
497 } | 546 } |
498 FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { | 547 FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { |
499 FX_FLOAT fontSpacing = spacing < 0 ? 0 : spacing; | 548 FX_FLOAT fontSpacing = spacing < 0 ? 0 : spacing; |
500 switch (_type) { | 549 switch (_type) { |
501 case FX_CONTEXT_Device: { | 550 case FX_CONTEXT_Device: { |
502 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 551 if (!_renderDevice) |
552 return FX_ERR_Property_Invalid; | |
503 _info._fontSpacing = fontSpacing; | 553 _info._fontSpacing = fontSpacing; |
504 return FX_ERR_Succeeded; | 554 return FX_ERR_Succeeded; |
505 } | 555 } |
506 default: { return FX_ERR_Property_Invalid; } | 556 default: { return FX_ERR_Property_Invalid; } |
507 } | 557 } |
508 } | 558 } |
509 FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { | 559 FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { |
510 switch (_type) { | 560 switch (_type) { |
511 case FX_CONTEXT_Device: { | 561 case FX_CONTEXT_Device: { |
512 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 562 if (!_renderDevice) |
563 return FX_ERR_Property_Invalid; | |
513 return FX_ERR_Succeeded; | 564 return FX_ERR_Succeeded; |
514 } | 565 } |
515 default: { return FX_ERR_Property_Invalid; } | 566 default: { return FX_ERR_Property_Invalid; } |
516 } | 567 } |
517 } | 568 } |
518 FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, | 569 FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, |
519 const CFX_WideString& text, | 570 const CFX_WideString& text, |
520 CFX_Matrix* matrix) { | 571 CFX_Matrix* matrix) { |
521 switch (_type) { | 572 switch (_type) { |
522 case FX_CONTEXT_Device: { | 573 case FX_CONTEXT_Device: { |
523 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 574 if (!_renderDevice) |
575 return FX_ERR_Property_Invalid; | |
524 return RenderDeviceShowText(point, text, matrix); | 576 return RenderDeviceShowText(point, text, matrix); |
525 } | 577 } |
526 default: { return FX_ERR_Property_Invalid; } | 578 default: { return FX_ERR_Property_Invalid; } |
527 } | 579 } |
528 } | 580 } |
529 FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, | 581 FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, |
530 const CFX_WideString& text, | 582 const CFX_WideString& text, |
531 FX_BOOL isMultiline, | 583 FX_BOOL isMultiline, |
532 CFX_Matrix* matrix) { | 584 CFX_Matrix* matrix) { |
533 switch (_type) { | 585 switch (_type) { |
534 case FX_CONTEXT_Device: { | 586 case FX_CONTEXT_Device: { |
535 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 587 if (!_renderDevice) |
588 return FX_ERR_Property_Invalid; | |
536 int32_t length = text.GetLength(); | 589 int32_t length = text.GetLength(); |
537 FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); | 590 FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); |
538 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); | 591 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); |
539 CalcTextInfo(text, charCodes, charPos, rect); | 592 CalcTextInfo(text, charCodes, charPos, rect); |
540 FX_Free(charPos); | 593 FX_Free(charPos); |
541 FX_Free(charCodes); | 594 FX_Free(charCodes); |
542 return FX_ERR_Succeeded; | 595 return FX_ERR_Succeeded; |
543 } | 596 } |
544 default: { return FX_ERR_Property_Invalid; } | 597 default: { return FX_ERR_Property_Invalid; } |
545 } | 598 } |
546 } | 599 } |
547 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, | 600 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, |
548 const CFX_Matrix* matrix) { | 601 const CFX_Matrix* matrix) { |
549 _FX_RETURN_VALUE_IF_FAIL(graphics, FX_ERR_Parameter_Invalid); | 602 if (!graphics) |
603 return FX_ERR_Parameter_Invalid; | |
550 CFX_Matrix m; | 604 CFX_Matrix m; |
551 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, | 605 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, |
552 _info._CTM.f); | 606 _info._CTM.f); |
553 if (matrix) { | 607 if (matrix) { |
554 m.Concat(*matrix); | 608 m.Concat(*matrix); |
555 } | 609 } |
556 switch (_type) { | 610 switch (_type) { |
557 case FX_CONTEXT_Device: { | 611 case FX_CONTEXT_Device: { |
558 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 612 if (!_renderDevice) |
613 return FX_ERR_Property_Invalid; | |
559 { | 614 { |
560 _FX_RETURN_VALUE_IF_FAIL(graphics->_renderDevice, | 615 if (!graphics->_renderDevice) |
561 FX_ERR_Parameter_Invalid); | 616 return FX_ERR_Parameter_Invalid; |
562 CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); | 617 CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); |
563 FX_BOOL result = _renderDevice->SetDIBits(bitmap, 0, 0); | 618 FX_BOOL result = _renderDevice->SetDIBits(bitmap, 0, 0); |
564 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Method_Not_Supported); | 619 if (!result) |
620 return FX_ERR_Method_Not_Supported; | |
565 } | 621 } |
566 } | 622 } |
567 default: { return FX_ERR_Property_Invalid; } | 623 default: { return FX_ERR_Property_Invalid; } |
568 } | 624 } |
569 } | 625 } |
570 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, | 626 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, |
571 FX_FLOAT srcLeft, | 627 FX_FLOAT srcLeft, |
572 FX_FLOAT srcTop, | 628 FX_FLOAT srcTop, |
573 const CFX_RectF& dstRect, | 629 const CFX_RectF& dstRect, |
574 const CFX_Matrix* matrix) { | 630 const CFX_Matrix* matrix) { |
575 _FX_RETURN_VALUE_IF_FAIL(graphics, FX_ERR_Parameter_Invalid); | 631 if (!graphics) |
632 return FX_ERR_Parameter_Invalid; | |
576 CFX_Matrix m; | 633 CFX_Matrix m; |
577 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, | 634 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, |
578 _info._CTM.f); | 635 _info._CTM.f); |
579 if (matrix) { | 636 if (matrix) { |
580 m.Concat(*matrix); | 637 m.Concat(*matrix); |
581 } | 638 } |
582 switch (_type) { | 639 switch (_type) { |
583 case FX_CONTEXT_Device: { | 640 case FX_CONTEXT_Device: { |
584 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 641 if (!_renderDevice) |
642 return FX_ERR_Property_Invalid; | |
585 { | 643 { |
586 _FX_RETURN_VALUE_IF_FAIL(graphics->_renderDevice, | 644 if (!graphics->_renderDevice) |
587 FX_ERR_Parameter_Invalid); | 645 return FX_ERR_Parameter_Invalid; |
588 CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); | 646 CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); |
589 FX_BOOL result = FX_ERR_Indefinite; | 647 FX_BOOL result = FX_ERR_Indefinite; |
Lei Zhang
2016/02/26 19:40:55
Combine with line 649.
Tom Sepez
2016/02/26 19:50:09
Done.
| |
590 CFX_DIBitmap bmp; | 648 CFX_DIBitmap bmp; |
591 result = bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, | 649 result = bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, |
592 bitmap->GetFormat()); | 650 bitmap->GetFormat()); |
593 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Intermediate_Value_Invalid); | 651 if (!result) |
652 return FX_ERR_Intermediate_Value_Invalid; | |
594 result = graphics->_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, | 653 result = graphics->_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, |
595 (int32_t)srcTop); | 654 (int32_t)srcTop); |
596 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Method_Not_Supported); | 655 if (!result) |
656 return FX_ERR_Method_Not_Supported; | |
597 result = _renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, | 657 result = _renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, |
598 (int32_t)dstRect.top); | 658 (int32_t)dstRect.top); |
599 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Method_Not_Supported); | 659 if (!result) |
660 return FX_ERR_Method_Not_Supported; | |
600 return FX_ERR_Succeeded; | 661 return FX_ERR_Succeeded; |
601 } | 662 } |
602 } | 663 } |
603 default: { return FX_ERR_Property_Invalid; } | 664 default: { return FX_ERR_Property_Invalid; } |
604 } | 665 } |
605 } | 666 } |
606 CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { | 667 CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { |
607 return _renderDevice; | 668 return _renderDevice; |
608 } | 669 } |
609 FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { | 670 FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { |
610 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 671 if (!_renderDevice) |
672 return FX_ERR_Property_Invalid; | |
611 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); | 673 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); |
612 _FX_RETURN_VALUE_IF_FAIL(bitmap, FX_ERR_Property_Invalid); | 674 if (!bitmap) |
675 return FX_ERR_Property_Invalid; | |
613 CFX_RectF temp(rect); | 676 CFX_RectF temp(rect); |
614 _info._CTM.TransformRect(temp); | 677 _info._CTM.TransformRect(temp); |
615 CFX_RectF r; | 678 CFX_RectF r; |
616 r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); | 679 r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); |
617 r.Intersect(temp); | 680 r.Intersect(temp); |
618 if (r.IsEmpty()) { | 681 if (r.IsEmpty()) { |
619 return FX_ERR_Parameter_Invalid; | 682 return FX_ERR_Parameter_Invalid; |
620 } | 683 } |
621 FX_ARGB* pBuf = | 684 FX_ARGB* pBuf = |
622 (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); | 685 (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); |
623 int32_t bottom = (int32_t)r.bottom(); | 686 int32_t bottom = (int32_t)r.bottom(); |
624 int32_t right = (int32_t)r.right(); | 687 int32_t right = (int32_t)r.right(); |
625 for (int32_t i = (int32_t)r.top; i < bottom; i++) { | 688 for (int32_t i = (int32_t)r.top; i < bottom; i++) { |
626 FX_ARGB* pLine = pBuf + (int32_t)r.left; | 689 FX_ARGB* pLine = pBuf + (int32_t)r.left; |
627 for (int32_t j = (int32_t)r.left; j < right; j++) { | 690 for (int32_t j = (int32_t)r.left; j < right; j++) { |
628 FX_ARGB c = *pLine; | 691 FX_ARGB c = *pLine; |
629 *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); | 692 *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); |
630 } | 693 } |
631 pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); | 694 pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); |
632 } | 695 } |
633 return FX_ERR_Succeeded; | 696 return FX_ERR_Succeeded; |
634 } | 697 } |
635 FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, | 698 FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, |
636 const CFX_RectF& rect) { | 699 const CFX_RectF& rect) { |
637 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 700 if (!_renderDevice) |
701 return FX_ERR_Property_Invalid; | |
638 CFX_DIBitmap* dst = _renderDevice->GetBitmap(); | 702 CFX_DIBitmap* dst = _renderDevice->GetBitmap(); |
639 _FX_RETURN_VALUE_IF_FAIL(dst, FX_ERR_Property_Invalid); | 703 if (!dst) |
704 return FX_ERR_Property_Invalid; | |
640 CFX_RectF temp(rect); | 705 CFX_RectF temp(rect); |
641 _info._CTM.TransformRect(temp); | 706 _info._CTM.TransformRect(temp); |
642 CFX_RectF r; | 707 CFX_RectF r; |
643 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); | 708 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); |
644 r.Intersect(temp); | 709 r.Intersect(temp); |
645 if (r.IsEmpty()) { | 710 if (r.IsEmpty()) { |
646 return FX_ERR_Parameter_Invalid; | 711 return FX_ERR_Parameter_Invalid; |
647 } | 712 } |
648 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + | 713 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + |
649 int32_t(r.top) * srcBitmap->GetPitch()); | 714 int32_t(r.top) * srcBitmap->GetPitch()); |
(...skipping 10 matching lines...) Expand all Loading... | |
660 ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); | 725 ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); |
661 pSrcLine++; | 726 pSrcLine++; |
662 } | 727 } |
663 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); | 728 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); |
664 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); | 729 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); |
665 } | 730 } |
666 return FX_ERR_Succeeded; | 731 return FX_ERR_Succeeded; |
667 } | 732 } |
668 FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, | 733 FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, |
669 const CFX_RectF& rect) { | 734 const CFX_RectF& rect) { |
670 _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); | 735 if (!_renderDevice) |
736 return FX_ERR_Property_Invalid; | |
671 CFX_DIBitmap* dst = _renderDevice->GetBitmap(); | 737 CFX_DIBitmap* dst = _renderDevice->GetBitmap(); |
672 _FX_RETURN_VALUE_IF_FAIL(dst, FX_ERR_Property_Invalid); | 738 if (!dst) |
739 return FX_ERR_Property_Invalid; | |
673 CFX_RectF temp(rect); | 740 CFX_RectF temp(rect); |
674 _info._CTM.TransformRect(temp); | 741 _info._CTM.TransformRect(temp); |
675 CFX_RectF r; | 742 CFX_RectF r; |
676 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); | 743 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); |
677 r.Intersect(temp); | 744 r.Intersect(temp); |
678 if (r.IsEmpty()) { | 745 if (r.IsEmpty()) { |
679 return FX_ERR_Parameter_Invalid; | 746 return FX_ERR_Parameter_Invalid; |
680 } | 747 } |
681 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + | 748 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + |
682 int32_t(r.top) * srcBitmap->GetPitch()); | 749 int32_t(r.top) * srcBitmap->GetPitch()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 case FX_DASHSTYLE_DashDotDot: { | 789 case FX_DASHSTYLE_DashDotDot: { |
723 FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; | 790 FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; |
724 SetLineDash(0, dashArray, 6); | 791 SetLineDash(0, dashArray, 6); |
725 return FX_ERR_Succeeded; | 792 return FX_ERR_Succeeded; |
726 } | 793 } |
727 default: { return FX_ERR_Parameter_Invalid; } | 794 default: { return FX_ERR_Parameter_Invalid; } |
728 } | 795 } |
729 } | 796 } |
730 FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, | 797 FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, |
731 CFX_Matrix* matrix) { | 798 CFX_Matrix* matrix) { |
732 _FX_RETURN_VALUE_IF_FAIL(_info._strokeColor, FX_ERR_Property_Invalid); | 799 if (!_info._strokeColor) |
800 return FX_ERR_Property_Invalid; | |
733 CFX_Matrix m; | 801 CFX_Matrix m; |
734 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, | 802 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, |
735 _info._CTM.f); | 803 _info._CTM.f); |
736 if (matrix) { | 804 if (matrix) { |
737 m.Concat(*matrix); | 805 m.Concat(*matrix); |
738 } | 806 } |
739 switch (_info._strokeColor->_type) { | 807 switch (_info._strokeColor->_type) { |
740 case FX_COLOR_Solid: { | 808 case FX_COLOR_Solid: { |
741 FX_BOOL result = _renderDevice->DrawPath( | 809 FX_BOOL result = _renderDevice->DrawPath( |
742 path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, 0x0, | 810 path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, 0x0, |
743 _info._strokeColor->_argb, 0); | 811 _info._strokeColor->_argb, 0); |
744 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Indefinite); | 812 if (!result) |
813 return FX_ERR_Indefinite; | |
745 return FX_ERR_Succeeded; | 814 return FX_ERR_Succeeded; |
746 } | 815 } |
747 case FX_COLOR_Pattern: { | 816 case FX_COLOR_Pattern: { |
748 return StrokePathWithPattern(path, &m); | 817 return StrokePathWithPattern(path, &m); |
749 } | 818 } |
750 case FX_COLOR_Shading: { | 819 case FX_COLOR_Shading: { |
751 return StrokePathWithShading(path, &m); | 820 return StrokePathWithShading(path, &m); |
752 } | 821 } |
753 default: { return FX_ERR_Property_Invalid; } | 822 default: { return FX_ERR_Property_Invalid; } |
754 } | 823 } |
755 } | 824 } |
756 FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, | 825 FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, |
757 FX_FillMode fillMode, | 826 FX_FillMode fillMode, |
758 CFX_Matrix* matrix) { | 827 CFX_Matrix* matrix) { |
759 _FX_RETURN_VALUE_IF_FAIL(_info._fillColor, FX_ERR_Property_Invalid); | 828 if (!_info._fillColor) |
829 return FX_ERR_Property_Invalid; | |
760 CFX_Matrix m; | 830 CFX_Matrix m; |
761 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, | 831 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, |
762 _info._CTM.f); | 832 _info._CTM.f); |
763 if (matrix) { | 833 if (matrix) { |
764 m.Concat(*matrix); | 834 m.Concat(*matrix); |
765 } | 835 } |
766 switch (_info._fillColor->_type) { | 836 switch (_info._fillColor->_type) { |
767 case FX_COLOR_Solid: { | 837 case FX_COLOR_Solid: { |
768 FX_BOOL result = _renderDevice->DrawPath( | 838 FX_BOOL result = _renderDevice->DrawPath( |
769 path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, | 839 path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, |
770 _info._fillColor->_argb, 0x0, fillMode); | 840 _info._fillColor->_argb, 0x0, fillMode); |
771 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Indefinite); | 841 if (!result) |
842 return FX_ERR_Indefinite; | |
772 return FX_ERR_Succeeded; | 843 return FX_ERR_Succeeded; |
773 } | 844 } |
774 case FX_COLOR_Pattern: { | 845 case FX_COLOR_Pattern: { |
775 { return FillPathWithPattern(path, fillMode, &m); } | 846 { return FillPathWithPattern(path, fillMode, &m); } |
776 } | 847 } |
777 case FX_COLOR_Shading: { | 848 case FX_COLOR_Shading: { |
778 { return FillPathWithShading(path, fillMode, &m); } | 849 { return FillPathWithShading(path, fillMode, &m); } |
779 } | 850 } |
780 default: { return FX_ERR_Property_Invalid; } | 851 default: { return FX_ERR_Property_Invalid; } |
781 } | 852 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, | 946 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, |
876 _info._CTM.f); | 947 _info._CTM.f); |
877 m.Translate(0, _info._fontSize * _info._fontHScale); | 948 m.Translate(0, _info._fontSize * _info._fontHScale); |
878 if (matrix) { | 949 if (matrix) { |
879 m.Concat(*matrix); | 950 m.Concat(*matrix); |
880 } | 951 } |
881 FX_BOOL result = _renderDevice->DrawNormalText( | 952 FX_BOOL result = _renderDevice->DrawNormalText( |
882 length, charPos, _info._font, CFX_GEModule::Get()->GetFontCache(), | 953 length, charPos, _info._font, CFX_GEModule::Get()->GetFontCache(), |
883 -_info._fontSize * _info._fontHScale, (CFX_Matrix*)&m, | 954 -_info._fontSize * _info._fontHScale, (CFX_Matrix*)&m, |
884 _info._fillColor->_argb, FXTEXT_CLEARTYPE); | 955 _info._fillColor->_argb, FXTEXT_CLEARTYPE); |
885 _FX_RETURN_VALUE_IF_FAIL(result, FX_ERR_Indefinite); | 956 if (!result) |
957 return FX_ERR_Indefinite; | |
886 FX_Free(charPos); | 958 FX_Free(charPos); |
887 FX_Free(charCodes); | 959 FX_Free(charCodes); |
888 return FX_ERR_Succeeded; | 960 return FX_ERR_Succeeded; |
889 } | 961 } |
890 FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { | 962 FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { |
891 return FX_ERR_Method_Not_Supported; | 963 return FX_ERR_Method_Not_Supported; |
892 } | 964 } |
893 FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { | 965 FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { |
894 return FX_ERR_Method_Not_Supported; | 966 return FX_ERR_Method_Not_Supported; |
895 } | 967 } |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1175 _generator->Create(); | 1247 _generator->Create(); |
1176 return FX_ERR_Succeeded; | 1248 return FX_ERR_Succeeded; |
1177 } | 1249 } |
1178 CFX_Path::~CFX_Path() { | 1250 CFX_Path::~CFX_Path() { |
1179 if (_generator) { | 1251 if (_generator) { |
1180 delete _generator; | 1252 delete _generator; |
1181 _generator = NULL; | 1253 _generator = NULL; |
1182 } | 1254 } |
1183 } | 1255 } |
1184 FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { | 1256 FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { |
1185 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1257 if (!_generator) |
1258 return FX_ERR_Property_Invalid; | |
1186 _generator->MoveTo(x, y); | 1259 _generator->MoveTo(x, y); |
1187 return FX_ERR_Succeeded; | 1260 return FX_ERR_Succeeded; |
1188 } | 1261 } |
1189 FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { | 1262 FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { |
1190 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1263 if (!_generator) |
1264 return FX_ERR_Property_Invalid; | |
1191 _generator->LineTo(x, y); | 1265 _generator->LineTo(x, y); |
1192 return FX_ERR_Succeeded; | 1266 return FX_ERR_Succeeded; |
1193 } | 1267 } |
1194 FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, | 1268 FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, |
1195 FX_FLOAT ctrlY1, | 1269 FX_FLOAT ctrlY1, |
1196 FX_FLOAT ctrlX2, | 1270 FX_FLOAT ctrlX2, |
1197 FX_FLOAT ctrlY2, | 1271 FX_FLOAT ctrlY2, |
1198 FX_FLOAT toX, | 1272 FX_FLOAT toX, |
1199 FX_FLOAT toY) { | 1273 FX_FLOAT toY) { |
1200 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1274 if (!_generator) |
1275 return FX_ERR_Property_Invalid; | |
1201 _generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); | 1276 _generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); |
1202 return FX_ERR_Succeeded; | 1277 return FX_ERR_Succeeded; |
1203 } | 1278 } |
1204 FX_ERR CFX_Path::ArcTo(FX_FLOAT left, | 1279 FX_ERR CFX_Path::ArcTo(FX_FLOAT left, |
1205 FX_FLOAT top, | 1280 FX_FLOAT top, |
1206 FX_FLOAT width, | 1281 FX_FLOAT width, |
1207 FX_FLOAT height, | 1282 FX_FLOAT height, |
1208 FX_FLOAT startAngle, | 1283 FX_FLOAT startAngle, |
1209 FX_FLOAT sweepAngle) { | 1284 FX_FLOAT sweepAngle) { |
1210 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1285 if (!_generator) |
1286 return FX_ERR_Property_Invalid; | |
1211 _generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, | 1287 _generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, |
1212 startAngle, sweepAngle); | 1288 startAngle, sweepAngle); |
1213 return FX_ERR_Succeeded; | 1289 return FX_ERR_Succeeded; |
1214 } | 1290 } |
1215 FX_ERR CFX_Path::Close() { | 1291 FX_ERR CFX_Path::Close() { |
1216 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1292 if (!_generator) |
1293 return FX_ERR_Property_Invalid; | |
1217 _generator->Close(); | 1294 _generator->Close(); |
1218 return FX_ERR_Succeeded; | 1295 return FX_ERR_Succeeded; |
1219 } | 1296 } |
1220 FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { | 1297 FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { |
1221 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1298 if (!_generator) |
1299 return FX_ERR_Property_Invalid; | |
1222 _generator->AddLine(x1, y1, x2, y2); | 1300 _generator->AddLine(x1, y1, x2, y2); |
1223 return FX_ERR_Succeeded; | 1301 return FX_ERR_Succeeded; |
1224 } | 1302 } |
1225 FX_ERR CFX_Path::AddBezier(FX_FLOAT startX, | 1303 FX_ERR CFX_Path::AddBezier(FX_FLOAT startX, |
1226 FX_FLOAT startY, | 1304 FX_FLOAT startY, |
1227 FX_FLOAT ctrlX1, | 1305 FX_FLOAT ctrlX1, |
1228 FX_FLOAT ctrlY1, | 1306 FX_FLOAT ctrlY1, |
1229 FX_FLOAT ctrlX2, | 1307 FX_FLOAT ctrlX2, |
1230 FX_FLOAT ctrlY2, | 1308 FX_FLOAT ctrlY2, |
1231 FX_FLOAT endX, | 1309 FX_FLOAT endX, |
1232 FX_FLOAT endY) { | 1310 FX_FLOAT endY) { |
1233 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1311 if (!_generator) |
1312 return FX_ERR_Property_Invalid; | |
1234 _generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, | 1313 _generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, |
1235 endY); | 1314 endY); |
1236 return FX_ERR_Succeeded; | 1315 return FX_ERR_Succeeded; |
1237 } | 1316 } |
1238 FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, | 1317 FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, |
1239 FX_FLOAT top, | 1318 FX_FLOAT top, |
1240 FX_FLOAT width, | 1319 FX_FLOAT width, |
1241 FX_FLOAT height) { | 1320 FX_FLOAT height) { |
1242 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1321 if (!_generator) |
1322 return FX_ERR_Property_Invalid; | |
1243 _generator->AddRectangle(left, top, left + width, top + height); | 1323 _generator->AddRectangle(left, top, left + width, top + height); |
1244 return FX_ERR_Succeeded; | 1324 return FX_ERR_Succeeded; |
1245 } | 1325 } |
1246 FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, | 1326 FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, |
1247 FX_FLOAT top, | 1327 FX_FLOAT top, |
1248 FX_FLOAT width, | 1328 FX_FLOAT width, |
1249 FX_FLOAT height) { | 1329 FX_FLOAT height) { |
1250 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1330 if (!_generator) |
1331 return FX_ERR_Property_Invalid; | |
1251 _generator->AddEllipse(left + width / 2, top + height / 2, width / 2, | 1332 _generator->AddEllipse(left + width / 2, top + height / 2, width / 2, |
1252 height / 2); | 1333 height / 2); |
1253 return FX_ERR_Succeeded; | 1334 return FX_ERR_Succeeded; |
1254 } | 1335 } |
1255 FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { | 1336 FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { |
1256 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1337 if (!_generator) |
1338 return FX_ERR_Property_Invalid; | |
1257 _generator->AddEllipse(rect.left + rect.Width() / 2, | 1339 _generator->AddEllipse(rect.left + rect.Width() / 2, |
1258 rect.top + rect.Height() / 2, rect.Width() / 2, | 1340 rect.top + rect.Height() / 2, rect.Width() / 2, |
1259 rect.Height() / 2); | 1341 rect.Height() / 2); |
1260 return FX_ERR_Succeeded; | 1342 return FX_ERR_Succeeded; |
1261 } | 1343 } |
1262 FX_ERR CFX_Path::AddArc(FX_FLOAT left, | 1344 FX_ERR CFX_Path::AddArc(FX_FLOAT left, |
1263 FX_FLOAT top, | 1345 FX_FLOAT top, |
1264 FX_FLOAT width, | 1346 FX_FLOAT width, |
1265 FX_FLOAT height, | 1347 FX_FLOAT height, |
1266 FX_FLOAT startAngle, | 1348 FX_FLOAT startAngle, |
1267 FX_FLOAT sweepAngle) { | 1349 FX_FLOAT sweepAngle) { |
1268 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1350 if (!_generator) |
1351 return FX_ERR_Property_Invalid; | |
1269 _generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, | 1352 _generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, |
1270 startAngle, sweepAngle); | 1353 startAngle, sweepAngle); |
1271 return FX_ERR_Succeeded; | 1354 return FX_ERR_Succeeded; |
1272 } | 1355 } |
1273 FX_ERR CFX_Path::AddPie(FX_FLOAT left, | 1356 FX_ERR CFX_Path::AddPie(FX_FLOAT left, |
1274 FX_FLOAT top, | 1357 FX_FLOAT top, |
1275 FX_FLOAT width, | 1358 FX_FLOAT width, |
1276 FX_FLOAT height, | 1359 FX_FLOAT height, |
1277 FX_FLOAT startAngle, | 1360 FX_FLOAT startAngle, |
1278 FX_FLOAT sweepAngle) { | 1361 FX_FLOAT sweepAngle) { |
1279 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1362 if (!_generator) |
1363 return FX_ERR_Property_Invalid; | |
1280 _generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, | 1364 _generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, |
1281 startAngle, sweepAngle); | 1365 startAngle, sweepAngle); |
1282 return FX_ERR_Succeeded; | 1366 return FX_ERR_Succeeded; |
1283 } | 1367 } |
1284 FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { | 1368 FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { |
1285 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1369 if (!_generator) |
1370 return FX_ERR_Property_Invalid; | |
1286 _generator->AddPathData(path->GetPathData()); | 1371 _generator->AddPathData(path->GetPathData()); |
1287 return FX_ERR_Succeeded; | 1372 return FX_ERR_Succeeded; |
1288 } | 1373 } |
1289 FX_ERR CFX_Path::Clear() { | 1374 FX_ERR CFX_Path::Clear() { |
1290 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1375 if (!_generator) |
1376 return FX_ERR_Property_Invalid; | |
1291 _generator->GetPathData()->SetPointCount(0); | 1377 _generator->GetPathData()->SetPointCount(0); |
1292 return FX_ERR_Succeeded; | 1378 return FX_ERR_Succeeded; |
1293 } | 1379 } |
1294 FX_BOOL CFX_Path::IsEmpty() { | 1380 FX_BOOL CFX_Path::IsEmpty() { |
1295 _FX_RETURN_VALUE_IF_FAIL(_generator, FX_ERR_Property_Invalid); | 1381 if (!_generator) |
1382 return FX_ERR_Property_Invalid; | |
1296 if (_generator->GetPathData()->GetPointCount() == 0) { | 1383 if (_generator->GetPathData()->GetPointCount() == 0) { |
1297 return TRUE; | 1384 return TRUE; |
1298 } | 1385 } |
1299 return FALSE; | 1386 return FALSE; |
1300 } | 1387 } |
1301 CFX_PathData* CFX_Path::GetPathData() { | 1388 CFX_PathData* CFX_Path::GetPathData() { |
1302 _FX_RETURN_VALUE_IF_FAIL(_generator, NULL); | 1389 if (!_generator) |
1390 return NULL; | |
1303 return _generator->GetPathData(); | 1391 return _generator->GetPathData(); |
1304 } | 1392 } |
1305 CFX_Color::CFX_Color() { | 1393 CFX_Color::CFX_Color() { |
1306 _type = FX_COLOR_None; | 1394 _type = FX_COLOR_None; |
1307 } | 1395 } |
1308 CFX_Color::CFX_Color(const FX_ARGB argb) { | 1396 CFX_Color::CFX_Color(const FX_ARGB argb) { |
1309 _type = FX_COLOR_None; | 1397 _type = FX_COLOR_None; |
1310 Set(argb); | 1398 Set(argb); |
1311 } | 1399 } |
1312 CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { | 1400 CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { |
1313 _type = FX_COLOR_None; | 1401 _type = FX_COLOR_None; |
1314 Set(pattern, argb); | 1402 Set(pattern, argb); |
1315 } | 1403 } |
1316 CFX_Color::CFX_Color(CFX_Shading* shading) { | 1404 CFX_Color::CFX_Color(CFX_Shading* shading) { |
1317 _type = FX_COLOR_None; | 1405 _type = FX_COLOR_None; |
1318 Set(shading); | 1406 Set(shading); |
1319 } | 1407 } |
1320 CFX_Color::~CFX_Color() { | 1408 CFX_Color::~CFX_Color() { |
1321 _type = FX_COLOR_None; | 1409 _type = FX_COLOR_None; |
1322 } | 1410 } |
1323 FX_ERR CFX_Color::Set(const FX_ARGB argb) { | 1411 FX_ERR CFX_Color::Set(const FX_ARGB argb) { |
1324 _type = FX_COLOR_Solid; | 1412 _type = FX_COLOR_Solid; |
1325 _argb = argb; | 1413 _argb = argb; |
1326 _pattern = NULL; | 1414 _pattern = NULL; |
1327 return FX_ERR_Succeeded; | 1415 return FX_ERR_Succeeded; |
1328 } | 1416 } |
1329 FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { | 1417 FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { |
1330 _FX_RETURN_VALUE_IF_FAIL(pattern, FX_ERR_Parameter_Invalid); | 1418 if (!pattern) |
1419 return FX_ERR_Parameter_Invalid; | |
1331 _type = FX_COLOR_Pattern; | 1420 _type = FX_COLOR_Pattern; |
1332 _argb = argb; | 1421 _argb = argb; |
1333 _pattern = pattern; | 1422 _pattern = pattern; |
1334 return FX_ERR_Succeeded; | 1423 return FX_ERR_Succeeded; |
1335 } | 1424 } |
1336 FX_ERR CFX_Color::Set(CFX_Shading* shading) { | 1425 FX_ERR CFX_Color::Set(CFX_Shading* shading) { |
1337 _FX_RETURN_VALUE_IF_FAIL(shading, FX_ERR_Parameter_Invalid); | 1426 if (!shading) |
1427 return FX_ERR_Parameter_Invalid; | |
1338 _type = FX_COLOR_Shading; | 1428 _type = FX_COLOR_Shading; |
1339 _shading = shading; | 1429 _shading = shading; |
1340 return FX_ERR_Succeeded; | 1430 return FX_ERR_Succeeded; |
1341 } | 1431 } |
1342 CFX_Pattern::CFX_Pattern() { | 1432 CFX_Pattern::CFX_Pattern() { |
1343 _type = FX_PATTERN_None; | 1433 _type = FX_PATTERN_None; |
1344 _matrix.SetIdentity(); | 1434 _matrix.SetIdentity(); |
1345 } | 1435 } |
1346 FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, | 1436 FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, |
1347 const FX_FLOAT xStep, | 1437 const FX_FLOAT xStep, |
1348 const FX_FLOAT yStep, | 1438 const FX_FLOAT yStep, |
1349 CFX_Matrix* matrix) { | 1439 CFX_Matrix* matrix) { |
1350 _FX_RETURN_VALUE_IF_FAIL(bitmap, FX_ERR_Parameter_Invalid); | 1440 if (!bitmap) |
1441 return FX_ERR_Parameter_Invalid; | |
1351 if (_type != FX_PATTERN_None) { | 1442 if (_type != FX_PATTERN_None) { |
1352 return FX_ERR_Property_Invalid; | 1443 return FX_ERR_Property_Invalid; |
1353 } | 1444 } |
1354 _type = FX_PATTERN_Bitmap; | 1445 _type = FX_PATTERN_Bitmap; |
1355 _bitmap = bitmap; | 1446 _bitmap = bitmap; |
1356 _x1Step = xStep; | 1447 _x1Step = xStep; |
1357 _y1Step = yStep; | 1448 _y1Step = yStep; |
1358 if (matrix) { | 1449 if (matrix) { |
1359 _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, | 1450 _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, |
1360 matrix->f); | 1451 matrix->f); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1449 b3 = (int32_t)(i * bScale); | 1540 b3 = (int32_t)(i * bScale); |
1450 _argbArray[i] = | 1541 _argbArray[i] = |
1451 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); | 1542 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); |
1452 } | 1543 } |
1453 return FX_ERR_Succeeded; | 1544 return FX_ERR_Succeeded; |
1454 } | 1545 } |
1455 class CFX_Pause : public IFX_Pause { | 1546 class CFX_Pause : public IFX_Pause { |
1456 public: | 1547 public: |
1457 virtual FX_BOOL NeedToPauseNow() { return TRUE; } | 1548 virtual FX_BOOL NeedToPauseNow() { return TRUE; } |
1458 }; | 1549 }; |
OLD | NEW |