1 //---------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //
4 // This file is automatically generated.  Please do not edit it directly.
5 //
6 // File name: D2D1_1.h
7 //---------------------------------------------------------------------------
8 #ifdef _MSC_VER
9 #pragma once
10 #endif // #ifdef _MSC_VER
11 
12 #ifndef _D2D1_1_H_
13 #define _D2D1_1_H_
14 
15 #ifndef _D2D1_H_
16 #include <d2d1.h>
17 #endif // #ifndef _D2D1_H_
18 #ifndef _D2D1_EFFECTS_
19 #include <d2d1effects.h>
20 #endif // #ifndef _D2D1_EFFECTS_
21 
22 /*#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)*/
23 #include <dxgi.h>
24 /*#endif*/ /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
25 
26 /*#include <winapifamily.h>*/
27 
28 /*#pragma region Application Family*/
29 /*#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)*/
30 
31 typedef interface ID2D1ColorContext ID2D1ColorContext;
32 typedef interface IWICColorContext IWICColorContext;
33 typedef interface IWICImagingFactory IWICImagingFactory;
34 typedef interface IPrintDocumentPackageTarget IPrintDocumentPackageTarget;
35 typedef interface IDWriteFactory IDWriteFactory;
36 typedef struct DWRITE_GLYPH_RUN_DESCRIPTION DWRITE_GLYPH_RUN_DESCRIPTION;
37 typedef struct D2D1_PROPERTY_BINDING D2D1_PROPERTY_BINDING;
38 
39 /// <summary>
40 /// Function pointer to construct a new effect once registered.
41 /// </summary>
42 typedef HRESULT (CALLBACK *PD2D1_EFFECT_FACTORY)(
43     _Outptr_ IUnknown **effectImpl
44     );
45 
46 #ifndef D2D_USE_C_DEFINITIONS
47 
48 interface ID2D1Device;
49 interface ID2D1Effect;
50 #else
51 
52 typedef interface ID2D1Device ID2D1Device;
53 typedef interface ID2D1Effect ID2D1Effect;
54 
55 #endif
56 #define D2D1_INVALID_PROPERTY_INDEX UINT_MAX
57 typedef D2D_RECT_L D2D1_RECT_L;
58 typedef D2D_POINT_2L D2D1_POINT_2L;
59 
60 /// <summary>
61 /// This defines the valid property types that can be used in an effect property
62 /// interface.
63 /// </summary>
64 typedef enum D2D1_PROPERTY_TYPE
65 {
66     D2D1_PROPERTY_TYPE_UNKNOWN = 0,
67     D2D1_PROPERTY_TYPE_STRING = 1,
68     D2D1_PROPERTY_TYPE_BOOL = 2,
69     D2D1_PROPERTY_TYPE_UINT32 = 3,
70     D2D1_PROPERTY_TYPE_INT32 = 4,
71     D2D1_PROPERTY_TYPE_FLOAT = 5,
72     D2D1_PROPERTY_TYPE_VECTOR2 = 6,
73     D2D1_PROPERTY_TYPE_VECTOR3 = 7,
74     D2D1_PROPERTY_TYPE_VECTOR4 = 8,
75     D2D1_PROPERTY_TYPE_BLOB = 9,
76     D2D1_PROPERTY_TYPE_IUNKNOWN = 10,
77     D2D1_PROPERTY_TYPE_ENUM = 11,
78     D2D1_PROPERTY_TYPE_ARRAY = 12,
79     D2D1_PROPERTY_TYPE_CLSID = 13,
80     D2D1_PROPERTY_TYPE_MATRIX_3X2 = 14,
81     D2D1_PROPERTY_TYPE_MATRIX_4X3 = 15,
82     D2D1_PROPERTY_TYPE_MATRIX_4X4 = 16,
83     D2D1_PROPERTY_TYPE_MATRIX_5X4 = 17,
84     D2D1_PROPERTY_TYPE_COLOR_CONTEXT = 18,
85     D2D1_PROPERTY_TYPE_FORCE_DWORD = 0xffffffff
86 
87 } D2D1_PROPERTY_TYPE;
88 
89 /// <summary>
90 /// This defines the list of system properties present on the root effect property
91 /// interface.
92 /// </summary>
93 typedef enum D2D1_PROPERTY
94 {
95     D2D1_PROPERTY_CLSID = 0x80000000,
96     D2D1_PROPERTY_DISPLAYNAME = 0x80000001,
97     D2D1_PROPERTY_AUTHOR = 0x80000002,
98     D2D1_PROPERTY_CATEGORY = 0x80000003,
99     D2D1_PROPERTY_DESCRIPTION = 0x80000004,
100     D2D1_PROPERTY_INPUTS = 0x80000005,
101     D2D1_PROPERTY_CACHED = 0x80000006,
102     D2D1_PROPERTY_PRECISION = 0x80000007,
103     D2D1_PROPERTY_MIN_INPUTS = 0x80000008,
104     D2D1_PROPERTY_MAX_INPUTS = 0x80000009,
105     D2D1_PROPERTY_FORCE_DWORD = 0xffffffff
106 
107 } D2D1_PROPERTY;
108 
109 /// <summary>
110 /// This defines the indices of sub-properties that may be present on any parent
111 /// property.
112 /// </summary>
113 typedef enum D2D1_SUBPROPERTY
114 {
115     D2D1_SUBPROPERTY_DISPLAYNAME = 0x80000000,
116     D2D1_SUBPROPERTY_ISREADONLY = 0x80000001,
117     D2D1_SUBPROPERTY_MIN = 0x80000002,
118     D2D1_SUBPROPERTY_MAX = 0x80000003,
119     D2D1_SUBPROPERTY_DEFAULT = 0x80000004,
120     D2D1_SUBPROPERTY_FIELDS = 0x80000005,
121     D2D1_SUBPROPERTY_INDEX = 0x80000006,
122     D2D1_SUBPROPERTY_FORCE_DWORD = 0xffffffff
123 
124 } D2D1_SUBPROPERTY;
125 
126 /// <summary>
127 /// Specifies how the bitmap can be used.
128 /// </summary>
129 typedef enum D2D1_BITMAP_OPTIONS
130 {
131 
132     /// <summary>
133     /// The bitmap is created with default properties.
134     /// </summary>
135     D2D1_BITMAP_OPTIONS_NONE = 0x00000000,
136 
137     /// <summary>
138     /// The bitmap can be specified as a target in ID2D1DeviceContext::SetTarget
139     /// </summary>
140     D2D1_BITMAP_OPTIONS_TARGET = 0x00000001,
141 
142     /// <summary>
143     /// The bitmap cannot be used as an input to DrawBitmap, DrawImage, in a bitmap
144     /// brush or as an input to an effect.
145     /// </summary>
146     D2D1_BITMAP_OPTIONS_CANNOT_DRAW = 0x00000002,
147 
148     /// <summary>
149     /// The bitmap can be read from the CPU.
150     /// </summary>
151     D2D1_BITMAP_OPTIONS_CPU_READ = 0x00000004,
152 
153     /// <summary>
154     /// The bitmap works with the ID2D1GdiInteropRenderTarget::GetDC API.
155     /// </summary>
156     D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE = 0x00000008,
157     D2D1_BITMAP_OPTIONS_FORCE_DWORD = 0xffffffff
158 
159 } D2D1_BITMAP_OPTIONS;
160 
161 DEFINE_ENUM_FLAG_OPERATORS(D2D1_BITMAP_OPTIONS);
162 
163 /// <summary>
164 /// Specifies the composite mode that will be applied.
165 /// </summary>
166 typedef enum D2D1_COMPOSITE_MODE
167 {
168     D2D1_COMPOSITE_MODE_SOURCE_OVER = 0,
169     D2D1_COMPOSITE_MODE_DESTINATION_OVER = 1,
170     D2D1_COMPOSITE_MODE_SOURCE_IN = 2,
171     D2D1_COMPOSITE_MODE_DESTINATION_IN = 3,
172     D2D1_COMPOSITE_MODE_SOURCE_OUT = 4,
173     D2D1_COMPOSITE_MODE_DESTINATION_OUT = 5,
174     D2D1_COMPOSITE_MODE_SOURCE_ATOP = 6,
175     D2D1_COMPOSITE_MODE_DESTINATION_ATOP = 7,
176     D2D1_COMPOSITE_MODE_XOR = 8,
177     D2D1_COMPOSITE_MODE_PLUS = 9,
178     D2D1_COMPOSITE_MODE_SOURCE_COPY = 10,
179     D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY = 11,
180     D2D1_COMPOSITE_MODE_MASK_INVERT = 12,
181     D2D1_COMPOSITE_MODE_FORCE_DWORD = 0xffffffff
182 
183 } D2D1_COMPOSITE_MODE;
184 
185 /// <summary>
186 /// This specifies the precision that should be used in buffers allocated by D2D.
187 /// </summary>
188 typedef enum D2D1_BUFFER_PRECISION
189 {
190     D2D1_BUFFER_PRECISION_UNKNOWN = 0,
191     D2D1_BUFFER_PRECISION_8BPC_UNORM = 1,
192     D2D1_BUFFER_PRECISION_8BPC_UNORM_SRGB = 2,
193     D2D1_BUFFER_PRECISION_16BPC_UNORM = 3,
194     D2D1_BUFFER_PRECISION_16BPC_FLOAT = 4,
195     D2D1_BUFFER_PRECISION_32BPC_FLOAT = 5,
196     D2D1_BUFFER_PRECISION_FORCE_DWORD = 0xffffffff
197 
198 } D2D1_BUFFER_PRECISION;
199 
200 /// <summary>
201 /// This describes how the individual mapping operation should be performed.
202 /// </summary>
203 typedef enum D2D1_MAP_OPTIONS
204 {
205 
206     /// <summary>
207     /// The mapped pointer has undefined behavior.
208     /// </summary>
209     D2D1_MAP_OPTIONS_NONE = 0,
210 
211     /// <summary>
212     /// The mapped pointer can be read from.
213     /// </summary>
214     D2D1_MAP_OPTIONS_READ = 1,
215 
216     /// <summary>
217     /// The mapped pointer can be written to.
218     /// </summary>
219     D2D1_MAP_OPTIONS_WRITE = 2,
220 
221     /// <summary>
222     /// The previous contents of the bitmap are discarded when it is mapped.
223     /// </summary>
224     D2D1_MAP_OPTIONS_DISCARD = 4,
225     D2D1_MAP_OPTIONS_FORCE_DWORD = 0xffffffff
226 
227 } D2D1_MAP_OPTIONS;
228 
229 DEFINE_ENUM_FLAG_OPERATORS(D2D1_MAP_OPTIONS);
230 
231 /// <summary>
232 /// This is used to specify the quality of image scaling with
233 /// ID2D1DeviceContext::DrawImage and with the 2D Affine Transform Effect.
234 /// </summary>
235 typedef enum D2D1_INTERPOLATION_MODE
236 {
237     D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR = D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR,
238     D2D1_INTERPOLATION_MODE_LINEAR = D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR,
239     D2D1_INTERPOLATION_MODE_CUBIC = D2D1_INTERPOLATION_MODE_DEFINITION_CUBIC,
240     D2D1_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR = D2D1_INTERPOLATION_MODE_DEFINITION_MULTI_SAMPLE_LINEAR,
241     D2D1_INTERPOLATION_MODE_ANISOTROPIC = D2D1_INTERPOLATION_MODE_DEFINITION_ANISOTROPIC,
242     D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC = D2D1_INTERPOLATION_MODE_DEFINITION_HIGH_QUALITY_CUBIC,
243     D2D1_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff
244 
245 } D2D1_INTERPOLATION_MODE;
246 
247 /// <summary>
248 /// This specifies what units should be accepted by the D2D API.
249 /// </summary>
250 typedef enum D2D1_UNIT_MODE
251 {
252     D2D1_UNIT_MODE_DIPS = 0,
253     D2D1_UNIT_MODE_PIXELS = 1,
254     D2D1_UNIT_MODE_FORCE_DWORD = 0xffffffff
255 
256 } D2D1_UNIT_MODE;
257 
258 /// <summary>
259 /// Defines a color space.
260 /// </summary>
261 typedef enum D2D1_COLOR_SPACE
262 {
263 
264     /// <summary>
265     /// The color space is described by accompanying data, such as a color profile.
266     /// </summary>
267     D2D1_COLOR_SPACE_CUSTOM = 0,
268 
269     /// <summary>
270     /// The sRGB color space.
271     /// </summary>
272     D2D1_COLOR_SPACE_SRGB = 1,
273 
274     /// <summary>
275     /// The scRGB color space.
276     /// </summary>
277     D2D1_COLOR_SPACE_SCRGB = 2,
278     D2D1_COLOR_SPACE_FORCE_DWORD = 0xffffffff
279 
280 } D2D1_COLOR_SPACE;
281 
282 /// <summary>
283 /// This specifies options that apply to the device context for its lifetime.
284 /// </summary>
285 typedef enum D2D1_DEVICE_CONTEXT_OPTIONS
286 {
287     D2D1_DEVICE_CONTEXT_OPTIONS_NONE = 0,
288 
289     /// <summary>
290     /// Geometry rendering will be performed on many threads in parallel, a single
291     /// thread is the default.
292     /// </summary>
293     D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS = 1,
294     D2D1_DEVICE_CONTEXT_OPTIONS_FORCE_DWORD = 0xffffffff
295 
296 } D2D1_DEVICE_CONTEXT_OPTIONS;
297 
298 DEFINE_ENUM_FLAG_OPERATORS(D2D1_DEVICE_CONTEXT_OPTIONS);
299 
300 /// <summary>
301 /// Defines how the world transform, dots per inch (dpi), and stroke width affect
302 /// the shape of the pen used to stroke a primitive.
303 /// </summary>
304 typedef enum D2D1_STROKE_TRANSFORM_TYPE
305 {
306 
307     /// <summary>
308     /// The stroke respects the world transform, the DPI, and the stroke width.
309     /// </summary>
310     D2D1_STROKE_TRANSFORM_TYPE_NORMAL = 0,
311 
312     /// <summary>
313     /// The stroke does not respect the world transform, but it does respect the DPI and
314     /// the stroke width.
315     /// </summary>
316     D2D1_STROKE_TRANSFORM_TYPE_FIXED = 1,
317 
318     /// <summary>
319     /// The stroke is forced to one pixel wide.
320     /// </summary>
321     D2D1_STROKE_TRANSFORM_TYPE_HAIRLINE = 2,
322     D2D1_STROKE_TRANSFORM_TYPE_FORCE_DWORD = 0xffffffff
323 
324 } D2D1_STROKE_TRANSFORM_TYPE;
325 
326 /// <summary>
327 /// A blend mode that applies to all primitives drawn on the context.
328 /// </summary>
329 typedef enum D2D1_PRIMITIVE_BLEND
330 {
331     D2D1_PRIMITIVE_BLEND_SOURCE_OVER = 0,
332     D2D1_PRIMITIVE_BLEND_COPY = 1,
333     D2D1_PRIMITIVE_BLEND_MIN = 2,
334     D2D1_PRIMITIVE_BLEND_ADD = 3,
335     D2D1_PRIMITIVE_BLEND_MAX = 4,
336     D2D1_PRIMITIVE_BLEND_FORCE_DWORD = 0xffffffff
337 
338 } D2D1_PRIMITIVE_BLEND;
339 
340 /// <summary>
341 /// This specifies the threading mode used while simultaneously creating the device,
342 /// factory, and device context.
343 /// </summary>
344 typedef enum D2D1_THREADING_MODE
345 {
346 
347     /// <summary>
348     /// Resources may only be invoked serially.  Reference counts on resources are
349     /// interlocked, however, resource and render target state is not protected from
350     /// multi-threaded access
351     /// </summary>
352     D2D1_THREADING_MODE_SINGLE_THREADED = D2D1_FACTORY_TYPE_SINGLE_THREADED,
353 
354     /// <summary>
355     /// Resources may be invoked from multiple threads. Resources use interlocked
356     /// reference counting and their state is protected.
357     /// </summary>
358     D2D1_THREADING_MODE_MULTI_THREADED = D2D1_FACTORY_TYPE_MULTI_THREADED,
359     D2D1_THREADING_MODE_FORCE_DWORD = 0xffffffff
360 
361 } D2D1_THREADING_MODE;
362 
363 /// <summary>
364 /// This specifies how colors are interpolated.
365 /// </summary>
366 typedef enum D2D1_COLOR_INTERPOLATION_MODE
367 {
368 
369     /// <summary>
370     /// Colors will be interpolated in straight alpha space.
371     /// </summary>
372     D2D1_COLOR_INTERPOLATION_MODE_STRAIGHT = 0,
373 
374     /// <summary>
375     /// Colors will be interpolated in premultiplied alpha space.
376     /// </summary>
377     D2D1_COLOR_INTERPOLATION_MODE_PREMULTIPLIED = 1,
378     D2D1_COLOR_INTERPOLATION_MODE_FORCE_DWORD = 0xffffffff
379 
380 } D2D1_COLOR_INTERPOLATION_MODE;
381 
382 typedef D2D_VECTOR_2F D2D1_VECTOR_2F;
383 typedef D2D_VECTOR_3F D2D1_VECTOR_3F;
384 typedef D2D_VECTOR_4F D2D1_VECTOR_4F;
385 
386 /// <summary>
387 /// Extended bitmap properties.
388 /// </summary>
389 typedef struct D2D1_BITMAP_PROPERTIES1
390 {
391     D2D1_PIXEL_FORMAT pixelFormat;
392     FLOAT dpiX;
393     FLOAT dpiY;
394 
395     /// <summary>
396     /// Specifies how the bitmap can be used.
397     /// </summary>
398     D2D1_BITMAP_OPTIONS bitmapOptions;
399     _Field_size_opt_(1) ID2D1ColorContext *colorContext;
400 
401 } D2D1_BITMAP_PROPERTIES1;
402 
403 /// <summary>
404 /// Describes mapped memory from the ID2D1Bitmap1::Map API.
405 /// </summary>
406 typedef struct D2D1_MAPPED_RECT
407 {
408     UINT32 pitch;
409     BYTE *bits;
410 
411 } D2D1_MAPPED_RECT;
412 
413 /// <summary>
414 /// This controls advanced settings of the Direct2D imaging pipeline.
415 /// </summary>
416 typedef struct D2D1_RENDERING_CONTROLS
417 {
418 
419     /// <summary>
420     /// The default buffer precision, used if the precision isn't otherwise specified.
421     /// </summary>
422     D2D1_BUFFER_PRECISION bufferPrecision;
423 
424     /// <summary>
425     /// The size of allocated tiles used to render imaging effects.
426     /// </summary>
427     D2D1_SIZE_U tileSize;
428 
429 } D2D1_RENDERING_CONTROLS;
430 
431 /// <summary>
432 /// This identifies a certain input connection of a certain effect.
433 /// </summary>
434 typedef struct D2D1_EFFECT_INPUT_DESCRIPTION
435 {
436 
437     /// <summary>
438     /// The effect whose input connection is being specified.
439     /// </summary>
440     ID2D1Effect *effect;
441 
442     /// <summary>
443     /// The index of the input connection into the specified effect.
444     /// </summary>
445     UINT32 inputIndex;
446 
447     /// <summary>
448     /// The rectangle which would be available on the specified input connection during
449     /// render operations.
450     /// </summary>
451     D2D1_RECT_F inputRectangle;
452 
453 } D2D1_EFFECT_INPUT_DESCRIPTION;
454 
455 typedef D2D_MATRIX_4X3_F D2D1_MATRIX_4X3_F;
456 typedef D2D_MATRIX_4X4_F D2D1_MATRIX_4X4_F;
457 typedef D2D_MATRIX_5X4_F D2D1_MATRIX_5X4_F;
458 
459 /// <summary>
460 /// Describes a point along a path.
461 /// </summary>
462 typedef struct D2D1_POINT_DESCRIPTION
463 {
464     D2D1_POINT_2F point;
465     D2D1_POINT_2F unitTangentVector;
466     UINT32 endSegment;
467     UINT32 endFigure;
468     FLOAT lengthToEndSegment;
469 
470 } D2D1_POINT_DESCRIPTION;
471 
472 /// <summary>
473 /// Creation properties for an image brush.
474 /// </summary>
475 typedef struct D2D1_IMAGE_BRUSH_PROPERTIES
476 {
477     D2D1_RECT_F sourceRectangle;
478     D2D1_EXTEND_MODE extendModeX;
479     D2D1_EXTEND_MODE extendModeY;
480     D2D1_INTERPOLATION_MODE interpolationMode;
481 
482 } D2D1_IMAGE_BRUSH_PROPERTIES;
483 
484 /// <summary>
485 /// Describes the extend modes and the interpolation mode of an ID2D1BitmapBrush.
486 /// </summary>
487 typedef struct D2D1_BITMAP_BRUSH_PROPERTIES1
488 {
489     D2D1_EXTEND_MODE extendModeX;
490     D2D1_EXTEND_MODE extendModeY;
491     D2D1_INTERPOLATION_MODE interpolationMode;
492 
493 } D2D1_BITMAP_BRUSH_PROPERTIES1;
494 
495 /// <summary>
496 /// This defines how geometries should be drawn and widened.
497 /// </summary>
498 typedef struct D2D1_STROKE_STYLE_PROPERTIES1
499 {
500     D2D1_CAP_STYLE startCap;
501     D2D1_CAP_STYLE endCap;
502     D2D1_CAP_STYLE dashCap;
503     D2D1_LINE_JOIN lineJoin;
504     FLOAT miterLimit;
505     D2D1_DASH_STYLE dashStyle;
506     FLOAT dashOffset;
507 
508     /// <summary>
509     /// How the nib of the stroke is influenced by the context properties.
510     /// </summary>
511     D2D1_STROKE_TRANSFORM_TYPE transformType;
512 
513 } D2D1_STROKE_STYLE_PROPERTIES1;
514 
515 /// <summary>
516 /// Specifies how the layer contents should be prepared.
517 /// </summary>
518 typedef enum D2D1_LAYER_OPTIONS1
519 {
520     D2D1_LAYER_OPTIONS1_NONE = 0,
521     D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND = 1,
522     D2D1_LAYER_OPTIONS1_IGNORE_ALPHA = 2,
523     D2D1_LAYER_OPTIONS1_FORCE_DWORD = 0xffffffff
524 
525 } D2D1_LAYER_OPTIONS1;
526 
527 DEFINE_ENUM_FLAG_OPERATORS(D2D1_LAYER_OPTIONS1);
528 
529 /// <summary>
530 /// All parameters related to pushing a layer.
531 /// </summary>
532 typedef struct D2D1_LAYER_PARAMETERS1
533 {
534     D2D1_RECT_F contentBounds;
535     _Field_size_opt_(1) ID2D1Geometry *geometricMask;
536     D2D1_ANTIALIAS_MODE maskAntialiasMode;
537     D2D1_MATRIX_3X2_F maskTransform;
538     FLOAT opacity;
539     _Field_size_opt_(1) ID2D1Brush *opacityBrush;
540     D2D1_LAYER_OPTIONS1 layerOptions;
541 
542 } D2D1_LAYER_PARAMETERS1;
543 
544 /// <summary>
545 /// Defines when font resources should be subset during printing.
546 /// </summary>
547 typedef enum D2D1_PRINT_FONT_SUBSET_MODE
548 {
549 
550     /// <summary>
551     /// Subset for used glyphs, send and discard font resource after every five pages
552     /// </summary>
553     D2D1_PRINT_FONT_SUBSET_MODE_DEFAULT = 0,
554 
555     /// <summary>
556     /// Subset for used glyphs, send and discard font resource after each page
557     /// </summary>
558     D2D1_PRINT_FONT_SUBSET_MODE_EACHPAGE = 1,
559 
560     /// <summary>
561     /// Do not subset, reuse font for all pages, send it after first page
562     /// </summary>
563     D2D1_PRINT_FONT_SUBSET_MODE_NONE = 2,
564     D2D1_PRINT_FONT_SUBSET_MODE_FORCE_DWORD = 0xffffffff
565 
566 } D2D1_PRINT_FONT_SUBSET_MODE;
567 
568 /// <summary>
569 /// This describes the drawing state.
570 /// </summary>
571 typedef struct D2D1_DRAWING_STATE_DESCRIPTION1
572 {
573     D2D1_ANTIALIAS_MODE antialiasMode;
574     D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode;
575     D2D1_TAG tag1;
576     D2D1_TAG tag2;
577     D2D1_MATRIX_3X2_F transform;
578     D2D1_PRIMITIVE_BLEND primitiveBlend;
579     D2D1_UNIT_MODE unitMode;
580 
581 } D2D1_DRAWING_STATE_DESCRIPTION1;
582 
583 /// <summary>
584 /// The creation properties for a ID2D1PrintControl object.
585 /// </summary>
586 typedef struct D2D1_PRINT_CONTROL_PROPERTIES
587 {
588     D2D1_PRINT_FONT_SUBSET_MODE fontSubset;
589 
590     /// <summary>
591     /// DPI for rasterization of all unsupported D2D commands or options, defaults to
592     /// 150.0
593     /// </summary>
594     FLOAT rasterDPI;
595 
596     /// <summary>
597     /// Color space for vector graphics in XPS package
598     /// </summary>
599     D2D1_COLOR_SPACE colorSpace;
600 
601 } D2D1_PRINT_CONTROL_PROPERTIES;
602 
603 /// <summary>
604 /// This specifies the options while simultaneously creating the device, factory,
605 /// and device context.
606 /// </summary>
607 typedef struct D2D1_CREATION_PROPERTIES
608 {
609 
610     /// <summary>
611     /// Describes locking behavior of D2D resources
612     /// </summary>
613     D2D1_THREADING_MODE threadingMode;
614     D2D1_DEBUG_LEVEL debugLevel;
615     D2D1_DEVICE_CONTEXT_OPTIONS options;
616 
617 } D2D1_CREATION_PROPERTIES;
618 
619 EXTERN_C CONST IID IID_ID2D1GdiMetafileSink;
620 EXTERN_C CONST IID IID_ID2D1GdiMetafile;
621 EXTERN_C CONST IID IID_ID2D1CommandSink;
622 EXTERN_C CONST IID IID_ID2D1CommandList;
623 EXTERN_C CONST IID IID_ID2D1PrintControl;
624 EXTERN_C CONST IID IID_ID2D1ImageBrush;
625 EXTERN_C CONST IID IID_ID2D1BitmapBrush1;
626 EXTERN_C CONST IID IID_ID2D1StrokeStyle1;
627 EXTERN_C CONST IID IID_ID2D1PathGeometry1;
628 EXTERN_C CONST IID IID_ID2D1Properties;
629 EXTERN_C CONST IID IID_ID2D1Effect;
630 EXTERN_C CONST IID IID_ID2D1Bitmap1;
631 EXTERN_C CONST IID IID_ID2D1ColorContext;
632 EXTERN_C CONST IID IID_ID2D1GradientStopCollection1;
633 EXTERN_C CONST IID IID_ID2D1DrawingStateBlock1;
634 EXTERN_C CONST IID IID_ID2D1DeviceContext;
635 EXTERN_C CONST IID IID_ID2D1Device;
636 EXTERN_C CONST IID IID_ID2D1Factory1;
637 EXTERN_C CONST IID IID_ID2D1Multithread;
638 
639 #ifndef D2D_USE_C_DEFINITIONS
640 
641 /// <summary>
642 /// User-implementable interface for introspecting on a metafile.
643 /// </summary>
644 interface DX_DECLARE_INTERFACE("82237326-8111-4f7c-bcf4-b5c1175564fe") ID2D1GdiMetafileSink  : public IUnknown
645 {
646 
647     /// <summary>
648     /// Callback for examining a metafile record.
649     /// </summary>
650     STDMETHOD(ProcessRecord)(
651         DWORD recordType,
652         _In_opt_ CONST void *recordData,
653         DWORD recordDataSize
654         ) PURE;
655 }; // interface ID2D1GdiMetafileSink
656 
657 /// <summary>
658 /// Interface encapsulating a GDI/GDI+ metafile.
659 /// </summary>
660 interface DX_DECLARE_INTERFACE("2f543dc3-cfc1-4211-864f-cfd91c6f3395") ID2D1GdiMetafile  : public ID2D1Resource
661 {
662 
663     /// <summary>
664     /// Play the metafile into a caller-supplied sink interface.
665     /// </summary>
666     STDMETHOD(Stream)(
667         _In_ ID2D1GdiMetafileSink *sink
668         ) PURE;
669 
670     /// <summary>
671     /// Gets the bounds of the metafile.
672     /// </summary>
673     STDMETHOD(GetBounds)(
674         _Out_ D2D1_RECT_F *bounds
675         ) PURE;
676 }; // interface ID2D1GdiMetafile
677 
678 /// <summary>
679 /// Caller-supplied implementation of an interface to receive the recorded command
680 /// list.
681 /// </summary>
682 interface DX_DECLARE_INTERFACE("54d7898a-a061-40a7-bec7-e465bcba2c4f") ID2D1CommandSink  : public IUnknown
683 {
684 
685     STDMETHOD(BeginDraw)(
686         ) PURE;
687 
688     STDMETHOD(EndDraw)(
689         ) PURE;
690 
691     STDMETHOD(SetAntialiasMode)(
692         D2D1_ANTIALIAS_MODE antialiasMode
693         ) PURE;
694 
695     STDMETHOD(SetTags)(
696         D2D1_TAG tag1,
697         D2D1_TAG tag2
698         ) PURE;
699 
700     STDMETHOD(SetTextAntialiasMode)(
701         D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode
702         ) PURE;
703 
704     STDMETHOD(SetTextRenderingParams)(
705         _In_opt_ IDWriteRenderingParams *textRenderingParams
706         ) PURE;
707 
708     STDMETHOD(SetTransform)(
709         _In_ CONST D2D1_MATRIX_3X2_F *transform
710         ) PURE;
711 
712     STDMETHOD(SetPrimitiveBlend)(
713         D2D1_PRIMITIVE_BLEND primitiveBlend
714         ) PURE;
715 
716     STDMETHOD(SetUnitMode)(
717         D2D1_UNIT_MODE unitMode
718         ) PURE;
719 
720     STDMETHOD(Clear)(
721         _In_opt_ CONST D2D1_COLOR_F *color
722         ) PURE;
723 
724     STDMETHOD(DrawGlyphRun)(
725         D2D1_POINT_2F baselineOrigin,
726         _In_ CONST DWRITE_GLYPH_RUN *glyphRun,
727         _In_opt_ CONST DWRITE_GLYPH_RUN_DESCRIPTION *glyphRunDescription,
728         _In_ ID2D1Brush *foregroundBrush,
729         DWRITE_MEASURING_MODE measuringMode
730         ) PURE;
731 
732     STDMETHOD(DrawLine)(
733         D2D1_POINT_2F point0,
734         D2D1_POINT_2F point1,
735         _In_ ID2D1Brush *brush,
736         FLOAT strokeWidth,
737         _In_opt_ ID2D1StrokeStyle *strokeStyle
738         ) PURE;
739 
740     STDMETHOD(DrawGeometry)(
741         _In_ ID2D1Geometry *geometry,
742         _In_ ID2D1Brush *brush,
743         FLOAT strokeWidth,
744         _In_opt_ ID2D1StrokeStyle *strokeStyle
745         ) PURE;
746 
747     STDMETHOD(DrawRectangle)(
748         _In_ CONST D2D1_RECT_F *rect,
749         _In_ ID2D1Brush *brush,
750         FLOAT strokeWidth,
751         _In_opt_ ID2D1StrokeStyle *strokeStyle
752         ) PURE;
753 
754     STDMETHOD(DrawBitmap)(
755         _In_ ID2D1Bitmap *bitmap,
756         _In_opt_ CONST D2D1_RECT_F *destinationRectangle,
757         FLOAT opacity,
758         D2D1_INTERPOLATION_MODE interpolationMode,
759         _In_opt_ CONST D2D1_RECT_F *sourceRectangle,
760         _In_opt_ CONST D2D1_MATRIX_4X4_F *perspectiveTransform
761         ) PURE;
762 
763     STDMETHOD(DrawImage)(
764         _In_ ID2D1Image *image,
765         _In_opt_ CONST D2D1_POINT_2F *targetOffset,
766         _In_opt_ CONST D2D1_RECT_F *imageRectangle,
767         D2D1_INTERPOLATION_MODE interpolationMode,
768         D2D1_COMPOSITE_MODE compositeMode
769         ) PURE;
770 
771     STDMETHOD(DrawGdiMetafile)(
772         _In_ ID2D1GdiMetafile *gdiMetafile,
773         _In_opt_ CONST D2D1_POINT_2F *targetOffset
774         ) PURE;
775 
776     STDMETHOD(FillMesh)(
777         _In_ ID2D1Mesh *mesh,
778         _In_ ID2D1Brush *brush
779         ) PURE;
780 
781     STDMETHOD(FillOpacityMask)(
782         _In_ ID2D1Bitmap *opacityMask,
783         _In_ ID2D1Brush *brush,
784         _In_opt_ CONST D2D1_RECT_F *destinationRectangle,
785         _In_opt_ CONST D2D1_RECT_F *sourceRectangle
786         ) PURE;
787 
788     STDMETHOD(FillGeometry)(
789         _In_ ID2D1Geometry *geometry,
790         _In_ ID2D1Brush *brush,
791         _In_opt_ ID2D1Brush *opacityBrush
792         ) PURE;
793 
794     STDMETHOD(FillRectangle)(
795         _In_ CONST D2D1_RECT_F *rect,
796         _In_ ID2D1Brush *brush
797         ) PURE;
798 
799     STDMETHOD(PushAxisAlignedClip)(
800         _In_ CONST D2D1_RECT_F *clipRect,
801         D2D1_ANTIALIAS_MODE antialiasMode
802         ) PURE;
803 
804     STDMETHOD(PushLayer)(
805         _In_ CONST D2D1_LAYER_PARAMETERS1 *layerParameters1,
806         _In_opt_ ID2D1Layer *layer
807         ) PURE;
808 
809     STDMETHOD(PopAxisAlignedClip)(
810         ) PURE;
811 
812     STDMETHOD(PopLayer)(
813         ) PURE;
814 }; // interface ID2D1CommandSink
815 
816 /// <summary>
817 /// The commandList interface.
818 /// </summary>
819 interface DX_DECLARE_INTERFACE("b4f34a19-2383-4d76-94f6-ec343657c3dc") ID2D1CommandList  : public ID2D1Image
820 {
821 
822     /// <summary>
823     /// Play the command list into a caller-supplied sink interface.
824     /// </summary>
825     STDMETHOD(Stream)(
826         _In_ ID2D1CommandSink *sink
827         ) PURE;
828 
829     /// <summary>
830     /// Marks the command list as ready for use.
831     /// </summary>
832     STDMETHOD(Close)(
833         ) PURE;
834 }; // interface ID2D1CommandList
835 
836 /// <summary>
837 /// Converts Direct2D primitives stored in an ID2D1CommandList into a fixed page
838 /// representation. The print sub-system then consumes the primitives.
839 /// </summary>
840 interface DX_DECLARE_INTERFACE("2c1d867d-c290-41c8-ae7e-34a98702e9a5") ID2D1PrintControl  : public IUnknown
841 {
842 
843     STDMETHOD(AddPage)(
844         _In_ ID2D1CommandList *commandList,
845         D2D_SIZE_F pageSize,
846         _In_opt_ IStream *pagePrintTicketStream,
847         _Out_opt_ D2D1_TAG *tag1 = NULL,
848         _Out_opt_ D2D1_TAG *tag2 = NULL
849         ) PURE;
850 
851     STDMETHOD(Close)(
852         ) PURE;
853 }; // interface ID2D1PrintControl
854 
855 /// <summary>
856 /// Provides a brush that can take any effect, command list or bitmap and use it to
857 /// fill a 2D shape.
858 /// </summary>
859 interface DX_DECLARE_INTERFACE("fe9e984d-3f95-407c-b5db-cb94d4e8f87c") ID2D1ImageBrush  : public ID2D1Brush
860 {
861 
862     STDMETHOD_(void, SetImage)(
863         _In_opt_ ID2D1Image *image
864         ) PURE;
865 
866     STDMETHOD_(void, SetExtendModeX)(
867         D2D1_EXTEND_MODE extendModeX
868         ) PURE;
869 
870     STDMETHOD_(void, SetExtendModeY)(
871         D2D1_EXTEND_MODE extendModeY
872         ) PURE;
873 
874     STDMETHOD_(void, SetInterpolationMode)(
875         D2D1_INTERPOLATION_MODE interpolationMode
876         ) PURE;
877 
878     STDMETHOD_(void, SetSourceRectangle)(
879         _In_ CONST D2D1_RECT_F *sourceRectangle
880         ) PURE;
881 
882     STDMETHOD_(void, GetImage)(
883         _Outptr_result_maybenull_ ID2D1Image **image
884         ) CONST PURE;
885 
886     STDMETHOD_(D2D1_EXTEND_MODE, GetExtendModeX)(
887         ) CONST PURE;
888 
889     STDMETHOD_(D2D1_EXTEND_MODE, GetExtendModeY)(
890         ) CONST PURE;
891 
892     STDMETHOD_(D2D1_INTERPOLATION_MODE, GetInterpolationMode)(
893         ) CONST PURE;
894 
895     STDMETHOD_(void, GetSourceRectangle)(
896         _Out_ D2D1_RECT_F *sourceRectangle
897         ) CONST PURE;
898 }; // interface ID2D1ImageBrush
899 
900 /// <summary>
901 /// A bitmap brush allows a bitmap to be used to fill a geometry.  Interpolation
902 /// mode is specified with D2D1_INTERPOLATION_MODE
903 /// </summary>
904 interface DX_DECLARE_INTERFACE("41343a53-e41a-49a2-91cd-21793bbb62e5") ID2D1BitmapBrush1  : public ID2D1BitmapBrush
905 {
906 
907     /// <summary>
908     /// Sets the interpolation mode used when this brush is used.
909     /// </summary>
910     STDMETHOD_(void, SetInterpolationMode1)(
911         D2D1_INTERPOLATION_MODE interpolationMode
912         ) PURE;
913 
914     STDMETHOD_(D2D1_INTERPOLATION_MODE, GetInterpolationMode1)(
915         ) CONST PURE;
916 }; // interface ID2D1BitmapBrush1
917 
918 /// <summary>
919 /// Extends a stroke style to allow nominal width strokes.
920 /// </summary>
921 interface DX_DECLARE_INTERFACE("10a72a66-e91c-43f4-993f-ddf4b82b0b4a") ID2D1StrokeStyle1  : public ID2D1StrokeStyle
922 {
923 
924     STDMETHOD_(D2D1_STROKE_TRANSFORM_TYPE, GetStrokeTransformType)(
925         ) CONST PURE;
926 }; // interface ID2D1StrokeStyle1
927 
928 /// <summary>
929 /// The ID2D1PathGeometry1 interface adds functionality to ID2D1PathGeometry. In
930 /// particular, it provides the path geometry-specific
931 /// ComputePointAndSegmentAtLength method.
932 /// </summary>
933 interface DX_DECLARE_INTERFACE("62baa2d2-ab54-41b7-b872-787e0106a421") ID2D1PathGeometry1  : public ID2D1PathGeometry
934 {
935 
936     STDMETHOD(ComputePointAndSegmentAtLength)(
937         FLOAT length,
938         UINT32 startSegment,
939         _In_opt_ CONST D2D1_MATRIX_3X2_F *worldTransform,
940         FLOAT flatteningTolerance,
941         _Out_ D2D1_POINT_DESCRIPTION *pointDescription
942         ) CONST PURE;
943 
944     COM_DECLSPEC_NOTHROW
945     HRESULT
ComputePointAndSegmentAtLength(FLOAT length,UINT32 startSegment,CONST D2D1_MATRIX_3X2_F & worldTransform,FLOAT flatteningTolerance,_Out_ D2D1_POINT_DESCRIPTION * pointDescription)946     ComputePointAndSegmentAtLength(
947         FLOAT length,
948         UINT32 startSegment,
949         CONST D2D1_MATRIX_3X2_F &worldTransform,
950         FLOAT flatteningTolerance,
951         _Out_ D2D1_POINT_DESCRIPTION *pointDescription
952         ) CONST
953     {
954         return ComputePointAndSegmentAtLength(length, startSegment, &worldTransform, flatteningTolerance, pointDescription);
955     }
956 
957     COM_DECLSPEC_NOTHROW
958     HRESULT
ComputePointAndSegmentAtLength(FLOAT length,UINT32 startSegment,_In_opt_ CONST D2D1_MATRIX_3X2_F * worldTransform,_Out_ D2D1_POINT_DESCRIPTION * pointDescription)959     ComputePointAndSegmentAtLength(
960         FLOAT length,
961         UINT32 startSegment,
962         _In_opt_ CONST D2D1_MATRIX_3X2_F *worldTransform,
963         _Out_ D2D1_POINT_DESCRIPTION *pointDescription
964         ) CONST
965     {
966         return ComputePointAndSegmentAtLength(length, startSegment, worldTransform, D2D1_DEFAULT_FLATTENING_TOLERANCE, pointDescription);
967     }
968 
969     COM_DECLSPEC_NOTHROW
970     HRESULT
ComputePointAndSegmentAtLength(FLOAT length,UINT32 startSegment,CONST D2D1_MATRIX_3X2_F & worldTransform,_Out_ D2D1_POINT_DESCRIPTION * pointDescription)971     ComputePointAndSegmentAtLength(
972         FLOAT length,
973         UINT32 startSegment,
974         CONST D2D1_MATRIX_3X2_F &worldTransform,
975         _Out_ D2D1_POINT_DESCRIPTION *pointDescription
976         ) CONST
977     {
978         return ComputePointAndSegmentAtLength(length, startSegment, &worldTransform, D2D1_DEFAULT_FLATTENING_TOLERANCE, pointDescription);
979     }
980 }; // interface ID2D1PathGeometry1
981 
982 /// <summary>
983 /// Represents a set of run-time bindable and discoverable properties that allow a
984 /// data-driven application to modify the state of a Direct2D effect.
985 /// </summary>
986 interface DX_DECLARE_INTERFACE("483473d7-cd46-4f9d-9d3a-3112aa80159d") ID2D1Properties  : public IUnknown
987 {
988 
989     /// <summary>
990     /// Returns the total number of custom properties in this interface.
991     /// </summary>
992     STDMETHOD_(UINT32, GetPropertyCount)(
993         ) CONST PURE;
994 
995     /// <summary>
996     /// Retrieves the property name from the given property index.
997     /// </summary>
998     STDMETHOD(GetPropertyName)(
999         UINT32 index,
1000         _Out_writes_(nameCount) PWSTR name,
1001         UINT32 nameCount
1002         ) CONST PURE;
1003 
1004     /// <summary>
1005     /// Returns the length of the property name from the given index.
1006     /// </summary>
1007     STDMETHOD_(UINT32, GetPropertyNameLength)(
1008         UINT32 index
1009         ) CONST PURE;
1010 
1011     /// <summary>
1012     /// Retrieves the type of the given property.
1013     /// </summary>
1014     STDMETHOD_(D2D1_PROPERTY_TYPE, GetType)(
1015         UINT32 index
1016         ) CONST PURE;
1017 
1018     /// <summary>
1019     /// Retrieves the property index for the given property name.
1020     /// </summary>
1021     STDMETHOD_(UINT32, GetPropertyIndex)(
1022         _In_ PCWSTR name
1023         ) CONST PURE;
1024 
1025     /// <summary>
1026     /// Sets the value of the given property using its name.
1027     /// </summary>
1028     STDMETHOD(SetValueByName)(
1029         _In_ PCWSTR name,
1030         D2D1_PROPERTY_TYPE type,
1031         _In_reads_(dataSize) CONST BYTE *data,
1032         UINT32 dataSize
1033         ) PURE;
1034 
1035     /// <summary>
1036     /// Sets the given value using the property index.
1037     /// </summary>
1038     STDMETHOD(SetValue)(
1039         UINT32 index,
1040         D2D1_PROPERTY_TYPE type,
1041         _In_reads_(dataSize) CONST BYTE *data,
1042         UINT32 dataSize
1043         ) PURE;
1044 
1045     /// <summary>
1046     /// Retrieves the given property or sub-property by name. '.' is the delimiter for
1047     /// sub-properties.
1048     /// </summary>
1049     STDMETHOD(GetValueByName)(
1050         _In_ PCWSTR name,
1051         D2D1_PROPERTY_TYPE type,
1052         _Out_writes_(dataSize) BYTE *data,
1053         UINT32 dataSize
1054         ) CONST PURE;
1055 
1056     /// <summary>
1057     /// Retrieves the given value by index.
1058     /// </summary>
1059     STDMETHOD(GetValue)(
1060         UINT32 index,
1061         D2D1_PROPERTY_TYPE type,
1062         _Out_writes_(dataSize) BYTE *data,
1063         UINT32 dataSize
1064         ) CONST PURE;
1065 
1066     /// <summary>
1067     /// Returns the value size for the given property index.
1068     /// </summary>
1069     STDMETHOD_(UINT32, GetValueSize)(
1070         UINT32 index
1071         ) CONST PURE;
1072 
1073     /// <summary>
1074     /// Retrieves the sub-properties of the given property by index.
1075     /// </summary>
1076     STDMETHOD(GetSubProperties)(
1077         UINT32 index,
1078         _COM_Outptr_result_maybenull_ ID2D1Properties **subProperties
1079         ) CONST PURE;
1080 
1081     COM_DECLSPEC_NOTHROW
1082     HRESULT
SetValueByName(_In_ PCWSTR name,_In_reads_ (dataSize)CONST BYTE * data,UINT32 dataSize)1083     SetValueByName(
1084         _In_ PCWSTR name,
1085         _In_reads_(dataSize) CONST BYTE *data,
1086         UINT32 dataSize
1087         )
1088     {
1089         return SetValueByName(name, D2D1_PROPERTY_TYPE_UNKNOWN, data, dataSize);
1090     }
1091 
1092     COM_DECLSPEC_NOTHROW
1093     HRESULT
SetValue(UINT32 index,_In_reads_ (dataSize)CONST BYTE * data,UINT32 dataSize)1094     SetValue(
1095         UINT32 index,
1096         _In_reads_(dataSize) CONST BYTE *data,
1097         UINT32 dataSize
1098         )
1099     {
1100         return SetValue(index, D2D1_PROPERTY_TYPE_UNKNOWN, data, dataSize);
1101     }
1102 
1103     COM_DECLSPEC_NOTHROW
1104     HRESULT
GetValueByName(_In_ PCWSTR name,_Out_writes_ (dataSize)BYTE * data,UINT32 dataSize)1105     GetValueByName(
1106         _In_ PCWSTR name,
1107         _Out_writes_(dataSize) BYTE *data,
1108         UINT32 dataSize
1109         ) CONST
1110     {
1111         return GetValueByName(name, D2D1_PROPERTY_TYPE_UNKNOWN, data, dataSize);
1112     }
1113 
1114     COM_DECLSPEC_NOTHROW
1115     HRESULT
GetValue(UINT32 index,_Out_writes_ (dataSize)BYTE * data,UINT32 dataSize)1116     GetValue(
1117         UINT32 index,
1118         _Out_writes_(dataSize) BYTE *data,
1119         UINT32 dataSize
1120         ) CONST
1121     {
1122         return GetValue(index, D2D1_PROPERTY_TYPE_UNKNOWN, data, dataSize);
1123     }
1124 
1125     //
1126     // Templatized helper functions:
1127     //
1128     template<typename T>
GetValueByName(_In_ PCWSTR propertyName,_Out_ T * value)1129     HRESULT GetValueByName(
1130         _In_ PCWSTR propertyName,
1131         _Out_ T *value
1132         ) const
1133     {
1134         return GetValueByName(propertyName, reinterpret_cast<BYTE *>(value), sizeof(*value));
1135     }
1136 
1137     template<typename T>
GetValueByName(_In_ PCWSTR propertyName)1138     T GetValueByName(
1139         _In_ PCWSTR propertyName
1140         ) const
1141     {
1142         T value;
1143         HRESULT ignoreHr = GetValueByName(propertyName, reinterpret_cast<BYTE *>(&value), sizeof(value));
1144         UNREFERENCED_PARAMETER(ignoreHr);
1145 
1146         return value;
1147     }
1148 
1149     template<typename T>
SetValueByName(_In_ PCWSTR propertyName,_In_ const T & value)1150     HRESULT SetValueByName(
1151         _In_ PCWSTR propertyName,
1152         _In_ const T &value
1153         )
1154     {
1155         return SetValueByName(propertyName, reinterpret_cast<const BYTE *>(&value), sizeof(value));
1156     }
1157 
1158     template<typename U>
GetValue(U index,_Out_writes_ (dataSize)BYTE * data,UINT32 dataSize)1159     HRESULT GetValue(
1160         U index,
1161         _Out_writes_(dataSize) BYTE *data,
1162         UINT32 dataSize
1163         ) CONST
1164     {
1165         return GetValue(static_cast<UINT32>(index), data, dataSize);
1166     }
1167 
1168     template<typename T, typename U>
GetValue(U index,_Out_ T * value)1169     HRESULT GetValue(
1170         U index,
1171         _Out_ T *value
1172         ) const
1173     {
1174         return GetValue(static_cast<UINT32>(index), reinterpret_cast<BYTE *>(value), sizeof(*value));
1175     }
1176 
1177     template<typename T, typename U>
GetValue(U index)1178     T GetValue(
1179         U index
1180         ) const
1181     {
1182         T value;
1183         HRESULT ignoreHr = GetValue(static_cast<UINT32>(index), reinterpret_cast<BYTE *>(&value), sizeof(value));
1184 
1185         // Unreferenced variable:
1186         ignoreHr;
1187 
1188         return value;
1189     }
1190 
1191     template<typename U>
SetValue(U index,_In_reads_ (dataSize)CONST BYTE * data,UINT32 dataSize)1192     HRESULT SetValue(
1193         U index,
1194         _In_reads_(dataSize) CONST BYTE *data,
1195         UINT32 dataSize
1196         )
1197     {
1198         return SetValue(static_cast<UINT32>(index), data, dataSize);
1199     }
1200 
1201     template<typename T, typename U>
SetValue(U index,_In_ const T & value)1202     HRESULT SetValue(
1203         U index,
1204         _In_ const T &value
1205         )
1206     {
1207         return SetValue(static_cast<UINT32>(index), reinterpret_cast<const BYTE *>(&value), sizeof(value));
1208     }
1209 
1210     template<typename U>
GetPropertyName(U index,_Out_writes_ (nameCount)PWSTR name,UINT32 nameCount)1211     HRESULT GetPropertyName(
1212         U index,
1213         _Out_writes_(nameCount) PWSTR name,
1214         UINT32 nameCount
1215         ) CONST
1216     {
1217         return GetPropertyName(static_cast<UINT32>(index), name, nameCount);
1218     }
1219 
1220     template<typename U>
GetPropertyNameLength(U index)1221     UINT32 GetPropertyNameLength(
1222         U index
1223         ) CONST
1224     {
1225         return GetPropertyNameLength(static_cast<UINT32>(index));
1226     }
1227 
1228     template<typename U>
GetType(U index)1229     D2D1_PROPERTY_TYPE GetType(
1230         U index
1231         ) CONST
1232     {
1233         return GetType(static_cast<UINT32>(index));
1234     }
1235 
1236     template<typename U>
GetValueSize(U index)1237     UINT32 GetValueSize(
1238         U index
1239         ) CONST
1240     {
1241         return GetValueSize(static_cast<UINT32>(index));
1242     }
1243 
1244     template<typename U>
GetSubProperties(U index,_Outptr_result_maybenull_ ID2D1Properties ** subProperties)1245     HRESULT GetSubProperties(
1246         U index,
1247         _Outptr_result_maybenull_ ID2D1Properties **subProperties
1248         ) CONST
1249     {
1250         return GetSubProperties(static_cast<UINT32>(index), subProperties);
1251     }
1252 }; // interface ID2D1Properties
1253 
1254 /// <summary>
1255 /// The effect interface. Properties control how the effect is rendered. The effect
1256 /// is Drawn with the DrawImage call.
1257 /// </summary>
1258 interface DX_DECLARE_INTERFACE("28211a43-7d89-476f-8181-2d6159b220ad") ID2D1Effect  : public ID2D1Properties
1259 {
1260 
1261     /// <summary>
1262     /// Sets the input to the given effect. The input can be a concrete bitmap or the
1263     /// output of another effect.
1264     /// </summary>
1265     STDMETHOD_(void, SetInput)(
1266         UINT32 index,
1267         _In_opt_ ID2D1Image *input,
1268         BOOL invalidate = TRUE
1269         ) PURE;
1270 
1271     /// <summary>
1272     /// If the effect supports a variable number of inputs, this sets the number of
1273     /// input that are currently active on the effect.
1274     /// </summary>
1275     STDMETHOD(SetInputCount)(
1276         UINT32 inputCount
1277         ) PURE;
1278 
1279     /// <summary>
1280     /// Returns the input image to the effect. The input could be another effect or a
1281     /// bitmap.
1282     /// </summary>
1283     STDMETHOD_(void, GetInput)(
1284         UINT32 index,
1285         _Outptr_result_maybenull_ ID2D1Image **input
1286         ) CONST PURE;
1287 
1288     /// <summary>
1289     /// This returns the number of input that are bound into this effect.
1290     /// </summary>
1291     STDMETHOD_(UINT32, GetInputCount)(
1292         ) CONST PURE;
1293 
1294     /// <summary>
1295     /// Returns the output image of the given effect. This can be set as the input to
1296     /// another effect or can be drawn with DrawImage.
1297     /// </summary>
1298     STDMETHOD_(void, GetOutput)(
1299         _Outptr_ ID2D1Image **outputImage
1300         ) CONST PURE;
1301 
1302     COM_DECLSPEC_NOTHROW
1303     void
1304     SetInputEffect(
1305         UINT32 index,
1306         _In_opt_ ID2D1Effect *inputEffect,
1307         BOOL invalidate = TRUE
1308         )
1309     {
1310 
1311         ID2D1Image *output = NULL;
1312         if (inputEffect != NULL)
1313         {
1314             inputEffect->GetOutput(&output);
1315         }
1316         SetInput(index, output, invalidate);
1317         if (output != NULL)
1318         {
1319             output->Release();
1320         }
1321     }
1322 }; // interface ID2D1Effect
1323 
1324 /// <summary>
1325 /// Represents a bitmap that can be used as a surface for an ID2D1DeviceContext or
1326 /// mapped into system memory, and can contain additional color context information.
1327 /// </summary>
1328 interface DX_DECLARE_INTERFACE("a898a84c-3873-4588-b08b-ebbf978df041") ID2D1Bitmap1  : public ID2D1Bitmap
1329 {
1330 
1331     /// <summary>
1332     /// Retrieves the color context information associated with the bitmap.
1333     /// </summary>
1334     STDMETHOD_(void, GetColorContext)(
1335         _Outptr_result_maybenull_ ID2D1ColorContext **colorContext
1336         ) CONST PURE;
1337 
1338     /// <summary>
1339     /// Retrieves the bitmap options used when creating the API.
1340     /// </summary>
1341     STDMETHOD_(D2D1_BITMAP_OPTIONS, GetOptions)(
1342         ) CONST PURE;
1343 
1344     /// <summary>
1345     /// Retrieves the DXGI surface from the corresponding bitmap, if the bitmap was
1346     /// created from a device derived from a D3D device.
1347     /// </summary>
1348     STDMETHOD(GetSurface)(
1349         _COM_Outptr_result_maybenull_ IDXGISurface **dxgiSurface
1350         ) CONST PURE;
1351 
1352     /// <summary>
1353     /// Maps the given bitmap into memory. The bitmap must have been created with the
1354     /// D2D1_BITMAP_OPTIONS_CPU_READ flag.
1355     /// </summary>
1356     STDMETHOD(Map)(
1357         D2D1_MAP_OPTIONS options,
1358         _Out_ D2D1_MAPPED_RECT *mappedRect
1359         ) PURE;
1360 
1361     /// <summary>
1362     /// Unmaps the given bitmap from memory.
1363     /// </summary>
1364     STDMETHOD(Unmap)(
1365         ) PURE;
1366 }; // interface ID2D1Bitmap1
1367 
1368 /// <summary>
1369 /// Represents a color context that can be used with an ID2D1Bitmap1 object.
1370 /// </summary>
1371 interface DX_DECLARE_INTERFACE("1c4820bb-5771-4518-a581-2fe4dd0ec657") ID2D1ColorContext  : public ID2D1Resource
1372 {
1373 
1374     /// <summary>
1375     /// Retrieves the color space of the color context.
1376     /// </summary>
1377     STDMETHOD_(D2D1_COLOR_SPACE, GetColorSpace)(
1378         ) CONST PURE;
1379 
1380     /// <summary>
1381     /// Retrieves the size of the color profile, in bytes.
1382     /// </summary>
1383     STDMETHOD_(UINT32, GetProfileSize)(
1384         ) CONST PURE;
1385 
1386     /// <summary>
1387     /// Retrieves the color profile bytes.
1388     /// </summary>
1389     STDMETHOD(GetProfile)(
1390         _Out_writes_(profileSize) BYTE *profile,
1391         UINT32 profileSize
1392         ) CONST PURE;
1393 }; // interface ID2D1ColorContext
1394 
1395 /// <summary>
1396 /// Represents an collection of gradient stops that can then be the source resource
1397 /// for either a linear or radial gradient brush.
1398 /// </summary>
1399 interface DX_DECLARE_INTERFACE("ae1572f4-5dd0-4777-998b-9279472ae63b") ID2D1GradientStopCollection1  : public ID2D1GradientStopCollection
1400 {
1401 
1402     /// <summary>
1403     /// Copies the gradient stops from the collection into the caller's memory. If this
1404     /// object was created using ID2D1DeviceContext::CreateGradientStopCollection, this
1405     /// method returns the same values as were specified in the creation method. If this
1406     /// object was created using ID2D1RenderTarget::CreateGradientStopCollection, the
1407     /// stops returned here will first be transformed into the gamma space specified by
1408     /// the colorInterpolationGamma parameter.
1409     /// </summary>
1410     STDMETHOD_(void, GetGradientStops1)(
1411         _Out_writes_to_(gradientStopsCount, _Inexpressible_("Retrieved through GetGradientStopCount()") ) D2D1_GRADIENT_STOP *gradientStops,
1412         UINT32 gradientStopsCount
1413         ) CONST PURE;
1414 
1415     /// <summary>
1416     /// Returns the color space in which interpolation occurs. If this object was
1417     /// created using ID2D1RenderTarget::CreateGradientStopCollection, this method
1418     /// returns the color space related to the color interpolation gamma.
1419     /// </summary>
1420     STDMETHOD_(D2D1_COLOR_SPACE, GetPreInterpolationSpace)(
1421         ) CONST PURE;
1422 
1423     /// <summary>
1424     /// Returns the color space colors will be converted to after interpolation occurs.
1425     /// If this object was created using
1426     /// ID2D1RenderTarget::CreateGradientStopCollection, this method returns
1427     /// D2D1_COLOR_SPACE_SRGB.
1428     /// </summary>
1429     STDMETHOD_(D2D1_COLOR_SPACE, GetPostInterpolationSpace)(
1430         ) CONST PURE;
1431 
1432     /// <summary>
1433     /// Returns the buffer precision of this gradient. If this object was created using
1434     /// ID2D1RenderTarget::CreateGradientStopCollection, this method returns
1435     /// D2D1_BUFFER_PRECISION_8BPC_UNORM.
1436     /// </summary>
1437     STDMETHOD_(D2D1_BUFFER_PRECISION, GetBufferPrecision)(
1438         ) CONST PURE;
1439 
1440     /// <summary>
1441     /// Returns the interpolation mode used to interpolate colors in the gradient.
1442     /// </summary>
1443     STDMETHOD_(D2D1_COLOR_INTERPOLATION_MODE, GetColorInterpolationMode)(
1444         ) CONST PURE;
1445 }; // interface ID2D1GradientStopCollection1
1446 
1447 /// <summary>
1448 /// Represents drawing state.
1449 /// </summary>
1450 interface DX_DECLARE_INTERFACE("689f1f85-c72e-4e33-8f19-85754efd5ace") ID2D1DrawingStateBlock1  : public ID2D1DrawingStateBlock
1451 {
1452 
1453     /// <summary>
1454     /// Retrieves the state currently contained within this state block resource.
1455     /// </summary>
1456     STDMETHOD_(void, GetDescription)(
1457         _Out_ D2D1_DRAWING_STATE_DESCRIPTION1 *stateDescription
1458         ) CONST PURE;
1459 
1460     using ID2D1DrawingStateBlock::GetDescription;
1461 
1462     /// <summary>
1463     /// Sets the state description of this state block resource.
1464     /// </summary>
1465     STDMETHOD_(void, SetDescription)(
1466         _In_ CONST D2D1_DRAWING_STATE_DESCRIPTION1 *stateDescription
1467         ) PURE;
1468 
1469     using ID2D1DrawingStateBlock::SetDescription;
1470 }; // interface ID2D1DrawingStateBlock1
1471 
1472 /// <summary>
1473 /// The device context represents a set of state and a command buffer that is used
1474 /// to render to a target bitmap.
1475 /// </summary>
1476 interface DX_DECLARE_INTERFACE("e8f7fe7a-191c-466d-ad95-975678bda998") ID2D1DeviceContext  : public ID2D1RenderTarget
1477 {
1478 
1479     /// <summary>
1480     /// Creates a bitmap with extended bitmap properties, potentially from a block of
1481     /// memory.
1482     /// </summary>
1483     STDMETHOD(CreateBitmap)(
1484         D2D1_SIZE_U size,
1485         _In_opt_ CONST void *sourceData,
1486         UINT32 pitch,
1487         _In_ CONST D2D1_BITMAP_PROPERTIES1 *bitmapProperties,
1488         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1489         ) PURE;
1490 
1491     using ID2D1RenderTarget::CreateBitmap;
1492 
1493     /// <summary>
1494     /// Create a D2D bitmap by copying a WIC bitmap.
1495     /// </summary>
1496     STDMETHOD(CreateBitmapFromWicBitmap)(
1497         _In_ IWICBitmapSource *wicBitmapSource,
1498         _In_opt_ CONST D2D1_BITMAP_PROPERTIES1 *bitmapProperties,
1499         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1500         ) PURE;
1501 
1502     using ID2D1RenderTarget::CreateBitmapFromWicBitmap;
1503 
1504     /// <summary>
1505     /// Creates a color context from a color space.  If the space is Custom, the context
1506     /// is initialized from the profile/profileSize arguments.  Otherwise the context is
1507     /// initialized with the profile bytes associated with the space and
1508     /// profile/profileSize are ignored.
1509     /// </summary>
1510     STDMETHOD(CreateColorContext)(
1511         D2D1_COLOR_SPACE space,
1512         _In_reads_opt_(profileSize) CONST BYTE *profile,
1513         UINT32 profileSize,
1514         _COM_Outptr_ ID2D1ColorContext **colorContext
1515         ) PURE;
1516 
1517     STDMETHOD(CreateColorContextFromFilename)(
1518         _In_ PCWSTR filename,
1519         _COM_Outptr_ ID2D1ColorContext **colorContext
1520         ) PURE;
1521 
1522     STDMETHOD(CreateColorContextFromWicColorContext)(
1523         _In_ IWICColorContext *wicColorContext,
1524         _COM_Outptr_ ID2D1ColorContext **colorContext
1525         ) PURE;
1526 
1527     /// <summary>
1528     /// Creates a bitmap from a DXGI surface with a set of extended properties.
1529     /// </summary>
1530     STDMETHOD(CreateBitmapFromDxgiSurface)(
1531         _In_ IDXGISurface *surface,
1532         _In_opt_ CONST D2D1_BITMAP_PROPERTIES1 *bitmapProperties,
1533         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1534         ) PURE;
1535 
1536     /// <summary>
1537     /// Create a new effect, the effect must either be built in or previously registered
1538     /// through ID2D1Factory1::RegisterEffectFromStream or
1539     /// ID2D1Factory1::RegisterEffectFromString.
1540     /// </summary>
1541     STDMETHOD(CreateEffect)(
1542         _In_ REFCLSID effectId,
1543         _COM_Outptr_ ID2D1Effect **effect
1544         ) PURE;
1545 
1546     /// <summary>
1547     /// A gradient stop collection represents a set of stops in an ideal unit length.
1548     /// This is the source resource for a linear gradient and radial gradient brush.
1549     /// </summary>
1550     /// <param name="preInterpolationSpace">Specifies both the input color space and the
1551     /// space in which the color interpolation occurs.</param>
1552     /// <param name="postInterpolationSpace">Specifies the color space colors will be
1553     /// converted to after interpolation occurs.</param>
1554     /// <param name="bufferPrecision">Specifies the precision in which the gradient
1555     /// buffer will be held.</param>
1556     /// <param name="extendMode">Specifies how the gradient will be extended outside of
1557     /// the unit length.</param>
1558     /// <param name="colorInterpolationMode">Determines if colors will be interpolated
1559     /// in straight alpha or premultiplied alpha space.</param>
1560     STDMETHOD(CreateGradientStopCollection)(
1561         _In_reads_(straightAlphaGradientStopsCount) CONST D2D1_GRADIENT_STOP *straightAlphaGradientStops,
1562         _In_range_(>=,1) UINT32 straightAlphaGradientStopsCount,
1563         D2D1_COLOR_SPACE preInterpolationSpace,
1564         D2D1_COLOR_SPACE postInterpolationSpace,
1565         D2D1_BUFFER_PRECISION bufferPrecision,
1566         D2D1_EXTEND_MODE extendMode,
1567         D2D1_COLOR_INTERPOLATION_MODE colorInterpolationMode,
1568         _COM_Outptr_ ID2D1GradientStopCollection1 **gradientStopCollection1
1569         ) PURE;
1570 
1571     using ID2D1RenderTarget::CreateGradientStopCollection;
1572 
1573     /// <summary>
1574     /// Creates an image brush, the input image can be any type of image, including a
1575     /// bitmap, effect and a command list.
1576     /// </summary>
1577     STDMETHOD(CreateImageBrush)(
1578         _In_opt_ ID2D1Image *image,
1579         _In_ CONST D2D1_IMAGE_BRUSH_PROPERTIES *imageBrushProperties,
1580         _In_opt_ CONST D2D1_BRUSH_PROPERTIES *brushProperties,
1581         _COM_Outptr_ ID2D1ImageBrush **imageBrush
1582         ) PURE;
1583 
1584     STDMETHOD(CreateBitmapBrush)(
1585         _In_opt_ ID2D1Bitmap *bitmap,
1586         _In_opt_ CONST D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmapBrushProperties,
1587         _In_opt_ CONST D2D1_BRUSH_PROPERTIES *brushProperties,
1588         _COM_Outptr_ ID2D1BitmapBrush1 **bitmapBrush
1589         ) PURE;
1590 
1591     using ID2D1RenderTarget::CreateBitmapBrush;
1592 
1593     /// <summary>
1594     /// Creates a new command list.
1595     /// </summary>
1596     STDMETHOD(CreateCommandList)(
1597         _COM_Outptr_ ID2D1CommandList **commandList
1598         ) PURE;
1599 
1600     /// <summary>
1601     /// Indicates whether the format is supported by D2D.
1602     /// </summary>
1603     STDMETHOD_(BOOL, IsDxgiFormatSupported)(
1604         DXGI_FORMAT format
1605         ) CONST PURE;
1606 
1607     /// <summary>
1608     /// Indicates whether the buffer precision is supported by D2D.
1609     /// </summary>
1610     STDMETHOD_(BOOL, IsBufferPrecisionSupported)(
1611         D2D1_BUFFER_PRECISION bufferPrecision
1612         ) CONST PURE;
1613 
1614     /// <summary>
1615     /// This retrieves the local-space bounds in DIPs of the current image using the
1616     /// device context DPI.
1617     /// </summary>
1618     STDMETHOD(GetImageLocalBounds)(
1619         _In_ ID2D1Image *image,
1620         _Out_ D2D1_RECT_F *localBounds
1621         ) CONST PURE;
1622 
1623     /// <summary>
1624     /// This retrieves the world-space bounds in DIPs of the current image using the
1625     /// device context DPI.
1626     /// </summary>
1627     STDMETHOD(GetImageWorldBounds)(
1628         _In_ ID2D1Image *image,
1629         _Out_ D2D1_RECT_F *worldBounds
1630         ) CONST PURE;
1631 
1632     /// <summary>
1633     /// Retrieves the world-space bounds in DIPs of the glyph run using the device
1634     /// context DPI.
1635     /// </summary>
1636     STDMETHOD(GetGlyphRunWorldBounds)(
1637         D2D1_POINT_2F baselineOrigin,
1638         _In_ CONST DWRITE_GLYPH_RUN *glyphRun,
1639         DWRITE_MEASURING_MODE measuringMode,
1640         _Out_ D2D1_RECT_F *bounds
1641         ) CONST PURE;
1642 
1643     /// <summary>
1644     /// Retrieves the device associated with this device context.
1645     /// </summary>
1646     STDMETHOD_(void, GetDevice)(
1647         _Outptr_ ID2D1Device **device
1648         ) CONST PURE;
1649 
1650     /// <summary>
1651     /// Sets the target for this device context to point to the given image. The image
1652     /// can be a command list or a bitmap created with the D2D1_BITMAP_OPTIONS_TARGET
1653     /// flag.
1654     /// </summary>
1655     STDMETHOD_(void, SetTarget)(
1656         _In_opt_ ID2D1Image *image
1657         ) PURE;
1658 
1659     /// <summary>
1660     /// Gets the target that this device context is currently pointing to.
1661     /// </summary>
1662     STDMETHOD_(void, GetTarget)(
1663         _Outptr_result_maybenull_ ID2D1Image **image
1664         ) CONST PURE;
1665 
1666     /// <summary>
1667     /// Sets tuning parameters for internal rendering inside the device context.
1668     /// </summary>
1669     STDMETHOD_(void, SetRenderingControls)(
1670         _In_ CONST D2D1_RENDERING_CONTROLS *renderingControls
1671         ) PURE;
1672 
1673     /// <summary>
1674     /// This retrieves the rendering controls currently selected into the device
1675     /// context.
1676     /// </summary>
1677     STDMETHOD_(void, GetRenderingControls)(
1678         _Out_ D2D1_RENDERING_CONTROLS *renderingControls
1679         ) CONST PURE;
1680 
1681     /// <summary>
1682     /// Changes the primitive blending mode for all of the rendering operations.
1683     /// </summary>
1684     STDMETHOD_(void, SetPrimitiveBlend)(
1685         D2D1_PRIMITIVE_BLEND primitiveBlend
1686         ) PURE;
1687 
1688     /// <summary>
1689     /// Returns the primitive blend currently selected into the device context.
1690     /// </summary>
1691     STDMETHOD_(D2D1_PRIMITIVE_BLEND, GetPrimitiveBlend)(
1692         ) CONST PURE;
1693 
1694     /// <summary>
1695     /// Changes the units used for all of the rendering operations.
1696     /// </summary>
1697     STDMETHOD_(void, SetUnitMode)(
1698         D2D1_UNIT_MODE unitMode
1699         ) PURE;
1700 
1701     /// <summary>
1702     /// Returns the unit mode currently set on the device context.
1703     /// </summary>
1704     STDMETHOD_(D2D1_UNIT_MODE, GetUnitMode)(
1705         ) CONST PURE;
1706 
1707     /// <summary>
1708     /// Draws the glyph run with an extended description to describe the glyphs.
1709     /// </summary>
1710     STDMETHOD_(void, DrawGlyphRun)(
1711         D2D1_POINT_2F baselineOrigin,
1712         _In_ CONST DWRITE_GLYPH_RUN *glyphRun,
1713         _In_opt_ CONST DWRITE_GLYPH_RUN_DESCRIPTION *glyphRunDescription,
1714         _In_ ID2D1Brush *foregroundBrush,
1715         DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE_NATURAL
1716         ) PURE;
1717 
1718     using ID2D1RenderTarget::DrawGlyphRun;
1719 
1720     /// <summary>
1721     /// Draw an image to the device context. The image represents either a concrete
1722     /// bitmap or the output of an effect graph.
1723     /// </summary>
1724     STDMETHOD_(void, DrawImage)(
1725         _In_ ID2D1Image *image,
1726         _In_opt_ CONST D2D1_POINT_2F *targetOffset = NULL,
1727         _In_opt_ CONST D2D1_RECT_F *imageRectangle = NULL,
1728         D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR,
1729         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1730         ) PURE;
1731 
1732     /// <summary>
1733     /// Draw a metafile to the device context.
1734     /// </summary>
1735     STDMETHOD_(void, DrawGdiMetafile)(
1736         _In_ ID2D1GdiMetafile *gdiMetafile,
1737         _In_opt_ CONST D2D1_POINT_2F *targetOffset = NULL
1738         ) PURE;
1739 
1740     STDMETHOD_(void, DrawBitmap)(
1741         _In_ ID2D1Bitmap *bitmap,
1742         _In_opt_ CONST D2D1_RECT_F *destinationRectangle,
1743         FLOAT opacity,
1744         D2D1_INTERPOLATION_MODE interpolationMode,
1745         _In_opt_ CONST D2D1_RECT_F *sourceRectangle = NULL,
1746         _In_opt_ CONST D2D1_MATRIX_4X4_F *perspectiveTransform = NULL
1747         ) PURE;
1748 
1749     using ID2D1RenderTarget::DrawBitmap;
1750 
1751     /// <summary>
1752     /// Push a layer on the device context.
1753     /// </summary>
1754     STDMETHOD_(void, PushLayer)(
1755         _In_ CONST D2D1_LAYER_PARAMETERS1 *layerParameters,
1756         _In_opt_ ID2D1Layer *layer
1757         ) PURE;
1758 
1759     using ID2D1RenderTarget::PushLayer;
1760 
1761     /// <summary>
1762     /// This indicates that a portion of an effect's input is invalid. This method can
1763     /// be called many times.
1764     /// </summary>
1765     STDMETHOD(InvalidateEffectInputRectangle)(
1766         _In_ ID2D1Effect *effect,
1767         UINT32 input,
1768         _In_ CONST D2D1_RECT_F *inputRectangle
1769         ) PURE;
1770 
1771     /// <summary>
1772     /// Gets the number of invalid ouptut rectangles that have accumulated at the
1773     /// effect.
1774     /// </summary>
1775     STDMETHOD(GetEffectInvalidRectangleCount)(
1776         _In_ ID2D1Effect *effect,
1777         _Out_ UINT32 *rectangleCount
1778         ) PURE;
1779 
1780     /// <summary>
1781     /// Gets the invalid rectangles that are at the output of the effect.
1782     /// </summary>
1783     STDMETHOD(GetEffectInvalidRectangles)(
1784         _In_ ID2D1Effect *effect,
1785         _Out_writes_(rectanglesCount) D2D1_RECT_F *rectangles,
1786         UINT32 rectanglesCount
1787         ) PURE;
1788 
1789     /// <summary>
1790     /// Gets the maximum region of each specified input which would be used during a
1791     /// subsequent rendering operation
1792     /// </summary>
1793     STDMETHOD(GetEffectRequiredInputRectangles)(
1794         _In_ ID2D1Effect *renderEffect,
1795         _In_opt_ CONST D2D1_RECT_F *renderImageRectangle,
1796         _In_reads_(inputCount) CONST D2D1_EFFECT_INPUT_DESCRIPTION *inputDescriptions,
1797         _Out_writes_(inputCount) D2D1_RECT_F *requiredInputRects,
1798         UINT32 inputCount
1799         ) PURE;
1800 
1801     /// <summary>
1802     /// Fill using the alpha channel of the supplied opacity mask bitmap. The brush
1803     /// opacity will be modulated by the mask. The render target antialiasing mode must
1804     /// be set to aliased.
1805     /// </summary>
1806     STDMETHOD_(void, FillOpacityMask)(
1807         _In_ ID2D1Bitmap *opacityMask,
1808         _In_ ID2D1Brush *brush,
1809         _In_opt_ CONST D2D1_RECT_F *destinationRectangle = NULL,
1810         _In_opt_ CONST D2D1_RECT_F *sourceRectangle = NULL
1811         ) PURE;
1812 
1813     using ID2D1RenderTarget::FillOpacityMask;
1814 
1815     COM_DECLSPEC_NOTHROW
1816     HRESULT
CreateBitmap(D2D1_SIZE_U size,_In_opt_ CONST void * sourceData,UINT32 pitch,CONST D2D1_BITMAP_PROPERTIES1 & bitmapProperties,_COM_Outptr_ ID2D1Bitmap1 ** bitmap)1817     CreateBitmap(
1818         D2D1_SIZE_U size,
1819         _In_opt_ CONST void *sourceData,
1820         UINT32 pitch,
1821         CONST D2D1_BITMAP_PROPERTIES1 &bitmapProperties,
1822         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1823         )
1824     {
1825         return CreateBitmap(size, sourceData, pitch, &bitmapProperties, bitmap);
1826     }
1827 
1828     /// <summary>
1829     /// Create a D2D bitmap by copying a WIC bitmap.
1830     /// </summary>
1831     COM_DECLSPEC_NOTHROW
1832     HRESULT
CreateBitmapFromWicBitmap(_In_ IWICBitmapSource * wicBitmapSource,CONST D2D1_BITMAP_PROPERTIES1 & bitmapProperties,_COM_Outptr_ ID2D1Bitmap1 ** bitmap)1833     CreateBitmapFromWicBitmap(
1834         _In_ IWICBitmapSource *wicBitmapSource,
1835         CONST D2D1_BITMAP_PROPERTIES1 &bitmapProperties,
1836         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1837         )
1838     {
1839         return CreateBitmapFromWicBitmap(wicBitmapSource, &bitmapProperties, bitmap);
1840     }
1841 
1842     /// <summary>
1843     /// Create a D2D bitmap by copying a WIC bitmap.
1844     /// </summary>
1845     COM_DECLSPEC_NOTHROW
1846     HRESULT
CreateBitmapFromWicBitmap(_In_ IWICBitmapSource * wicBitmapSource,_COM_Outptr_ ID2D1Bitmap1 ** bitmap)1847     CreateBitmapFromWicBitmap(
1848         _In_ IWICBitmapSource *wicBitmapSource,
1849         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1850         )
1851     {
1852         return CreateBitmapFromWicBitmap(wicBitmapSource, NULL, bitmap);
1853     }
1854 
1855     COM_DECLSPEC_NOTHROW
1856     HRESULT
CreateBitmapFromDxgiSurface(_In_ IDXGISurface * surface,CONST D2D1_BITMAP_PROPERTIES1 & bitmapProperties,_COM_Outptr_ ID2D1Bitmap1 ** bitmap)1857     CreateBitmapFromDxgiSurface(
1858         _In_ IDXGISurface *surface,
1859         CONST D2D1_BITMAP_PROPERTIES1 &bitmapProperties,
1860         _COM_Outptr_ ID2D1Bitmap1 **bitmap
1861         )
1862     {
1863         return CreateBitmapFromDxgiSurface(surface, &bitmapProperties, bitmap);
1864     }
1865 
1866     COM_DECLSPEC_NOTHROW
1867     HRESULT
CreateImageBrush(_In_opt_ ID2D1Image * image,CONST D2D1_IMAGE_BRUSH_PROPERTIES & imageBrushProperties,CONST D2D1_BRUSH_PROPERTIES & brushProperties,_COM_Outptr_ ID2D1ImageBrush ** imageBrush)1868     CreateImageBrush(
1869         _In_opt_ ID2D1Image *image,
1870         CONST D2D1_IMAGE_BRUSH_PROPERTIES &imageBrushProperties,
1871         CONST D2D1_BRUSH_PROPERTIES &brushProperties,
1872         _COM_Outptr_ ID2D1ImageBrush **imageBrush
1873         )
1874     {
1875         return CreateImageBrush(image, &imageBrushProperties, &brushProperties, imageBrush);
1876     }
1877 
1878     COM_DECLSPEC_NOTHROW
1879     HRESULT
CreateImageBrush(_In_opt_ ID2D1Image * image,CONST D2D1_IMAGE_BRUSH_PROPERTIES & imageBrushProperties,_COM_Outptr_ ID2D1ImageBrush ** imageBrush)1880     CreateImageBrush(
1881         _In_opt_ ID2D1Image *image,
1882         CONST D2D1_IMAGE_BRUSH_PROPERTIES &imageBrushProperties,
1883         _COM_Outptr_ ID2D1ImageBrush **imageBrush
1884         )
1885     {
1886         return CreateImageBrush(image,&imageBrushProperties, NULL, imageBrush);
1887     }
1888 
1889     COM_DECLSPEC_NOTHROW
1890     HRESULT
CreateBitmapBrush(_In_opt_ ID2D1Bitmap * bitmap,_COM_Outptr_ ID2D1BitmapBrush1 ** bitmapBrush)1891     CreateBitmapBrush(
1892         _In_opt_ ID2D1Bitmap *bitmap,
1893         _COM_Outptr_ ID2D1BitmapBrush1 **bitmapBrush
1894         )
1895     {
1896         return CreateBitmapBrush(bitmap, NULL, NULL, bitmapBrush);
1897     }
1898 
1899     COM_DECLSPEC_NOTHROW
1900     HRESULT
CreateBitmapBrush(_In_opt_ ID2D1Bitmap * bitmap,CONST D2D1_BITMAP_BRUSH_PROPERTIES1 & bitmapBrushProperties,_COM_Outptr_ ID2D1BitmapBrush1 ** bitmapBrush)1901     CreateBitmapBrush(
1902         _In_opt_ ID2D1Bitmap *bitmap,
1903         CONST D2D1_BITMAP_BRUSH_PROPERTIES1 &bitmapBrushProperties,
1904         _COM_Outptr_ ID2D1BitmapBrush1 **bitmapBrush
1905         )
1906     {
1907         return CreateBitmapBrush(bitmap, &bitmapBrushProperties, NULL, bitmapBrush);
1908     }
1909 
1910     COM_DECLSPEC_NOTHROW
1911     HRESULT
CreateBitmapBrush(_In_opt_ ID2D1Bitmap * bitmap,CONST D2D1_BITMAP_BRUSH_PROPERTIES1 & bitmapBrushProperties,CONST D2D1_BRUSH_PROPERTIES & brushProperties,_COM_Outptr_ ID2D1BitmapBrush1 ** bitmapBrush)1912     CreateBitmapBrush(
1913         _In_opt_ ID2D1Bitmap *bitmap,
1914         CONST D2D1_BITMAP_BRUSH_PROPERTIES1 &bitmapBrushProperties,
1915         CONST D2D1_BRUSH_PROPERTIES &brushProperties,
1916         _COM_Outptr_ ID2D1BitmapBrush1 **bitmapBrush
1917         )
1918     {
1919         return CreateBitmapBrush(bitmap, &bitmapBrushProperties, &brushProperties, bitmapBrush);
1920     }
1921 
1922     /// <summary>
1923     /// Draws the output of the effect as an image.
1924     /// </summary>
1925     COM_DECLSPEC_NOTHROW
1926     void
1927     DrawImage(
1928         _In_ ID2D1Effect *effect,
1929         _In_opt_ CONST D2D1_POINT_2F *targetOffset = NULL,
1930         _In_opt_ CONST D2D1_RECT_F *imageRectangle = NULL,
1931         D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR,
1932         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1933         )
1934     {
1935 
1936         ID2D1Image *output = NULL;
1937         effect->GetOutput(&output);
1938         DrawImage(output, targetOffset, imageRectangle, interpolationMode, compositeMode);
1939         output->Release();
1940     }
1941 
1942     COM_DECLSPEC_NOTHROW
1943     void
1944     DrawImage(
1945         _In_ ID2D1Image *image,
1946         D2D1_INTERPOLATION_MODE interpolationMode,
1947         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1948         )
1949     {
1950         DrawImage(image, NULL, NULL, interpolationMode, compositeMode);
1951     }
1952 
1953     COM_DECLSPEC_NOTHROW
1954     void
1955     DrawImage(
1956         _In_ ID2D1Effect *effect,
1957         D2D1_INTERPOLATION_MODE interpolationMode,
1958         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1959         )
1960     {
1961         DrawImage(effect, NULL, NULL, interpolationMode, compositeMode);
1962     }
1963 
1964     COM_DECLSPEC_NOTHROW
1965     void
1966     DrawImage(
1967         _In_ ID2D1Image *image,
1968         D2D1_POINT_2F targetOffset,
1969         D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR,
1970         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1971         )
1972     {
1973         DrawImage(image, &targetOffset, NULL, interpolationMode, compositeMode);
1974     }
1975 
1976     COM_DECLSPEC_NOTHROW
1977     void
1978     DrawImage(
1979         _In_ ID2D1Effect *effect,
1980         D2D1_POINT_2F targetOffset,
1981         D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR,
1982         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1983         )
1984     {
1985         DrawImage(effect, &targetOffset, NULL, interpolationMode, compositeMode);
1986     }
1987 
1988     COM_DECLSPEC_NOTHROW
1989     void
1990     DrawImage(
1991         _In_ ID2D1Image *image,
1992         D2D1_POINT_2F targetOffset,
1993         CONST D2D1_RECT_F &imageRectangle,
1994         D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR,
1995         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
1996         )
1997     {
1998         DrawImage(image, &targetOffset, &imageRectangle, interpolationMode, compositeMode);
1999     }
2000 
2001     COM_DECLSPEC_NOTHROW
2002     void
2003     DrawImage(
2004         _In_ ID2D1Effect *effect,
2005         D2D1_POINT_2F targetOffset,
2006         CONST D2D1_RECT_F &imageRectangle,
2007         D2D1_INTERPOLATION_MODE interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR,
2008         D2D1_COMPOSITE_MODE compositeMode = D2D1_COMPOSITE_MODE_SOURCE_OVER
2009         )
2010     {
2011         DrawImage(effect, &targetOffset, &imageRectangle, interpolationMode, compositeMode);
2012     }
2013 
2014     COM_DECLSPEC_NOTHROW
2015     void
PushLayer(CONST D2D1_LAYER_PARAMETERS1 & layerParameters,_In_opt_ ID2D1Layer * layer)2016     PushLayer(
2017         CONST D2D1_LAYER_PARAMETERS1 &layerParameters,
2018         _In_opt_ ID2D1Layer *layer
2019         )
2020     {
2021         PushLayer(&layerParameters, layer);
2022     }
2023 
2024     COM_DECLSPEC_NOTHROW
2025     void
DrawGdiMetafile(_In_ ID2D1GdiMetafile * gdiMetafile,D2D1_POINT_2F targetOffset)2026     DrawGdiMetafile(
2027         _In_ ID2D1GdiMetafile *gdiMetafile,
2028         D2D1_POINT_2F targetOffset
2029         )
2030     {
2031         DrawGdiMetafile(gdiMetafile, &targetOffset);
2032     }
2033 
2034     COM_DECLSPEC_NOTHROW
2035     void
2036     DrawBitmap(
2037         _In_ ID2D1Bitmap *bitmap,
2038         CONST D2D1_RECT_F &destinationRectangle,
2039         FLOAT opacity,
2040         D2D1_INTERPOLATION_MODE interpolationMode,
2041         _In_opt_ CONST D2D1_RECT_F *sourceRectangle = NULL,
2042         _In_opt_ CONST D2D1_MATRIX_4X4_F *perspectiveTransform = NULL
2043         )
2044     {
2045         DrawBitmap(bitmap, &destinationRectangle, opacity, interpolationMode, sourceRectangle, perspectiveTransform);
2046     }
2047 
2048     COM_DECLSPEC_NOTHROW
2049     void
2050     DrawBitmap(
2051         _In_ ID2D1Bitmap *bitmap,
2052         CONST D2D1_RECT_F &destinationRectangle,
2053         FLOAT opacity,
2054         D2D1_INTERPOLATION_MODE interpolationMode,
2055         CONST D2D1_RECT_F &sourceRectangle,
2056         _In_opt_ CONST D2D1_MATRIX_4X4_F *perspectiveTransform = NULL
2057         )
2058     {
2059         DrawBitmap(bitmap, &destinationRectangle, opacity, interpolationMode, &sourceRectangle, perspectiveTransform);
2060     }
2061 
2062     COM_DECLSPEC_NOTHROW
2063     void
DrawBitmap(_In_ ID2D1Bitmap * bitmap,CONST D2D1_RECT_F & destinationRectangle,FLOAT opacity,D2D1_INTERPOLATION_MODE interpolationMode,CONST D2D1_RECT_F & sourceRectangle,CONST D2D1_MATRIX_4X4_F & perspectiveTransform)2064     DrawBitmap(
2065         _In_ ID2D1Bitmap *bitmap,
2066         CONST D2D1_RECT_F &destinationRectangle,
2067         FLOAT opacity,
2068         D2D1_INTERPOLATION_MODE interpolationMode,
2069         CONST D2D1_RECT_F &sourceRectangle,
2070         CONST D2D1_MATRIX_4X4_F &perspectiveTransform
2071         )
2072     {
2073         DrawBitmap(bitmap, &destinationRectangle, opacity, interpolationMode, &sourceRectangle, &perspectiveTransform);
2074     }
2075 
2076     COM_DECLSPEC_NOTHROW
2077     void
2078     FillOpacityMask(
2079         _In_ ID2D1Bitmap *opacityMask,
2080         _In_ ID2D1Brush *brush,
2081         CONST D2D1_RECT_F &destinationRectangle,
2082         _In_opt_ CONST D2D1_RECT_F *sourceRectangle = NULL
2083         )
2084     {
2085         FillOpacityMask(opacityMask, brush, &destinationRectangle, sourceRectangle);
2086     }
2087 
2088     COM_DECLSPEC_NOTHROW
2089     void
FillOpacityMask(_In_ ID2D1Bitmap * opacityMask,_In_ ID2D1Brush * brush,CONST D2D1_RECT_F & destinationRectangle,CONST D2D1_RECT_F & sourceRectangle)2090     FillOpacityMask(
2091         _In_ ID2D1Bitmap *opacityMask,
2092         _In_ ID2D1Brush *brush,
2093         CONST D2D1_RECT_F &destinationRectangle,
2094         CONST D2D1_RECT_F &sourceRectangle
2095         )
2096     {
2097         FillOpacityMask(opacityMask, brush, &destinationRectangle, &sourceRectangle);
2098     }
2099 
2100     /// <summary>
2101     /// Sets tuning parameters for internal rendering inside the device context.
2102     /// </summary>
2103     COM_DECLSPEC_NOTHROW
2104     void
SetRenderingControls(CONST D2D1_RENDERING_CONTROLS & renderingControls)2105     SetRenderingControls(
2106         CONST D2D1_RENDERING_CONTROLS &renderingControls
2107         )
2108     {
2109         return SetRenderingControls(&renderingControls);
2110     }
2111 }; // interface ID2D1DeviceContext
2112 
2113 /// <summary>
2114 /// The device defines a resource domain whose objects and device contexts can be
2115 /// used together.
2116 /// </summary>
2117 interface DX_DECLARE_INTERFACE("47dd575d-ac05-4cdd-8049-9b02cd16f44c") ID2D1Device  : public ID2D1Resource
2118 {
2119 
2120     /// <summary>
2121     /// Creates a new device context with no initially assigned target.
2122     /// </summary>
2123     STDMETHOD(CreateDeviceContext)(
2124         D2D1_DEVICE_CONTEXT_OPTIONS options,
2125         _COM_Outptr_ ID2D1DeviceContext **deviceContext
2126         ) PURE;
2127 
2128     /// <summary>
2129     /// Creates a D2D print control.
2130     /// </summary>
2131     STDMETHOD(CreatePrintControl)(
2132         _In_ IWICImagingFactory *wicFactory,
2133         _In_ IPrintDocumentPackageTarget *documentTarget,
2134         _In_opt_ CONST D2D1_PRINT_CONTROL_PROPERTIES *printControlProperties,
2135         _COM_Outptr_ ID2D1PrintControl **printControl
2136         ) PURE;
2137 
2138     /// <summary>
2139     /// Sets the maximum amount of texture memory to maintain before evicting caches.
2140     /// </summary>
2141     STDMETHOD_(void, SetMaximumTextureMemory)(
2142         UINT64 maximumInBytes
2143         ) PURE;
2144 
2145     /// <summary>
2146     /// Gets the maximum amount of texture memory to maintain before evicting caches.
2147     /// </summary>
2148     STDMETHOD_(UINT64, GetMaximumTextureMemory)(
2149         ) CONST PURE;
2150 
2151     /// <summary>
2152     /// Clears all resources that are cached but not held in use by the application
2153     /// through an interface reference.
2154     /// </summary>
2155     STDMETHOD_(void, ClearResources)(
2156         UINT32 millisecondsSinceUse = 0
2157         ) PURE;
2158 
2159     COM_DECLSPEC_NOTHROW
2160     HRESULT
CreatePrintControl(_In_ IWICImagingFactory * wicFactory,_In_ IPrintDocumentPackageTarget * documentTarget,CONST D2D1_PRINT_CONTROL_PROPERTIES & printControlProperties,_COM_Outptr_ ID2D1PrintControl ** printControl)2161     CreatePrintControl(
2162         _In_ IWICImagingFactory *wicFactory,
2163         _In_ IPrintDocumentPackageTarget *documentTarget,
2164         CONST D2D1_PRINT_CONTROL_PROPERTIES &printControlProperties,
2165         _COM_Outptr_ ID2D1PrintControl **printControl
2166         )
2167     {
2168         return CreatePrintControl(wicFactory, documentTarget, &printControlProperties, printControl);
2169     }
2170 }; // interface ID2D1Device
2171 
2172 /// <summary>
2173 /// Creates Direct2D resources.
2174 /// </summary>
2175 interface DX_DECLARE_INTERFACE("bb12d362-daee-4b9a-aa1d-14ba401cfa1f") ID2D1Factory1  : public ID2D1Factory
2176 {
2177 
2178     /// <summary>
2179     /// This creates a new Direct2D device from the given IDXGIDevice.
2180     /// </summary>
2181     STDMETHOD(CreateDevice)(
2182         _In_ IDXGIDevice *dxgiDevice,
2183         _COM_Outptr_ ID2D1Device **d2dDevice
2184         ) PURE;
2185 
2186     /// <summary>
2187     /// This creates a stroke style with the ability to preserve stroke width in various
2188     /// ways.
2189     /// </summary>
2190     STDMETHOD(CreateStrokeStyle)(
2191         _In_ CONST D2D1_STROKE_STYLE_PROPERTIES1 *strokeStyleProperties,
2192         _In_reads_opt_(dashesCount) CONST FLOAT *dashes,
2193         UINT32 dashesCount,
2194         _COM_Outptr_ ID2D1StrokeStyle1 **strokeStyle
2195         ) PURE;
2196 
2197     using ID2D1Factory::CreateStrokeStyle;
2198 
2199     /// <summary>
2200     /// Creates a path geometry with new operational methods.
2201     /// </summary>
2202     STDMETHOD(CreatePathGeometry)(
2203         _COM_Outptr_ ID2D1PathGeometry1 **pathGeometry
2204         ) PURE;
2205 
2206     using ID2D1Factory::CreatePathGeometry;
2207 
2208     /// <summary>
2209     /// Creates a new drawing state block, this can be used in subsequent
2210     /// SaveDrawingState and RestoreDrawingState operations on the render target.
2211     /// </summary>
2212     STDMETHOD(CreateDrawingStateBlock)(
2213         _In_opt_ CONST D2D1_DRAWING_STATE_DESCRIPTION1 *drawingStateDescription,
2214         _In_opt_ IDWriteRenderingParams *textRenderingParams,
2215         _COM_Outptr_ ID2D1DrawingStateBlock1 **drawingStateBlock
2216         ) PURE;
2217 
2218     using ID2D1Factory::CreateDrawingStateBlock;
2219 
2220     /// <summary>
2221     /// Creates a new GDI metafile.
2222     /// </summary>
2223     STDMETHOD(CreateGdiMetafile)(
2224         _In_ IStream *metafileStream,
2225         _COM_Outptr_ ID2D1GdiMetafile **metafile
2226         ) PURE;
2227 
2228     /// <summary>
2229     /// This globally registers the given effect. The effect can later be instantiated
2230     /// by using the registered class id. The effect registration is reference counted.
2231     /// </summary>
2232     STDMETHOD(RegisterEffectFromStream)(
2233         _In_ REFCLSID classId,
2234         _In_ IStream *propertyXml,
2235         _In_reads_opt_(bindingsCount) CONST D2D1_PROPERTY_BINDING *bindings,
2236         UINT32 bindingsCount,
2237         _In_ CONST PD2D1_EFFECT_FACTORY effectFactory
2238         ) PURE;
2239 
2240     /// <summary>
2241     /// This globally registers the given effect. The effect can later be instantiated
2242     /// by using the registered class id. The effect registration is reference counted.
2243     /// </summary>
2244     STDMETHOD(RegisterEffectFromString)(
2245         _In_ REFCLSID classId,
2246         _In_ PCWSTR propertyXml,
2247         _In_reads_opt_(bindingsCount) CONST D2D1_PROPERTY_BINDING *bindings,
2248         UINT32 bindingsCount,
2249         _In_ CONST PD2D1_EFFECT_FACTORY effectFactory
2250         ) PURE;
2251 
2252     /// <summary>
2253     /// This unregisters the given effect by its class id, you need to call
2254     /// UnregisterEffect for every call to ID2D1Factory1::RegisterEffectFromStream and
2255     /// ID2D1Factory1::RegisterEffectFromString to completely unregister it.
2256     /// </summary>
2257     STDMETHOD(UnregisterEffect)(
2258         _In_ REFCLSID classId
2259         ) PURE;
2260 
2261     /// <summary>
2262     /// This returns all of the registered effects in the process, including any
2263     /// built-in effects.
2264     /// </summary>
2265     /// <param name="effectsReturned">The number of effects returned into the passed in
2266     /// effects array.</param>
2267     /// <param name="effectsRegistered">The number of effects currently registered in
2268     /// the system.</param>
2269     STDMETHOD(GetRegisteredEffects)(
2270         _Out_writes_to_opt_(effectsCount, *effectsReturned) CLSID *effects,
2271         UINT32 effectsCount,
2272         _Out_opt_ UINT32 *effectsReturned,
2273         _Out_opt_ UINT32 *effectsRegistered
2274         ) CONST PURE;
2275 
2276     /// <summary>
2277     /// This retrieves the effect properties for the given effect, all of the effect
2278     /// properties will be set to a default value since an effect is not instantiated to
2279     /// implement the returned property interface.
2280     /// </summary>
2281     STDMETHOD(GetEffectProperties)(
2282         _In_ REFCLSID effectId,
2283         _COM_Outptr_ ID2D1Properties **properties
2284         ) CONST PURE;
2285 
2286     COM_DECLSPEC_NOTHROW
2287     HRESULT
CreateStrokeStyle(CONST D2D1_STROKE_STYLE_PROPERTIES1 & strokeStyleProperties,_In_reads_opt_ (dashesCount)CONST FLOAT * dashes,UINT32 dashesCount,_COM_Outptr_ ID2D1StrokeStyle1 ** strokeStyle)2288     CreateStrokeStyle(
2289         CONST D2D1_STROKE_STYLE_PROPERTIES1 &strokeStyleProperties,
2290         _In_reads_opt_(dashesCount) CONST FLOAT *dashes,
2291         UINT32 dashesCount,
2292         _COM_Outptr_ ID2D1StrokeStyle1 **strokeStyle
2293         )
2294     {
2295         return CreateStrokeStyle(&strokeStyleProperties, dashes, dashesCount, strokeStyle);
2296     }
2297 
2298     COM_DECLSPEC_NOTHROW
2299     HRESULT
CreateDrawingStateBlock(CONST D2D1_DRAWING_STATE_DESCRIPTION1 & drawingStateDescription,_COM_Outptr_ ID2D1DrawingStateBlock1 ** drawingStateBlock)2300     CreateDrawingStateBlock(
2301         CONST D2D1_DRAWING_STATE_DESCRIPTION1 &drawingStateDescription,
2302         _COM_Outptr_ ID2D1DrawingStateBlock1 **drawingStateBlock
2303         )
2304     {
2305         return CreateDrawingStateBlock(&drawingStateDescription, NULL, drawingStateBlock);
2306     }
2307 
2308     COM_DECLSPEC_NOTHROW
2309     HRESULT
CreateDrawingStateBlock(_COM_Outptr_ ID2D1DrawingStateBlock1 ** drawingStateBlock)2310     CreateDrawingStateBlock(
2311         _COM_Outptr_ ID2D1DrawingStateBlock1 **drawingStateBlock
2312         )
2313     {
2314         return CreateDrawingStateBlock(NULL, NULL, drawingStateBlock);
2315     }
2316 }; // interface ID2D1Factory1
2317 
2318 /// <summary>
2319 /// A locking mechanism from a Direct2D factory that Direct2D uses to control
2320 /// exclusive resource access in an app that is uses multiple threads.
2321 /// </summary>
2322 interface DX_DECLARE_INTERFACE("31e6e7bc-e0ff-4d46-8c64-a0a8c41c15d3") ID2D1Multithread  : public IUnknown
2323 {
2324 
2325     /// <summary>
2326     /// Returns whether the D2D factory was created with
2327     /// D2D1_FACTORY_TYPE_MULTI_THREADED.
2328     /// </summary>
2329     STDMETHOD_(BOOL, GetMultithreadProtected)(
2330         ) CONST PURE;
2331 
2332     /// <summary>
2333     /// Enters the D2D API critical section, if it exists.
2334     /// </summary>
2335     STDMETHOD_(void, Enter)(
2336         ) PURE;
2337 
2338     /// <summary>
2339     /// Leaves the D2D API critical section, if it exists.
2340     /// </summary>
2341     STDMETHOD_(void, Leave)(
2342         ) PURE;
2343 }; // interface ID2D1Multithread
2344 
2345 #endif
2346 
2347 #ifdef D2D_USE_C_DEFINITIONS
2348 
2349 typedef interface ID2D1GdiMetafileSink ID2D1GdiMetafileSink;
2350 
2351 typedef interface ID2D1GdiMetafile ID2D1GdiMetafile;
2352 
2353 typedef interface ID2D1CommandSink ID2D1CommandSink;
2354 
2355 typedef interface ID2D1CommandList ID2D1CommandList;
2356 
2357 typedef interface ID2D1PrintControl ID2D1PrintControl;
2358 
2359 typedef interface ID2D1ImageBrush ID2D1ImageBrush;
2360 
2361 typedef interface ID2D1BitmapBrush1 ID2D1BitmapBrush1;
2362 
2363 typedef interface ID2D1StrokeStyle1 ID2D1StrokeStyle1;
2364 
2365 typedef interface ID2D1PathGeometry1 ID2D1PathGeometry1;
2366 
2367 typedef interface ID2D1Properties ID2D1Properties;
2368 
2369 typedef interface ID2D1Effect ID2D1Effect;
2370 
2371 typedef interface ID2D1Bitmap1 ID2D1Bitmap1;
2372 
2373 typedef interface ID2D1ColorContext ID2D1ColorContext;
2374 
2375 typedef interface ID2D1GradientStopCollection1 ID2D1GradientStopCollection1;
2376 
2377 typedef interface ID2D1DrawingStateBlock1 ID2D1DrawingStateBlock1;
2378 
2379 typedef interface ID2D1DeviceContext ID2D1DeviceContext;
2380 
2381 typedef interface ID2D1Device ID2D1Device;
2382 
2383 typedef interface ID2D1Factory1 ID2D1Factory1;
2384 
2385 typedef interface ID2D1Multithread ID2D1Multithread;
2386 
2387 #endif
2388 
2389 #ifdef __cplusplus
2390 extern "C"
2391 {
2392 #endif
2393 
2394     HRESULT WINAPI
2395     D2D1CreateDevice(
2396         _In_ IDXGIDevice *dxgiDevice,
2397         _In_opt_ CONST D2D1_CREATION_PROPERTIES *creationProperties,
2398         _Outptr_ ID2D1Device **d2dDevice
2399         );
2400 
2401     HRESULT WINAPI
2402     D2D1CreateDeviceContext(
2403         _In_ IDXGISurface *dxgiSurface,
2404         _In_opt_ CONST D2D1_CREATION_PROPERTIES *creationProperties,
2405         _Outptr_ ID2D1DeviceContext **d2dDeviceContext
2406         );
2407 
2408     D2D1_COLOR_F WINAPI
2409     D2D1ConvertColorSpace(
2410         D2D1_COLOR_SPACE sourceColorSpace,
2411         D2D1_COLOR_SPACE destinationColorSpace,
2412         _In_ CONST D2D1_COLOR_F* color
2413         );
2414 
2415     void WINAPI
2416     D2D1SinCos(
2417       _In_ FLOAT angle,
2418       _Out_ FLOAT *s,
2419       _Out_ FLOAT *c
2420       );
2421 
2422     FLOAT WINAPI
2423     D2D1Tan(
2424         _In_ FLOAT angle
2425         );
2426 
2427     FLOAT WINAPI
2428     D2D1Vec3Length(
2429       _In_ FLOAT x,
2430       _In_ FLOAT y,
2431       _In_ FLOAT z
2432       );
2433 
2434 #ifdef __cplusplus
2435 }
2436 #endif
2437 
2438 #include <d2d1_1helper.h>
2439 
2440 #ifndef D2D_USE_C_DEFINITIONS
2441 
2442 inline HRESULT
D2D1CreateDevice(_In_ IDXGIDevice * dxgiDevice,_In_ CONST D2D1_CREATION_PROPERTIES & creationProperties,_Outptr_ ID2D1Device ** d2dDevice)2443 D2D1CreateDevice(
2444     _In_ IDXGIDevice *dxgiDevice,
2445     _In_ CONST D2D1_CREATION_PROPERTIES &creationProperties,
2446     _Outptr_ ID2D1Device **d2dDevice
2447     )
2448 {
2449 
2450     return
2451         D2D1CreateDevice(
2452             dxgiDevice,
2453             &creationProperties,
2454             d2dDevice);
2455 }
2456 
2457 inline HRESULT
D2D1CreateDeviceContext(_In_ IDXGISurface * dxgiSurface,_In_ CONST D2D1_CREATION_PROPERTIES & creationProperties,_Outptr_ ID2D1DeviceContext ** d2dDeviceContext)2458 D2D1CreateDeviceContext(
2459     _In_ IDXGISurface *dxgiSurface,
2460     _In_ CONST D2D1_CREATION_PROPERTIES &creationProperties,
2461     _Outptr_ ID2D1DeviceContext **d2dDeviceContext
2462     )
2463 {
2464     return
2465         D2D1CreateDeviceContext(
2466             dxgiSurface,
2467             &creationProperties,
2468             d2dDeviceContext);
2469 }
2470 
2471 #endif // #ifndef D2D_USE_C_DEFINITIONS
2472 
2473 /*#endif*/ /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
2474 /*#pragma endregion*/
2475 #endif // #ifndef _D2D1_1_H_
2476