|
| 1 | +// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. |
| 2 | +// See the LICENCE file in the repository root for full licence text. |
| 3 | + |
| 4 | +using System; |
| 5 | +using System.Runtime.InteropServices; |
| 6 | + |
| 7 | +// ReSharper disable InconsistentNaming |
| 8 | + |
| 9 | +namespace osu.Framework.Platform.Apple.Native |
| 10 | +{ |
| 11 | + internal partial class Accelerate |
| 12 | + { |
| 13 | + private const string library = "/System/Library/Frameworks/Accelerate.framework/Accelerate"; |
| 14 | + |
| 15 | + [LibraryImport(library)] |
| 16 | + internal static unsafe partial vImageError vImageBuffer_Init(vImageBuffer* buf, uint height, uint width, uint pixelBits, vImageFlags flags); |
| 17 | + |
| 18 | + [LibraryImport(library)] |
| 19 | + internal static unsafe partial vImageError vImageBuffer_InitWithCGImage(vImageBuffer* buf, vImage_CGImageFormat* format, double* backgroundColour, IntPtr image, vImageFlags flags); |
| 20 | + |
| 21 | + public enum vImageError : long |
| 22 | + { |
| 23 | + OutOfPlaceOperationRequired = -21780, // 0xFFFFFFFFFFFFAAEC |
| 24 | + ColorSyncIsAbsent = -21779, // 0xFFFFFFFFFFFFAAED |
| 25 | + InvalidImageFormat = -21778, // 0xFFFFFFFFFFFFAAEE |
| 26 | + InvalidRowBytes = -21777, // 0xFFFFFFFFFFFFAAEF |
| 27 | + InternalError = -21776, // 0xFFFFFFFFFFFFAAF0 |
| 28 | + UnknownFlagsBit = -21775, // 0xFFFFFFFFFFFFAAF1 |
| 29 | + BufferSizeMismatch = -21774, // 0xFFFFFFFFFFFFAAF2 |
| 30 | + InvalidParameter = -21773, // 0xFFFFFFFFFFFFAAF3 |
| 31 | + NullPointerArgument = -21772, // 0xFFFFFFFFFFFFAAF4 |
| 32 | + MemoryAllocationError = -21771, // 0xFFFFFFFFFFFFAAF5 |
| 33 | + InvalidOffsetY = -21770, // 0xFFFFFFFFFFFFAAF6 |
| 34 | + InvalidOffsetX = -21769, // 0xFFFFFFFFFFFFAAF7 |
| 35 | + InvalidEdgeStyle = -21768, // 0xFFFFFFFFFFFFAAF8 |
| 36 | + InvalidKernelSize = -21767, // 0xFFFFFFFFFFFFAAF9 |
| 37 | + RoiLargerThanInputBuffer = -21766, // 0xFFFFFFFFFFFFAAFA |
| 38 | + NoError = 0, |
| 39 | + } |
| 40 | + |
| 41 | + public enum vImageFlags : uint |
| 42 | + { |
| 43 | + NoFlags = 0, |
| 44 | + LeaveAlphaUnchanged = 1, |
| 45 | + CopyInPlace = 2, |
| 46 | + BackgroundColorFill = 4, |
| 47 | + EdgeExtend = 8, |
| 48 | + DoNotTile = 16, // 0x00000010 |
| 49 | + HighQualityResampling = 32, // 0x00000020 |
| 50 | + TruncateKernel = 64, // 0x00000040 |
| 51 | + GetTempBufferSize = 128, // 0x00000080 |
| 52 | + PrintDiagnosticsToConsole = 256, // 0x00000100 |
| 53 | + NoAllocate = 512, // 0x00000200 |
| 54 | + } |
| 55 | + |
| 56 | + public unsafe struct vImageBuffer |
| 57 | + { |
| 58 | + public byte* Data; |
| 59 | + public nuint Height; |
| 60 | + public nuint Width; |
| 61 | + public nuint BytesPerRow; |
| 62 | + } |
| 63 | + |
| 64 | + public unsafe struct vImage_CGImageFormat |
| 65 | + { |
| 66 | + public uint BitsPerComponent; |
| 67 | + public uint BitsPerPixel; |
| 68 | + public CGColorSpace ColorSpace; |
| 69 | + public CGBitmapFlags BitmapInfo; |
| 70 | + public uint Version; |
| 71 | + public double* Decode; |
| 72 | + public CGColorRenderingIntent RenderingIntent; |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments