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

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

Issue 1784323006: Re-enable warning 4201 for xfa and other clean up (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: remove tags Created 4 years, 9 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.gyp ('k') | xfa/include/fxgraphics/fx_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 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 "xfa/include/fxgraphics/fx_graphics.h" 7 #include "xfa/include/fxgraphics/fx_graphics.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "xfa/fxgraphics/fx_path_generator.h" 11 #include "xfa/fxgraphics/fx_path_generator.h"
12 #include "xfa/fxgraphics/pre.h" 12 #include "xfa/fxgraphics/pre.h"
13 13
14 class CAGG_Graphics { 14 CFX_Graphics::CFX_Graphics()
15 public: 15 : m_renderDevice(nullptr), m_aggGraphics(nullptr) {}
16 CAGG_Graphics(); 16
17 FX_ERR Create(CFX_Graphics* owner,
18 int32_t width,
19 int32_t height,
20 FXDIB_Format format);
21 virtual ~CAGG_Graphics();
22
23 private:
24 CFX_Graphics* _owner;
25 };
26 CFX_Graphics::CFX_Graphics() {
27 _type = FX_CONTEXT_None;
28 _info._graphState.SetDashCount(0);
29 _info._isAntialiasing = TRUE;
30 _info._strokeAlignment = FX_STROKEALIGNMENT_Center;
31 _info._CTM.SetIdentity();
32 _info._isActOnDash = FALSE;
33 _info._strokeColor = NULL;
34 _info._fillColor = NULL;
35 _info._font = NULL;
36 _info._fontSize = 40.0;
37 _info._fontHScale = 1.0;
38 _info._fontSpacing = 0.0;
39 _renderDevice = NULL;
40 _aggGraphics = NULL;
41 }
42 FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, 17 FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice,
43 FX_BOOL isAntialiasing) { 18 FX_BOOL isAntialiasing) {
44 if (!renderDevice) 19 if (!renderDevice)
45 return FX_ERR_Parameter_Invalid; 20 return FX_ERR_Parameter_Invalid;
46 if (_type != FX_CONTEXT_None) { 21 if (m_type != FX_CONTEXT_None)
47 return FX_ERR_Property_Invalid; 22 return FX_ERR_Property_Invalid;
48 } 23
49 _type = FX_CONTEXT_Device; 24 m_type = FX_CONTEXT_Device;
50 _info._isAntialiasing = isAntialiasing; 25 m_info.isAntialiasing = isAntialiasing;
51 _renderDevice = renderDevice; 26 m_renderDevice = renderDevice;
52 if (_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) { 27 if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)
53 return FX_ERR_Succeeded; 28 return FX_ERR_Succeeded;
54 }
55 return FX_ERR_Indefinite; 29 return FX_ERR_Indefinite;
56 } 30 }
31
57 FX_ERR CFX_Graphics::Create(int32_t width, 32 FX_ERR CFX_Graphics::Create(int32_t width,
58 int32_t height, 33 int32_t height,
59 FXDIB_Format format, 34 FXDIB_Format format,
60 FX_BOOL isNative, 35 FX_BOOL isNative,
61 FX_BOOL isAntialiasing) { 36 FX_BOOL isAntialiasing) {
62 if (_type != FX_CONTEXT_None) { 37 if (m_type != FX_CONTEXT_None)
63 return FX_ERR_Property_Invalid; 38 return FX_ERR_Property_Invalid;
64 } 39
65 _type = FX_CONTEXT_Device; 40 m_type = FX_CONTEXT_Device;
66 _info._isAntialiasing = isAntialiasing; 41 m_info.isAntialiasing = isAntialiasing;
67 { 42 m_aggGraphics = new CAGG_Graphics;
68 _aggGraphics = new CAGG_Graphics; 43 return m_aggGraphics->Create(this, width, height, format);
69 return _aggGraphics->Create(this, width, height, format); 44 }
70 } 45
71 }
72 CFX_Graphics::~CFX_Graphics() { 46 CFX_Graphics::~CFX_Graphics() {
73 if (_aggGraphics) { 47 delete m_aggGraphics;
74 delete _aggGraphics; 48 }
75 _aggGraphics = NULL; 49
76 }
77 _renderDevice = NULL;
78 _info._graphState.SetDashCount(0);
79 _type = FX_CONTEXT_None;
80 }
81 FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { 50 FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) {
82 switch (_type) { 51 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
83 case FX_CONTEXT_Device: { 52 capVal = m_renderDevice->GetDeviceCaps(capID);
84 if (!_renderDevice) 53 return FX_ERR_Succeeded;
85 return FX_ERR_Property_Invalid; 54 }
86 capVal = _renderDevice->GetDeviceCaps(capID); 55 return FX_ERR_Property_Invalid;
87 return FX_ERR_Succeeded; 56 }
57
58 FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) {
59 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
60 isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER;
61 return FX_ERR_Succeeded;
62 }
63 return FX_ERR_Property_Invalid;
64 }
65
66 FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) {
67 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
68 m_info.isAntialiasing = isAntialiasing;
69 return FX_ERR_Succeeded;
70 }
71 return FX_ERR_Property_Invalid;
72 }
73
74 FX_ERR CFX_Graphics::SaveGraphState() {
75 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
76 m_renderDevice->SaveState();
77 m_infoStack.Add(new TInfo(m_info));
78 return FX_ERR_Succeeded;
79 }
80 return FX_ERR_Property_Invalid;
81 }
82
83 FX_ERR CFX_Graphics::RestoreGraphState() {
84 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
85 m_renderDevice->RestoreState();
86 int32_t size = m_infoStack.GetSize();
87 if (size <= 0) {
88 return FX_ERR_Intermediate_Value_Invalid;
88 } 89 }
89 default: { return FX_ERR_Property_Invalid; } 90 int32_t topIndex = size - 1;
90 } 91 std::unique_ptr<TInfo> info(
91 } 92 reinterpret_cast<TInfo*>(m_infoStack.GetAt(topIndex)));
92 FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { 93 if (!info)
93 switch (_type) { 94 return FX_ERR_Intermediate_Value_Invalid;
94 case FX_CONTEXT_Device: { 95 m_info = *info;
95 if (!_renderDevice) 96 m_infoStack.RemoveAt(topIndex);
96 return FX_ERR_Property_Invalid; 97 return FX_ERR_Succeeded;
97 int32_t deviceClass = _renderDevice->GetDeviceClass(); 98 }
98 if (deviceClass == FXDC_PRINTER) { 99 return FX_ERR_Property_Invalid;
99 isPrinter = TRUE; 100 }
100 } else { 101
101 isPrinter = FALSE; 102 FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const {
102 } 103 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
103 return FX_ERR_Succeeded; 104 lineCap = m_info.graphState.m_LineCap;
104 } 105 return FX_ERR_Succeeded;
105 default: { return FX_ERR_Property_Invalid; } 106 }
106 } 107 return FX_ERR_Property_Invalid;
107 } 108 }
108 FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { 109
109 switch (_type) {
110 case FX_CONTEXT_Device: {
111 if (!_renderDevice)
112 return FX_ERR_Property_Invalid;
113 _info._isAntialiasing = isAntialiasing;
114 return FX_ERR_Succeeded;
115 }
116 default: { return FX_ERR_Property_Invalid; }
117 }
118 }
119 FX_ERR CFX_Graphics::SaveGraphState() {
120 switch (_type) {
121 case FX_CONTEXT_Device: {
122 if (!_renderDevice)
123 return FX_ERR_Property_Invalid;
124 _renderDevice->SaveState();
125 TInfo* info = new TInfo;
126 info->_graphState.Copy(_info._graphState);
127 info->_isAntialiasing = _info._isAntialiasing;
128 info->_strokeAlignment = _info._strokeAlignment;
129 info->_CTM = _info._CTM;
130 info->_isActOnDash = _info._isActOnDash;
131 info->_strokeColor = _info._strokeColor;
132 info->_fillColor = _info._fillColor;
133 info->_font = _info._font;
134 info->_fontSize = _info._fontSize;
135 info->_fontHScale = _info._fontHScale;
136 info->_fontSpacing = _info._fontSpacing;
137 _infoStack.Add(info);
138 return FX_ERR_Succeeded;
139 }
140 default: { return FX_ERR_Property_Invalid; }
141 }
142 }
143 FX_ERR CFX_Graphics::RestoreGraphState() {
144 switch (_type) {
145 case FX_CONTEXT_Device: {
146 if (!_renderDevice)
147 return FX_ERR_Property_Invalid;
148 _renderDevice->RestoreState();
149 int32_t size = _infoStack.GetSize();
150 if (size <= 0) {
151 return FX_ERR_Intermediate_Value_Invalid;
152 }
153 int32_t topIndex = size - 1;
154 TInfo* info = (TInfo*)_infoStack.GetAt(topIndex);
155 if (!info)
156 return FX_ERR_Intermediate_Value_Invalid;
157 _info._graphState.Copy(info->_graphState);
158 _info._isAntialiasing = info->_isAntialiasing;
159 _info._strokeAlignment = info->_strokeAlignment;
160 _info._CTM = info->_CTM;
161 _info._isActOnDash = info->_isActOnDash;
162 _info._strokeColor = info->_strokeColor;
163 _info._fillColor = info->_fillColor;
164 _info._font = info->_font;
165 _info._fontSize = info->_fontSize;
166 _info._fontHScale = info->_fontHScale;
167 _info._fontSpacing = info->_fontSpacing;
168 delete info;
169 info = NULL;
170 _infoStack.RemoveAt(topIndex);
171 return FX_ERR_Succeeded;
172 }
173 default: { return FX_ERR_Property_Invalid; }
174 }
175 }
176 FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) {
177 switch (_type) {
178 case FX_CONTEXT_Device: {
179 if (!_renderDevice)
180 return FX_ERR_Property_Invalid;
181 lineCap = _info._graphState.m_LineCap;
182 return FX_ERR_Succeeded;
183 }
184 default: { return FX_ERR_Property_Invalid; }
185 }
186 }
187 FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { 110 FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) {
188 switch (_type) { 111 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
189 case FX_CONTEXT_Device: { 112 m_info.graphState.m_LineCap = lineCap;
190 if (!_renderDevice) 113 return FX_ERR_Succeeded;
191 return FX_ERR_Property_Invalid; 114 }
192 _info._graphState.m_LineCap = lineCap; 115 return FX_ERR_Property_Invalid;
193 return FX_ERR_Succeeded; 116 }
194 } 117
195 default: { return FX_ERR_Property_Invalid; } 118 FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) const {
196 } 119 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
197 } 120 dashCount = m_info.graphState.m_DashCount;
198 FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) { 121 return FX_ERR_Succeeded;
199 switch (_type) { 122 }
200 case FX_CONTEXT_Device: { 123 return FX_ERR_Property_Invalid;
201 if (!_renderDevice) 124 }
202 return FX_ERR_Property_Invalid; 125
203 dashCount = _info._graphState.m_DashCount; 126 FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase,
204 return FX_ERR_Succeeded; 127 FX_FLOAT* dashArray) const {
205 }
206 default: { return FX_ERR_Property_Invalid; }
207 }
208 }
209 FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) {
210 if (!dashArray) 128 if (!dashArray)
211 return FX_ERR_Parameter_Invalid; 129 return FX_ERR_Parameter_Invalid;
212 switch (_type) { 130 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
213 case FX_CONTEXT_Device: { 131 dashPhase = m_info.graphState.m_DashPhase;
214 if (!_renderDevice) 132 FXSYS_memcpy(dashArray, m_info.graphState.m_DashArray,
215 return FX_ERR_Property_Invalid; 133 m_info.graphState.m_DashCount * sizeof(FX_FLOAT));
216 dashPhase = _info._graphState.m_DashPhase; 134 return FX_ERR_Succeeded;
217 FXSYS_memcpy(dashArray, _info._graphState.m_DashArray, 135 }
218 _info._graphState.m_DashCount * sizeof(FX_FLOAT)); 136 return FX_ERR_Property_Invalid;
219 return FX_ERR_Succeeded; 137 }
220 } 138
221 default: { return FX_ERR_Property_Invalid; }
222 }
223 }
224 FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, 139 FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase,
225 FX_FLOAT* dashArray, 140 FX_FLOAT* dashArray,
226 int32_t dashCount) { 141 int32_t dashCount) {
227 if (dashCount > 0 && !dashArray) { 142 if (dashCount > 0 && !dashArray)
228 return FX_ERR_Parameter_Invalid; 143 return FX_ERR_Parameter_Invalid;
229 } 144
230 dashCount = dashCount < 0 ? 0 : dashCount; 145 dashCount = dashCount < 0 ? 0 : dashCount;
231 switch (_type) { 146 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
232 case FX_CONTEXT_Device: { 147 FX_FLOAT scale = 1.0;
233 if (!_renderDevice) 148 if (m_info.isActOnDash) {
234 return FX_ERR_Property_Invalid; 149 scale = m_info.graphState.m_LineWidth;
235 FX_FLOAT scale = 1.0;
236 if (_info._isActOnDash) {
237 scale = _info._graphState.m_LineWidth;
238 }
239 _info._graphState.m_DashPhase = dashPhase;
240 _info._graphState.SetDashCount(dashCount);
241 for (int32_t i = 0; i < dashCount; i++) {
242 _info._graphState.m_DashArray[i] = dashArray[i] * scale;
243 }
244 return FX_ERR_Succeeded;
245 } 150 }
246 default: { return FX_ERR_Property_Invalid; } 151 m_info.graphState.m_DashPhase = dashPhase;
247 } 152 m_info.graphState.SetDashCount(dashCount);
248 } 153 for (int32_t i = 0; i < dashCount; i++) {
154 m_info.graphState.m_DashArray[i] = dashArray[i] * scale;
155 }
156 return FX_ERR_Succeeded;
157 }
158 return FX_ERR_Property_Invalid;
159 }
160
249 FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { 161 FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) {
250 switch (_type) { 162 if (m_type == FX_CONTEXT_Device && m_renderDevice)
251 case FX_CONTEXT_Device: { 163 return RenderDeviceSetLineDash(dashStyle);
252 if (!_renderDevice) 164 return FX_ERR_Property_Invalid;
253 return FX_ERR_Property_Invalid; 165 }
254 return RenderDeviceSetLineDash(dashStyle); 166
255 } 167 FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const {
256 default: { return FX_ERR_Property_Invalid; } 168 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
257 } 169 lineJoin = m_info.graphState.m_LineJoin;
258 } 170 return FX_ERR_Succeeded;
259 FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) { 171 }
260 switch (_type) { 172 return FX_ERR_Property_Invalid;
261 case FX_CONTEXT_Device: { 173 }
262 if (!_renderDevice) 174
263 return FX_ERR_Property_Invalid;
264 lineJoin = _info._graphState.m_LineJoin;
265 return FX_ERR_Succeeded;
266 }
267 default: { return FX_ERR_Property_Invalid; }
268 }
269 }
270 FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { 175 FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) {
271 switch (_type) { 176 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
272 case FX_CONTEXT_Device: { 177 m_info.graphState.m_LineJoin = lineJoin;
273 if (!_renderDevice) 178 return FX_ERR_Succeeded;
274 return FX_ERR_Property_Invalid; 179 }
275 _info._graphState.m_LineJoin = lineJoin; 180 return FX_ERR_Property_Invalid;
276 return FX_ERR_Succeeded; 181 }
277 } 182
278 default: { return FX_ERR_Property_Invalid; } 183 FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const {
279 } 184 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
280 } 185 miterLimit = m_info.graphState.m_MiterLimit;
281 FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) { 186 return FX_ERR_Succeeded;
282 switch (_type) { 187 }
283 case FX_CONTEXT_Device: { 188 return FX_ERR_Property_Invalid;
284 if (!_renderDevice) 189 }
285 return FX_ERR_Property_Invalid; 190
286 miterLimit = _info._graphState.m_MiterLimit;
287 return FX_ERR_Succeeded;
288 }
289 default: { return FX_ERR_Property_Invalid; }
290 }
291 }
292 FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { 191 FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) {
293 switch (_type) { 192 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
294 case FX_CONTEXT_Device: { 193 m_info.graphState.m_MiterLimit = miterLimit;
295 if (!_renderDevice) 194 return FX_ERR_Succeeded;
296 return FX_ERR_Property_Invalid; 195 }
297 _info._graphState.m_MiterLimit = miterLimit; 196 return FX_ERR_Property_Invalid;
298 return FX_ERR_Succeeded; 197 }
299 } 198
300 default: { return FX_ERR_Property_Invalid; } 199 FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const {
301 } 200 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
302 } 201 lineWidth = m_info.graphState.m_LineWidth;
303 FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) { 202 return FX_ERR_Succeeded;
304 switch (_type) { 203 }
305 case FX_CONTEXT_Device: { 204 return FX_ERR_Property_Invalid;
306 if (!_renderDevice) 205 }
307 return FX_ERR_Property_Invalid; 206
308 lineWidth = _info._graphState.m_LineWidth;
309 return FX_ERR_Succeeded;
310 }
311 default: { return FX_ERR_Property_Invalid; }
312 }
313 }
314 FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { 207 FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) {
315 switch (_type) { 208 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
316 case FX_CONTEXT_Device: { 209 m_info.graphState.m_LineWidth = lineWidth;
317 if (!_renderDevice) 210 m_info.isActOnDash = isActOnDash;
318 return FX_ERR_Property_Invalid; 211 return FX_ERR_Succeeded;
319 _info._graphState.m_LineWidth = lineWidth; 212 }
320 _info._isActOnDash = isActOnDash; 213 return FX_ERR_Property_Invalid;
321 return FX_ERR_Succeeded; 214 }
322 } 215
323 default: { return FX_ERR_Property_Invalid; } 216 FX_ERR CFX_Graphics::GetStrokeAlignment(
324 } 217 FX_StrokeAlignment& strokeAlignment) const {
325 } 218 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
326 FX_ERR CFX_Graphics::GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) { 219 strokeAlignment = m_info.strokeAlignment;
327 switch (_type) { 220 return FX_ERR_Succeeded;
328 case FX_CONTEXT_Device: { 221 }
329 if (!_renderDevice) 222 return FX_ERR_Property_Invalid;
330 return FX_ERR_Property_Invalid; 223 }
331 strokeAlignment = _info._strokeAlignment; 224
332 return FX_ERR_Succeeded;
333 }
334 default: { return FX_ERR_Property_Invalid; }
335 }
336 }
337 FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { 225 FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) {
338 switch (_type) { 226 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
339 case FX_CONTEXT_Device: { 227 m_info.strokeAlignment = strokeAlignment;
340 if (!_renderDevice) 228 return FX_ERR_Succeeded;
341 return FX_ERR_Property_Invalid; 229 }
342 _info._strokeAlignment = strokeAlignment; 230 return FX_ERR_Property_Invalid;
343 return FX_ERR_Succeeded; 231 }
344 } 232
345 default: { return FX_ERR_Property_Invalid; }
346 }
347 }
348 FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { 233 FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) {
349 if (!color) 234 if (!color)
350 return FX_ERR_Parameter_Invalid; 235 return FX_ERR_Parameter_Invalid;
351 switch (_type) { 236 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
352 case FX_CONTEXT_Device: { 237 m_info.strokeColor = color;
353 if (!_renderDevice) 238 return FX_ERR_Succeeded;
354 return FX_ERR_Property_Invalid; 239 }
355 _info._strokeColor = color; 240 return FX_ERR_Property_Invalid;
356 return FX_ERR_Succeeded; 241 }
357 } 242
358 default: { return FX_ERR_Property_Invalid; }
359 }
360 }
361 FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { 243 FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) {
362 if (!color) 244 if (!color)
363 return FX_ERR_Parameter_Invalid; 245 return FX_ERR_Parameter_Invalid;
364 switch (_type) { 246 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
365 case FX_CONTEXT_Device: { 247 m_info.fillColor = color;
366 if (!_renderDevice) 248 return FX_ERR_Succeeded;
367 return FX_ERR_Property_Invalid; 249 }
368 _info._fillColor = color; 250 return FX_ERR_Property_Invalid;
369 return FX_ERR_Succeeded; 251 }
370 } 252
371 default: { return FX_ERR_Property_Invalid; }
372 }
373 }
374 FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { 253 FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) {
375 if (!path) 254 if (!path)
376 return FX_ERR_Parameter_Invalid; 255 return FX_ERR_Parameter_Invalid;
377 switch (_type) { 256 if (m_type == FX_CONTEXT_Device && m_renderDevice)
378 case FX_CONTEXT_Device: { 257 return RenderDeviceStrokePath(path, matrix);
379 if (!_renderDevice) 258 return FX_ERR_Property_Invalid;
380 return FX_ERR_Property_Invalid; 259 }
381 return RenderDeviceStrokePath(path, matrix); 260
382 }
383 default: { return FX_ERR_Property_Invalid; }
384 }
385 }
386 FX_ERR CFX_Graphics::FillPath(CFX_Path* path, 261 FX_ERR CFX_Graphics::FillPath(CFX_Path* path,
387 FX_FillMode fillMode, 262 FX_FillMode fillMode,
388 CFX_Matrix* matrix) { 263 CFX_Matrix* matrix) {
389 if (!path) 264 if (!path)
390 return FX_ERR_Parameter_Invalid; 265 return FX_ERR_Parameter_Invalid;
391 switch (_type) { 266 if (m_type == FX_CONTEXT_Device && m_renderDevice)
392 case FX_CONTEXT_Device: { 267 return RenderDeviceFillPath(path, fillMode, matrix);
393 if (!_renderDevice) 268 return FX_ERR_Property_Invalid;
394 return FX_ERR_Property_Invalid; 269 }
395 return RenderDeviceFillPath(path, fillMode, matrix); 270
396 }
397 default: { return FX_ERR_Property_Invalid; }
398 }
399 }
400 FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, 271 FX_ERR CFX_Graphics::ClipPath(CFX_Path* path,
401 FX_FillMode fillMode, 272 FX_FillMode fillMode,
402 CFX_Matrix* matrix) { 273 CFX_Matrix* matrix) {
403 if (!path) 274 if (!path)
404 return FX_ERR_Parameter_Invalid; 275 return FX_ERR_Parameter_Invalid;
405 switch (_type) { 276 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
406 case FX_CONTEXT_Device: { 277 FX_BOOL result = m_renderDevice->SetClip_PathFill(
407 if (!_renderDevice) 278 path->GetPathData(), (CFX_Matrix*)matrix, fillMode);
408 return FX_ERR_Property_Invalid; 279 if (!result)
409 FX_BOOL result = _renderDevice->SetClip_PathFill( 280 return FX_ERR_Indefinite;
410 path->GetPathData(), (CFX_Matrix*)matrix, fillMode); 281 return FX_ERR_Succeeded;
411 if (!result) 282 }
412 return FX_ERR_Indefinite; 283 return FX_ERR_Property_Invalid;
413 return FX_ERR_Succeeded; 284 }
414 } 285
415 default: { return FX_ERR_Property_Invalid; }
416 }
417 }
418 FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, 286 FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source,
419 const CFX_PointF& point, 287 const CFX_PointF& point,
420 CFX_Matrix* matrix) { 288 CFX_Matrix* matrix) {
421 if (!source) 289 if (!source)
422 return FX_ERR_Parameter_Invalid; 290 return FX_ERR_Parameter_Invalid;
423 switch (_type) { 291 if (m_type == FX_CONTEXT_Device && m_renderDevice)
424 case FX_CONTEXT_Device: { 292 return RenderDeviceDrawImage(source, point, matrix);
425 if (!_renderDevice) 293 return FX_ERR_Property_Invalid;
426 return FX_ERR_Property_Invalid; 294 }
427 return RenderDeviceDrawImage(source, point, matrix); 295
428 }
429 default: { return FX_ERR_Property_Invalid; }
430 }
431 }
432 FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, 296 FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source,
433 const CFX_RectF& rect, 297 const CFX_RectF& rect,
434 CFX_Matrix* matrix) { 298 CFX_Matrix* matrix) {
435 if (!source) 299 if (!source)
436 return FX_ERR_Parameter_Invalid; 300 return FX_ERR_Parameter_Invalid;
437 switch (_type) { 301 if (m_type == FX_CONTEXT_Device && m_renderDevice)
438 case FX_CONTEXT_Device: { 302 return RenderDeviceStretchImage(source, rect, matrix);
439 if (!_renderDevice) 303 return FX_ERR_Property_Invalid;
440 return FX_ERR_Property_Invalid; 304 }
441 return RenderDeviceStretchImage(source, rect, matrix); 305
442 }
443 default: { return FX_ERR_Property_Invalid; }
444 }
445 }
446 FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { 306 FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) {
447 if (!matrix) 307 if (!matrix)
448 return FX_ERR_Parameter_Invalid; 308 return FX_ERR_Parameter_Invalid;
449 switch (_type) { 309 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
450 case FX_CONTEXT_Device: { 310 m_info.CTM.Concat(*matrix);
451 if (!_renderDevice) 311 return FX_ERR_Succeeded;
452 return FX_ERR_Property_Invalid; 312 }
453 _info._CTM.Concat(*matrix); 313 return FX_ERR_Property_Invalid;
454 return FX_ERR_Succeeded; 314 }
315
316 CFX_Matrix* CFX_Graphics::GetMatrix() {
317 if (m_type == FX_CONTEXT_Device && m_renderDevice)
318 return &m_info.CTM;
319 return nullptr;
320 }
321
322 FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) const {
323 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
324 FX_RECT r = m_renderDevice->GetClipBox();
325 rect.left = (FX_FLOAT)r.left;
326 rect.top = (FX_FLOAT)r.top;
327 rect.width = (FX_FLOAT)r.Width();
328 rect.height = (FX_FLOAT)r.Height();
329 return FX_ERR_Succeeded;
330 }
331 return FX_ERR_Property_Invalid;
332 }
333
334 FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
335 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
336 if (!m_renderDevice->SetClip_Rect(
337 FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
338 FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) {
339 return FX_ERR_Method_Not_Supported;
455 } 340 }
456 default: { return FX_ERR_Property_Invalid; } 341 return FX_ERR_Succeeded;
457 } 342 }
458 } 343 return FX_ERR_Property_Invalid;
459 CFX_Matrix* CFX_Graphics::GetMatrix() { 344 }
460 switch (_type) { 345
461 case FX_CONTEXT_Device: {
462 if (!_renderDevice)
463 return NULL;
464 return &_info._CTM;
465 }
466 default: { return NULL; }
467 }
468 }
469 FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) {
470 switch (_type) {
471 case FX_CONTEXT_Device: {
472 if (!_renderDevice)
473 return FX_ERR_Property_Invalid;
474 FX_RECT r = _renderDevice->GetClipBox();
475 rect.left = (FX_FLOAT)r.left;
476 rect.top = (FX_FLOAT)r.top;
477 rect.width = (FX_FLOAT)r.Width();
478 rect.height = (FX_FLOAT)r.Height();
479 return FX_ERR_Succeeded;
480 }
481 default: { return FX_ERR_Property_Invalid; }
482 }
483 }
484 FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
485 switch (_type) {
486 case FX_CONTEXT_Device: {
487 if (!_renderDevice)
488 return FX_ERR_Property_Invalid;
489 if (!_renderDevice->SetClip_Rect(
490 FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
491 FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) {
492 return FX_ERR_Method_Not_Supported;
493 }
494 return FX_ERR_Succeeded;
495 }
496 default: { return FX_ERR_Property_Invalid; }
497 }
498 }
499 FX_ERR CFX_Graphics::ClearClip() { 346 FX_ERR CFX_Graphics::ClearClip() {
500 switch (_type) { 347 if (m_type == FX_CONTEXT_Device && m_renderDevice)
501 case FX_CONTEXT_Device: { 348 return FX_ERR_Succeeded;
502 if (!_renderDevice) 349 return FX_ERR_Property_Invalid;
503 return FX_ERR_Property_Invalid; 350 }
504 return FX_ERR_Succeeded; 351
505 }
506 default: { return FX_ERR_Property_Invalid; }
507 }
508 }
509 FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { 352 FX_ERR CFX_Graphics::SetFont(CFX_Font* font) {
510 if (!font) 353 if (!font)
511 return FX_ERR_Parameter_Invalid; 354 return FX_ERR_Parameter_Invalid;
512 switch (_type) { 355 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
513 case FX_CONTEXT_Device: { 356 m_info.font = font;
514 if (!_renderDevice) 357 return FX_ERR_Succeeded;
515 return FX_ERR_Property_Invalid; 358 }
516 _info._font = font; 359 return FX_ERR_Property_Invalid;
517 return FX_ERR_Succeeded; 360 }
518 } 361
519 default: { return FX_ERR_Property_Invalid; }
520 }
521 }
522 FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { 362 FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) {
523 FX_FLOAT fontSize = size <= 0 ? 1.0f : size; 363 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
524 switch (_type) { 364 m_info.fontSize = size <= 0 ? 1.0f : size;
525 case FX_CONTEXT_Device: { 365 return FX_ERR_Succeeded;
526 if (!_renderDevice) 366 }
527 return FX_ERR_Property_Invalid; 367 return FX_ERR_Property_Invalid;
528 _info._fontSize = fontSize; 368 }
529 return FX_ERR_Succeeded; 369
530 }
531 default: { return FX_ERR_Property_Invalid; }
532 }
533 }
534 FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { 370 FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) {
535 FX_FLOAT fontHScale = scale <= 0 ? 1.0f : scale; 371 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
536 switch (_type) { 372 m_info.fontHScale = scale <= 0 ? 1.0f : scale;
537 case FX_CONTEXT_Device: { 373 return FX_ERR_Succeeded;
538 if (!_renderDevice) 374 }
539 return FX_ERR_Property_Invalid; 375 return FX_ERR_Property_Invalid;
540 _info._fontHScale = fontHScale; 376 }
541 return FX_ERR_Succeeded; 377
542 }
543 default: { return FX_ERR_Property_Invalid; }
544 }
545 }
546 FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { 378 FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) {
547 FX_FLOAT fontSpacing = spacing < 0 ? 0 : spacing; 379 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
548 switch (_type) { 380 m_info.fontSpacing = spacing < 0 ? 0 : spacing;
549 case FX_CONTEXT_Device: { 381 return FX_ERR_Succeeded;
550 if (!_renderDevice) 382 }
551 return FX_ERR_Property_Invalid; 383 return FX_ERR_Property_Invalid;
552 _info._fontSpacing = fontSpacing; 384 }
553 return FX_ERR_Succeeded; 385
554 }
555 default: { return FX_ERR_Property_Invalid; }
556 }
557 }
558 FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { 386 FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) {
559 switch (_type) { 387 if (m_type == FX_CONTEXT_Device && m_renderDevice)
560 case FX_CONTEXT_Device: { 388 return FX_ERR_Succeeded;
561 if (!_renderDevice) 389 return FX_ERR_Property_Invalid;
562 return FX_ERR_Property_Invalid; 390 }
563 return FX_ERR_Succeeded; 391
564 }
565 default: { return FX_ERR_Property_Invalid; }
566 }
567 }
568 FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, 392 FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point,
569 const CFX_WideString& text, 393 const CFX_WideString& text,
570 CFX_Matrix* matrix) { 394 CFX_Matrix* matrix) {
571 switch (_type) { 395 if (m_type == FX_CONTEXT_Device && m_renderDevice)
572 case FX_CONTEXT_Device: { 396 return RenderDeviceShowText(point, text, matrix);
573 if (!_renderDevice) 397 return FX_ERR_Property_Invalid;
574 return FX_ERR_Property_Invalid; 398 }
575 return RenderDeviceShowText(point, text, matrix); 399
576 }
577 default: { return FX_ERR_Property_Invalid; }
578 }
579 }
580 FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, 400 FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect,
581 const CFX_WideString& text, 401 const CFX_WideString& text,
582 FX_BOOL isMultiline, 402 FX_BOOL isMultiline,
583 CFX_Matrix* matrix) { 403 CFX_Matrix* matrix) {
584 switch (_type) { 404 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
585 case FX_CONTEXT_Device: { 405 int32_t length = text.GetLength();
586 if (!_renderDevice) 406 FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length);
587 return FX_ERR_Property_Invalid; 407 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length);
588 int32_t length = text.GetLength(); 408 CalcTextInfo(text, charCodes, charPos, rect);
589 FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); 409 FX_Free(charPos);
590 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); 410 FX_Free(charCodes);
591 CalcTextInfo(text, charCodes, charPos, rect); 411 return FX_ERR_Succeeded;
592 FX_Free(charPos); 412 }
593 FX_Free(charCodes); 413 return FX_ERR_Property_Invalid;
594 return FX_ERR_Succeeded; 414 }
595 } 415
596 default: { return FX_ERR_Property_Invalid; }
597 }
598 }
599 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, 416 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics,
600 const CFX_Matrix* matrix) { 417 const CFX_Matrix* matrix) {
601 if (!graphics) 418 if (!graphics || !graphics->m_renderDevice)
602 return FX_ERR_Parameter_Invalid; 419 return FX_ERR_Parameter_Invalid;
603 CFX_Matrix m; 420 CFX_Matrix m;
604 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 421 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
605 _info._CTM.f); 422 m_info.CTM.f);
606 if (matrix) { 423 if (matrix) {
607 m.Concat(*matrix); 424 m.Concat(*matrix);
608 } 425 }
609 switch (_type) { 426 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
610 case FX_CONTEXT_Device: { 427 CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap();
611 if (!_renderDevice) 428 FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0);
612 return FX_ERR_Property_Invalid; 429 if (!result)
613 { 430 return FX_ERR_Method_Not_Supported;
614 if (!graphics->_renderDevice) 431 return FX_ERR_Succeeded;
615 return FX_ERR_Parameter_Invalid; 432 }
616 CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); 433 return FX_ERR_Property_Invalid;
617 FX_BOOL result = _renderDevice->SetDIBits(bitmap, 0, 0); 434 }
618 if (!result) 435
619 return FX_ERR_Method_Not_Supported;
620 }
621 }
622 default: { return FX_ERR_Property_Invalid; }
623 }
624 }
625 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, 436 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics,
626 FX_FLOAT srcLeft, 437 FX_FLOAT srcLeft,
627 FX_FLOAT srcTop, 438 FX_FLOAT srcTop,
628 const CFX_RectF& dstRect, 439 const CFX_RectF& dstRect,
629 const CFX_Matrix* matrix) { 440 const CFX_Matrix* matrix) {
630 if (!graphics) 441 if (!graphics || !graphics->m_renderDevice)
631 return FX_ERR_Parameter_Invalid; 442 return FX_ERR_Parameter_Invalid;
632 CFX_Matrix m; 443 CFX_Matrix m;
633 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 444 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
634 _info._CTM.f); 445 m_info.CTM.f);
635 if (matrix) { 446 if (matrix) {
636 m.Concat(*matrix); 447 m.Concat(*matrix);
637 } 448 }
638 switch (_type) { 449 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
639 case FX_CONTEXT_Device: { 450 CFX_DIBitmap bmp;
640 if (!_renderDevice) 451 FX_BOOL result =
641 return FX_ERR_Property_Invalid; 452 bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height,
642 { 453 graphics->m_renderDevice->GetBitmap()->GetFormat());
643 if (!graphics->_renderDevice) 454 if (!result)
644 return FX_ERR_Parameter_Invalid; 455 return FX_ERR_Intermediate_Value_Invalid;
645 CFX_DIBitmap* bitmap = graphics->_renderDevice->GetBitmap(); 456 result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft,
646 CFX_DIBitmap bmp; 457 (int32_t)srcTop);
647 FX_BOOL result = 458 if (!result)
648 bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, 459 return FX_ERR_Method_Not_Supported;
649 bitmap->GetFormat()); 460 result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left,
650 if (!result) 461 (int32_t)dstRect.top);
651 return FX_ERR_Intermediate_Value_Invalid; 462 if (!result)
652 result = graphics->_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, 463 return FX_ERR_Method_Not_Supported;
653 (int32_t)srcTop); 464 return FX_ERR_Succeeded;
654 if (!result) 465 }
655 return FX_ERR_Method_Not_Supported; 466 return FX_ERR_Property_Invalid;
656 result = _renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, 467 }
657 (int32_t)dstRect.top); 468
658 if (!result)
659 return FX_ERR_Method_Not_Supported;
660 return FX_ERR_Succeeded;
661 }
662 }
663 default: { return FX_ERR_Property_Invalid; }
664 }
665 }
666 CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { 469 CFX_RenderDevice* CFX_Graphics::GetRenderDevice() {
667 return _renderDevice; 470 return m_renderDevice;
668 } 471 }
472
669 FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { 473 FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) {
670 if (!_renderDevice) 474 if (!m_renderDevice)
671 return FX_ERR_Property_Invalid; 475 return FX_ERR_Property_Invalid;
672 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); 476 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
673 if (!bitmap) 477 if (!bitmap)
674 return FX_ERR_Property_Invalid; 478 return FX_ERR_Property_Invalid;
675 CFX_RectF temp(rect); 479 CFX_RectF temp(rect);
676 _info._CTM.TransformRect(temp); 480 m_info.CTM.TransformRect(temp);
677 CFX_RectF r; 481 CFX_RectF r;
678 r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); 482 r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth());
679 r.Intersect(temp); 483 r.Intersect(temp);
680 if (r.IsEmpty()) { 484 if (r.IsEmpty()) {
681 return FX_ERR_Parameter_Invalid; 485 return FX_ERR_Parameter_Invalid;
682 } 486 }
683 FX_ARGB* pBuf = 487 FX_ARGB* pBuf =
684 (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); 488 (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch());
685 int32_t bottom = (int32_t)r.bottom(); 489 int32_t bottom = (int32_t)r.bottom();
686 int32_t right = (int32_t)r.right(); 490 int32_t right = (int32_t)r.right();
687 for (int32_t i = (int32_t)r.top; i < bottom; i++) { 491 for (int32_t i = (int32_t)r.top; i < bottom; i++) {
688 FX_ARGB* pLine = pBuf + (int32_t)r.left; 492 FX_ARGB* pLine = pBuf + (int32_t)r.left;
689 for (int32_t j = (int32_t)r.left; j < right; j++) { 493 for (int32_t j = (int32_t)r.left; j < right; j++) {
690 FX_ARGB c = *pLine; 494 FX_ARGB c = *pLine;
691 *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); 495 *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF));
692 } 496 }
693 pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); 497 pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch());
694 } 498 }
695 return FX_ERR_Succeeded; 499 return FX_ERR_Succeeded;
696 } 500 }
501
697 FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, 502 FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap,
698 const CFX_RectF& rect) { 503 const CFX_RectF& rect) {
699 if (!_renderDevice) 504 if (!m_renderDevice)
700 return FX_ERR_Property_Invalid; 505 return FX_ERR_Property_Invalid;
701 CFX_DIBitmap* dst = _renderDevice->GetBitmap(); 506 CFX_DIBitmap* dst = m_renderDevice->GetBitmap();
702 if (!dst) 507 if (!dst)
703 return FX_ERR_Property_Invalid; 508 return FX_ERR_Property_Invalid;
704 CFX_RectF temp(rect); 509 CFX_RectF temp(rect);
705 _info._CTM.TransformRect(temp); 510 m_info.CTM.TransformRect(temp);
706 CFX_RectF r; 511 CFX_RectF r;
707 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); 512 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth());
708 r.Intersect(temp); 513 r.Intersect(temp);
709 if (r.IsEmpty()) { 514 if (r.IsEmpty()) {
710 return FX_ERR_Parameter_Invalid; 515 return FX_ERR_Parameter_Invalid;
711 } 516 }
712 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + 517 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() +
713 int32_t(r.top) * srcBitmap->GetPitch()); 518 int32_t(r.top) * srcBitmap->GetPitch());
714 FX_ARGB* pDstBuf = 519 FX_ARGB* pDstBuf =
715 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); 520 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch());
716 int32_t bottom = (int32_t)r.bottom(); 521 int32_t bottom = (int32_t)r.bottom();
717 int32_t right = (int32_t)r.right(); 522 int32_t right = (int32_t)r.right();
718 for (int32_t i = (int32_t)r.top; i < bottom; i++) { 523 for (int32_t i = (int32_t)r.top; i < bottom; i++) {
719 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; 524 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left;
720 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; 525 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left;
721 for (int32_t j = (int32_t)r.left; j < right; j++) { 526 for (int32_t j = (int32_t)r.left; j < right; j++) {
722 FX_ARGB c = *pDstLine; 527 FX_ARGB c = *pDstLine;
723 *pDstLine++ = 528 *pDstLine++ =
724 ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); 529 ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF));
725 pSrcLine++; 530 pSrcLine++;
726 } 531 }
727 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); 532 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch());
728 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); 533 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch());
729 } 534 }
730 return FX_ERR_Succeeded; 535 return FX_ERR_Succeeded;
731 } 536 }
537
732 FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, 538 FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap,
733 const CFX_RectF& rect) { 539 const CFX_RectF& rect) {
734 if (!_renderDevice) 540 if (!m_renderDevice)
735 return FX_ERR_Property_Invalid; 541 return FX_ERR_Property_Invalid;
736 CFX_DIBitmap* dst = _renderDevice->GetBitmap(); 542 CFX_DIBitmap* dst = m_renderDevice->GetBitmap();
737 if (!dst) 543 if (!dst)
738 return FX_ERR_Property_Invalid; 544 return FX_ERR_Property_Invalid;
739 CFX_RectF temp(rect); 545 CFX_RectF temp(rect);
740 _info._CTM.TransformRect(temp); 546 m_info.CTM.TransformRect(temp);
741 CFX_RectF r; 547 CFX_RectF r;
742 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); 548 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth());
743 r.Intersect(temp); 549 r.Intersect(temp);
744 if (r.IsEmpty()) { 550 if (r.IsEmpty()) {
745 return FX_ERR_Parameter_Invalid; 551 return FX_ERR_Parameter_Invalid;
746 } 552 }
747 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + 553 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() +
748 int32_t(r.top) * srcBitmap->GetPitch()); 554 int32_t(r.top) * srcBitmap->GetPitch());
749 FX_ARGB* pDstBuf = 555 FX_ARGB* pDstBuf =
750 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); 556 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch());
751 int32_t bottom = (int32_t)r.bottom(); 557 int32_t bottom = (int32_t)r.bottom();
752 int32_t right = (int32_t)r.right(); 558 int32_t right = (int32_t)r.right();
753 for (int32_t i = (int32_t)r.top; i < bottom; i++) { 559 for (int32_t i = (int32_t)r.top; i < bottom; i++) {
754 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; 560 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left;
755 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; 561 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left;
756 for (int32_t j = (int32_t)r.left; j < right; j++) { 562 for (int32_t j = (int32_t)r.left; j < right; j++) {
757 FX_ARGB c = *pDstLine; 563 FX_ARGB c = *pDstLine;
758 *pDstLine++ = 564 *pDstLine++ =
759 ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF))); 565 ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)));
760 pSrcLine++; 566 pSrcLine++;
761 } 567 }
762 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); 568 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch());
763 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); 569 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch());
764 } 570 }
765 return FX_ERR_Succeeded; 571 return FX_ERR_Succeeded;
766 } 572 }
573
767 FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { 574 FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) {
768 switch (dashStyle) { 575 switch (dashStyle) {
769 case FX_DASHSTYLE_Solid: { 576 case FX_DASHSTYLE_Solid: {
770 _info._graphState.SetDashCount(0); 577 m_info.graphState.SetDashCount(0);
771 return FX_ERR_Succeeded; 578 return FX_ERR_Succeeded;
772 } 579 }
773 case FX_DASHSTYLE_Dash: { 580 case FX_DASHSTYLE_Dash: {
774 FX_FLOAT dashArray[] = {3, 1}; 581 FX_FLOAT dashArray[] = {3, 1};
775 SetLineDash(0, dashArray, 2); 582 SetLineDash(0, dashArray, 2);
776 return FX_ERR_Succeeded; 583 return FX_ERR_Succeeded;
777 } 584 }
778 case FX_DASHSTYLE_Dot: { 585 case FX_DASHSTYLE_Dot: {
779 FX_FLOAT dashArray[] = {1, 1}; 586 FX_FLOAT dashArray[] = {1, 1};
780 SetLineDash(0, dashArray, 2); 587 SetLineDash(0, dashArray, 2);
781 return FX_ERR_Succeeded; 588 return FX_ERR_Succeeded;
782 } 589 }
783 case FX_DASHSTYLE_DashDot: { 590 case FX_DASHSTYLE_DashDot: {
784 FX_FLOAT dashArray[] = {3, 1, 1, 1}; 591 FX_FLOAT dashArray[] = {3, 1, 1, 1};
785 SetLineDash(0, dashArray, 4); 592 SetLineDash(0, dashArray, 4);
786 return FX_ERR_Succeeded; 593 return FX_ERR_Succeeded;
787 } 594 }
788 case FX_DASHSTYLE_DashDotDot: { 595 case FX_DASHSTYLE_DashDotDot: {
789 FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; 596 FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1};
790 SetLineDash(0, dashArray, 6); 597 SetLineDash(0, dashArray, 6);
791 return FX_ERR_Succeeded; 598 return FX_ERR_Succeeded;
792 } 599 }
793 default: { return FX_ERR_Parameter_Invalid; } 600 default:
601 return FX_ERR_Parameter_Invalid;
794 } 602 }
795 } 603 }
604
796 FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, 605 FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path,
797 CFX_Matrix* matrix) { 606 CFX_Matrix* matrix) {
798 if (!_info._strokeColor) 607 if (!m_info.strokeColor)
799 return FX_ERR_Property_Invalid; 608 return FX_ERR_Property_Invalid;
800 CFX_Matrix m; 609 CFX_Matrix m;
801 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 610 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
802 _info._CTM.f); 611 m_info.CTM.f);
803 if (matrix) { 612 if (matrix) {
804 m.Concat(*matrix); 613 m.Concat(*matrix);
805 } 614 }
806 switch (_info._strokeColor->_type) { 615 switch (m_info.strokeColor->m_type) {
807 case FX_COLOR_Solid: { 616 case FX_COLOR_Solid: {
808 FX_BOOL result = _renderDevice->DrawPath( 617 FX_BOOL result = m_renderDevice->DrawPath(
809 path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, 0x0, 618 path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 0x0,
810 _info._strokeColor->_argb, 0); 619 m_info.strokeColor->m_info.argb, 0);
811 if (!result) 620 if (!result)
812 return FX_ERR_Indefinite; 621 return FX_ERR_Indefinite;
813 return FX_ERR_Succeeded; 622 return FX_ERR_Succeeded;
814 } 623 }
815 case FX_COLOR_Pattern: { 624 case FX_COLOR_Pattern:
816 return StrokePathWithPattern(path, &m); 625 return StrokePathWithPattern(path, &m);
817 } 626 case FX_COLOR_Shading:
818 case FX_COLOR_Shading: {
819 return StrokePathWithShading(path, &m); 627 return StrokePathWithShading(path, &m);
820 } 628 default:
821 default: { return FX_ERR_Property_Invalid; } 629 return FX_ERR_Property_Invalid;
822 } 630 }
823 } 631 }
632
824 FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, 633 FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path,
825 FX_FillMode fillMode, 634 FX_FillMode fillMode,
826 CFX_Matrix* matrix) { 635 CFX_Matrix* matrix) {
827 if (!_info._fillColor) 636 if (!m_info.fillColor)
828 return FX_ERR_Property_Invalid; 637 return FX_ERR_Property_Invalid;
829 CFX_Matrix m; 638 CFX_Matrix m;
830 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 639 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
831 _info._CTM.f); 640 m_info.CTM.f);
832 if (matrix) { 641 if (matrix) {
833 m.Concat(*matrix); 642 m.Concat(*matrix);
834 } 643 }
835 switch (_info._fillColor->_type) { 644 switch (m_info.fillColor->m_type) {
836 case FX_COLOR_Solid: { 645 case FX_COLOR_Solid: {
837 FX_BOOL result = _renderDevice->DrawPath( 646 FX_BOOL result = m_renderDevice->DrawPath(
838 path->GetPathData(), (CFX_Matrix*)&m, &_info._graphState, 647 path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState,
839 _info._fillColor->_argb, 0x0, fillMode); 648 m_info.fillColor->m_info.argb, 0x0, fillMode);
840 if (!result) 649 if (!result)
841 return FX_ERR_Indefinite; 650 return FX_ERR_Indefinite;
842 return FX_ERR_Succeeded; 651 return FX_ERR_Succeeded;
843 } 652 }
844 case FX_COLOR_Pattern: { 653 case FX_COLOR_Pattern:
845 { return FillPathWithPattern(path, fillMode, &m); } 654 return FillPathWithPattern(path, fillMode, &m);
846 } 655 case FX_COLOR_Shading:
847 case FX_COLOR_Shading: { 656 return FillPathWithShading(path, fillMode, &m);
848 { return FillPathWithShading(path, fillMode, &m); } 657 default:
849 } 658 return FX_ERR_Property_Invalid;
850 default: { return FX_ERR_Property_Invalid; }
851 } 659 }
852 } 660 }
661
853 FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, 662 FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source,
854 const CFX_PointF& point, 663 const CFX_PointF& point,
855 CFX_Matrix* matrix) { 664 CFX_Matrix* matrix) {
856 CFX_Matrix m1; 665 CFX_Matrix m1;
857 m1.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 666 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
858 _info._CTM.f); 667 m_info.CTM.f);
859 if (matrix) { 668 if (matrix) {
860 m1.Concat(*matrix); 669 m1.Concat(*matrix);
861 } 670 }
862 CFX_Matrix m2; 671 CFX_Matrix m2;
863 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), 672 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(),
864 point.x, point.y); 673 point.x, point.y);
865 m2.Concat(m1); 674 m2.Concat(m1);
866 int32_t left, top; 675 int32_t left, top;
867 CFX_DIBitmap* bmp1 = source->FlipImage(FALSE, TRUE); 676 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE));
868 CFX_DIBitmap* bmp2 = bmp1->TransformTo((CFX_Matrix*)&m2, left, top); 677 std::unique_ptr<CFX_DIBitmap> bmp2(
678 bmp1->TransformTo((CFX_Matrix*)&m2, left, top));
869 CFX_RectF r; 679 CFX_RectF r;
870 GetClipRect(r); 680 GetClipRect(r);
871 FX_ERR result = FX_ERR_Indefinite; 681 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
872 { 682 CFX_DIBitmap bmp;
873 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); 683 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) &&
874 CFX_DIBitmap bmp; 684 m_renderDevice->GetDIBits(&bmp, 0, 0) &&
875 bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb); 685 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top),
876 _renderDevice->GetDIBits(&bmp, 0, 0); 686 FXSYS_round(r.Width()), FXSYS_round(r.Height()),
877 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), 687 bmp2.get(), FXSYS_round(r.left - left),
878 FXSYS_round(r.Width()), FXSYS_round(r.Height()), bmp2, 688 FXSYS_round(r.top - top)) &&
879 FXSYS_round(r.left - left), FXSYS_round(r.top - top)); 689 m_renderDevice->SetDIBits(&bmp, 0, 0)) {
880 _renderDevice->SetDIBits(&bmp, 0, 0); 690 return FX_ERR_Succeeded;
881 result = FX_ERR_Succeeded;
882 } 691 }
883 if (bmp2) { 692 return FX_ERR_Indefinite;
884 delete bmp2;
885 bmp2 = NULL;
886 }
887 if (bmp1) {
888 delete bmp1;
889 bmp1 = NULL;
890 }
891 return result;
892 } 693 }
694
893 FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, 695 FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source,
894 const CFX_RectF& rect, 696 const CFX_RectF& rect,
895 CFX_Matrix* matrix) { 697 CFX_Matrix* matrix) {
896 CFX_Matrix m1; 698 CFX_Matrix m1;
897 m1.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 699 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
898 _info._CTM.f); 700 m_info.CTM.f);
899 if (matrix) { 701 if (matrix) {
900 m1.Concat(*matrix); 702 m1.Concat(*matrix);
901 } 703 }
902 CFX_DIBitmap* bmp1 = 704 std::unique_ptr<CFX_DIBitmap> bmp1(
903 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()); 705 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()));
904 CFX_Matrix m2; 706 CFX_Matrix m2;
905 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); 707 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top);
906 m2.Concat(m1); 708 m2.Concat(m1);
907 int32_t left, top; 709 int32_t left, top;
908 CFX_DIBitmap* bmp2 = bmp1->FlipImage(FALSE, TRUE); 710 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->FlipImage(FALSE, TRUE));
909 CFX_DIBitmap* bmp3 = bmp2->TransformTo((CFX_Matrix*)&m2, left, top); 711 std::unique_ptr<CFX_DIBitmap> bmp3(
712 bmp2->TransformTo((CFX_Matrix*)&m2, left, top));
910 CFX_RectF r; 713 CFX_RectF r;
911 GetClipRect(r); 714 GetClipRect(r);
912 FX_ERR result = FX_ERR_Indefinite; 715 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
913 { 716 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top),
914 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); 717 FXSYS_round(r.Width()), FXSYS_round(r.Height()),
915 bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), 718 bmp3.get(), FXSYS_round(r.left - left),
916 FXSYS_round(r.Width()), FXSYS_round(r.Height()), 719 FXSYS_round(r.top - top))) {
917 bmp3, FXSYS_round(r.left - left), 720 return FX_ERR_Succeeded;
918 FXSYS_round(r.top - top));
919 result = FX_ERR_Succeeded;
920 } 721 }
921 if (bmp3) { 722 return FX_ERR_Indefinite;
922 delete bmp3;
923 bmp3 = NULL;
924 }
925 if (bmp2) {
926 delete bmp2;
927 bmp2 = NULL;
928 }
929 if (bmp1) {
930 delete bmp1;
931 bmp1 = NULL;
932 }
933 return result;
934 } 723 }
724
935 FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, 725 FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point,
936 const CFX_WideString& text, 726 const CFX_WideString& text,
937 CFX_Matrix* matrix) { 727 CFX_Matrix* matrix) {
938 int32_t length = text.GetLength(); 728 int32_t length = text.GetLength();
939 FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); 729 FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length);
940 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); 730 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length);
941 CFX_RectF rect; 731 CFX_RectF rect;
942 rect.Set(point.x, point.y, 0, 0); 732 rect.Set(point.x, point.y, 0, 0);
943 CalcTextInfo(text, charCodes, charPos, rect); 733 CalcTextInfo(text, charCodes, charPos, rect);
944 CFX_Matrix m; 734 CFX_Matrix m;
945 m.Set(_info._CTM.a, _info._CTM.b, _info._CTM.c, _info._CTM.d, _info._CTM.e, 735 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
946 _info._CTM.f); 736 m_info.CTM.f);
947 m.Translate(0, _info._fontSize * _info._fontHScale); 737 m.Translate(0, m_info.fontSize * m_info.fontHScale);
948 if (matrix) { 738 if (matrix) {
949 m.Concat(*matrix); 739 m.Concat(*matrix);
950 } 740 }
951 FX_BOOL result = _renderDevice->DrawNormalText( 741 FX_BOOL result = m_renderDevice->DrawNormalText(
952 length, charPos, _info._font, CFX_GEModule::Get()->GetFontCache(), 742 length, charPos, m_info.font, CFX_GEModule::Get()->GetFontCache(),
953 -_info._fontSize * _info._fontHScale, (CFX_Matrix*)&m, 743 -m_info.fontSize * m_info.fontHScale, (CFX_Matrix*)&m,
954 _info._fillColor->_argb, FXTEXT_CLEARTYPE); 744 m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE);
955 if (!result) 745 if (!result)
956 return FX_ERR_Indefinite; 746 return FX_ERR_Indefinite;
957 FX_Free(charPos); 747 FX_Free(charPos);
958 FX_Free(charCodes); 748 FX_Free(charCodes);
959 return FX_ERR_Succeeded; 749 return FX_ERR_Succeeded;
960 } 750 }
751
961 FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { 752 FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) {
962 return FX_ERR_Method_Not_Supported; 753 return FX_ERR_Method_Not_Supported;
963 } 754 }
755
964 FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { 756 FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) {
965 return FX_ERR_Method_Not_Supported; 757 return FX_ERR_Method_Not_Supported;
966 } 758 }
759
967 FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path, 760 FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path,
968 FX_FillMode fillMode, 761 FX_FillMode fillMode,
969 CFX_Matrix* matrix) { 762 CFX_Matrix* matrix) {
970 CFX_Pattern* pattern = _info._fillColor->_pattern; 763 CFX_Pattern* pattern = m_info.fillColor->m_info.pattern;
971 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); 764 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
972 int32_t width = bitmap->GetWidth(); 765 int32_t width = bitmap->GetWidth();
973 int32_t height = bitmap->GetHeight(); 766 int32_t height = bitmap->GetHeight();
974 CFX_DIBitmap bmp; 767 CFX_DIBitmap bmp;
975 bmp.Create(width, height, FXDIB_Argb); 768 bmp.Create(width, height, FXDIB_Argb);
976 _renderDevice->GetDIBits(&bmp, 0, 0); 769 m_renderDevice->GetDIBits(&bmp, 0, 0);
977 switch (pattern->_type) { 770 switch (pattern->m_type) {
978 case FX_PATTERN_Bitmap: { 771 case FX_PATTERN_Bitmap: {
979 int32_t xStep = FXSYS_round(pattern->_x1Step); 772 int32_t xStep = FXSYS_round(pattern->m_bitmapInfo.x1Step);
980 int32_t yStep = FXSYS_round(pattern->_y1Step); 773 int32_t yStep = FXSYS_round(pattern->m_bitmapInfo.y1Step);
981 int32_t xCount = width / xStep + 1; 774 int32_t xCount = width / xStep + 1;
982 int32_t yCount = height / yStep + 1; 775 int32_t yCount = height / yStep + 1;
983 for (int32_t i = 0; i <= yCount; i++) { 776 for (int32_t i = 0; i <= yCount; i++) {
984 for (int32_t j = 0; j <= xCount; j++) { 777 for (int32_t j = 0; j <= xCount; j++) {
985 bmp.TransferBitmap(j * xStep, i * yStep, xStep, yStep, 778 bmp.TransferBitmap(j * xStep, i * yStep, xStep, yStep,
986 pattern->_bitmap, 0, 0); 779 pattern->m_bitmapInfo.bitmap, 0, 0);
987 } 780 }
988 } 781 }
989 break; 782 break;
990 } 783 }
991 case FX_PATTERN_Hatch: { 784 case FX_PATTERN_Hatch: {
992 FX_HatchStyle hatchStyle = _info._fillColor->_pattern->_hatchStyle; 785 FX_HatchStyle hatchStyle =
786 m_info.fillColor->m_info.pattern->m_hatchInfo.hatchStyle;
993 if (hatchStyle < FX_HATCHSTYLE_Horizontal || 787 if (hatchStyle < FX_HATCHSTYLE_Horizontal ||
994 hatchStyle > FX_HATCHSTYLE_SolidDiamond) { 788 hatchStyle > FX_HATCHSTYLE_SolidDiamond) {
995 return FX_ERR_Intermediate_Value_Invalid; 789 return FX_ERR_Intermediate_Value_Invalid;
996 } 790 }
997 const FX_HATCHDATA& data = hatchBitmapData[hatchStyle]; 791 const FX_HATCHDATA& data = hatchBitmapData[hatchStyle];
998 CFX_DIBitmap mask; 792 CFX_DIBitmap mask;
999 mask.Create(data.width, data.height, FXDIB_1bppMask); 793 mask.Create(data.width, data.height, FXDIB_1bppMask);
1000 FXSYS_memcpy(mask.GetBuffer(), data.maskBits, 794 FXSYS_memcpy(mask.GetBuffer(), data.maskBits,
1001 mask.GetPitch() * data.height); 795 mask.GetPitch() * data.height);
1002 CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); 796 CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox();
1003 if (matrix) { 797 if (matrix) {
1004 rectf.Transform((const CFX_Matrix*)matrix); 798 rectf.Transform((const CFX_Matrix*)matrix);
1005 } 799 }
1006 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), 800 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top),
1007 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); 801 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom));
1008 CFX_FxgeDevice device; 802 CFX_FxgeDevice device;
1009 device.Attach(&bmp); 803 device.Attach(&bmp);
1010 device.FillRect(&rect, _info._fillColor->_pattern->_backArgb); 804 device.FillRect(&rect,
805 m_info.fillColor->m_info.pattern->m_hatchInfo.backArgb);
1011 for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { 806 for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) {
1012 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { 807 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) {
1013 device.SetBitMask(&mask, i, j, _info._fillColor->_pattern->_foreArgb); 808 device.SetBitMask(
809 &mask, i, j,
810 m_info.fillColor->m_info.pattern->m_hatchInfo.foreArgb);
1014 } 811 }
1015 } 812 }
1016 break; 813 break;
1017 } 814 }
1018 } 815 }
1019 _renderDevice->SaveState(); 816 m_renderDevice->SaveState();
1020 _renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, 817 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix,
1021 fillMode); 818 fillMode);
1022 SetDIBitsWithMatrix(&bmp, &pattern->_matrix); 819 SetDIBitsWithMatrix(&bmp, &pattern->m_matrix);
1023 _renderDevice->RestoreState(); 820 m_renderDevice->RestoreState();
1024 return FX_ERR_Succeeded; 821 return FX_ERR_Succeeded;
1025 } 822 }
823
1026 FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path, 824 FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path,
1027 FX_FillMode fillMode, 825 FX_FillMode fillMode,
1028 CFX_Matrix* matrix) { 826 CFX_Matrix* matrix) {
1029 CFX_DIBitmap* bitmap = _renderDevice->GetBitmap(); 827 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
1030 int32_t width = bitmap->GetWidth(); 828 int32_t width = bitmap->GetWidth();
1031 int32_t height = bitmap->GetHeight(); 829 int32_t height = bitmap->GetHeight();
1032 FX_FLOAT start_x = _info._fillColor->_shading->_beginPoint.x; 830 FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x;
1033 FX_FLOAT start_y = _info._fillColor->_shading->_beginPoint.y; 831 FX_FLOAT start_y = m_info.fillColor->m_shading->m_beginPoint.y;
1034 FX_FLOAT end_x = _info._fillColor->_shading->_endPoint.x; 832 FX_FLOAT end_x = m_info.fillColor->m_shading->m_endPoint.x;
1035 FX_FLOAT end_y = _info._fillColor->_shading->_endPoint.y; 833 FX_FLOAT end_y = m_info.fillColor->m_shading->m_endPoint.y;
1036 CFX_DIBitmap bmp; 834 CFX_DIBitmap bmp;
1037 bmp.Create(width, height, FXDIB_Argb); 835 bmp.Create(width, height, FXDIB_Argb);
1038 _renderDevice->GetDIBits(&bmp, 0, 0); 836 m_renderDevice->GetDIBits(&bmp, 0, 0);
1039 int32_t pitch = bmp.GetPitch(); 837 int32_t pitch = bmp.GetPitch();
1040 FX_BOOL result = FALSE; 838 FX_BOOL result = FALSE;
1041 switch (_info._fillColor->_shading->_type) { 839 switch (m_info.fillColor->m_shading->m_type) {
1042 case FX_SHADING_Axial: { 840 case FX_SHADING_Axial: {
1043 FX_FLOAT x_span = end_x - start_x; 841 FX_FLOAT x_span = end_x - start_x;
1044 FX_FLOAT y_span = end_y - start_y; 842 FX_FLOAT y_span = end_y - start_y;
1045 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); 843 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span);
1046 for (int32_t row = 0; row < height; row++) { 844 for (int32_t row = 0; row < height; row++) {
1047 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); 845 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch);
1048 for (int32_t column = 0; column < width; column++) { 846 for (int32_t column = 0; column < width; column++) {
1049 FX_FLOAT x = (FX_FLOAT)(column); 847 FX_FLOAT x = (FX_FLOAT)(column);
1050 FX_FLOAT y = (FX_FLOAT)(row); 848 FX_FLOAT y = (FX_FLOAT)(row);
1051 FX_FLOAT scale = 849 FX_FLOAT scale =
1052 (((x - start_x) * x_span) + ((y - start_y) * y_span)) / 850 (((x - start_x) * x_span) + ((y - start_y) * y_span)) /
1053 axis_len_square; 851 axis_len_square;
1054 if (scale < 0) { 852 if (scale < 0) {
1055 if (!_info._fillColor->_shading->_isExtendedBegin) { 853 if (!m_info.fillColor->m_shading->m_isExtendedBegin) {
1056 continue; 854 continue;
1057 } 855 }
1058 scale = 0; 856 scale = 0;
1059 } else if (scale > 1.0f) { 857 } else if (scale > 1.0f) {
1060 if (!_info._fillColor->_shading->_isExtendedEnd) { 858 if (!m_info.fillColor->m_shading->m_isExtendedEnd) {
1061 continue; 859 continue;
1062 } 860 }
1063 scale = 1.0f; 861 scale = 1.0f;
1064 } 862 }
1065 int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); 863 int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1));
1066 dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; 864 dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index];
1067 } 865 }
1068 } 866 }
1069 result = TRUE; 867 result = TRUE;
1070 break; 868 break;
1071 } 869 }
1072 case FX_SHADING_Radial: { 870 case FX_SHADING_Radial: {
1073 FX_FLOAT start_r = _info._fillColor->_shading->_beginRadius; 871 FX_FLOAT start_r = m_info.fillColor->m_shading->m_beginRadius;
1074 FX_FLOAT end_r = _info._fillColor->_shading->_endRadius; 872 FX_FLOAT end_r = m_info.fillColor->m_shading->m_endRadius;
1075 FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + 873 FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) +
1076 ((start_y - end_y) * (start_y - end_y)) - 874 ((start_y - end_y) * (start_y - end_y)) -
1077 ((start_r - end_r) * (start_r - end_r)); 875 ((start_r - end_r) * (start_r - end_r));
1078 for (int32_t row = 0; row < height; row++) { 876 for (int32_t row = 0; row < height; row++) {
1079 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); 877 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch);
1080 for (int32_t column = 0; column < width; column++) { 878 for (int32_t column = 0; column < width; column++) {
1081 FX_FLOAT x = (FX_FLOAT)(column); 879 FX_FLOAT x = (FX_FLOAT)(column);
1082 FX_FLOAT y = (FX_FLOAT)(row); 880 FX_FLOAT y = (FX_FLOAT)(row);
1083 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + 881 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) +
1084 ((y - start_y) * (end_y - start_y)) + 882 ((y - start_y) * (end_y - start_y)) +
(...skipping 10 matching lines...) Expand all
1095 } 893 }
1096 FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); 894 FX_FLOAT root = (FXSYS_sqrt(b2_4ac));
1097 FX_FLOAT s1, s2; 895 FX_FLOAT s1, s2;
1098 if (a > 0) { 896 if (a > 0) {
1099 s1 = (-b - root) / (2 * a); 897 s1 = (-b - root) / (2 * a);
1100 s2 = (-b + root) / (2 * a); 898 s2 = (-b + root) / (2 * a);
1101 } else { 899 } else {
1102 s2 = (-b - root) / (2 * a); 900 s2 = (-b - root) / (2 * a);
1103 s1 = (-b + root) / (2 * a); 901 s1 = (-b + root) / (2 * a);
1104 } 902 }
1105 if (s2 <= 1.0f || _info._fillColor->_shading->_isExtendedEnd) { 903 if (s2 <= 1.0f || m_info.fillColor->m_shading->m_isExtendedEnd) {
1106 s = (s2); 904 s = (s2);
1107 } else { 905 } else {
1108 s = (s1); 906 s = (s1);
1109 } 907 }
1110 if ((start_r) + s * (end_r - start_r) < 0) { 908 if ((start_r) + s * (end_r - start_r) < 0) {
1111 continue; 909 continue;
1112 } 910 }
1113 } 911 }
1114 if (s < 0) { 912 if (s < 0) {
1115 if (!_info._fillColor->_shading->_isExtendedBegin) { 913 if (!m_info.fillColor->m_shading->m_isExtendedBegin) {
1116 continue; 914 continue;
1117 } 915 }
1118 s = 0; 916 s = 0;
1119 } 917 }
1120 if (s > 1.0f) { 918 if (s > 1.0f) {
1121 if (!_info._fillColor->_shading->_isExtendedEnd) { 919 if (!m_info.fillColor->m_shading->m_isExtendedEnd) {
1122 continue; 920 continue;
1123 } 921 }
1124 s = 1.0f; 922 s = 1.0f;
1125 } 923 }
1126 int index = (int32_t)(s * (FX_SHADING_Steps - 1)); 924 int index = (int32_t)(s * (FX_SHADING_Steps - 1));
1127 dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; 925 dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index];
1128 } 926 }
1129 } 927 }
1130 result = TRUE; 928 result = TRUE;
1131 break; 929 break;
1132 } 930 }
1133 default: { result = FALSE; } 931 default: { result = FALSE; }
1134 } 932 }
1135 if (result) { 933 if (result) {
1136 _renderDevice->SaveState(); 934 m_renderDevice->SaveState();
1137 _renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, 935 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix,
1138 fillMode); 936 fillMode);
1139 SetDIBitsWithMatrix(&bmp, matrix); 937 SetDIBitsWithMatrix(&bmp, matrix);
1140 _renderDevice->RestoreState(); 938 m_renderDevice->RestoreState();
1141 } 939 }
1142 return result; 940 return result;
1143 } 941 }
942
1144 FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, 943 FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
1145 CFX_Matrix* matrix) { 944 CFX_Matrix* matrix) {
1146 if (matrix->IsIdentity()) { 945 if (matrix->IsIdentity()) {
1147 _renderDevice->SetDIBits(source, 0, 0); 946 m_renderDevice->SetDIBits(source, 0, 0);
1148 } else { 947 } else {
1149 CFX_Matrix m; 948 CFX_Matrix m;
1150 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, 949 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0,
1151 0); 950 0);
1152 m.Concat(*matrix); 951 m.Concat(*matrix);
1153 int32_t left, top; 952 int32_t left, top;
1154 CFX_DIBitmap* bmp1 = source->FlipImage(FALSE, TRUE); 953 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE));
1155 CFX_DIBitmap* bmp2 = bmp1->TransformTo((CFX_Matrix*)&m, left, top); 954 std::unique_ptr<CFX_DIBitmap> bmp2(
1156 _renderDevice->SetDIBits(bmp2, left, top); 955 bmp1->TransformTo((CFX_Matrix*)&m, left, top));
1157 if (bmp2) { 956 m_renderDevice->SetDIBits(bmp2.get(), left, top);
1158 delete bmp2;
1159 bmp2 = NULL;
1160 }
1161 if (bmp1) {
1162 delete bmp1;
1163 bmp1 = NULL;
1164 }
1165 } 957 }
1166 return FX_ERR_Succeeded; 958 return FX_ERR_Succeeded;
1167 } 959 }
960
1168 FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, 961 FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text,
1169 FX_DWORD* charCodes, 962 FX_DWORD* charCodes,
1170 FXTEXT_CHARPOS* charPos, 963 FXTEXT_CHARPOS* charPos,
1171 CFX_RectF& rect) { 964 CFX_RectF& rect) {
1172 std::unique_ptr<CFX_UnicodeEncoding> encoding( 965 std::unique_ptr<CFX_UnicodeEncoding> encoding(
1173 new CFX_UnicodeEncoding(_info._font)); 966 new CFX_UnicodeEncoding(m_info.font));
1174 int32_t length = text.GetLength(); 967 int32_t length = text.GetLength();
1175 FX_FLOAT penX = (FX_FLOAT)rect.left; 968 FX_FLOAT penX = (FX_FLOAT)rect.left;
1176 FX_FLOAT penY = (FX_FLOAT)rect.top; 969 FX_FLOAT penY = (FX_FLOAT)rect.top;
1177 FX_FLOAT left = (FX_FLOAT)(0); 970 FX_FLOAT left = (FX_FLOAT)(0);
1178 FX_FLOAT top = (FX_FLOAT)(0); 971 FX_FLOAT top = (FX_FLOAT)(0);
1179 charCodes[0] = text.GetAt(0); 972 charCodes[0] = text.GetAt(0);
1180 charPos[0].m_OriginX = penX + left; 973 charPos[0].m_OriginX = penX + left;
1181 charPos[0].m_OriginY = penY + top; 974 charPos[0].m_OriginY = penY + top;
1182 charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); 975 charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]);
1183 charPos[0].m_FontCharWidth = FXSYS_round( 976 charPos[0].m_FontCharWidth = FXSYS_round(
1184 _info._font->GetGlyphWidth(charPos[0].m_GlyphIndex) * _info._fontHScale); 977 m_info.font->GetGlyphWidth(charPos[0].m_GlyphIndex) * m_info.fontHScale);
1185 charPos[0].m_bGlyphAdjust = TRUE; 978 charPos[0].m_bGlyphAdjust = TRUE;
1186 charPos[0].m_AdjustMatrix[0] = -1; 979 charPos[0].m_AdjustMatrix[0] = -1;
1187 charPos[0].m_AdjustMatrix[1] = 0; 980 charPos[0].m_AdjustMatrix[1] = 0;
1188 charPos[0].m_AdjustMatrix[2] = 0; 981 charPos[0].m_AdjustMatrix[2] = 0;
1189 charPos[0].m_AdjustMatrix[3] = 1; 982 charPos[0].m_AdjustMatrix[3] = 1;
1190 penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * _info._fontSize / 1000 + 983 penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * m_info.fontSize / 1000 +
1191 _info._fontSpacing; 984 m_info.fontSpacing;
1192 for (int32_t i = 1; i < length; i++) { 985 for (int32_t i = 1; i < length; i++) {
1193 charCodes[i] = text.GetAt(i); 986 charCodes[i] = text.GetAt(i);
1194 charPos[i].m_OriginX = penX + left; 987 charPos[i].m_OriginX = penX + left;
1195 charPos[i].m_OriginY = penY + top; 988 charPos[i].m_OriginY = penY + top;
1196 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); 989 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]);
1197 charPos[i].m_FontCharWidth = 990 charPos[i].m_FontCharWidth =
1198 FXSYS_round(_info._font->GetGlyphWidth(charPos[i].m_GlyphIndex) * 991 FXSYS_round(m_info.font->GetGlyphWidth(charPos[i].m_GlyphIndex) *
1199 _info._fontHScale); 992 m_info.fontHScale);
1200 charPos[i].m_bGlyphAdjust = TRUE; 993 charPos[i].m_bGlyphAdjust = TRUE;
1201 charPos[i].m_AdjustMatrix[0] = -1; 994 charPos[i].m_AdjustMatrix[0] = -1;
1202 charPos[i].m_AdjustMatrix[1] = 0; 995 charPos[i].m_AdjustMatrix[1] = 0;
1203 charPos[i].m_AdjustMatrix[2] = 0; 996 charPos[i].m_AdjustMatrix[2] = 0;
1204 charPos[i].m_AdjustMatrix[3] = 1; 997 charPos[i].m_AdjustMatrix[3] = 1;
1205 penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * _info._fontSize / 1000 + 998 penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 +
1206 _info._fontSpacing; 999 m_info.fontSpacing;
1207 } 1000 }
1208 rect.width = (FX_FLOAT)penX - rect.left; 1001 rect.width = (FX_FLOAT)penX - rect.left;
1209 rect.height = rect.top + _info._fontSize * _info._fontHScale - rect.top; 1002 rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top;
1210 return FX_ERR_Succeeded; 1003 return FX_ERR_Succeeded;
1211 } 1004 }
1005
1006 CFX_Graphics::TInfo::TInfo(const TInfo& info)
1007 : graphState(info.graphState),
1008 isAntialiasing(info.isAntialiasing),
1009 strokeAlignment(info.strokeAlignment),
1010 CTM(info.CTM),
1011 isActOnDash(info.isActOnDash),
1012 strokeColor(info.strokeColor),
1013 fillColor(info.fillColor),
1014 font(info.font),
1015 fontSize(info.fontSize),
1016 fontHScale(info.fontHScale),
1017 fontSpacing(info.fontSpacing) {}
1018
1019 CFX_Graphics::TInfo& CFX_Graphics::TInfo::operator=(const TInfo& other) {
1020 graphState.Copy(other.graphState);
1021 isAntialiasing = other.isAntialiasing;
1022 strokeAlignment = other.strokeAlignment;
1023 CTM = other.CTM;
1024 isActOnDash = other.isActOnDash;
1025 strokeColor = other.strokeColor;
1026 fillColor = other.fillColor;
1027 font = other.font;
1028 fontSize = other.fontSize;
1029 fontHScale = other.fontHScale;
1030 fontSpacing = other.fontSpacing;
1031 return *this;
1032 }
1033
1212 CAGG_Graphics::CAGG_Graphics() { 1034 CAGG_Graphics::CAGG_Graphics() {
1213 _owner = NULL; 1035 m_owner = nullptr;
1214 } 1036 }
1037
1215 FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner, 1038 FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner,
1216 int32_t width, 1039 int32_t width,
1217 int32_t height, 1040 int32_t height,
1218 FXDIB_Format format) { 1041 FXDIB_Format format) {
1219 if (owner->_renderDevice) { 1042 if (owner->m_renderDevice)
1220 return FX_ERR_Parameter_Invalid; 1043 return FX_ERR_Parameter_Invalid;
1221 } 1044 if (m_owner)
1222 if (_owner) {
1223 return FX_ERR_Property_Invalid; 1045 return FX_ERR_Property_Invalid;
1224 } 1046
1225 CFX_FxgeDevice* device = new CFX_FxgeDevice; 1047 CFX_FxgeDevice* device = new CFX_FxgeDevice;
1226 device->Create(width, height, format); 1048 device->Create(width, height, format);
1227 _owner = owner; 1049 m_owner = owner;
1228 _owner->_renderDevice = device; 1050 m_owner->m_renderDevice = device;
1229 _owner->_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); 1051 m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF);
1230 return FX_ERR_Succeeded; 1052 return FX_ERR_Succeeded;
1231 } 1053 }
1054
1232 CAGG_Graphics::~CAGG_Graphics() { 1055 CAGG_Graphics::~CAGG_Graphics() {
1233 if (_owner->_renderDevice) { 1056 if (m_owner->m_renderDevice)
1234 delete (CFX_FxgeDevice*)_owner->_renderDevice; 1057 delete (CFX_FxgeDevice*)m_owner->m_renderDevice;
1235 } 1058 m_owner = nullptr;
1236 _owner = NULL;
1237 } 1059 }
1060
1238 CFX_Path::CFX_Path() { 1061 CFX_Path::CFX_Path() {
1239 _generator = NULL; 1062 m_generator = nullptr;
1240 } 1063 }
1064
1241 FX_ERR CFX_Path::Create() { 1065 FX_ERR CFX_Path::Create() {
1242 if (_generator) { 1066 if (m_generator)
1243 return FX_ERR_Property_Invalid; 1067 return FX_ERR_Property_Invalid;
1244 } 1068
1245 _generator = new CFX_PathGenerator; 1069 m_generator = new CFX_PathGenerator;
1246 _generator->Create(); 1070 m_generator->Create();
1247 return FX_ERR_Succeeded; 1071 return FX_ERR_Succeeded;
1248 } 1072 }
1073
1249 CFX_Path::~CFX_Path() { 1074 CFX_Path::~CFX_Path() {
1250 if (_generator) { 1075 delete m_generator;
1251 delete _generator;
1252 _generator = NULL;
1253 }
1254 } 1076 }
1077
1255 FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { 1078 FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) {
1256 if (!_generator) 1079 if (!m_generator)
1257 return FX_ERR_Property_Invalid; 1080 return FX_ERR_Property_Invalid;
1258 _generator->MoveTo(x, y); 1081 m_generator->MoveTo(x, y);
1259 return FX_ERR_Succeeded; 1082 return FX_ERR_Succeeded;
1260 } 1083 }
1084
1261 FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { 1085 FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) {
1262 if (!_generator) 1086 if (!m_generator)
1263 return FX_ERR_Property_Invalid; 1087 return FX_ERR_Property_Invalid;
1264 _generator->LineTo(x, y); 1088 m_generator->LineTo(x, y);
1265 return FX_ERR_Succeeded; 1089 return FX_ERR_Succeeded;
1266 } 1090 }
1091
1267 FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, 1092 FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1,
1268 FX_FLOAT ctrlY1, 1093 FX_FLOAT ctrlY1,
1269 FX_FLOAT ctrlX2, 1094 FX_FLOAT ctrlX2,
1270 FX_FLOAT ctrlY2, 1095 FX_FLOAT ctrlY2,
1271 FX_FLOAT toX, 1096 FX_FLOAT toX,
1272 FX_FLOAT toY) { 1097 FX_FLOAT toY) {
1273 if (!_generator) 1098 if (!m_generator)
1274 return FX_ERR_Property_Invalid; 1099 return FX_ERR_Property_Invalid;
1275 _generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); 1100 m_generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY);
1276 return FX_ERR_Succeeded; 1101 return FX_ERR_Succeeded;
1277 } 1102 }
1103
1278 FX_ERR CFX_Path::ArcTo(FX_FLOAT left, 1104 FX_ERR CFX_Path::ArcTo(FX_FLOAT left,
1279 FX_FLOAT top, 1105 FX_FLOAT top,
1280 FX_FLOAT width, 1106 FX_FLOAT width,
1281 FX_FLOAT height, 1107 FX_FLOAT height,
1282 FX_FLOAT startAngle, 1108 FX_FLOAT startAngle,
1283 FX_FLOAT sweepAngle) { 1109 FX_FLOAT sweepAngle) {
1284 if (!_generator) 1110 if (!m_generator)
1285 return FX_ERR_Property_Invalid; 1111 return FX_ERR_Property_Invalid;
1286 _generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, 1112 m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2,
1287 startAngle, sweepAngle); 1113 startAngle, sweepAngle);
1288 return FX_ERR_Succeeded; 1114 return FX_ERR_Succeeded;
1289 } 1115 }
1116
1290 FX_ERR CFX_Path::Close() { 1117 FX_ERR CFX_Path::Close() {
1291 if (!_generator) 1118 if (!m_generator)
1292 return FX_ERR_Property_Invalid; 1119 return FX_ERR_Property_Invalid;
1293 _generator->Close(); 1120 m_generator->Close();
1294 return FX_ERR_Succeeded; 1121 return FX_ERR_Succeeded;
1295 } 1122 }
1123
1296 FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { 1124 FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) {
1297 if (!_generator) 1125 if (!m_generator)
1298 return FX_ERR_Property_Invalid; 1126 return FX_ERR_Property_Invalid;
1299 _generator->AddLine(x1, y1, x2, y2); 1127 m_generator->AddLine(x1, y1, x2, y2);
1300 return FX_ERR_Succeeded; 1128 return FX_ERR_Succeeded;
1301 } 1129 }
1130
1302 FX_ERR CFX_Path::AddBezier(FX_FLOAT startX, 1131 FX_ERR CFX_Path::AddBezier(FX_FLOAT startX,
1303 FX_FLOAT startY, 1132 FX_FLOAT startY,
1304 FX_FLOAT ctrlX1, 1133 FX_FLOAT ctrlX1,
1305 FX_FLOAT ctrlY1, 1134 FX_FLOAT ctrlY1,
1306 FX_FLOAT ctrlX2, 1135 FX_FLOAT ctrlX2,
1307 FX_FLOAT ctrlY2, 1136 FX_FLOAT ctrlY2,
1308 FX_FLOAT endX, 1137 FX_FLOAT endX,
1309 FX_FLOAT endY) { 1138 FX_FLOAT endY) {
1310 if (!_generator) 1139 if (!m_generator)
1311 return FX_ERR_Property_Invalid; 1140 return FX_ERR_Property_Invalid;
1312 _generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, 1141 m_generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX,
1313 endY); 1142 endY);
1314 return FX_ERR_Succeeded; 1143 return FX_ERR_Succeeded;
1315 } 1144 }
1145
1316 FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, 1146 FX_ERR CFX_Path::AddRectangle(FX_FLOAT left,
1317 FX_FLOAT top, 1147 FX_FLOAT top,
1318 FX_FLOAT width, 1148 FX_FLOAT width,
1319 FX_FLOAT height) { 1149 FX_FLOAT height) {
1320 if (!_generator) 1150 if (!m_generator)
1321 return FX_ERR_Property_Invalid; 1151 return FX_ERR_Property_Invalid;
1322 _generator->AddRectangle(left, top, left + width, top + height); 1152 m_generator->AddRectangle(left, top, left + width, top + height);
1323 return FX_ERR_Succeeded; 1153 return FX_ERR_Succeeded;
1324 } 1154 }
1155
1325 FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, 1156 FX_ERR CFX_Path::AddEllipse(FX_FLOAT left,
1326 FX_FLOAT top, 1157 FX_FLOAT top,
1327 FX_FLOAT width, 1158 FX_FLOAT width,
1328 FX_FLOAT height) { 1159 FX_FLOAT height) {
1329 if (!_generator) 1160 if (!m_generator)
1330 return FX_ERR_Property_Invalid; 1161 return FX_ERR_Property_Invalid;
1331 _generator->AddEllipse(left + width / 2, top + height / 2, width / 2, 1162 m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2,
1332 height / 2); 1163 height / 2);
1333 return FX_ERR_Succeeded; 1164 return FX_ERR_Succeeded;
1334 } 1165 }
1166
1335 FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { 1167 FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) {
1336 if (!_generator) 1168 if (!m_generator)
1337 return FX_ERR_Property_Invalid; 1169 return FX_ERR_Property_Invalid;
1338 _generator->AddEllipse(rect.left + rect.Width() / 2, 1170 m_generator->AddEllipse(rect.left + rect.Width() / 2,
1339 rect.top + rect.Height() / 2, rect.Width() / 2, 1171 rect.top + rect.Height() / 2, rect.Width() / 2,
1340 rect.Height() / 2); 1172 rect.Height() / 2);
1341 return FX_ERR_Succeeded; 1173 return FX_ERR_Succeeded;
1342 } 1174 }
1175
1343 FX_ERR CFX_Path::AddArc(FX_FLOAT left, 1176 FX_ERR CFX_Path::AddArc(FX_FLOAT left,
1344 FX_FLOAT top, 1177 FX_FLOAT top,
1345 FX_FLOAT width, 1178 FX_FLOAT width,
1346 FX_FLOAT height, 1179 FX_FLOAT height,
1347 FX_FLOAT startAngle, 1180 FX_FLOAT startAngle,
1348 FX_FLOAT sweepAngle) { 1181 FX_FLOAT sweepAngle) {
1349 if (!_generator) 1182 if (!m_generator)
1350 return FX_ERR_Property_Invalid; 1183 return FX_ERR_Property_Invalid;
1351 _generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, 1184 m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2,
1352 startAngle, sweepAngle); 1185 startAngle, sweepAngle);
1353 return FX_ERR_Succeeded; 1186 return FX_ERR_Succeeded;
1354 } 1187 }
1188
1355 FX_ERR CFX_Path::AddPie(FX_FLOAT left, 1189 FX_ERR CFX_Path::AddPie(FX_FLOAT left,
1356 FX_FLOAT top, 1190 FX_FLOAT top,
1357 FX_FLOAT width, 1191 FX_FLOAT width,
1358 FX_FLOAT height, 1192 FX_FLOAT height,
1359 FX_FLOAT startAngle, 1193 FX_FLOAT startAngle,
1360 FX_FLOAT sweepAngle) { 1194 FX_FLOAT sweepAngle) {
1361 if (!_generator) 1195 if (!m_generator)
1362 return FX_ERR_Property_Invalid; 1196 return FX_ERR_Property_Invalid;
1363 _generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, 1197 m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2,
1364 startAngle, sweepAngle); 1198 startAngle, sweepAngle);
1365 return FX_ERR_Succeeded; 1199 return FX_ERR_Succeeded;
1366 } 1200 }
1201
1367 FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { 1202 FX_ERR CFX_Path::AddSubpath(CFX_Path* path) {
1368 if (!_generator) 1203 if (!m_generator)
1369 return FX_ERR_Property_Invalid; 1204 return FX_ERR_Property_Invalid;
1370 _generator->AddPathData(path->GetPathData()); 1205 m_generator->AddPathData(path->GetPathData());
1371 return FX_ERR_Succeeded; 1206 return FX_ERR_Succeeded;
1372 } 1207 }
1208
1373 FX_ERR CFX_Path::Clear() { 1209 FX_ERR CFX_Path::Clear() {
1374 if (!_generator) 1210 if (!m_generator)
1375 return FX_ERR_Property_Invalid; 1211 return FX_ERR_Property_Invalid;
1376 _generator->GetPathData()->SetPointCount(0); 1212 m_generator->GetPathData()->SetPointCount(0);
1377 return FX_ERR_Succeeded; 1213 return FX_ERR_Succeeded;
1378 } 1214 }
1215
1379 FX_BOOL CFX_Path::IsEmpty() { 1216 FX_BOOL CFX_Path::IsEmpty() {
1380 if (!_generator) 1217 if (!m_generator)
1381 return FX_ERR_Property_Invalid; 1218 return FX_ERR_Property_Invalid;
1382 if (_generator->GetPathData()->GetPointCount() == 0) { 1219 if (m_generator->GetPathData()->GetPointCount() == 0) {
1383 return TRUE; 1220 return TRUE;
1384 } 1221 }
1385 return FALSE; 1222 return FALSE;
1386 } 1223 }
1224
1387 CFX_PathData* CFX_Path::GetPathData() { 1225 CFX_PathData* CFX_Path::GetPathData() {
1388 if (!_generator) 1226 if (!m_generator)
1389 return NULL; 1227 return nullptr;
1390 return _generator->GetPathData(); 1228 return m_generator->GetPathData();
1391 } 1229 }
1392 CFX_Color::CFX_Color() { 1230
1393 _type = FX_COLOR_None; 1231 CFX_Color::CFX_Color() : m_type(FX_COLOR_None) {}
1394 } 1232
1395 CFX_Color::CFX_Color(const FX_ARGB argb) { 1233 CFX_Color::CFX_Color(const FX_ARGB argb) {
1396 _type = FX_COLOR_None;
1397 Set(argb); 1234 Set(argb);
1398 } 1235 }
1236
1399 CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { 1237 CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) {
1400 _type = FX_COLOR_None;
1401 Set(pattern, argb); 1238 Set(pattern, argb);
1402 } 1239 }
1240
1403 CFX_Color::CFX_Color(CFX_Shading* shading) { 1241 CFX_Color::CFX_Color(CFX_Shading* shading) {
1404 _type = FX_COLOR_None;
1405 Set(shading); 1242 Set(shading);
1406 } 1243 }
1244
1407 CFX_Color::~CFX_Color() { 1245 CFX_Color::~CFX_Color() {
1408 _type = FX_COLOR_None; 1246 m_type = FX_COLOR_None;
1409 } 1247 }
1248
1410 FX_ERR CFX_Color::Set(const FX_ARGB argb) { 1249 FX_ERR CFX_Color::Set(const FX_ARGB argb) {
1411 _type = FX_COLOR_Solid; 1250 m_type = FX_COLOR_Solid;
1412 _argb = argb; 1251 m_info.argb = argb;
1413 _pattern = NULL; 1252 m_info.pattern = nullptr;
1414 return FX_ERR_Succeeded; 1253 return FX_ERR_Succeeded;
1415 } 1254 }
1255
1416 FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { 1256 FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) {
1417 if (!pattern) 1257 if (!pattern)
1418 return FX_ERR_Parameter_Invalid; 1258 return FX_ERR_Parameter_Invalid;
1419 _type = FX_COLOR_Pattern; 1259 m_type = FX_COLOR_Pattern;
1420 _argb = argb; 1260 m_info.argb = argb;
1421 _pattern = pattern; 1261 m_info.pattern = pattern;
1422 return FX_ERR_Succeeded; 1262 return FX_ERR_Succeeded;
1423 } 1263 }
1264
1424 FX_ERR CFX_Color::Set(CFX_Shading* shading) { 1265 FX_ERR CFX_Color::Set(CFX_Shading* shading) {
1425 if (!shading) 1266 if (!shading)
1426 return FX_ERR_Parameter_Invalid; 1267 return FX_ERR_Parameter_Invalid;
1427 _type = FX_COLOR_Shading; 1268 m_type = FX_COLOR_Shading;
1428 _shading = shading; 1269 m_shading = shading;
1429 return FX_ERR_Succeeded; 1270 return FX_ERR_Succeeded;
1430 } 1271 }
1272
1431 CFX_Pattern::CFX_Pattern() { 1273 CFX_Pattern::CFX_Pattern() {
1432 _type = FX_PATTERN_None; 1274 m_type = FX_PATTERN_None;
1433 _matrix.SetIdentity(); 1275 m_matrix.SetIdentity();
1434 } 1276 }
1277
1435 FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, 1278 FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap,
1436 const FX_FLOAT xStep, 1279 const FX_FLOAT xStep,
1437 const FX_FLOAT yStep, 1280 const FX_FLOAT yStep,
1438 CFX_Matrix* matrix) { 1281 CFX_Matrix* matrix) {
1439 if (!bitmap) 1282 if (!bitmap)
1440 return FX_ERR_Parameter_Invalid; 1283 return FX_ERR_Parameter_Invalid;
1441 if (_type != FX_PATTERN_None) { 1284 if (m_type != FX_PATTERN_None) {
1442 return FX_ERR_Property_Invalid; 1285 return FX_ERR_Property_Invalid;
1443 } 1286 }
1444 _type = FX_PATTERN_Bitmap; 1287 m_type = FX_PATTERN_Bitmap;
1445 _bitmap = bitmap; 1288 m_bitmapInfo.bitmap = bitmap;
1446 _x1Step = xStep; 1289 m_bitmapInfo.x1Step = xStep;
1447 _y1Step = yStep; 1290 m_bitmapInfo.y1Step = yStep;
1448 if (matrix) { 1291 if (matrix) {
1449 _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, 1292 m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e,
1450 matrix->f); 1293 matrix->f);
1451 } 1294 }
1452 return FX_ERR_Succeeded; 1295 return FX_ERR_Succeeded;
1453 } 1296 }
1297
1454 FX_ERR CFX_Pattern::Create(FX_HatchStyle hatchStyle, 1298 FX_ERR CFX_Pattern::Create(FX_HatchStyle hatchStyle,
1455 const FX_ARGB foreArgb, 1299 const FX_ARGB foreArgb,
1456 const FX_ARGB backArgb, 1300 const FX_ARGB backArgb,
1457 CFX_Matrix* matrix) { 1301 CFX_Matrix* matrix) {
1458 if (hatchStyle < FX_HATCHSTYLE_Horizontal || 1302 if (hatchStyle < FX_HATCHSTYLE_Horizontal ||
1459 hatchStyle > FX_HATCHSTYLE_SolidDiamond) { 1303 hatchStyle > FX_HATCHSTYLE_SolidDiamond) {
1460 return FX_ERR_Parameter_Invalid; 1304 return FX_ERR_Parameter_Invalid;
1461 } 1305 }
1462 if (_type != FX_PATTERN_None) { 1306 if (m_type != FX_PATTERN_None) {
1463 return FX_ERR_Property_Invalid; 1307 return FX_ERR_Property_Invalid;
1464 } 1308 }
1465 _type = FX_PATTERN_Hatch; 1309 m_type = FX_PATTERN_Hatch;
1466 _hatchStyle = hatchStyle; 1310 m_hatchInfo.hatchStyle = hatchStyle;
1467 _foreArgb = foreArgb; 1311 m_hatchInfo.foreArgb = foreArgb;
1468 _backArgb = backArgb; 1312 m_hatchInfo.backArgb = backArgb;
1469 if (matrix) { 1313 if (matrix) {
1470 _matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, 1314 m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e,
1471 matrix->f); 1315 matrix->f);
1472 } 1316 }
1473 return FX_ERR_Succeeded; 1317 return FX_ERR_Succeeded;
1474 } 1318 }
1319
1475 CFX_Pattern::~CFX_Pattern() { 1320 CFX_Pattern::~CFX_Pattern() {
1476 _type = FX_PATTERN_None; 1321 m_type = FX_PATTERN_None;
1477 } 1322 }
1323
1478 CFX_Shading::CFX_Shading() { 1324 CFX_Shading::CFX_Shading() {
1479 _type = FX_SHADING_None; 1325 m_type = FX_SHADING_None;
1480 } 1326 }
1327
1481 FX_ERR CFX_Shading::CreateAxial(const CFX_PointF& beginPoint, 1328 FX_ERR CFX_Shading::CreateAxial(const CFX_PointF& beginPoint,
1482 const CFX_PointF& endPoint, 1329 const CFX_PointF& endPoint,
1483 FX_BOOL isExtendedBegin, 1330 FX_BOOL isExtendedBegin,
1484 FX_BOOL isExtendedEnd, 1331 FX_BOOL isExtendedEnd,
1485 const FX_ARGB beginArgb, 1332 const FX_ARGB beginArgb,
1486 const FX_ARGB endArgb) { 1333 const FX_ARGB endArgb) {
1487 if (_type != FX_SHADING_None) { 1334 if (m_type != FX_SHADING_None) {
1488 return FX_ERR_Property_Invalid; 1335 return FX_ERR_Property_Invalid;
1489 } 1336 }
1490 _type = FX_SHADING_Axial; 1337 m_type = FX_SHADING_Axial;
1491 _beginPoint = beginPoint; 1338 m_beginPoint = beginPoint;
1492 _endPoint = endPoint; 1339 m_endPoint = endPoint;
1493 _isExtendedBegin = isExtendedBegin; 1340 m_isExtendedBegin = isExtendedBegin;
1494 _isExtendedEnd = isExtendedEnd; 1341 m_isExtendedEnd = isExtendedEnd;
1495 _beginArgb = beginArgb; 1342 m_beginArgb = beginArgb;
1496 _endArgb = endArgb; 1343 m_endArgb = endArgb;
1497 return InitArgbArray(); 1344 return InitArgbArray();
1498 } 1345 }
1346
1499 FX_ERR CFX_Shading::CreateRadial(const CFX_PointF& beginPoint, 1347 FX_ERR CFX_Shading::CreateRadial(const CFX_PointF& beginPoint,
1500 const CFX_PointF& endPoint, 1348 const CFX_PointF& endPoint,
1501 const FX_FLOAT beginRadius, 1349 const FX_FLOAT beginRadius,
1502 const FX_FLOAT endRadius, 1350 const FX_FLOAT endRadius,
1503 FX_BOOL isExtendedBegin, 1351 FX_BOOL isExtendedBegin,
1504 FX_BOOL isExtendedEnd, 1352 FX_BOOL isExtendedEnd,
1505 const FX_ARGB beginArgb, 1353 const FX_ARGB beginArgb,
1506 const FX_ARGB endArgb) { 1354 const FX_ARGB endArgb) {
1507 if (_type != FX_SHADING_None) { 1355 if (m_type != FX_SHADING_None) {
1508 return FX_ERR_Property_Invalid; 1356 return FX_ERR_Property_Invalid;
1509 } 1357 }
1510 _type = FX_SHADING_Radial; 1358 m_type = FX_SHADING_Radial;
1511 _beginPoint = beginPoint; 1359 m_beginPoint = beginPoint;
1512 _endPoint = endPoint; 1360 m_endPoint = endPoint;
1513 _beginRadius = beginRadius; 1361 m_beginRadius = beginRadius;
1514 _endRadius = endRadius; 1362 m_endRadius = endRadius;
1515 _isExtendedBegin = isExtendedBegin; 1363 m_isExtendedBegin = isExtendedBegin;
1516 _isExtendedEnd = isExtendedEnd; 1364 m_isExtendedEnd = isExtendedEnd;
1517 _beginArgb = beginArgb; 1365 m_beginArgb = beginArgb;
1518 _endArgb = endArgb; 1366 m_endArgb = endArgb;
1519 return InitArgbArray(); 1367 return InitArgbArray();
1520 } 1368 }
1369
1521 CFX_Shading::~CFX_Shading() { 1370 CFX_Shading::~CFX_Shading() {
1522 _type = FX_SHADING_None; 1371 m_type = FX_SHADING_None;
1523 } 1372 }
1373
1524 FX_ERR CFX_Shading::InitArgbArray() { 1374 FX_ERR CFX_Shading::InitArgbArray() {
1525 int32_t a1, r1, g1, b1; 1375 int32_t a1, r1, g1, b1;
1526 ArgbDecode(_beginArgb, a1, r1, g1, b1); 1376 ArgbDecode(m_beginArgb, a1, r1, g1, b1);
1527 int32_t a2, r2, g2, b2; 1377 int32_t a2, r2, g2, b2;
1528 ArgbDecode(_endArgb, a2, r2, g2, b2); 1378 ArgbDecode(m_endArgb, a2, r2, g2, b2);
1529 FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1); 1379 FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1);
1530 FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f); 1380 FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f);
1531 FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f); 1381 FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f);
1532 FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f); 1382 FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f);
1533 FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f); 1383 FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f);
1534 int32_t a3, r3, g3, b3; 1384 int32_t a3, r3, g3, b3;
1535 for (int32_t i = 0; i < FX_SHADING_Steps; i++) { 1385 for (int32_t i = 0; i < FX_SHADING_Steps; i++) {
1536 a3 = (int32_t)(i * aScale); 1386 a3 = (int32_t)(i * aScale);
1537 r3 = (int32_t)(i * rScale); 1387 r3 = (int32_t)(i * rScale);
1538 g3 = (int32_t)(i * gScale); 1388 g3 = (int32_t)(i * gScale);
1539 b3 = (int32_t)(i * bScale); 1389 b3 = (int32_t)(i * bScale);
1540 _argbArray[i] = 1390 m_argbArray[i] =
1541 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); 1391 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3)));
1542 } 1392 }
1543 return FX_ERR_Succeeded; 1393 return FX_ERR_Succeeded;
1544 } 1394 }
1545 class CFX_Pause : public IFX_Pause {
1546 public:
1547 virtual FX_BOOL NeedToPauseNow() { return TRUE; }
1548 };
OLDNEW
« no previous file with comments | « xfa.gyp ('k') | xfa/include/fxgraphics/fx_graphics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698