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