Skip to content

Commit

Permalink
Bindings - More MF bindings and map to System.Drawing types for Point…
Browse files Browse the repository at this point in the history
…, PointF, Size, SizeF, Rectangle, RectangleF.
  • Loading branch information
amerkoleci committed Apr 19, 2021
1 parent 95abfe1 commit 2d7a9dd
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/Vortice.DirectComposition/IDCompositionSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Distributed under the MIT license. See the LICENSE file in the project root for more information.

using System;
using System.Net.Http.Headers;
using System.Drawing;
using SharpGen.Runtime;
using Vortice.Mathematics;

namespace Vortice.DirectComposition
{
Expand Down
20 changes: 14 additions & 6 deletions src/Vortice.DirectX/Mappings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
<define struct="System.Numerics.Matrix4x4" sizeof="64" />
<define struct="System.Numerics.Plane" sizeof="16" />

<!-- System.Drawing types -->
<define struct="System.Drawing.Point" sizeof="8" />
<define struct="System.Drawing.PointF" sizeof="8" />
<define struct="System.Drawing.Size" sizeof="8" />
<define struct="System.Drawing.SizeF" sizeof="8" />
<define struct="System.Drawing.Rectangle" sizeof="16" />
<define struct="System.Drawing.RectangleF" sizeof="16" />

<!-- Vortice.Mathematics types -->
<define struct="Vortice.Mathematics.Point" sizeof="8" />
<define struct="Vortice.Mathematics.PointF" sizeof="8" />
Expand Down Expand Up @@ -70,8 +78,8 @@
<bind from="HPALETTE" to="System.IntPtr"/>
<bind from="HMONITOR" to="System.IntPtr"/>

<bind from="POINT" to="Vortice.Mathematics.Point" />
<bind from="SIZE" to="Vortice.Mathematics.Size" />
<bind from="POINT" to="System.Drawing.Point" />
<bind from="SIZE" to="System.Drawing.Size" />
<bind from="RECT" to="Vortice.RawRect" />
<bind from="D3DCOLORVALUE" to="Vortice.Mathematics.Color4" />
<bind from="MSG" to="Vortice.Win32.NativeMessage" />
Expand All @@ -82,10 +90,10 @@
<bind from="DXGI_RGBA" to="Vortice.Mathematics.Color4" />

<!-- DCommon -->
<bind from="D2D_SIZE_U" to="Vortice.Mathematics.Size" />
<bind from="D2D_SIZE_F" to="Vortice.Mathematics.SizeF" />
<bind from="D2D_POINT_2U" to="Vortice.Mathematics.Point" />
<bind from="D2D_POINT_2F" to="Vortice.Mathematics.PointF" />
<bind from="D2D_SIZE_U" to="System.Drawing.Size" />
<bind from="D2D_SIZE_F" to="System.Drawing.SizeF" />
<bind from="D2D_POINT_2U" to="System.Drawing.Point" />
<bind from="D2D_POINT_2F" to="System.Drawing.PointF" />
<bind from="D2D_RECT_U" to="Vortice.RawRect" />
<bind from="D2D_RECT_F" to="Vortice.RawRectF" />
<bind from="D2D_VECTOR_2F" to="System.Numerics.Vector2" />
Expand Down
2 changes: 1 addition & 1 deletion src/Vortice.DirectX/Win32/NativeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Runtime.InteropServices;
using Vortice.Mathematics;
using System.Drawing;

namespace Vortice.Win32
{
Expand Down
168 changes: 167 additions & 1 deletion src/Vortice.MediaFoundation/Mappings.xml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/Vortice.MediaFoundation/MediaFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,26 @@ namespace Vortice.MediaFoundation
{
public partial class MediaFactory
{
private static bool s_started;

public static void Startup(bool useLightVersion = false)
{
if (s_started)
return;

if (MFStartup(Version, useLightVersion ? 1 : 0).Success)
{
s_started = true;
}
}

public static void Shutdown()
{
if (!s_started)
return;

MFShutdown().CheckError();
s_started = false;
}
}
}
2 changes: 1 addition & 1 deletion src/Vortice.Multimedia/WaveFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public unsafe static WaveFormat MarshalFrom(byte[] rawdata)
/// </summary>
/// <param name="pointer">Pointer to the WaveFormat rawdata</param>
/// <returns>WaveFormat structure</returns>
public unsafe static WaveFormat MarshalFrom(IntPtr pointer)
public unsafe static WaveFormat? MarshalFrom(IntPtr pointer)
{
if (pointer == IntPtr.Zero)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Vortice.Multimedia/WaveFormatAdpcm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public WaveFormatAdpcm(int rate, int channels, int blockAlign = 0) : base(rate,
/// <value>
/// The coefficients.
/// </value>
public short[] Coefficients1 { get; set; }
public short[]? Coefficients1 { get; set; }

/// <summary>
/// Gets or sets the coefficients.
/// </summary>
/// <value>
/// The coefficients.
/// </value>
public short[] Coefficients2 { get; set; }
public short[]? Coefficients2 { get; set; }

#region Marshal
protected unsafe override IntPtr MarshalToPtr()
Expand Down
4 changes: 4 additions & 0 deletions src/samples/HelloDirect3D11/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ private class TestApplication : Application
public TestApplication(bool headless = false)
: base(headless)
{
using FileStream stream = File.OpenRead("Screenshot.jpg");
using var wicFactory = new IWICImagingFactory();
using IWICStream? wicStream = wicFactory.CreateStream(stream);
using IWICBitmapDecoder decoder = wicFactory.CreateDecoderFromStream(wicStream!);
}

protected override void InitializeBeforeRun()
Expand Down

0 comments on commit 2d7a9dd

Please sign in to comment.