Skip to content

Commit 2d7a9dd

Browse files
committed
Bindings - More MF bindings and map to System.Drawing types for Point, PointF, Size, SizeF, Rectangle, RectangleF.
1 parent 95abfe1 commit 2d7a9dd

File tree

8 files changed

+211
-13
lines changed

8 files changed

+211
-13
lines changed

src/Vortice.DirectComposition/IDCompositionSurface.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// Distributed under the MIT license. See the LICENSE file in the project root for more information.
33

44
using System;
5-
using System.Net.Http.Headers;
5+
using System.Drawing;
66
using SharpGen.Runtime;
7-
using Vortice.Mathematics;
87

98
namespace Vortice.DirectComposition
109
{

src/Vortice.DirectX/Mappings.xml

+14-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
<define struct="System.Numerics.Matrix4x4" sizeof="64" />
3131
<define struct="System.Numerics.Plane" sizeof="16" />
3232

33+
<!-- System.Drawing types -->
34+
<define struct="System.Drawing.Point" sizeof="8" />
35+
<define struct="System.Drawing.PointF" sizeof="8" />
36+
<define struct="System.Drawing.Size" sizeof="8" />
37+
<define struct="System.Drawing.SizeF" sizeof="8" />
38+
<define struct="System.Drawing.Rectangle" sizeof="16" />
39+
<define struct="System.Drawing.RectangleF" sizeof="16" />
40+
3341
<!-- Vortice.Mathematics types -->
3442
<define struct="Vortice.Mathematics.Point" sizeof="8" />
3543
<define struct="Vortice.Mathematics.PointF" sizeof="8" />
@@ -70,8 +78,8 @@
7078
<bind from="HPALETTE" to="System.IntPtr"/>
7179
<bind from="HMONITOR" to="System.IntPtr"/>
7280

73-
<bind from="POINT" to="Vortice.Mathematics.Point" />
74-
<bind from="SIZE" to="Vortice.Mathematics.Size" />
81+
<bind from="POINT" to="System.Drawing.Point" />
82+
<bind from="SIZE" to="System.Drawing.Size" />
7583
<bind from="RECT" to="Vortice.RawRect" />
7684
<bind from="D3DCOLORVALUE" to="Vortice.Mathematics.Color4" />
7785
<bind from="MSG" to="Vortice.Win32.NativeMessage" />
@@ -82,10 +90,10 @@
8290
<bind from="DXGI_RGBA" to="Vortice.Mathematics.Color4" />
8391

8492
<!-- DCommon -->
85-
<bind from="D2D_SIZE_U" to="Vortice.Mathematics.Size" />
86-
<bind from="D2D_SIZE_F" to="Vortice.Mathematics.SizeF" />
87-
<bind from="D2D_POINT_2U" to="Vortice.Mathematics.Point" />
88-
<bind from="D2D_POINT_2F" to="Vortice.Mathematics.PointF" />
93+
<bind from="D2D_SIZE_U" to="System.Drawing.Size" />
94+
<bind from="D2D_SIZE_F" to="System.Drawing.SizeF" />
95+
<bind from="D2D_POINT_2U" to="System.Drawing.Point" />
96+
<bind from="D2D_POINT_2F" to="System.Drawing.PointF" />
8997
<bind from="D2D_RECT_U" to="Vortice.RawRect" />
9098
<bind from="D2D_RECT_F" to="Vortice.RawRectF" />
9199
<bind from="D2D_VECTOR_2F" to="System.Numerics.Vector2" />

src/Vortice.DirectX/Win32/NativeMessage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
using Vortice.Mathematics;
6+
using System.Drawing;
77

88
namespace Vortice.Win32
99
{

src/Vortice.MediaFoundation/Mappings.xml

+167-1
Large diffs are not rendered by default.

src/Vortice.MediaFoundation/MediaFactory.cs

+21
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,26 @@ namespace Vortice.MediaFoundation
55
{
66
public partial class MediaFactory
77
{
8+
private static bool s_started;
9+
10+
public static void Startup(bool useLightVersion = false)
11+
{
12+
if (s_started)
13+
return;
14+
15+
if (MFStartup(Version, useLightVersion ? 1 : 0).Success)
16+
{
17+
s_started = true;
18+
}
19+
}
20+
21+
public static void Shutdown()
22+
{
23+
if (!s_started)
24+
return;
25+
26+
MFShutdown().CheckError();
27+
s_started = false;
28+
}
829
}
930
}

src/Vortice.Multimedia/WaveFormat.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public unsafe static WaveFormat MarshalFrom(byte[] rawdata)
261261
/// </summary>
262262
/// <param name="pointer">Pointer to the WaveFormat rawdata</param>
263263
/// <returns>WaveFormat structure</returns>
264-
public unsafe static WaveFormat MarshalFrom(IntPtr pointer)
264+
public unsafe static WaveFormat? MarshalFrom(IntPtr pointer)
265265
{
266266
if (pointer == IntPtr.Zero)
267267
{

src/Vortice.Multimedia/WaveFormatAdpcm.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public WaveFormatAdpcm(int rate, int channels, int blockAlign = 0) : base(rate,
7474
/// <value>
7575
/// The coefficients.
7676
/// </value>
77-
public short[] Coefficients1 { get; set; }
77+
public short[]? Coefficients1 { get; set; }
7878

7979
/// <summary>
8080
/// Gets or sets the coefficients.
8181
/// </summary>
8282
/// <value>
8383
/// The coefficients.
8484
/// </value>
85-
public short[] Coefficients2 { get; set; }
85+
public short[]? Coefficients2 { get; set; }
8686

8787
#region Marshal
8888
protected unsafe override IntPtr MarshalToPtr()

src/samples/HelloDirect3D11/Program.cs

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ private class TestApplication : Application
2222
public TestApplication(bool headless = false)
2323
: base(headless)
2424
{
25+
using FileStream stream = File.OpenRead("Screenshot.jpg");
26+
using var wicFactory = new IWICImagingFactory();
27+
using IWICStream? wicStream = wicFactory.CreateStream(stream);
28+
using IWICBitmapDecoder decoder = wicFactory.CreateDecoderFromStream(wicStream!);
2529
}
2630

2731
protected override void InitializeBeforeRun()

0 commit comments

Comments
 (0)