RetroArch
d2d1_1helper.h
Go to the documentation of this file.
1 
2 /*=========================================================================*\
3 
4  Copyright (c) Microsoft Corporation. All rights reserved.
5 
6  File: D2D1_1Helper.h
7 
8  Module Name: D2D
9 
10  Description: Helper files over the D2D interfaces and APIs.
11 
12 \*=========================================================================*/
13 #pragma once
14 
15 #ifndef _D2D1_1HELPER_H_
16 #define _D2D1_1HELPER_H_
17 
18 #ifndef _D2D1_1_H_
19 #include <d2d1_1.h>
20 #endif // #ifndef _D2D1_H_
21 
22 #ifndef D2D_USE_C_DEFINITIONS
23 
24 /*#include <winapifamily.h>*/
25 
26 /*#pragma region Application Family*/
27 /*#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)*/
28 
29 namespace D2D1
30 {
31  template<>
32  struct TypeTraits<INT32>
33  {
34  typedef D2D1_POINT_2L Point;
35  typedef D2D1_RECT_L Rect;
36  };
37 
38  template<>
39  struct TypeTraits<LONG>
40  {
41  typedef D2D1_POINT_2L Point;
42  typedef D2D1_RECT_L Rect;
43  };
44 
45  class Matrix4x3F : public D2D1_MATRIX_4X3_F
46  {
47  public:
48 
49  COM_DECLSPEC_NOTHROW
50  inline
51  Matrix4x3F(
52  FLOAT m11, FLOAT m12, FLOAT m13,
53  FLOAT m21, FLOAT m22, FLOAT m23,
54  FLOAT m31, FLOAT m32, FLOAT m33,
55  FLOAT m41, FLOAT m42, FLOAT m43
56  )
57  {
58  _11 = m11;
59  _12 = m12;
60  _13 = m13;
61 
62  _21 = m21;
63  _22 = m22;
64  _23 = m23;
65 
66  _31 = m31;
67  _32 = m32;
68  _33 = m33;
69 
70  _41 = m41;
71  _42 = m42;
72  _43 = m43;
73  }
74 
75  COM_DECLSPEC_NOTHROW
76  inline
77  Matrix4x3F()
78  {
79  _11 = 1;
80  _12 = 0;
81  _13 = 0;
82 
83  _21 = 0;
84  _22 = 1;
85  _23 = 0;
86 
87  _31 = 0;
88  _32 = 0;
89  _33 = 1;
90 
91  _41 = 0;
92  _42 = 0;
93  _43 = 0;
94  }
95  };
96 
97  class Matrix4x4F : public D2D1_MATRIX_4X4_F
98  {
99  public:
100 
101  COM_DECLSPEC_NOTHROW
102  inline
103  Matrix4x4F(
104  FLOAT m11, FLOAT m12, FLOAT m13, FLOAT m14,
105  FLOAT m21, FLOAT m22, FLOAT m23, FLOAT m24,
106  FLOAT m31, FLOAT m32, FLOAT m33, FLOAT m34,
107  FLOAT m41, FLOAT m42, FLOAT m43, FLOAT m44
108  )
109  {
110  _11 = m11;
111  _12 = m12;
112  _13 = m13;
113  _14 = m14;
114 
115  _21 = m21;
116  _22 = m22;
117  _23 = m23;
118  _24 = m24;
119 
120  _31 = m31;
121  _32 = m32;
122  _33 = m33;
123  _34 = m34;
124 
125  _41 = m41;
126  _42 = m42;
127  _43 = m43;
128  _44 = m44;
129  }
130 
131  COM_DECLSPEC_NOTHROW
132  inline
133  Matrix4x4F()
134  {
135  _11 = 1;
136  _12 = 0;
137  _13 = 0;
138  _14 = 0;
139 
140  _21 = 0;
141  _22 = 1;
142  _23 = 0;
143  _24 = 0;
144 
145  _31 = 0;
146  _32 = 0;
147  _33 = 1;
148  _34 = 0;
149 
150  _41 = 0;
151  _42 = 0;
152  _43 = 0;
153  _44 = 1;
154  }
155 
156  COM_DECLSPEC_NOTHROW
157  inline
158  bool
159  operator==(
160  const Matrix4x4F& r
161  ) const
162  {
163  return _11 == r._11 && _12 == r._12 && _13 == r._13 && _14 == r._14 &&
164  _21 == r._21 && _22 == r._22 && _23 == r._23 && _24 == r._24 &&
165  _31 == r._31 && _32 == r._32 && _33 == r._33 && _34 == r._34 &&
166  _41 == r._41 && _42 == r._42 && _43 == r._43 && _44 == r._44;
167  }
168 
169  COM_DECLSPEC_NOTHROW
170  inline
171  bool
172  operator!=(
173  const Matrix4x4F& r
174  ) const
175  {
176  return !(*this == r);
177  }
178 
179  static
180  COM_DECLSPEC_NOTHROW
181  inline
182  Matrix4x4F
183  Translation(FLOAT x, FLOAT y, FLOAT z)
184  {
185  Matrix4x4F translation;
186 
187  translation._11 = 1.0; translation._12 = 0.0; translation._13 = 0.0; translation._14 = 0.0;
188  translation._21 = 0.0; translation._22 = 1.0; translation._23 = 0.0; translation._24 = 0.0;
189  translation._31 = 0.0; translation._32 = 0.0; translation._33 = 1.0; translation._34 = 0.0;
190  translation._41 = x; translation._42 = y; translation._43 = z; translation._44 = 1.0;
191 
192  return translation;
193  }
194 
195  static
196  COM_DECLSPEC_NOTHROW
197  inline
198  Matrix4x4F
199  Scale(FLOAT x, FLOAT y, FLOAT z)
200  {
201  Matrix4x4F scale;
202 
203  scale._11 = x; scale._12 = 0.0; scale._13 = 0.0; scale._14 = 0.0;
204  scale._21 = 0.0; scale._22 = y; scale._23 = 0.0; scale._24 = 0.0;
205  scale._31 = 0.0; scale._32 = 0.0; scale._33 = z; scale._34 = 0.0;
206  scale._41 = 0.0; scale._42 = 0.0; scale._43 = 0.0; scale._44 = 1.0;
207 
208  return scale;
209  }
210 
211  static
212  COM_DECLSPEC_NOTHROW
213  inline
214  Matrix4x4F
215  RotationX(FLOAT degreeX)
216  {
217  FLOAT angleInRadian = degreeX * (3.141592654f / 180.0f);
218 
219  FLOAT sinAngle = 0.0;
220  FLOAT cosAngle = 0.0;
221  D2D1SinCos(angleInRadian, &sinAngle, &cosAngle);
222 
223  Matrix4x4F rotationX(
224  1, 0, 0, 0,
225  0, cosAngle, sinAngle, 0,
226  0, -sinAngle, cosAngle, 0,
227  0, 0, 0, 1
228  );
229 
230  return rotationX;
231  }
232 
233  static
234  COM_DECLSPEC_NOTHROW
235  inline
236  Matrix4x4F
237  RotationY(FLOAT degreeY)
238  {
239  FLOAT angleInRadian = degreeY * (3.141592654f / 180.0f);
240 
241  FLOAT sinAngle = 0.0;
242  FLOAT cosAngle = 0.0;
243  D2D1SinCos(angleInRadian, &sinAngle, &cosAngle);
244 
245  Matrix4x4F rotationY(
246  cosAngle, 0, -sinAngle, 0,
247  0, 1, 0, 0,
248  sinAngle, 0, cosAngle, 0,
249  0, 0, 0, 1
250  );
251 
252  return rotationY;
253  }
254 
255  static
256  COM_DECLSPEC_NOTHROW
257  inline
258  Matrix4x4F
259  RotationZ(FLOAT degreeZ)
260  {
261  FLOAT angleInRadian = degreeZ * (3.141592654f / 180.0f);
262 
263  FLOAT sinAngle = 0.0;
264  FLOAT cosAngle = 0.0;
265  D2D1SinCos(angleInRadian, &sinAngle, &cosAngle);
266 
267  Matrix4x4F rotationZ(
268  cosAngle, sinAngle, 0, 0,
269  -sinAngle, cosAngle, 0, 0,
270  0, 0, 1, 0,
271  0, 0, 0, 1
272  );
273 
274  return rotationZ;
275  }
276 
277  //
278  // 3D Rotation matrix for an arbitrary axis specified by x, y and z
279  //
280  static
281  COM_DECLSPEC_NOTHROW
282  inline
283  Matrix4x4F
284  RotationArbitraryAxis(FLOAT x, FLOAT y, FLOAT z, FLOAT degree)
285  {
286  // Normalize the vector represented by x, y, and z
287  FLOAT magnitude = D2D1Vec3Length(x, y, z);
288  x /= magnitude;
289  y /= magnitude;
290  z /= magnitude;
291 
292  FLOAT angleInRadian = degree * (3.141592654f / 180.0f);
293 
294  FLOAT sinAngle = 0.0;
295  FLOAT cosAngle = 0.0;
296  D2D1SinCos(angleInRadian, &sinAngle, &cosAngle);
297 
298  FLOAT oneMinusCosAngle = 1 - cosAngle;
299 
300  Matrix4x4F rotationArb(
301  1 + oneMinusCosAngle * (x * x - 1),
302  z * sinAngle + oneMinusCosAngle * x * y,
303  -y * sinAngle + oneMinusCosAngle * x * z,
304  0,
305 
306  -z * sinAngle + oneMinusCosAngle * y * x,
307  1 + oneMinusCosAngle * (y * y - 1),
308  x * sinAngle + oneMinusCosAngle * y * z,
309  0,
310 
311  y * sinAngle + oneMinusCosAngle * z * x,
312  -x * sinAngle + oneMinusCosAngle * z * y,
313  1 + oneMinusCosAngle * (z * z - 1) ,
314  0,
315 
316  0, 0, 0, 1
317  );
318 
319  return rotationArb;
320  }
321 
322  static
323  COM_DECLSPEC_NOTHROW
324  inline
325  Matrix4x4F
326  SkewX(FLOAT degreeX)
327  {
328  FLOAT angleInRadian = degreeX * (3.141592654f / 180.0f);
329 
330  FLOAT tanAngle = D2D1Tan(angleInRadian);
331 
332  Matrix4x4F skewX(
333  1, 0, 0, 0,
334  tanAngle, 1, 0, 0,
335  0, 0, 1, 0,
336  0, 0, 0, 1
337  );
338 
339  return skewX;
340  }
341 
342  static
343  COM_DECLSPEC_NOTHROW
344  inline
345  Matrix4x4F
346  SkewY(FLOAT degreeY)
347  {
348  FLOAT angleInRadian = degreeY * (3.141592654f / 180.0f);
349 
350  FLOAT tanAngle = D2D1Tan(angleInRadian);
351 
352  Matrix4x4F skewY(
353  1, tanAngle, 0, 0,
354  0, 1, 0, 0,
355  0, 0, 1, 0,
356  0, 0, 0, 1
357  );
358 
359  return skewY;
360  }
361 
362 
363  static
364  COM_DECLSPEC_NOTHROW
365  inline
366  Matrix4x4F
367  PerspectiveProjection(FLOAT depth)
368  {
369  float proj = 0;
370 
371  if (depth > 0)
372  {
373  proj = -1/depth;
374  }
375 
376  Matrix4x4F projection(
377  1, 0, 0, 0,
378  0, 1, 0, 0,
379  0, 0, 1, proj,
380  0, 0, 0, 1
381  );
382 
383  return projection;
384  }
385 
386  //
387  // Functions for convertion from the base D2D1_MATRIX_4X4_f to
388  // this type without making a copy
389  //
390  static
391  COM_DECLSPEC_NOTHROW
392  inline
393  const Matrix4x4F*
394  ReinterpretBaseType(const D2D1_MATRIX_4X4_F *pMatrix)
395  {
396  return static_cast<const Matrix4x4F *>(pMatrix);
397  }
398 
399  static
400  COM_DECLSPEC_NOTHROW
401  inline
402  Matrix4x4F*
403  ReinterpretBaseType(D2D1_MATRIX_4X4_F *pMatrix)
404  {
405  return static_cast<Matrix4x4F *>(pMatrix);
406  }
407 
408  COM_DECLSPEC_NOTHROW
409  inline
410  FLOAT
411  Determinant() const
412  {
413  FLOAT minor1 = _41 * (_12 * (_23 * _34 - _33 * _24) - _13 * (_22 * _34 - _24 * _32) + _14 * (_22 * _33 - _23 * _32));
414  FLOAT minor2 = _42 * (_11 * (_21 * _34 - _31 * _24) - _13 * (_21 * _34 - _24 * _31) + _14 * (_21 * _33 - _23 * _31));
415  FLOAT minor3 = _43 * (_11 * (_22 * _34 - _32 * _24) - _12 * (_21 * _34 - _24 * _31) + _14 * (_21 * _32 - _22 * _31));
416  FLOAT minor4 = _44 * (_11 * (_22 * _33 - _32 * _23) - _12 * (_21 * _33 - _23 * _31) + _13 * (_21 * _32 - _22 * _31));
417 
418  return minor1 - minor2 + minor3 - minor4;
419  }
420 
421  COM_DECLSPEC_NOTHROW
422  inline
423  bool
424  IsIdentity() const
425  {
426  return _11 == 1.f && _12 == 0.f && _13 == 0.f && _14 == 0.f
427  && _21 == 0.f && _22 == 1.f && _23 == 0.f && _24 == 0.f
428  && _31 == 0.f && _32 == 0.f && _33 == 1.f && _34 == 0.f
429  && _41 == 0.f && _42 == 0.f && _43 == 0.f && _44 == 1.f;
430  }
431 
432  COM_DECLSPEC_NOTHROW
433  inline
434  void
435  SetProduct(const Matrix4x4F &a, const Matrix4x4F &b)
436  {
437  _11 = a._11 * b._11 + a._12 * b._21 + a._13 * b._31 + a._14 * b._41;
438  _12 = a._11 * b._12 + a._12 * b._22 + a._13 * b._32 + a._14 * b._42;
439  _13 = a._11 * b._13 + a._12 * b._23 + a._13 * b._33 + a._14 * b._43;
440  _14 = a._11 * b._14 + a._12 * b._24 + a._13 * b._34 + a._14 * b._44;
441 
442  _21 = a._21 * b._11 + a._22 * b._21 + a._23 * b._31 + a._24 * b._41;
443  _22 = a._21 * b._12 + a._22 * b._22 + a._23 * b._32 + a._24 * b._42;
444  _23 = a._21 * b._13 + a._22 * b._23 + a._23 * b._33 + a._24 * b._43;
445  _24 = a._21 * b._14 + a._22 * b._24 + a._23 * b._34 + a._24 * b._44;
446 
447  _31 = a._31 * b._11 + a._32 * b._21 + a._33 * b._31 + a._34 * b._41;
448  _32 = a._31 * b._12 + a._32 * b._22 + a._33 * b._32 + a._34 * b._42;
449  _33 = a._31 * b._13 + a._32 * b._23 + a._33 * b._33 + a._34 * b._43;
450  _34 = a._31 * b._14 + a._32 * b._24 + a._33 * b._34 + a._34 * b._44;
451 
452  _41 = a._41 * b._11 + a._42 * b._21 + a._43 * b._31 + a._44 * b._41;
453  _42 = a._41 * b._12 + a._42 * b._22 + a._43 * b._32 + a._44 * b._42;
454  _43 = a._41 * b._13 + a._42 * b._23 + a._43 * b._33 + a._44 * b._43;
455  _44 = a._41 * b._14 + a._42 * b._24 + a._43 * b._34 + a._44 * b._44;
456  }
457 
458  COM_DECLSPEC_NOTHROW
459  inline
460  Matrix4x4F
461  operator*(const Matrix4x4F &matrix) const
462  {
463  Matrix4x4F result;
464 
465  result.SetProduct(*this, matrix);
466 
467  return result;
468  }
469  };
470 
471 
472  class Matrix5x4F : public D2D1_MATRIX_5X4_F
473  {
474  public:
475 
476  COM_DECLSPEC_NOTHROW
477  inline
478  Matrix5x4F(
479  FLOAT m11, FLOAT m12, FLOAT m13, FLOAT m14,
480  FLOAT m21, FLOAT m22, FLOAT m23, FLOAT m24,
481  FLOAT m31, FLOAT m32, FLOAT m33, FLOAT m34,
482  FLOAT m41, FLOAT m42, FLOAT m43, FLOAT m44,
483  FLOAT m51, FLOAT m52, FLOAT m53, FLOAT m54
484  )
485  {
486  _11 = m11;
487  _12 = m12;
488  _13 = m13;
489  _14 = m14;
490 
491  _21 = m21;
492  _22 = m22;
493  _23 = m23;
494  _24 = m24;
495 
496  _31 = m31;
497  _32 = m32;
498  _33 = m33;
499  _34 = m34;
500 
501  _41 = m41;
502  _42 = m42;
503  _43 = m43;
504  _44 = m44;
505 
506  _51 = m51;
507  _52 = m52;
508  _53 = m53;
509  _54 = m54;
510  }
511 
512  COM_DECLSPEC_NOTHROW
513  inline
514  Matrix5x4F()
515  {
516  _11 = 1;
517  _12 = 0;
518  _13 = 0;
519  _14 = 0;
520 
521  _21 = 0;
522  _22 = 1;
523  _23 = 0;
524  _24 = 0;
525 
526  _31 = 0;
527  _32 = 0;
528  _33 = 1;
529  _34 = 0;
530 
531  _41 = 0;
532  _42 = 0;
533  _43 = 0;
534  _44 = 1;
535 
536  _51 = 0;
537  _52 = 0;
538  _53 = 0;
539  _54 = 0;
540  }
541  };
542 
543  COM_DECLSPEC_NOTHROW
544  inline
546  ConvertColorSpace(
547  D2D1_COLOR_SPACE sourceColorSpace,
548  D2D1_COLOR_SPACE destinationColorSpace,
549  const D2D1_COLOR_F& color
550  )
551  {
552  return D2D1ConvertColorSpace(
553  sourceColorSpace,
554  destinationColorSpace,
555  &color
556  );
557  }
558 
559  COM_DECLSPEC_NOTHROW
562  DrawingStateDescription1(
565  D2D1_TAG tag1 = 0,
566  D2D1_TAG tag2 = 0,
567  _In_ const D2D1_MATRIX_3X2_F &transform = D2D1::IdentityMatrix(),
570  )
571  {
572  D2D1_DRAWING_STATE_DESCRIPTION1 drawingStateDescription1;
573 
574  drawingStateDescription1.antialiasMode = antialiasMode;
575  drawingStateDescription1.textAntialiasMode = textAntialiasMode;
576  drawingStateDescription1.tag1 = tag1;
577  drawingStateDescription1.tag2 = tag2;
578  drawingStateDescription1.transform = transform;
579  drawingStateDescription1.primitiveBlend = primitiveBlend;
580  drawingStateDescription1.unitMode = unitMode;
581 
582  return drawingStateDescription1;
583  }
584 
585  COM_DECLSPEC_NOTHROW
588  DrawingStateDescription1(
589  _In_ const D2D1_DRAWING_STATE_DESCRIPTION &desc,
592  )
593  {
594  D2D1_DRAWING_STATE_DESCRIPTION1 drawingStateDescription1;
595 
596  drawingStateDescription1.antialiasMode = desc.antialiasMode;
597  drawingStateDescription1.textAntialiasMode = desc.textAntialiasMode;
598  drawingStateDescription1.tag1 = desc.tag1;
599  drawingStateDescription1.tag2 = desc.tag2;
600  drawingStateDescription1.transform = desc.transform;
601  drawingStateDescription1.primitiveBlend = primitiveBlend;
602  drawingStateDescription1.unitMode = unitMode;
603 
604  return drawingStateDescription1;
605  }
606 
607  COM_DECLSPEC_NOTHROW
610  BitmapProperties1(
612  _In_ CONST D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(),
613  FLOAT dpiX = 96.0f,
614  FLOAT dpiY = 96.0f,
615  _In_opt_ ID2D1ColorContext *colorContext = NULL
616  )
617  {
618  D2D1_BITMAP_PROPERTIES1 bitmapProperties =
619  {
620  pixelFormat,
621  dpiX, dpiY,
622  bitmapOptions,
623  colorContext
624  };
625 
626  return bitmapProperties;
627  }
628 
629  COM_DECLSPEC_NOTHROW
632  LayerParameters1(
633  _In_ CONST D2D1_RECT_F &contentBounds = D2D1::InfiniteRect(),
634  _In_opt_ ID2D1Geometry *geometricMask = NULL,
636  D2D1_MATRIX_3X2_F maskTransform = D2D1::IdentityMatrix(),
637  FLOAT opacity = 1.0,
638  _In_opt_ ID2D1Brush *opacityBrush = NULL,
640  )
641  {
642  D2D1_LAYER_PARAMETERS1 layerParameters = { 0 };
643 
644  layerParameters.contentBounds = contentBounds;
645  layerParameters.geometricMask = geometricMask;
646  layerParameters.maskAntialiasMode = maskAntialiasMode;
647  layerParameters.maskTransform = maskTransform;
648  layerParameters.opacity = opacity;
649  layerParameters.opacityBrush = opacityBrush;
650  layerParameters.layerOptions = layerOptions;
651 
652  return layerParameters;
653  }
654 
655  COM_DECLSPEC_NOTHROW
658  StrokeStyleProperties1(
663  FLOAT miterLimit = 10.0f,
665  FLOAT dashOffset = 0.0f,
667  )
668  {
669  D2D1_STROKE_STYLE_PROPERTIES1 strokeStyleProperties;
670 
671  strokeStyleProperties.startCap = startCap;
672  strokeStyleProperties.endCap = endCap;
673  strokeStyleProperties.dashCap = dashCap;
674  strokeStyleProperties.lineJoin = lineJoin;
675  strokeStyleProperties.miterLimit = miterLimit;
676  strokeStyleProperties.dashStyle = dashStyle;
677  strokeStyleProperties.dashOffset = dashOffset;
678  strokeStyleProperties.transformType = transformType;
679 
680  return strokeStyleProperties;
681  }
682 
683  COM_DECLSPEC_NOTHROW
686  ImageBrushProperties(
687  D2D1_RECT_F sourceRectangle,
691  )
692  {
693  D2D1_IMAGE_BRUSH_PROPERTIES imageBrushProperties;
694 
695  imageBrushProperties.extendModeX = extendModeX;
696  imageBrushProperties.extendModeY = extendModeY;
697  imageBrushProperties.interpolationMode = interpolationMode;
698  imageBrushProperties.sourceRectangle = sourceRectangle;
699 
700  return imageBrushProperties;
701  }
702 
703  COM_DECLSPEC_NOTHROW
706  BitmapBrushProperties1(
710  )
711  {
712  D2D1_BITMAP_BRUSH_PROPERTIES1 bitmapBrush1Properties;
713 
714  bitmapBrush1Properties.extendModeX = extendModeX;
715  bitmapBrush1Properties.extendModeY = extendModeY;
716  bitmapBrush1Properties.interpolationMode = interpolationMode;
717 
718  return bitmapBrush1Properties;
719  }
720 
721  COM_DECLSPEC_NOTHROW
724  PrintControlProperties(
726  FLOAT rasterDpi = 150.0f,
728  )
729  {
730  D2D1_PRINT_CONTROL_PROPERTIES printControlProps;
731 
732  printControlProps.fontSubset = fontSubsetMode;
733  printControlProps.rasterDPI = rasterDpi;
734  printControlProps.colorSpace = colorSpace;
735 
736  return printControlProps;
737  }
738 
739  COM_DECLSPEC_NOTHROW
742  RenderingControls(
743  D2D1_BUFFER_PRECISION bufferPrecision,
744  D2D1_SIZE_U tileSize
745  )
746  {
747  D2D1_RENDERING_CONTROLS renderingControls;
748 
749  renderingControls.bufferPrecision = bufferPrecision;
750  renderingControls.tileSize = tileSize;
751 
752  return renderingControls;
753  }
754 
755  COM_DECLSPEC_NOTHROW
758  EffectInputDescription(
759  ID2D1Effect *effect,
760  UINT32 inputIndex,
761  D2D1_RECT_F inputRectangle
762  )
763  {
765 
766  description.effect = effect;
767  description.inputIndex = inputIndex;
768  description.inputRectangle = inputRectangle;
769 
770  return description;
771  }
772 
773  COM_DECLSPEC_NOTHROW
776  CreationProperties(
777  D2D1_THREADING_MODE threadingMode,
778  D2D1_DEBUG_LEVEL debugLevel,
780  )
781  {
782  D2D1_CREATION_PROPERTIES creationProperties;
783 
784  creationProperties.threadingMode = threadingMode;
785  creationProperties.debugLevel = debugLevel;
786  creationProperties.options = options;
787 
788  return creationProperties;
789  }
790 
791  COM_DECLSPEC_NOTHROW
794  Vector2F(
795  FLOAT x = 0.0f,
796  FLOAT y = 0.0f
797  )
798  {
799  D2D1_VECTOR_2F vec2 = {x, y};
800  return vec2;
801  }
802 
803  COM_DECLSPEC_NOTHROW
806  Vector3F(
807  FLOAT x = 0.0f,
808  FLOAT y = 0.0f,
809  FLOAT z = 0.0f
810  )
811  {
812  D2D1_VECTOR_3F vec3 = {x, y, z};
813  return vec3;
814  }
815 
816  COM_DECLSPEC_NOTHROW
819  Vector4F(
820  FLOAT x = 0.0f,
821  FLOAT y = 0.0f,
822  FLOAT z = 0.0f,
823  FLOAT w = 0.0f
824  )
825  {
826  D2D1_VECTOR_4F vec4 = {x, y, z, w};
827  return vec4;
828  }
829 
830  COM_DECLSPEC_NOTHROW
833  Point2L(
834  INT32 x = 0,
835  INT32 y = 0
836  )
837  {
838  return Point2<INT32>(x, y);
839  }
840 
841  COM_DECLSPEC_NOTHROW
844  RectL(
845  INT32 left = 0.f,
846  INT32 top = 0.f,
847  INT32 right = 0.f,
848  INT32 bottom = 0.f
849  )
850  {
851  return Rect<INT32>(left, top, right, bottom);
852  }
853 
854  //
855  // Sets a bitmap as an effect input, while inserting a DPI compensation effect
856  // to preserve visual appearance as the device context's DPI changes.
857  //
858  COM_DECLSPEC_NOTHROW
860  HRESULT
861  SetDpiCompensatedEffectInput(
862  _In_ ID2D1DeviceContext *deviceContext,
863  _In_ ID2D1Effect *effect,
864  UINT32 inputIndex,
865  _In_opt_ ID2D1Bitmap *inputBitmap,
868  )
869  {
870  HRESULT hr = S_OK;
871  ID2D1Effect *dpiCompensationEffect = NULL;
872 
873  if (!inputBitmap)
874  {
875  effect->SetInput(inputIndex, NULL);
876  return hr;
877  }
878 
879  hr = deviceContext->CreateEffect(CLSID_D2D1DpiCompensation, &dpiCompensationEffect);
880 
881  if (SUCCEEDED(hr))
882  {
883  if (SUCCEEDED(hr))
884  {
885  dpiCompensationEffect->SetInput(0, inputBitmap);
886 
887  D2D1_POINT_2F bitmapDpi;
888  inputBitmap->GetDpi(&bitmapDpi.x, &bitmapDpi.y);
889  hr = dpiCompensationEffect->SetValue(D2D1_DPICOMPENSATION_PROP_INPUT_DPI, bitmapDpi);
890  }
891 
892  if (SUCCEEDED(hr))
893  {
894  hr = dpiCompensationEffect->SetValue(D2D1_DPICOMPENSATION_PROP_INTERPOLATION_MODE, interpolationMode);
895  }
896 
897  if (SUCCEEDED(hr))
898  {
899  hr = dpiCompensationEffect->SetValue(D2D1_DPICOMPENSATION_PROP_BORDER_MODE, borderMode);
900  }
901 
902  if (SUCCEEDED(hr))
903  {
904  effect->SetInputEffect(inputIndex, dpiCompensationEffect);
905  }
906 
907  if (dpiCompensationEffect)
908  {
909  dpiCompensationEffect->Release();
910  }
911  }
912 
913  return hr;
914  }
915 
916 } // namespace D2D1
917 
918 /*#endif*/ /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
919 /*#pragma endregion*/
920 
921 #endif // #ifndef D2D_USE_C_DEFINITIONS
922 
923 #endif // #ifndef _D2D1_HELPER_H_
924 
FLOAT y
Definition: dcommon.h:178
FLOAT WINAPI D2D1Tan(_In_ FLOAT angle)
D2D1_CAP_STYLE
Enum which describes the drawing of the ends of a line.
Definition: d2d1.h:380
#define D2D1FORCEINLINE
Definition: d2d1.h:3704
Definition: d2d1_1.h:260
FLOAT rasterDPI
DPI for rasterization of all unsupported D2D commands or options, defaults to 150....
Definition: d2d1_1.h:619
D2D1_TAG tag1
Definition: d2d1_1.h:599
Render text using the current system setting.
Definition: d2d1.h:205
D2D1_BUFFER_PRECISION bufferPrecision
The default buffer precision, used if the precision isn't otherwise specified.
Definition: d2d1_1.h:438
D2D1_CAP_STYLE endCap
Definition: d2d1_1.h:521
Definition: glslang_tab.cpp:129
This describes the drawing state.
Definition: d2d1_1.h:595
#define PixelFormat
Definition: record_ffmpeg.c:117
D2D1_TEXT_ANTIALIAS_MODE
Describes the antialiasing mode used for drawing text.
Definition: d2d1.h:199
D2D1_ANTIALIAS_MODE antialiasMode
Definition: d2d1_1.h:597
GLdouble GLdouble GLdouble r
Definition: glext.h:6406
D2D1_DEVICE_CONTEXT_OPTIONS
This specifies options that apply to the device context for its lifetime.
Definition: d2d1_1.h:295
D2D1_CAP_STYLE dashCap
Definition: d2d1_1.h:522
D2D_POINT_2L D2D1_POINT_2L
Definition: d2d1_1.h:58
D2D1_CAP_STYLE startCap
Definition: d2d1_1.h:520
D2D1_PRIMITIVE_BLEND primitiveBlend
Definition: d2d1_1.h:602
GLfloat f
Definition: glext.h:8207
D2D1_EXTEND_MODE extendModeY
Definition: d2d1_1.h:497
D2D1_DASH_STYLE
Describes the sequence of dashes and gaps in a stroke.
Definition: d2d1.h:410
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9939
D2D1_UNIT_MODE unitMode
Definition: d2d1_1.h:603
GLuint GLenum matrix
Definition: glext.h:10314
GLdouble GLdouble z
Definition: glext.h:6514
Definition: d2d1_1.h:245
Represents a rectangle defined by the coordinates of the upper-left corner (left, top) and the coordi...
Definition: dcommon.h:224
typedef HRESULT(WINAPI *PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)(_In_ const D3D12_ROOT_SIGNATURE_DESC *pRootSignature
GLint GLint bottom
Definition: glext.h:8393
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:11766
D2D1_LINE_JOIN lineJoin
Definition: d2d1_1.h:523
D2D1_RECT_F sourceRectangle
Definition: d2d1_1.h:495
GLdouble GLdouble right
Definition: glext.h:11766
The edges of each primitive are antialiased sequentially.
Definition: d2d1.h:185
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
Miter join.
Definition: d2d1.h:432
Subset for used glyphs, send and discard font resource after every five pages
Definition: d2d1_1.h:576
The bitmap is created with default properties.
Definition: d2d1_1.h:138
The sRGB color space.
Definition: d2d1_1.h:281
D2D1_DEBUG_LEVEL
Indicates the debug level to be output by the debug layer.
Definition: d2d1.h:971
Represents a 5-by-4 matrix.
Definition: dcommon.h:371
D2D1_PRIMITIVE_BLEND
A blend mode that applies to all primitives drawn on the context.
Definition: d2d1_1.h:341
D2D1_COLOR_SPACE
Defines a color space.
Definition: d2d1_1.h:270
D2D1_DEBUG_LEVEL debugLevel
Definition: d2d1_1.h:640
D2D1_INTERPOLATION_MODE interpolationMode
Definition: d2d1_1.h:510
#define NULL
Pointer to 0.
Definition: gctypes.h:65
interface ID2D1Effect ID2D1Effect
Definition: d2d1_1.h:53
D2D1_LINE_JOIN
Enum which describes the drawing of the corners on the line.
Definition: d2d1.h:426
Extend the edges of the source out by clamping sample points outside the source to the edges.
Definition: d2d1.h:158
int32_t INT32
Definition: coretypes.h:17
FLOAT x
Definition: dcommon.h:177
D2D1_INTERPOLATION_MODE
This is used to specify the quality of image scaling with ID2D1DeviceContext::DrawImage and with the ...
Definition: d2d1_1.h:242
void WINAPI D2D1SinCos(_In_ FLOAT angle, _Out_ FLOAT *s, _Out_ FLOAT *c)
D2D1_INTERPOLATION_MODE interpolationMode
Definition: d2d1_1.h:498
D2D1_STROKE_TRANSFORM_TYPE
Defines how the world transform, dots per inch (dpi), and stroke width affect the shape of the pen us...
Definition: d2d1_1.h:315
A vector of 2 FLOAT values (x, y).
Definition: dcommon.h:187
interface ID2D1DeviceContext ID2D1DeviceContext
Definition: d2d1_1.h:2432
Description of a pixel format.
Definition: dcommon.h:155
Definition: d2d1.h:412
D2D1_THREADING_MODE threadingMode
Describes locking behavior of D2D resources
Definition: d2d1_1.h:639
interface ID2D1Geometry ID2D1Geometry
Definition: d2d1.h:76
D2D1_EXTEND_MODE
Enum which describes how to sample from a source outside its base tile.
Definition: d2d1.h:151
D2D1_ANTIALIAS_MODE
Enum which describes the manner in which we render edges of non-text primitives.
Definition: d2d1.h:179
D2D1_DASH_STYLE dashStyle
Definition: d2d1_1.h:525
D2D1_BITMAP_OPTIONS
Specifies how the bitmap can be used.
Definition: d2d1_1.h:132
D2D1_RECT_F contentBounds
Definition: d2d1_1.h:556
D2D1_UNIT_MODE
This specifies what units should be accepted by the D2D API.
Definition: d2d1_1.h:258
UINT64 D2D1_TAG
Definition: d2d1.h:290
Definition: d2d1effects.h:73
D2D1_MATRIX_3X2_F maskTransform
Definition: d2d1_1.h:559
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
A vector of 4 FLOAT values (x, y, z, w).
Definition: dcommon.h:210
D2D1_PRINT_FONT_SUBSET_MODE
Defines when font resources should be subset during printing.
Definition: d2d1_1.h:570
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
GLuint64EXT * result
Definition: glext.h:12211
Represents an x-coordinate and y-coordinate pair in two-dimensional space.
Definition: dcommon.h:175
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glext.h:6293
Describes the extend modes and the interpolation mode of an ID2D1BitmapBrush.
Definition: d2d1_1.h:506
description
Definition: setup.py:7
FLOAT dashOffset
Definition: d2d1_1.h:526
D2D1_BUFFER_PRECISION
This specifies the precision that should be used in buffers allocated by D2D.
Definition: d2d1_1.h:193
D2D1_LAYER_OPTIONS1
Specifies how the layer contents should be prepared.
Definition: d2d1_1.h:539
D2D1_MATRIX_3X2_F transform
Definition: d2d1_1.h:601
The stroke respects the world transform, the DPI, and the stroke width.
Definition: d2d1_1.h:321
D2D1_THREADING_MODE
This specifies the threading mode used while simultaneously creating the device, factory,...
Definition: d2d1_1.h:357
Represents a 3-by-2 matrix.
Definition: dcommon.h:275
interface ID2D1ColorContext ID2D1ColorContext
Definition: d2d1_1.h:31
D2D1_EXTEND_MODE extendModeX
Definition: d2d1_1.h:496
D2D1_SIZE_U tileSize
The size of allocated tiles used to render imaging effects.
Definition: d2d1_1.h:443
Allows the drawing state to be atomically created. This also specifies the drawing state that is save...
Definition: d2d1.h:936
Flat line cap.
Definition: d2d1.h:386
This specifies the options while simultaneously creating the device, factory, and device context.
Definition: d2d1_1.h:633
A vector of 3 FLOAT values (x, y, z).
Definition: dcommon.h:198
bool operator==(const FloatProxy< T > &first, const FloatProxy< T > &second)
Definition: hex_float.h:162
interface ID2D1Bitmap ID2D1Bitmap
Definition: d2d1.h:3580
uint32_t UINT32
Definition: coretypes.h:10
GLuint color
Definition: glext.h:6883
interface ID2D1Brush ID2D1Brush
Definition: d2d1.h:77
D2D1_COLOR_SPACE colorSpace
Color space for vector graphics in XPS package
Definition: d2d1_1.h:624
Property Name: "BorderMode" Property Type: D2D1_BORDER_MODE
Definition: d2d1effects.h:597
FLOAT opacity
Definition: d2d1_1.h:560
This identifies a certain input connection of a certain effect.
Definition: d2d1_1.h:451
D2D1_EXTEND_MODE extendModeX
Definition: d2d1_1.h:508
FLOAT WINAPI D2D1Vec3Length(_In_ FLOAT x, _In_ FLOAT y, _In_ FLOAT z)
Extended bitmap properties.
Definition: d2d1_1.h:403
Stores an ordered pair of integers, typically the width and height of a rectangle.
Definition: dcommon.h:264
D2D1_PRINT_FONT_SUBSET_MODE fontSubset
Definition: d2d1_1.h:613
GLuint GLenum GLenum transform
Definition: glext.h:10314
Definition: d2d1_1.h:541
D2D1_LAYER_OPTIONS1 layerOptions
Definition: d2d1_1.h:562
Definition: glslang_tab.cpp:133
D2D1_ANTIALIAS_MODE maskAntialiasMode
Definition: d2d1_1.h:558
GLuint GLenum transformType
Definition: glext.h:12627
D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode
Definition: d2d1_1.h:598
D2D1_EXTEND_MODE extendModeY
Definition: d2d1_1.h:509
All parameters related to pushing a layer.
Definition: d2d1_1.h:554
Represents a 4-by-4 matrix.
Definition: dcommon.h:350
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6742
D2D1_COLOR_F WINAPI D2D1ConvertColorSpace(D2D1_COLOR_SPACE sourceColorSpace, D2D1_COLOR_SPACE destinationColorSpace, _In_ CONST D2D1_COLOR_F *color)
Definition: d2d1_1.h:343
Creation properties for an image brush.
Definition: d2d1_1.h:493
D2D1_TAG tag2
Definition: d2d1_1.h:600
Represents a 4-by-3 matrix.
Definition: dcommon.h:329
GLint left
Definition: glext.h:8393
This controls advanced settings of the Direct2D imaging pipeline.
Definition: d2d1_1.h:432
D2D1_BORDER_MODE
Specifies how the Crop effect handles the crop rectangle falling on fractional pixel coordinates.
Definition: d2d1effects.h:70
D2D_RECT_L D2D1_RECT_L
Definition: d2d1_1.h:57
Property Name: "InputDpi" Property Type: D2D1_VECTOR_2F
Definition: d2d1effects.h:603
D2D1_DEVICE_CONTEXT_OPTIONS options
Definition: d2d1_1.h:641
Property Name: "InterpolationMode" Property Type: D2D1_DPICOMPENSATION_INTERPOLATION_MODE
Definition: d2d1effects.h:591
bf_uint8_t options
Definition: connect_ps4.c:78
FLOAT miterLimit
Definition: d2d1_1.h:524
The text renderer interface represents a set of application-defined callbacks that perform rendering ...
Definition: d3d8types.h:57
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844
D2D1_STROKE_TRANSFORM_TYPE transformType
How the nib of the stroke is influenced by the context properties.
Definition: d2d1_1.h:531
The creation properties for a ID2D1PrintControl object.
Definition: d2d1_1.h:611
This defines how geometries should be drawn and widened.
Definition: d2d1_1.h:518