mirror of
https://github.com/amerkoleci/Vortice.Win32.git
synced 2026-01-14 16:16:04 +08:00
Improve in CheckFeatureSupport support across library.
This commit is contained in:
@@ -9,180 +9,241 @@ using static Win32.Graphics.Direct2D.Apis;
|
||||
|
||||
namespace Win32.Graphics.Direct2D;
|
||||
|
||||
public unsafe partial struct ID2D1DeviceContext
|
||||
public static unsafe class ID2D1DeviceContextExtensions
|
||||
{
|
||||
public HResult CreateBitmap(Size size, BitmapProperties* bitmapProperties, ID2D1Bitmap** bitmap)
|
||||
public static HResult CreateBitmapt<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, Size size, BitmapProperties* bitmapProperties, ID2D1Bitmap** bitmap)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateBitmap(size, null, 0, bitmapProperties, bitmap);
|
||||
return self.CreateBitmap(size, null, 0, bitmapProperties, bitmap);
|
||||
}
|
||||
|
||||
public HResult CreateBitmapFromWicBitmap(IWICBitmapSource* wicBitmapSource, ID2D1Bitmap** bitmap)
|
||||
public static HResult CreateBitmapFromWicBitmapt<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, IWICBitmapSource* wicBitmapSource, ID2D1Bitmap** bitmap)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
|
||||
return self.CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
|
||||
}
|
||||
|
||||
public HResult CreateBitmapBrush(ID2D1Bitmap* bitmap, ID2D1BitmapBrush** bitmapBrush)
|
||||
public static HResult CreateBitmapBrusht<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Bitmap* bitmap, ID2D1BitmapBrush** bitmapBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateBitmapBrush(bitmap, null, null, bitmapBrush);
|
||||
return self.CreateBitmapBrush(bitmap, null, null, bitmapBrush);
|
||||
}
|
||||
|
||||
public HResult CreateBitmapBrush(ID2D1Bitmap* bitmap, BitmapBrushProperties* bitmapBrushProperties, ID2D1BitmapBrush** bitmapBrush)
|
||||
public static HResult CreateBitmapBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Bitmap* bitmap, BitmapBrushProperties* bitmapBrushProperties, ID2D1BitmapBrush** bitmapBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateBitmapBrush(bitmap, bitmapBrushProperties, null, bitmapBrush);
|
||||
return self.CreateBitmapBrush(bitmap, bitmapBrushProperties, null, bitmapBrush);
|
||||
}
|
||||
|
||||
public HResult CreateSolidColorBrush(Color4* color, ID2D1SolidColorBrush** solidColorBrush)
|
||||
public static HResult CreateSolidColorBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, Color4* color, ID2D1SolidColorBrush** solidColorBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateSolidColorBrush(color, null, solidColorBrush);
|
||||
return self.CreateSolidColorBrush(color, null, solidColorBrush);
|
||||
}
|
||||
|
||||
public HResult CreateGradientStopCollection(GradientStop* gradientStops, uint gradientStopsCount, ID2D1GradientStopCollection** gradientStopCollection)
|
||||
public static HResult CreateSolidColorBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, Color4 color, ID2D1SolidColorBrush** solidColorBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateGradientStopCollection(gradientStops, gradientStopsCount, Gamma.Gamma_2_2, ExtendMode.Clamp, gradientStopCollection);
|
||||
return self.CreateSolidColorBrush(&color, null, solidColorBrush);
|
||||
}
|
||||
|
||||
public HResult CreateLinearGradientBrush(LinearGradientBrushProperties* linearGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1LinearGradientBrush** linearGradientBrush)
|
||||
public static HResult CreateGradientStopCollection<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, GradientStop* gradientStops, int gradientStopsCount, ID2D1GradientStopCollection** gradientStopCollection)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateLinearGradientBrush(linearGradientBrushProperties, null, gradientStopCollection, linearGradientBrush);
|
||||
return self.CreateGradientStopCollection(gradientStops, (uint)gradientStopsCount, Gamma.Gamma_2_2, ExtendMode.Clamp, gradientStopCollection);
|
||||
}
|
||||
|
||||
public HResult CreateRadialGradientBrush(RadialGradientBrushProperties* radialGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1RadialGradientBrush** radialGradientBrush)
|
||||
public static HResult CreateLinearGradientBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, LinearGradientBrushProperties* linearGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1LinearGradientBrush** linearGradientBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateRadialGradientBrush(radialGradientBrushProperties, null, gradientStopCollection, radialGradientBrush);
|
||||
return self.CreateLinearGradientBrush(linearGradientBrushProperties, null, gradientStopCollection, linearGradientBrush);
|
||||
}
|
||||
|
||||
public HResult CreateCompatibleRenderTarget(ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
public static HResult CreateRadialGradientBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, RadialGradientBrushProperties* radialGradientBrushProperties, ID2D1GradientStopCollection* gradientStopCollection, ID2D1RadialGradientBrush** radialGradientBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateCompatibleRenderTarget(null, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
return self.CreateRadialGradientBrush(radialGradientBrushProperties, null, gradientStopCollection, radialGradientBrush);
|
||||
}
|
||||
|
||||
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateCompatibleRenderTarget(&desiredSize, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
return self.CreateCompatibleRenderTarget(null, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
}
|
||||
|
||||
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, Size desiredPixelSize, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, SizeF desiredSize, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
return self.CreateCompatibleRenderTarget(&desiredSize, null, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
}
|
||||
|
||||
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, SizeF desiredSize, Size desiredPixelSize, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
return self.CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, null, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
}
|
||||
|
||||
public HResult CreateCompatibleRenderTarget(SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, CompatibleRenderTargetOptions options, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, options, bitmapRenderTarget);
|
||||
return self.CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, CompatibleRenderTargetOptions.None, bitmapRenderTarget);
|
||||
}
|
||||
|
||||
public HResult CreateLayer(SizeF size, ID2D1Layer** layer)
|
||||
public static HResult CreateCompatibleRenderTarget<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, SizeF desiredSize, Size desiredPixelSize, PixelFormat desiredFormat, CompatibleRenderTargetOptions options, ID2D1BitmapRenderTarget** bitmapRenderTarget)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateLayer(&size, layer);
|
||||
return self.CreateCompatibleRenderTarget(&desiredSize, &desiredPixelSize, &desiredFormat, options, bitmapRenderTarget);
|
||||
}
|
||||
|
||||
public HResult CreateLayer(ID2D1Layer** layer)
|
||||
public static HResult CreateLayer<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, SizeF size, ID2D1Layer** layer)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateLayer(null, layer);
|
||||
}
|
||||
public HResult CreateBitmapFromWicBitmap(IWICBitmapSource* wicBitmapSource, ID2D1Bitmap1** bitmap)
|
||||
{
|
||||
return CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
|
||||
return self.CreateLayer(&size, layer);
|
||||
}
|
||||
|
||||
public HResult CreateImageBrush(ID2D1Image* image, ImageBrushProperties* imageBrushProperties, ID2D1ImageBrush** imageBrush)
|
||||
public static HResult CreateLayer<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Layer** layer)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateImageBrush(image, imageBrushProperties, null, imageBrush);
|
||||
return self.CreateLayer(null, layer);
|
||||
}
|
||||
public static HResult CreateBitmapFromWicBitmap<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, IWICBitmapSource* wicBitmapSource, ID2D1Bitmap1** bitmap)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return self.CreateBitmapFromWicBitmap(wicBitmapSource, null, bitmap);
|
||||
}
|
||||
|
||||
public HResult CreateBitmapBrush(ID2D1Bitmap* bitmap, ID2D1BitmapBrush1** bitmapBrush)
|
||||
public static HResult CreateImageBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Image* image, ImageBrushProperties* imageBrushProperties, ID2D1ImageBrush** imageBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateBitmapBrush(bitmap, null, null, bitmapBrush);
|
||||
return self.CreateImageBrush(image, imageBrushProperties, null, imageBrush);
|
||||
}
|
||||
|
||||
public HResult CreateEffect(in Guid effectId, ID2D1Effect** effect)
|
||||
public static HResult CreateBitmapBrush<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Bitmap* bitmap, ID2D1BitmapBrush1** bitmapBrush)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect);
|
||||
return self.CreateBitmapBrush(bitmap, null, null, bitmapBrush);
|
||||
}
|
||||
|
||||
public ComPtr<ID2D1Effect> CreateEffect(in Guid effectId)
|
||||
public static HResult CreateEffect<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, in Guid effectId, ID2D1Effect** effect)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
return self.CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect);
|
||||
}
|
||||
|
||||
public static ComPtr<ID2D1Effect> CreateEffect<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, in Guid effectId)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
using ComPtr<ID2D1Effect> effect = default;
|
||||
ThrowIfFailed(CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect.GetAddressOf()));
|
||||
ThrowIfFailed(self.CreateEffect((Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in effectId)), effect.GetAddressOf()));
|
||||
return effect.Move();
|
||||
}
|
||||
|
||||
public void DrawImage(
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self,
|
||||
ID2D1Effect* effect,
|
||||
Vector2* targetOffset = null,
|
||||
RectF* imageRectangle = null,
|
||||
InterpolationMode interpolationMode = InterpolationMode.Linear,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
ID2D1Image* output = null;
|
||||
|
||||
effect->GetOutput(&output);
|
||||
DrawImage(output, targetOffset, imageRectangle, interpolationMode, compositeMode);
|
||||
self.DrawImage(output, targetOffset, imageRectangle, interpolationMode, compositeMode);
|
||||
_ = output->Release();
|
||||
}
|
||||
|
||||
public void DrawImage(
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self,
|
||||
ID2D1Image* image,
|
||||
InterpolationMode interpolationMode,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawImage(image, null, null, interpolationMode, compositeMode);
|
||||
self.DrawImage(image, null, null, interpolationMode, compositeMode);
|
||||
}
|
||||
|
||||
public void DrawImage(ID2D1Effect* effect,
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self,
|
||||
ID2D1Effect* effect,
|
||||
InterpolationMode interpolationMode,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawImage(effect, null, null, interpolationMode, compositeMode);
|
||||
self.DrawImage(effect, null, null, interpolationMode, compositeMode);
|
||||
}
|
||||
|
||||
public void DrawImage(ID2D1Image* image,
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Image* image,
|
||||
Vector2 targetOffset,
|
||||
InterpolationMode interpolationMode = InterpolationMode.Linear,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawImage(image, &targetOffset, null, interpolationMode, compositeMode);
|
||||
self.DrawImage(image, &targetOffset, null, interpolationMode, compositeMode);
|
||||
}
|
||||
|
||||
public void DrawImage(ID2D1Effect* effect,
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Effect* effect,
|
||||
Vector2 targetOffset,
|
||||
InterpolationMode interpolationMode = InterpolationMode.Linear,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawImage(effect, &targetOffset, null, interpolationMode, compositeMode);
|
||||
self.DrawImage(effect, &targetOffset, null, interpolationMode, compositeMode);
|
||||
}
|
||||
|
||||
public void DrawImage(ID2D1Image* image,
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Image* image,
|
||||
Vector2 targetOffset,
|
||||
RectF* imageRectangle,
|
||||
InterpolationMode interpolationMode = InterpolationMode.Linear,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawImage(image, &targetOffset, imageRectangle, interpolationMode, compositeMode);
|
||||
self.DrawImage(image, &targetOffset, imageRectangle, interpolationMode, compositeMode);
|
||||
}
|
||||
|
||||
public void DrawImage(ID2D1Effect* effect,
|
||||
public static void DrawImage<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1Effect* effect,
|
||||
Vector2 targetOffset,
|
||||
RectF* imageRectangle,
|
||||
InterpolationMode interpolationMode = InterpolationMode.Linear,
|
||||
CompositeMode compositeMode = CompositeMode.SourceOver)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawImage(effect, &targetOffset, imageRectangle, interpolationMode, compositeMode);
|
||||
self.DrawImage(effect, &targetOffset, imageRectangle, interpolationMode, compositeMode);
|
||||
}
|
||||
|
||||
public void DrawGdiMetafile(ID2D1GdiMetafile* gdiMetafile, Vector2 targetOffset)
|
||||
public static void DrawGdiMetafile<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self, ID2D1GdiMetafile* gdiMetafile, Vector2 targetOffset)
|
||||
where TD2D1DeviceContext : unmanaged, ID2D1DeviceContext.Interface
|
||||
{
|
||||
DrawGdiMetafile(gdiMetafile, &targetOffset);
|
||||
self.DrawGdiMetafile(gdiMetafile, &targetOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe partial class ID2D1DeviceContextExtensions
|
||||
{
|
||||
public static HResult SetDpiCompensatedEffectInput<TD2D1DeviceContext>(
|
||||
ref this TD2D1DeviceContext self,
|
||||
ID2D1Effect* effect,
|
||||
|
||||
Reference in New Issue
Block a user