1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! Mappings for the contents of d2d1svg.h
7 use ctypes::c_void;
8 use shared::basetsd::UINT32;
9 use shared::guiddef::REFIID;
10 use shared::minwindef::{BOOL, FLOAT};
11 use shared::ntdef::{PCWSTR, PWSTR, WCHAR};
12 use shared::winerror::HRESULT;
13 use um::d2d1::{
14     D2D1_CAP_STYLE_FLAT, D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_SQUARE, D2D1_COLOR_F, D2D1_FILL_MODE,
15     D2D1_LINE_JOIN_BEVEL, D2D1_LINE_JOIN_MITER_OR_BEVEL, D2D1_LINE_JOIN_ROUND, D2D1_POINT_2F,
16     D2D1_SIZE_F, ID2D1Resource, ID2D1ResourceVtbl
17 };
18 use um::d2d1_1::ID2D1PathGeometry1;
19 use um::objidlbase::IStream;
20 ENUM!{enum D2D1_SVG_PAINT_TYPE {
21     D2D1_SVG_PAINT_TYPE_NONE = 0,
22     D2D1_SVG_PAINT_TYPE_COLOR = 1,
23     D2D1_SVG_PAINT_TYPE_CURRENT_COLOR = 2,
24     D2D1_SVG_PAINT_TYPE_URI = 3,
25     D2D1_SVG_PAINT_TYPE_URI_NONE = 4,
26     D2D1_SVG_PAINT_TYPE_URI_COLOR = 5,
27     D2D1_SVG_PAINT_TYPE_URI_CURRENT_COLOR = 6,
28 }}
29 ENUM!{enum D2D1_SVG_LENGTH_UNITS {
30     D2D1_SVG_LENGTH_UNITS_NUMBER = 0,
31     D2D1_SVG_LENGTH_UNITS_PERCENTAGE = 1,
32 }}
33 ENUM!{enum D2D1_SVG_DISPLAY {
34     D2D1_SVG_DISPLAY_INLINE = 0,
35     D2D1_SVG_DISPLAY_NONE = 1,
36 }}
37 ENUM!{enum D2D1_SVG_VISIBILITY {
38     D2D1_SVG_VISIBILITY_VISIBLE = 0,
39     D2D1_SVG_VISIBILITY_HIDDEN = 1,
40 }}
41 ENUM!{enum D2D1_SVG_OVERFLOW {
42     D2D1_SVG_OVERFLOW_VISIBLE = 0,
43     D2D1_SVG_OVERFLOW_HIDDEN = 1,
44 }}
45 ENUM!{enum D2D1_SVG_LINE_CAP {
46     D2D1_SVG_LINE_CAP_BUTT = D2D1_CAP_STYLE_FLAT,
47     D2D1_SVG_LINE_CAP_SQUARE = D2D1_CAP_STYLE_SQUARE,
48     D2D1_SVG_LINE_CAP_ROUND = D2D1_CAP_STYLE_ROUND,
49 }}
50 ENUM!{enum D2D1_SVG_LINE_JOIN {
51     D2D1_SVG_LINE_JOIN_BEVEL = D2D1_LINE_JOIN_BEVEL,
52     D2D1_SVG_LINE_JOIN_MITER = D2D1_LINE_JOIN_MITER_OR_BEVEL,
53     D2D1_SVG_LINE_JOIN_ROUND = D2D1_LINE_JOIN_ROUND,
54 }}
55 ENUM!{enum D2D1_SVG_ASPECT_ALIGN {
56     D2D1_SVG_ASPECT_ALIGN_NONE = 0,
57     D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MIN = 1,
58     D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MIN = 2,
59     D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MIN = 3,
60     D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MID = 4,
61     D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MID = 5,
62     D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MID = 6,
63     D2D1_SVG_ASPECT_ALIGN_X_MIN_Y_MAX = 7,
64     D2D1_SVG_ASPECT_ALIGN_X_MID_Y_MAX = 8,
65     D2D1_SVG_ASPECT_ALIGN_X_MAX_Y_MAX = 9,
66 }}
67 ENUM!{enum D2D1_SVG_ASPECT_SCALING {
68     D2D1_SVG_ASPECT_SCALING_MEET = 0,
69     D2D1_SVG_ASPECT_SCALING_SLICE = 1,
70 }}
71 ENUM!{enum D2D1_SVG_PATH_COMMAND {
72     D2D1_SVG_PATH_COMMAND_CLOSE_PATH = 0,
73     D2D1_SVG_PATH_COMMAND_MOVE_ABSOLUTE = 1,
74     D2D1_SVG_PATH_COMMAND_MOVE_RELATIVE = 2,
75     D2D1_SVG_PATH_COMMAND_LINE_ABSOLUTE = 3,
76     D2D1_SVG_PATH_COMMAND_LINE_RELATIVE = 4,
77     D2D1_SVG_PATH_COMMAND_CUBIC_ABSOLUTE = 5,
78     D2D1_SVG_PATH_COMMAND_CUBIC_RELATIVE = 6,
79     D2D1_SVG_PATH_COMMAND_QUADRADIC_ABSOLUTE = 7,
80     D2D1_SVG_PATH_COMMAND_QUADRADIC_RELATIVE = 8,
81     D2D1_SVG_PATH_COMMAND_ARC_ABSOLUTE = 9,
82     D2D1_SVG_PATH_COMMAND_ARC_RELATIVE = 10,
83     D2D1_SVG_PATH_COMMAND_HORIZONTAL_ABSOLUTE = 11,
84     D2D1_SVG_PATH_COMMAND_HORIZONTAL_RELATIVE = 12,
85     D2D1_SVG_PATH_COMMAND_VERTICAL_ABSOLUTE = 13,
86     D2D1_SVG_PATH_COMMAND_VERTICAL_RELATIVE = 14,
87     D2D1_SVG_PATH_COMMAND_CUBIC_SMOOTH_ABSOLUTE = 15,
88     D2D1_SVG_PATH_COMMAND_CUBIC_SMOOTH_RELATIVE = 16,
89     D2D1_SVG_PATH_COMMAND_QUADRADIC_SMOOTH_ABSOLUTE = 17,
90     D2D1_SVG_PATH_COMMAND_QUADRADIC_SMOOTH_RELATIVE = 18,
91 }}
92 ENUM!{enum D2D1_SVG_UNIT_TYPE {
93     D2D1_SVG_UNIT_TYPE_USER_SPACE_ON_USE = 0,
94     D2D1_SVG_UNIT_TYPE_OBJECT_BOUNDING_BOX = 1,
95 }}
96 ENUM!{enum D2D1_SVG_ATTRIBUTE_STRING_TYPE {
97     D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG = 0,
98     D2D1_SVG_ATTRIBUTE_STRING_TYPE_ID = 1,
99 }}
100 ENUM!{enum D2D1_SVG_ATTRIBUTE_POD_TYPE {
101     D2D1_SVG_ATTRIBUTE_POD_TYPE_FLOAT = 0,
102     D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR = 1,
103     D2D1_SVG_ATTRIBUTE_POD_TYPE_FILL_MODE = 2,
104     D2D1_SVG_ATTRIBUTE_POD_TYPE_DISPLAY = 3,
105     D2D1_SVG_ATTRIBUTE_POD_TYPE_OVERFLOW = 4,
106     D2D1_SVG_ATTRIBUTE_POD_TYPE_LINE_CAP = 5,
107     D2D1_SVG_ATTRIBUTE_POD_TYPE_LINE_JOIN = 6,
108     D2D1_SVG_ATTRIBUTE_POD_TYPE_VISIBILITY = 7,
109     D2D1_SVG_ATTRIBUTE_POD_TYPE_MATRIX = 8,
110     D2D1_SVG_ATTRIBUTE_POD_TYPE_UNIT_TYPE = 9,
111     D2D1_SVG_ATTRIBUTE_POD_TYPE_EXTEND_MODE = 10,
112     D2D1_SVG_ATTRIBUTE_POD_TYPE_PRESERVE_ASPECT_RATIO = 11,
113     D2D1_SVG_ATTRIBUTE_POD_TYPE_VIEWBOX = 12,
114     D2D1_SVG_ATTRIBUTE_POD_TYPE_LENGTH = 13,
115 }}
116 STRUCT!{struct D2D1_SVG_LENGTH {
117     value: FLOAT,
118     units: D2D1_SVG_LENGTH_UNITS,
119 }}
120 STRUCT!{struct D2D1_SVG_PRESERVE_ASPECT_RATIO {
121     defer: BOOL,
122     align: D2D1_SVG_ASPECT_ALIGN,
123     meetOrSlice: D2D1_SVG_ASPECT_SCALING,
124 }}
125 STRUCT!{struct D2D1_SVG_VIEWBOX {
126     x: FLOAT,
127     y: FLOAT,
128     width: FLOAT,
129     height: FLOAT,
130 }}
131 DEFINE_GUID!{IID_ID2D1SvgAttribute,
132     0xc9cdb0dd, 0xf8c9, 0x4e70, 0xb7, 0xc2, 0x30, 0x1c, 0x80, 0x29, 0x2c, 0x5e}
133 DEFINE_GUID!{IID_ID2D1SvgPaint,
134     0xd59bab0a, 0x68a2, 0x455b, 0xa5, 0xdc, 0x9e, 0xb2, 0x85, 0x4e, 0x24, 0x90}
135 DEFINE_GUID!{IID_ID2D1SvgStrokeDashArray,
136     0xf1c0ca52, 0x92a3, 0x4f00, 0xb4, 0xce, 0xf3, 0x56, 0x91, 0xef, 0xd9, 0xd9}
137 DEFINE_GUID!{IID_ID2D1SvgPointCollection,
138     0x9dbe4c0d, 0x3572, 0x4dd9, 0x98, 0x25, 0x55, 0x30, 0x81, 0x3b, 0xb7, 0x12}
139 DEFINE_GUID!{IID_ID2D1SvgPathData,
140     0xc095e4f4, 0xbb98, 0x43d6, 0x97, 0x45, 0x4d, 0x1b, 0x84, 0xec, 0x98, 0x88}
141 DEFINE_GUID!{IID_ID2D1SvgElement,
142     0xac7b67a6, 0x183e, 0x49c1, 0xa8, 0x23, 0x0e, 0xbe, 0x40, 0xb0, 0xdb, 0x29}
143 DEFINE_GUID!{IID_ID2D1SvgDocument,
144     0x86b88e4d, 0xafa4, 0x4d7b, 0x88, 0xe4, 0x68, 0xa5, 0x1c, 0x4a, 0x0a, 0xec}
145 RIDL!{#[uuid(0xc9cdb0dd, 0xf8c9, 0x4e70, 0xb7, 0xc2, 0x30, 0x1c, 0x80, 0x29, 0x2c, 0x5e)]
146 interface ID2D1SvgAttribute(ID2D1SvgAttributeVtbl): ID2D1Resource(ID2D1ResourceVtbl) {
147     fn GetElement(
148         element: *mut *mut ID2D1SvgElement,
149     ) -> (),
150     fn Clone(
151         attribute: *mut *mut ID2D1SvgAttribute,
152     ) -> HRESULT,
153 }}
154 RIDL!{#[uuid(0xd59bab0a, 0x68a2, 0x455b, 0xa5, 0xdc, 0x9e, 0xb2, 0x85, 0x4e, 0x24, 0x90)]
155 interface ID2D1SvgPaint(ID2D1SvgPaintVtbl): ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) {
156     fn SetPaintType(
157         paintType: D2D1_SVG_PAINT_TYPE,
158     ) -> HRESULT,
159     fn GetPaintType() -> D2D1_SVG_PAINT_TYPE,
160     fn SetColor(
161         color: D2D1_COLOR_F,
162     ) -> HRESULT,
163     fn GetColor(
164         color: *mut D2D1_COLOR_F,
165     ) -> (),
166     fn SetId(
167         id: PCWSTR,
168     ) -> HRESULT,
169     fn GetId(
170         id: PWSTR,
171         idCount: UINT32,
172     ) -> HRESULT,
173     fn GetIdLength() -> UINT32,
174 }}
175 RIDL!{#[uuid(0xf1c0ca52, 0x92a3, 0x4f00, 0xb4, 0xce, 0xf3, 0x56, 0x91, 0xef, 0xd9, 0xd9)]
176 interface ID2D1SvgStrokeDashArray(ID2D1SvgStrokeDashArrayVtbl):
177     ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) {
178     fn RemoveDashesAtEnd(
179         dashesCount: UINT32,
180     ) -> HRESULT,
181     fn UpdateDashes_1(
182         dashes: *const D2D1_SVG_LENGTH,
183         dashesCount: UINT32,
184         startIndex: UINT32,
185     ) -> HRESULT,
186     fn UpdateDashes_2(
187         dashes: *const FLOAT,
188         dashesCount: UINT32,
189         startIndex: UINT32,
190     ) -> HRESULT,
191     fn GetDashes_1(
192         dashes: *mut D2D1_SVG_LENGTH,
193         dashesCount: UINT32,
194         startIndex: UINT32,
195     ) -> HRESULT,
196     fn GetDashes_2(
197         dashes: *mut FLOAT,
198         dashesCount: UINT32,
199         startIndex: UINT32,
200     ) -> HRESULT,
201     fn GetDashesCount() -> UINT32,
202 }}
203 RIDL!{#[uuid(0x9dbe4c0d, 0x3572, 0x4dd9, 0x98, 0x25, 0x55, 0x30, 0x81, 0x3b, 0xb7, 0x12)]
204 interface ID2D1SvgPointCollection(ID2D1SvgPointCollectionVtbl):
205     ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) {
206     fn RemovePointsAtEnd(
207         pointsCount: UINT32,
208     ) -> HRESULT,
209     fn UpdatePoints(
210         points: *const D2D1_POINT_2F,
211         pointsCount: UINT32,
212         startIndex: UINT32,
213     ) -> HRESULT,
214     fn GetPoints(
215         points: *mut D2D1_POINT_2F,
216         pointsCount: UINT32,
217         startIndex: UINT32,
218     ) -> HRESULT,
219     fn GetPointsCount() -> UINT32,
220 }}
221 RIDL!{#[uuid(0xc095e4f4, 0xbb98, 0x43d6, 0x97, 0x45, 0x4d, 0x1b, 0x84, 0xec, 0x98, 0x88)]
222 interface ID2D1SvgPathData(ID2D1SvgPathDataVtbl): ID2D1SvgAttribute(ID2D1SvgAttributeVtbl) {
223     fn RemoveSegmentDataAtEnd(
224         dataCount: UINT32,
225     ) -> HRESULT,
226     fn UpdateSegmentData(
227         data: *const FLOAT,
228         dataCount: UINT32,
229         startIndex: UINT32,
230     ) -> HRESULT,
231     fn GetSegmentData(
232         data: *mut FLOAT,
233         dataCount: UINT32,
234         startIndex: UINT32,
235     ) -> HRESULT,
236     fn GetSegmentDataCount() -> UINT32,
237     fn RemoveCommandsAtEnd(
238         commandsCount: UINT32,
239     ) -> HRESULT,
240     fn UpdateCommands(
241         commands: *const D2D1_SVG_PATH_COMMAND,
242         commandsCount: UINT32,
243         startIndex: UINT32,
244     ) -> HRESULT,
245     fn GetCommands(
246         commands: *mut D2D1_SVG_PATH_COMMAND,
247         commandsCount: UINT32,
248         startIndex: UINT32,
249     ) -> HRESULT,
250     fn GetCommandsCount() -> UINT32,
251     fn CreatePathGeometry(
252         fillMode: D2D1_FILL_MODE,
253         pathGeometry: *mut *mut ID2D1PathGeometry1,
254     ) -> HRESULT,
255 }}
256 RIDL!{#[uuid(0xac7b67a6, 0x183e, 0x49c1, 0xa8, 0x23, 0x0e, 0xbe, 0x40, 0xb0, 0xdb, 0x29)]
257 interface ID2D1SvgElement(ID2D1SvgElementVtbl): ID2D1Resource(ID2D1ResourceVtbl) {
258     fn GetDocument(
259         document: *mut *mut ID2D1SvgDocument,
260     ) -> (),
261     fn GetTagName(
262         name: PWSTR,
263         nameCount: UINT32,
264     ) -> HRESULT,
265     fn GetTagNameLength() -> UINT32,
266     fn IsTextContent() -> BOOL,
267     fn GetParent(
268         parent: *mut *mut ID2D1SvgElement,
269     ) -> (),
270     fn HasChildren() -> BOOL,
271     fn GetFirstChild(
272         child: *mut *mut ID2D1SvgElement,
273     ) -> (),
274     fn GetLastChild(
275         child: *mut *mut ID2D1SvgElement,
276     ) -> (),
277     fn GetPreviousChild(
278         referenceChild: *mut ID2D1SvgElement,
279         previousChild: *mut *mut ID2D1SvgElement,
280     ) -> HRESULT,
281     fn GetNextChild(
282         referenceChild: *mut ID2D1SvgElement,
283         nextChild: *mut *mut ID2D1SvgElement,
284     ) -> HRESULT,
285     fn InsertChildBefore(
286         newChild: *mut ID2D1SvgElement,
287         referenceChild: *mut ID2D1SvgElement,
288     ) -> HRESULT,
289     fn AppendChild(
290         newChild: *mut ID2D1SvgElement,
291     ) -> HRESULT,
292     fn ReplaceChild(
293         newChild: *mut ID2D1SvgElement,
294         oldChild: *mut ID2D1SvgElement,
295     ) -> HRESULT,
296     fn RemoveChild(
297         oldChild: *mut ID2D1SvgElement,
298     ) -> HRESULT,
299     fn IsAttributeSpecified(
300         name: PCWSTR, inherited: *mut BOOL,
301     ) -> BOOL,
302     fn GetSpecifiedAttributeCount() -> UINT32,
303     fn GetSpecifiedAttributeName(
304         index: UINT32,
305         name: PWSTR,
306         nameCount: UINT32,
307         inherited: *mut BOOL,
308     ) -> HRESULT,
309     fn GetSpecifiedAttributeNameLength(
310         index: UINT32,
311         nameLength: *mut UINT32,
312         inherited: *mut BOOL,
313     ) -> HRESULT,
314     fn RemoveAttribute(
315         name: PCWSTR,
316     ) -> HRESULT,
317     fn SetTextValue(
318         name: *const WCHAR,
319         nameCount: UINT32,
320     ) -> HRESULT,
321     fn GetTextValue(
322         name: PWSTR,
323         nameCount: UINT32,
324     ) -> HRESULT,
325     fn GetTextValueLength() -> UINT32,
326     fn SetAttributeValue_1(
327         name: PCWSTR,
328         value: *mut ID2D1SvgAttribute,
329     ) -> HRESULT,
330     fn SetAttributeValue_2(
331         name: PCWSTR,
332         type_: D2D1_SVG_ATTRIBUTE_POD_TYPE,
333         value: *const c_void,
334         valueSizeInBytes: UINT32,
335     ) -> HRESULT,
336     fn SetAttributeValue_3(
337         name: PCWSTR,
338         type_: D2D1_SVG_ATTRIBUTE_STRING_TYPE,
339         value: PCWSTR,
340     ) -> HRESULT,
341     fn GetAttributeValue_1(
342         name: PCWSTR,
343         riid: REFIID,
344         value: *mut *mut c_void,
345     ) -> HRESULT,
346     fn GetAttributeValue_2(
347         name: PCWSTR,
348         type_: D2D1_SVG_ATTRIBUTE_POD_TYPE,
349         value: *mut c_void,
350         valueSizeInBytes: UINT32,
351     ) -> HRESULT,
352     fn GetAttributeValue_3(
353         name: PCWSTR,
354         type_: D2D1_SVG_ATTRIBUTE_STRING_TYPE,
355         value: PWSTR,
356         valueCount: UINT32,
357     ) -> HRESULT,
358     fn GetAttributeValueLength(
359         name: PCWSTR,
360         type_: D2D1_SVG_ATTRIBUTE_STRING_TYPE,
361         valueLength: *mut UINT32,
362     ) -> HRESULT,
363 }}
364 RIDL!{#[uuid(0x86b88e4d, 0xafa4, 0x4d7b, 0x88, 0xe4, 0x68, 0xa5, 0x1c, 0x4a, 0x0a, 0xec)]
365 interface ID2D1SvgDocument(ID2D1SvgDocumentVtbl): ID2D1Resource(ID2D1ResourceVtbl) {
366     fn SetViewportSize(
367         viewportSize: D2D1_SIZE_F,
368     ) -> HRESULT,
369     fn GetViewportSize() -> D2D1_SIZE_F,
370     fn SetRoot(
371         root: *mut ID2D1SvgElement,
372     ) -> HRESULT,
373     fn GetRoot(
374         root: *mut *mut ID2D1SvgElement,
375     ) -> (),
376     fn FindElementById(
377         id: PCWSTR,
378         svgElement: *mut *mut ID2D1SvgElement,
379     ) -> HRESULT,
380     fn Serialize(
381         outputXmlStream: *mut IStream,
382         subtree: *mut ID2D1SvgElement,
383     ) -> HRESULT,
384     fn Deserialize(
385         inputXmlStream: *mut IStream,
386         subtree: *mut *mut ID2D1SvgElement,
387     ) -> HRESULT,
388     fn CreatePaint(
389         paintType: D2D1_SVG_PAINT_TYPE,
390         color: *const D2D1_COLOR_F,
391         id: PCWSTR,
392         paint: *mut *mut ID2D1SvgPaint,
393     ) -> HRESULT,
394     fn CreateStrokeDashArray(
395         dashes: *const D2D1_SVG_LENGTH,
396         dashesCount: UINT32,
397         strokeDashArray: *mut *mut ID2D1SvgStrokeDashArray,
398     ) -> HRESULT,
399     fn CreatePointCollection(
400         points: *const D2D1_POINT_2F,
401         pountsCount: UINT32,
402         pointCollection: *mut ID2D1SvgPointCollection,
403     ) -> HRESULT,
404     fn CreatePathData(
405         segmentData: *const FLOAT,
406         segmentDataCount: UINT32,
407         commands: *const D2D1_SVG_PATH_COMMAND,
408         commandsCount: UINT32,
409         pathData: *mut *mut ID2D1SvgPathData,
410     ) -> HRESULT,
411 }}
412