master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#ifndef _D2D1_3HELPER_H_
8#define _D2D1_3HELPER_H_
9
10#if NTDDI_VERSION >= NTDDI_WINTHRESHOLD
11
12#ifndef _D2D1_3_H_
13#include <d2d1_3.h>
14#endif
15
16#ifndef D2D_USE_C_DEFINITIONS
17
18#include <winapifamily.h>
19
20#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
21
22namespace D2D1 {
23 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_GRADIENT_MESH_PATCH GradientMeshPatch(
24 D2D1_POINT_2F point00,
25 D2D1_POINT_2F point01,
26 D2D1_POINT_2F point02,
27 D2D1_POINT_2F point03,
28 D2D1_POINT_2F point10,
29 D2D1_POINT_2F point11,
30 D2D1_POINT_2F point12,
31 D2D1_POINT_2F point13,
32 D2D1_POINT_2F point20,
33 D2D1_POINT_2F point21,
34 D2D1_POINT_2F point22,
35 D2D1_POINT_2F point23,
36 D2D1_POINT_2F point30,
37 D2D1_POINT_2F point31,
38 D2D1_POINT_2F point32,
39 D2D1_POINT_2F point33,
40 D2D1_COLOR_F color00,
41 D2D1_COLOR_F color03,
42 D2D1_COLOR_F color30,
43 D2D1_COLOR_F color33,
44 D2D1_PATCH_EDGE_MODE top_edge_mode,
45 D2D1_PATCH_EDGE_MODE left_edge_mode,
46 D2D1_PATCH_EDGE_MODE bottom_edge_mode,
47 D2D1_PATCH_EDGE_MODE right_edge_mode
48 )
49 {
50 D2D1_GRADIENT_MESH_PATCH new_patch;
51 new_patch.point00 = point00;
52 new_patch.point01 = point01;
53 new_patch.point02 = point02;
54 new_patch.point03 = point03;
55 new_patch.point10 = point10;
56 new_patch.point11 = point11;
57 new_patch.point12 = point12;
58 new_patch.point13 = point13;
59 new_patch.point20 = point20;
60 new_patch.point21 = point21;
61 new_patch.point22 = point22;
62 new_patch.point23 = point23;
63 new_patch.point30 = point30;
64 new_patch.point31 = point31;
65 new_patch.point32 = point32;
66 new_patch.point33 = point33;
67
68 new_patch.color00 = color00;
69 new_patch.color03 = color03;
70 new_patch.color30 = color30;
71 new_patch.color33 = color33;
72
73 new_patch.topEdgeMode = top_edge_mode;
74 new_patch.leftEdgeMode = left_edge_mode;
75 new_patch.bottomEdgeMode = bottom_edge_mode;
76 new_patch.rightEdgeMode = right_edge_mode;
77
78 return new_patch;
79 }
80
81 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_GRADIENT_MESH_PATCH GradientMeshPatchFromCoonsPatch(
82 D2D1_POINT_2F point0,
83 D2D1_POINT_2F point1,
84 D2D1_POINT_2F point2,
85 D2D1_POINT_2F point3,
86 D2D1_POINT_2F point4,
87 D2D1_POINT_2F point5,
88 D2D1_POINT_2F point6,
89 D2D1_POINT_2F point7,
90 D2D1_POINT_2F point8,
91 D2D1_POINT_2F point9,
92 D2D1_POINT_2F point10,
93 D2D1_POINT_2F point11,
94 D2D1_COLOR_F color0,
95 D2D1_COLOR_F color1,
96 D2D1_COLOR_F color2,
97 D2D1_COLOR_F color3,
98 D2D1_PATCH_EDGE_MODE top_edge_mode,
99 D2D1_PATCH_EDGE_MODE left_edge_mode,
100 D2D1_PATCH_EDGE_MODE bottom_edge_mode,
101 D2D1_PATCH_EDGE_MODE right_edge_mode
102 )
103 {
104 D2D1_GRADIENT_MESH_PATCH new_patch;
105 new_patch.point00 = point0;
106 new_patch.point01 = point1;
107 new_patch.point02 = point2;
108 new_patch.point03 = point3;
109 new_patch.point13 = point4;
110 new_patch.point23 = point5;
111 new_patch.point33 = point6;
112 new_patch.point32 = point7;
113 new_patch.point31 = point8;
114 new_patch.point30 = point9;
115 new_patch.point20 = point10;
116 new_patch.point10 = point11;
117
118 D2D1GetGradientMeshInteriorPointsFromCoonsPatch(
119 &point0,
120 &point1,
121 &point2,
122 &point3,
123 &point4,
124 &point5,
125 &point6,
126 &point7,
127 &point8,
128 &point9,
129 &point10,
130 &point11,
131 &new_patch.point11,
132 &new_patch.point12,
133 &new_patch.point21,
134 &new_patch.point22
135 );
136
137 new_patch.color00 = color0;
138 new_patch.color03 = color1;
139 new_patch.color33 = color2;
140 new_patch.color30 = color3;
141 new_patch.topEdgeMode = top_edge_mode;
142 new_patch.leftEdgeMode = left_edge_mode;
143 new_patch.bottomEdgeMode = bottom_edge_mode;
144 new_patch.rightEdgeMode = right_edge_mode;
145
146 return new_patch;
147 }
148
149 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_INK_POINT InkPoint(const D2D1_POINT_2F &point, FLOAT radius) {
150 D2D1_INK_POINT ink_point;
151
152 ink_point.x = point.x;
153 ink_point.y = point.y;
154 ink_point.radius = radius;
155
156 return ink_point;
157 }
158
159 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_INK_BEZIER_SEGMENT InkBezierSegment(const D2D1_INK_POINT &point1, const D2D1_INK_POINT &point2, const D2D1_INK_POINT &point3) {
160 D2D1_INK_BEZIER_SEGMENT ink_bezier_segment;
161
162 ink_bezier_segment.point1 = point1;
163 ink_bezier_segment.point2 = point2;
164 ink_bezier_segment.point3 = point3;
165
166 return ink_bezier_segment;
167 }
168
169 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_INK_STYLE_PROPERTIES InkStyleProperties(D2D1_INK_NIB_SHAPE nib_shape, const D2D1_MATRIX_3X2_F &nib_transform) {
170 D2D1_INK_STYLE_PROPERTIES ink_style_properties;
171
172 ink_style_properties.nibShape = nib_shape;
173 ink_style_properties.nibTransform = nib_transform;
174
175 return ink_style_properties;
176 }
177
178 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_RECT_U InfiniteRectU(void) {
179 D2D1_RECT_U rect = { 0, 0, UINT_MAX, UINT_MAX };
180
181 return rect;
182 }
183
184 COM_DECLSPEC_NOTHROW D2D1FORCEINLINE D2D1_SIMPLE_COLOR_PROFILE SimpleColorProfile(
185 const D2D1_POINT_2F &red_primary,
186 const D2D1_POINT_2F &green_primary,
187 const D2D1_POINT_2F &blue_primary,
188 const D2D1_GAMMA1 gamma,
189 const D2D1_POINT_2F &white_point_xz
190 )
191 {
192 D2D1_SIMPLE_COLOR_PROFILE simple_color_profile;
193
194 simple_color_profile.redPrimary = red_primary;
195 simple_color_profile.greenPrimary = green_primary;
196 simple_color_profile.bluePrimary = blue_primary;
197 simple_color_profile.gamma = gamma;
198 simple_color_profile.whitePointXZ = white_point_xz;
199
200 return simple_color_profile;
201 }
202} /* namespace D2D1 */
203
204#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
205
206#endif /* D2D_USE_C_DEFINITIONS */
207
208#endif /* NTDDI_VERSION >= NTDDI_WINTHRESHOLD */
209
210#endif /* _D2D1_HELPER_H_ */