NativeMethods.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace GpuInterop;
  4. static class NativeMethods
  5. {
  6. [Flags]
  7. public enum IOSurfaceLockOptions : uint
  8. {
  9. None = 0,
  10. ReadOnly = 1 << 0,
  11. AvoidSync = 1 << 1,
  12. }
  13. [DllImport("/System/Library/Frameworks/IOSurface.framework/IOSurface")]
  14. public static extern int IOSurfaceLock(IntPtr surface, IOSurfaceLockOptions options, IntPtr seed);
  15. [DllImport("/System/Library/Frameworks/IOSurface.framework/IOSurface")]
  16. public static extern nint IOSurfaceGetWidth(IntPtr surface);
  17. [DllImport("/System/Library/Frameworks/IOSurface.framework/IOSurface")]
  18. public static extern nint IOSurfaceGetHeight(IntPtr surface);
  19. [DllImport("/System/Library/Frameworks/IOSurface.framework/IOSurface")]
  20. public static extern nint IOSurfaceGetBytesPerRow(IntPtr surface);
  21. [DllImport("/System/Library/Frameworks/IOSurface.framework/IOSurface")]
  22. public static extern IntPtr IOSurfaceGetBaseAddress(IntPtr surface);
  23. [DllImport("/System/Library/Frameworks/IOSurface.framework/IOSurface")]
  24. public static extern void IOSurfaceUnlock(IntPtr surface, IOSurfaceLockOptions options, IntPtr seed);
  25. [DllImport("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
  26. public static extern IntPtr CFRetain(IntPtr cf);
  27. [DllImport("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
  28. public static extern void CFRelease(IntPtr cf);
  29. [DllImport("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
  30. public static extern nint CFGetRetainCount(IntPtr cf);
  31. }