[CoreVideo] Add Support for DotNet Attributes (#12627)

This commit is contained in:
TJ Lambert 2021-09-09 22:51:12 -05:00 коммит произвёл GitHub
Родитель 55e8c60e0d
Коммит 4e0151657f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 169 добавлений и 0 удалений

Просмотреть файл

@ -27,6 +27,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
using Foundation;
@ -36,7 +37,9 @@ using Foundation;
namespace CoreVideo {
// CVBuffer.h
#if !NET
[Watch (4,0)]
#endif
public partial class CVBuffer : INativeObject
#if !COREBUILD
, IDisposable

Просмотреть файл

@ -27,6 +27,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
using Foundation;
@ -37,7 +38,9 @@ using CoreGraphics;
namespace CoreVideo {
// CVImageBuffer.h
#if !NET
[Watch (4,0)]
#endif
public partial class CVImageBuffer : CVBuffer {
#if !COREBUILD
internal CVImageBuffer (IntPtr handle) : base (handle)
@ -93,8 +96,13 @@ namespace CoreVideo {
[DllImport (Constants.CoreVideoLibrary)]
extern static /* CGColorSpaceRef */ IntPtr CVImageBufferGetColorSpace (/* CVImageBufferRef */ IntPtr imageBuffer);
#if !NET
[Deprecated (PlatformName.MacOSX, 10, 4)]
[Unavailable (PlatformName.iOS)]
#else
[UnsupportedOSPlatform ("macos10.4")]
[UnsupportedOSPlatform ("ios")]
#endif
public CGColorSpace? ColorSpace {
get {
var h = CVImageBufferGetColorSpace (handle);
@ -102,8 +110,13 @@ namespace CoreVideo {
}
}
#elif !XAMCORE_3_0
#if !NET
[Deprecated (PlatformName.MacOSX, 10, 4)]
[Unavailable (PlatformName.iOS)]
#else
[UnsupportedOSPlatform ("macos10.4")]
[UnsupportedOSPlatform ("ios")]
#endif
#if IOS
[Obsolete ("This API is not available on this platform.")]
#endif
@ -128,40 +141,80 @@ namespace CoreVideo {
#endif
[DllImport (Constants.CoreVideoLibrary)]
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
extern static int CVYCbCrMatrixGetIntegerCodePointForString (IntPtr yCbCrMatrixString);
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static int GetCodePoint (CVImageBufferYCbCrMatrix yCbCrMatrix)
{
return CVYCbCrMatrixGetIntegerCodePointForString (yCbCrMatrix.GetConstant ()!.Handle);
}
[DllImport (Constants.CoreVideoLibrary)]
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
extern static int CVColorPrimariesGetIntegerCodePointForString (IntPtr colorPrimariesString);
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static int GetCodePoint (CVImageBufferColorPrimaries color)
{
return CVColorPrimariesGetIntegerCodePointForString (color.GetConstant ()!.Handle);
}
[DllImport (Constants.CoreVideoLibrary)]
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
extern static int CVTransferFunctionGetIntegerCodePointForString (IntPtr colorPrimariesString);
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static int GetCodePoint (CVImageBufferTransferFunction function)
{
return CVTransferFunctionGetIntegerCodePointForString (function.GetConstant ()!.Handle);
}
[DllImport (Constants.CoreVideoLibrary)]
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
extern static IntPtr CVYCbCrMatrixGetStringForIntegerCodePoint (int yCbCrMatrixCodePoint);
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static CVImageBufferYCbCrMatrix GetYCbCrMatrixOption (int yCbCrMatrixCodePoint)
{
var ret = Runtime.GetNSObject<NSString> (CVYCbCrMatrixGetStringForIntegerCodePoint (yCbCrMatrixCodePoint));
@ -169,10 +222,20 @@ namespace CoreVideo {
}
[DllImport (Constants.CoreVideoLibrary)]
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
extern static IntPtr CVColorPrimariesGetStringForIntegerCodePoint (int colorPrimariesCodePoint);
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static CVImageBufferColorPrimaries GetColorPrimariesOption (int colorPrimariesCodePoint)
{
var ret = Runtime.GetNSObject<NSString> (CVColorPrimariesGetStringForIntegerCodePoint (colorPrimariesCodePoint));
@ -180,10 +243,20 @@ namespace CoreVideo {
}
[DllImport (Constants.CoreVideoLibrary)]
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
extern static IntPtr CVTransferFunctionGetStringForIntegerCodePoint (int transferFunctionCodePoint);
#if !NET
[iOS (11, 0), Mac (10, 13), TV (11, 0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static CVImageBufferTransferFunction GetTransferFunctionOption (int transferFunctionCodePoint)
{
var ret = Runtime.GetNSObject<NSString> (CVTransferFunctionGetStringForIntegerCodePoint (transferFunctionCodePoint));

Просмотреть файл

@ -12,6 +12,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using CoreFoundation;
@ -22,7 +23,9 @@ using Metal;
namespace CoreVideo {
#if !NET
[iOS (8,0)]
#endif
public class CVMetalTexture : INativeObject, IDisposable {
internal IntPtr handle;

Просмотреть файл

@ -12,6 +12,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using CoreFoundation;
using Foundation;
@ -21,7 +22,9 @@ using Metal;
namespace CoreVideo {
#if !NET
[iOS (8,0)]
#endif
public partial class CVMetalTextureCache : INativeObject, IDisposable {
internal IntPtr handle;

Просмотреть файл

@ -22,7 +22,9 @@ using CVPixelBufferRef=System.IntPtr;
namespace CoreVideo {
#if !NET
[Watch (4,0)]
#endif
public partial class CVPixelBuffer : CVImageBuffer {
#if !COREBUILD
[DllImport (Constants.CoreVideoLibrary, EntryPoint = "CVPixelBufferGetTypeID")]

Просмотреть файл

@ -29,12 +29,15 @@ using System;
using Foundation;
using CoreFoundation;
using ObjCRuntime;
using System.Runtime.Versioning;
#nullable enable
namespace CoreVideo {
#if !NET
[Watch (4,0)]
#endif
public class CVPixelBufferAttributes : DictionaryContainer
{
#if !COREBUILD
@ -200,7 +203,9 @@ namespace CoreVideo {
}
#endif
#if !NET
[iOS (8,0)]
#endif
public bool? MetalCompatibility {
set {
SetBooleanValue (CVPixelBuffer.MetalCompatibilityKey, value);

Просмотреть файл

@ -9,6 +9,7 @@
#if !WATCH
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using Foundation;
using ObjCRuntime;
@ -18,13 +19,23 @@ using ObjCRuntime;
namespace CoreVideo {
public partial class CVPixelBuffer : CVImageBuffer {
#if !NET
[iOS (11,0), Mac (10,13), TV (11,0), NoWatch]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
[DllImport (Constants.CoreVideoLibrary)]
extern static IntPtr /* IOSurfaceRef */ CVPixelBufferGetIOSurface (
/* CVPixelBufferRef CV_NULLABLE */ IntPtr pixelBuffer
);
#if !NET
[iOS (11,0), Mac (10,13), TV (11,0), NoWatch]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public IOSurface.IOSurface? GetIOSurface ()
{
if (Handle == IntPtr.Zero)
@ -37,7 +48,12 @@ namespace CoreVideo {
return Runtime.GetINativeObject <IOSurface.IOSurface> (ret, false);
}
#if !NET
[iOS (11,0), Mac (10,13), TV (11,0), NoWatch]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
[DllImport (Constants.CoreVideoLibrary)]
extern static CVReturn /* IOSurfaceRef */ CVPixelBufferCreateWithIOSurface (
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
@ -46,7 +62,12 @@ namespace CoreVideo {
/* CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ out IntPtr pixelBufferOut
);
#if !NET
[iOS (11,0), Mac (10,13), TV (11,0), NoWatch]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static CVPixelBuffer? Create (IOSurface.IOSurface surface, out CVReturn result, CVPixelBufferAttributes? pixelBufferAttributes = null)
{
if (surface == null)
@ -66,7 +87,12 @@ namespace CoreVideo {
return new CVPixelBuffer (pixelBufferPtr, true);
}
#if !NET
[iOS (11,0), Mac (10,13), TV (11,0), NoWatch]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public static CVPixelBuffer? Create (IOSurface.IOSurface surface, CVPixelBufferAttributes? pixelBufferAttributes = null)
{
CVReturn result;

Просмотреть файл

@ -9,6 +9,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
using Foundation;
@ -18,7 +19,9 @@ using Foundation;
namespace CoreVideo {
// CVPixelBufferPool.h
#if !NET
[Watch (4,0)]
#endif
public partial class CVPixelBufferPool : INativeObject
#if !COREBUILD
, IDisposable
@ -166,12 +169,16 @@ namespace CoreVideo {
}
#if !NET
[iOS (9,0)][Mac (10,11)]
#endif
[DllImport (Constants.CoreVideoLibrary)]
static extern void CVPixelBufferPoolFlush (/* CVPixelBufferPoolRef __nonnull */ IntPtr pool,
CVPixelBufferPoolFlushFlags options);
#if !NET
[iOS (9,0)][Mac (10,11)]
#endif
public void Flush (CVPixelBufferPoolFlushFlags options)
{
CVPixelBufferPoolFlush (handle, options);

Просмотреть файл

@ -30,12 +30,15 @@ using System;
using Foundation;
using CoreFoundation;
using ObjCRuntime;
using System.Runtime.Versioning;
#nullable enable
namespace CoreVideo {
#if !NET
[Watch (4,0)]
#endif
public class CVPixelBufferPoolSettings : DictionaryContainer
{
#if !COREBUILD
@ -69,7 +72,9 @@ namespace CoreVideo {
#endif
}
#if !NET
[Watch (4,0)]
#endif
public partial class CVPixelBufferPoolAllocationSettings : DictionaryContainer {
#if !COREBUILD
public CVPixelBufferPoolAllocationSettings ()

Просмотреть файл

@ -27,6 +27,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
using Foundation;
@ -35,7 +36,9 @@ using Foundation;
namespace CoreVideo {
#if !NET
[Watch (4,0)]
#endif
public static class CVPixelFormatDescription {
#if !COREBUILD
public static readonly NSString NameKey;
@ -65,21 +68,38 @@ namespace CoreVideo {
public static readonly NSString FillExtendedPixelsCallbackKey;
#if !NET
[iOS (8,0)][Mac (10,10)]
#endif
public static readonly NSString ContainsRgb;
#if !NET
[iOS (8,0)][Mac (10,10)]
#endif
public static readonly NSString ContainsYCbCr;
#if !NET
[iOS (9,0)][Mac (10,10)]
#endif
public static readonly NSString ComponentRangeKey;
#if !NET
[iOS (9,0)][Mac (10,10)]
#endif
public static readonly NSString ComponentRangeFullRangeKey;
#if !NET
[iOS (9,0)][Mac (10,10)]
#endif
public static readonly NSString ComponentRangeVideoRangeKey;
#if !NET
[iOS (9,0)][Mac (10,10)]
#endif
public static readonly NSString ComponentRangeWideRangeKey;
#if !NET
[iOS (12,0)][TV (12,0)][Watch (5,0)][Mac (10,14)]
#else
[SupportedOSPlatform ("ios12.0")]
[SupportedOSPlatform ("tvos12.0")]
#endif
public static readonly NSString ContainsGrayscaleKey;
static CVPixelFormatDescription ()

Просмотреть файл

@ -41,7 +41,9 @@ namespace CoreVideo {
// for which ObjC API uses `int` instead of the enum
// untyped enum, some are 4CC -> CVPixelBuffer.h
#if !NET
[Watch (3,0)]
#endif
public enum CVPixelFormatType : uint {
// FIXME: These all start with integers; what should we do here?
CV1Monochrome = 0x00000001,

Просмотреть файл

@ -27,6 +27,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
@ -35,7 +36,9 @@ using ObjCRuntime;
namespace CoreVideo {
// CVBase.h
#if !NET
[Watch (4,0)]
#endif
public struct CVTime {
public /* int64_t */ long TimeValue;

Просмотреть файл

@ -27,6 +27,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using Foundation;
using ObjCRuntime;
@ -36,33 +37,43 @@ using ObjCRuntime;
namespace CoreVideo {
// CVPixelBuffer.h
#if !NET
[Watch (4,0)]
#endif
public struct CVPlanarComponentInfo {
public /* int32_t */ int Offset;
public /* uint32_t */ uint RowBytes;
}
// CVPixelBuffer.h
#if !NET
[Watch (4,0)]
#endif
public struct CVPlanarPixelBufferInfo {
public CVPlanarComponentInfo[] ComponentInfo;
}
// CVPixelBuffer.h
#if !NET
[Watch (4,0)]
#endif
public struct CVPlanarPixelBufferInfo_YCbCrPlanar {
public CVPlanarComponentInfo ComponentInfoY;
public CVPlanarComponentInfo ComponentInfoCb;
public CVPlanarComponentInfo ComponentInfoCr;
}
#if !NET
[Watch (4,0)]
#endif
public struct CVPlanarPixelBufferInfo_YCbCrBiPlanar {
public CVPlanarComponentInfo ComponentInfoY;
public CVPlanarComponentInfo ComponentInfoCbCr;
}
#if !NET
[Watch (4,0)]
#endif
public struct CVTimeStamp {
public UInt32 Version;
public Int32 VideoTimeScale;
@ -75,7 +86,9 @@ namespace CoreVideo {
public UInt64 Reserved;
}
#if !NET
[Watch (4,0)]
#endif
public struct CVSMPTETime {
public Int16 Subframes;
public Int16 SubframeDivisor;
@ -88,13 +101,17 @@ namespace CoreVideo {
public Int16 Frames;
}
#if !NET
[Watch (4,0)]
#endif
public struct CVFillExtendedPixelsCallBackData {
public nint /* CFIndex */ Version;
public CVFillExtendedPixelsCallBack FillCallBack;
public IntPtr UserInfo;
}
#if !NET
[Watch (4,0)]
#endif
public delegate bool CVFillExtendedPixelsCallBack (IntPtr pixelBuffer, IntPtr refCon);
}