Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #764 from andrewst/directWriteNext
Browse files Browse the repository at this point in the history
[Direct2D] Improve Direct2D and DirectWrite
  • Loading branch information
xoofx authored Jun 23, 2016
2 parents 91cced3 + 0566aab commit 9673433
Show file tree
Hide file tree
Showing 19 changed files with 3,704 additions and 13 deletions.
480 changes: 471 additions & 9 deletions External/gccxml/share/gccxml-0.9/vc12/overrides/um/d2d1_3.h

Large diffs are not rendered by default.

965 changes: 965 additions & 0 deletions External/gccxml/share/gccxml-0.9/vc12/overrides/um/dwrite_2.h

Large diffs are not rendered by default.

1,743 changes: 1,743 additions & 0 deletions External/gccxml/share/gccxml-0.9/vc12/overrides/um/dwrite_3.h

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions Source/SharpDX.Direct2D1/CommandSink3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

namespace SharpDX.Direct2D1
{
public partial interface CommandSink3
{
/// <summary>
/// <p>Renders part or all of the given sprite batch to the device context using the specified drawing options.</p>
/// </summary>
/// <param name="spriteBatch"><dd> <p>The sprite batch to draw.</p> </dd></param>
/// <param name="startIndex"><dd> <p>The index of the first sprite in the sprite batch to draw.</p> </dd></param>
/// <param name="spriteCount"><dd> <p>The number of sprites to draw.</p> </dd></param>
/// <param name="bitmap"><dd> <p>The bitmap from which the sprites are to be sourced. Each sprite?s source rectangle refers to a portion of this bitmap.</p> </dd></param>
/// <param name="interpolationMode"><dd> <p>The interpolation mode to use when drawing this sprite batch. This determines how Direct2D interpolates pixels within the drawn sprites if scaling is performed.</p> </dd></param>
/// <param name="spriteOptions"><dd> <p>The additional drawing options, if any, to be used for this sprite batch.</p> </dd></param>
/// <returns><p>If this method succeeds, it returns <strong><see cref="SharpDX.Result.Ok"/></strong>. Otherwise, it returns an <strong><see cref="SharpDX.Result"/></strong> error code.</p></returns>
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID2D1CommandSink3::DrawSpriteBatch']/*"/>
/// <msdn-id>mt619823</msdn-id>
/// <unmanaged>HRESULT ID2D1CommandSink3::DrawSpriteBatch([In] ID2D1SpriteBatch* spriteBatch,[In] unsigned int startIndex,[In] unsigned int spriteCount,[In] ID2D1Bitmap* bitmap,[In] D2D1_BITMAP_INTERPOLATION_MODE interpolationMode,[In] D2D1_SPRITE_OPTIONS spriteOptions)</unmanaged>
/// <unmanaged-short>ID2D1CommandSink3::DrawSpriteBatch</unmanaged-short>
void DrawSpriteBatch(SharpDX.Direct2D1.SpriteBatch spriteBatch,
int startIndex,
int spriteCount,
SharpDX.Direct2D1.Bitmap bitmap,
SharpDX.Direct2D1.BitmapInterpolationMode interpolationMode,
SharpDX.Direct2D1.SpriteOptions spriteOptions);

}
}
49 changes: 49 additions & 0 deletions Source/SharpDX.Direct2D1/CommandSink3Native.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

namespace SharpDX.Direct2D1
{
internal partial class CommandSink3Native
{
/// <summary>
/// <p>Renders part or all of the given sprite batch to the device context using the specified drawing options.</p>
/// </summary>
/// <param name="spriteBatch"><dd> <p>The sprite batch to draw.</p> </dd></param>
/// <param name="startIndex"><dd> <p>The index of the first sprite in the sprite batch to draw.</p> </dd></param>
/// <param name="spriteCount"><dd> <p>The number of sprites to draw.</p> </dd></param>
/// <param name="bitmap"><dd> <p>The bitmap from which the sprites are to be sourced. Each sprite?s source rectangle refers to a portion of this bitmap.</p> </dd></param>
/// <param name="interpolationMode"><dd> <p>The interpolation mode to use when drawing this sprite batch. This determines how Direct2D interpolates pixels within the drawn sprites if scaling is performed.</p> </dd></param>
/// <param name="spriteOptions"><dd> <p>The additional drawing options, if any, to be used for this sprite batch.</p> </dd></param>
/// <returns><p>If this method succeeds, it returns <strong><see cref="SharpDX.Result.Ok"/></strong>. Otherwise, it returns an <strong><see cref="SharpDX.Result"/></strong> error code.</p></returns>
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID2D1CommandSink3::DrawSpriteBatch']/*"/>
/// <msdn-id>mt619823</msdn-id>
/// <unmanaged>HRESULT ID2D1CommandSink3::DrawSpriteBatch([In] ID2D1SpriteBatch* spriteBatch,[In] unsigned int startIndex,[In] unsigned int spriteCount,[In] ID2D1Bitmap* bitmap,[In] D2D1_BITMAP_INTERPOLATION_MODE interpolationMode,[In] D2D1_SPRITE_OPTIONS spriteOptions)</unmanaged>
/// <unmanaged-short>ID2D1CommandSink3::DrawSpriteBatch</unmanaged-short>
public void DrawSpriteBatch(SpriteBatch spriteBatch,
int startIndex,
int spriteCount,
Bitmap bitmap,
BitmapInterpolationMode interpolationMode,
SpriteOptions spriteOptions)
{
DrawSpriteBatch_(spriteBatch, startIndex, spriteCount, bitmap, interpolationMode, spriteOptions);
}
}
}
42 changes: 42 additions & 0 deletions Source/SharpDX.Direct2D1/Device3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;

namespace SharpDX.Direct2D1
{
public partial class Device3
{
/// <summary>
/// Initializes a new instance of the <see cref="Device3"/> class.
/// </summary>
/// <param name="factory"><para>The <see cref="Factory4"/> object used when creating the <see cref="SharpDX.Direct2D1.Device3"/>. </para></param>
/// <param name="device"><para>The <see cref="SharpDX.DXGI.Device"/> object used when creating the <see cref="SharpDX.Direct2D1.Device3"/>. </para></param>
/// <remarks>
/// Each call to CreateDevice returns a unique <see cref="SharpDX.Direct2D1.Device3"/> object.The <see cref="SharpDX.DXGI.Device"/> object is obtained by calling QueryInterface on an ID3D10Device or an ID3D11Device.
/// </remarks>
/// <unmanaged>HRESULT ID2D1Factory3::CreateDevice([In] IDXGIDevice* dxgiDevice,[Out] ID2D1Device2** d2dDevice2)</unmanaged>
public Device3(Factory4 factory, SharpDX.DXGI.Device3 device)
: base(IntPtr.Zero)
{
factory.CreateDevice(device, this);
}
}
}
42 changes: 42 additions & 0 deletions Source/SharpDX.Direct2D1/DeviceContext3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;

namespace SharpDX.Direct2D1
{
public partial class DeviceContext3
{
/// <summary>
/// Initializes a new instance of the <see cref="DeviceContext3"/> class using an existing <see cref="Device3"/>.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="options">The options to be applied to the created device context.</param>
/// <remarks>
/// The new device context will not have a selected target bitmap. The caller must create and select a bitmap as the target surface of the context.
/// </remarks>
/// <unmanaged>HRESULT ID2D1Device3::CreateDeviceContext([In] D2D1_DEVICE_CONTEXT_OPTIONS options,[Out] ID2D1DeviceContext3** deviceContext3)</unmanaged>
public DeviceContext3(Device3 device, DeviceContextOptions options)
: base(IntPtr.Zero)
{
device.CreateDeviceContext(options, this);
}
}
}
11 changes: 11 additions & 0 deletions Source/SharpDX.Direct2D1/DirectWrite/GdiInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ public class LogFont
public string lfFaceName;
}

[StructLayout(LayoutKind.Sequential)]
public struct FontSignature
{
public int fsUsb1;
public int fsUsb2;
public int fsUsb3;
public int fsUsb4;
public int fsCsb1;
public int fsCsb2;
}

/// <summary>
/// Creates a font object that matches the properties specified by the LOGFONT structure.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions Source/SharpDX.Direct2D1/DirectWrite/Mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

<include file="dwrite.h" attach="true" output="DirectWrite"/>
<include file="dwrite_1.h" attach="true" output="DirectWrite"/>
<include file="dwrite_2.h" attach="true" output="DirectWrite"/>
<include file="dwrite_3.h" attach="true" output="DirectWrite"/>

<naming />

Expand All @@ -43,6 +45,8 @@
<mapping>
<context>dwrite</context>
<context>dwrite_1</context>
<context>dwrite_2</context>
<context>dwrite_3</context>

<!--
// *****************************************************************
Expand Down Expand Up @@ -143,10 +147,18 @@
<map interface="IDWriteFontFileEnumerator" callback="true" callback-dual="false" />
<map interface="IDWritePixelSnapping" callback="true" callback-dual="false" />
<map interface="IDWriteTextRenderer" callback="true" callback-dual="false" />
<map interface="IDWriteTextRenderer1" callback="true" callback-dual="false" />
<map method="IDWriteGdiInterop::.*?LOGFONT" visibility="internal" />
<map param="logFont" type="void" attribute="in" />
<map param="IDWriteGdiInterop::CreateBitmapRenderTarget::renderTarget" return="true" />
<map param="IDWriteGdiInterop::CreateFontFaceFromHdc::fontFace" return="true" />

<map method="IDWriteGdiInterop1::.*?LOGFONT" visibility="internal" />
<map param="logFont" type="void" attribute="in" />
<map param="IDWriteGdiInterop1::CreateBitmapRenderTarget::renderTarget" return="true" />
<map param="IDWriteGdiInterop1::CreateFontFaceFromHdc::fontFace" return="true" />
<map param="IDWriteGdiInterop1::GetFontSignature::fontSignature" return="true" />
<map param="IDWriteGdiInterop1::CreateFontFromLOGFONT::font" return="true" />

<map param="IDWriteGlyphRunAnalysis::GetAlphaTextureBounds::textureBounds" return="true" />
<map param="IDWriteLocalFontFileLoader::GetFilePathLengthFromKey::filePathLength" return="true" />
Expand Down
36 changes: 36 additions & 0 deletions Source/SharpDX.Direct2D1/GradientMesh.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;

namespace SharpDX.Direct2D1
{
public partial class GradientMesh
{
/// <summary>
/// Initializes a new instance of the <see cref="GradientMesh"/>.
/// </summary>
public GradientMesh(DeviceContext2 context2, GradientMeshPatch[] atchesRef, int patchesCount)
: this(IntPtr.Zero)
{
context2.CreateGradientMesh(atchesRef, patchesCount, this);
}
}
}
36 changes: 36 additions & 0 deletions Source/SharpDX.Direct2D1/ImageSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;

namespace SharpDX.Direct2D1
{
public partial class ImageSource
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageSource"/>.
/// </summary>
public ImageSource(DeviceContext2 context2, DXGI.Surface[] surfaces, int surfaceCount, DXGI.ColorSpaceType colorSpace, ImageSourceFromDxgiOptions options)
: this(IntPtr.Zero)
{
context2.CreateImageSourceFromDxgi(surfaces, surfaceCount, colorSpace, options, this);
}
}
}
36 changes: 36 additions & 0 deletions Source/SharpDX.Direct2D1/ImageSourceFromWic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;

namespace SharpDX.Direct2D1
{
public partial class ImageSourceFromWic
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageSourceFromWic"/>.
/// </summary>
public ImageSourceFromWic(DeviceContext2 context2, WIC.BitmapSource wicBitmapSource, ImageSourceLoadingOptions loadingOptions, AlphaMode alphaMode)
: this(IntPtr.Zero)
{
context2.CreateImageSourceFromWic(wicBitmapSource, loadingOptions, alphaMode, this);
}
}
}
Loading

0 comments on commit 9673433

Please sign in to comment.