Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xcode9] Add IOSurface bindings #2363

Merged
merged 16 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Constants.iOS.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ namespace MonoTouch {
public const string VisionLibrary = "/System/Library/Frameworks/Vision.framework/Vision";
public const string FileProviderLibrary = "/System/Library/Frameworks/FileProvider.framework/FileProvider";
public const string FileProviderUILibrary = "/System/Library/Frameworks/FileProviderUI.framework/FileProviderUI";
public static string IOSurfaceLibrary {
get {
// Disabled because of bug #59201
// #if !COREBUILD && !MTOUCH
// // Sidenote: this is in /System/Library/Frameworks/IOSurface.framework/IOSurface in macOS 10.12.
// if (!XamCore.UIKit.UIDevice.CurrentDevice.CheckSystemVersion (11, 0))
// return "/System/Library/PrivateFrameworks/IOSurface.framework/IOSurface";
// #endif
return "/System/Library/Frameworks/IOSurface.framework/IOSurface";
}
}
public const string PdfKitLibrary = "/System/Library/Frameworks/PDFKit.framework/PDFKit";
}
}
1 change: 1 addition & 0 deletions src/Constants.mac.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ namespace MonoMac {
// macOS 10.13
public const string CoreMLLibrary = "/System/Library/Frameworks/CoreML.framework/CoreML";
public const string VisionLibrary = "/System/Library/Frameworks/Vision.framework/Vision";
public const string IOSurfaceLibrary = "/System/Library/Frameworks/IOSurface.framework/IOSurface";
public const string PhotosUILibrary = "/System/Library/Frameworks/Photos.framework/PhotosUI";
public const string ExternalAccessoryLibrary = "/System/Library/Frameworks/ExternalAccessory.framework/ExternalAccessory";
}
Expand Down
1 change: 1 addition & 0 deletions src/Foundation/NSObject.mac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public partial class NSObject : INativeObject
static IntPtr pc = Dlfcn.dlopen (Constants.PrintCoreLibrary, 1);
static IntPtr cml = Dlfcn.dlopen (Constants.CoreMLLibrary, 1);
static IntPtr vn = Dlfcn.dlopen (Constants.VisionLibrary, 1);
static IntPtr ios = Dlfcn.dlopen (Constants.IOSurfaceLibrary, 1);
static IntPtr ex = Dlfcn.dlopen (Constants.ExternalAccessoryLibrary, 1);
#endif
// ** IF YOU ADD ITEMS HERE PLEASE UPDATE linker/ObjCExtensions.cs and mmp/linker/MonoMac.Tuner/MonoMacNamespaces.cs
Expand Down
38 changes: 38 additions & 0 deletions src/IOSurface/IODefs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// IOSurface
//
// Authors:
// Miguel de Icaza (miguel@xamarin.com)
//
// Copyright 2017 Microsoft
//

using System;
using XamCore.ObjCRuntime;

namespace XamCore.IOSurface {

public enum IOSurfaceLockOptions : uint {
ReadOnly = 1,
AvoidSync = 2,
}

public enum IOSurfacePurgeabilityState : uint {
NonVolatile = 0,
Volatile = 1,
Empty = 2,
KeepCurrent = 3,
}

// To be used with kIOSurfaceCacheMode or IOSurfacePropertyKeyCacheMode
public enum IOSurfaceMemoryMap {
DefaultCache = 0,
InhibitCache = 1 << 8,
WriteThruCache = 2 << 8,
CopybackCache = 3 << 8,
WriteCombineCache = 4 << 8,
CopybackInnerCache = 5 << 8,
};


}
98 changes: 98 additions & 0 deletions src/IOSurface/IOSurface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// IOSurface.cs
//
// Copyright 2016 Microsoft
//
// 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.
//
#if XAMCORE_2_0
using System;
using System.Runtime.InteropServices;
using XamCore.CoreFoundation;
using XamCore.ObjCRuntime;

namespace XamCore.IOSurface {
public partial class IOSurface {

// kern_return_t
// See bug #59201 [iOS (10,0)]
[iOS (11, 0)]
[Mac (10, 12)]
public int Lock (IOSurfaceLockOptions options, ref int seed)
{
unsafe {
fixed (int *p = &seed){
return _Lock (options, (IntPtr) p);
}
}
}

// kern_return_t
// See bug #59201 [iOS (10,0)]
[iOS (11, 0)]
[Mac (10, 12)]
public int Lock (IOSurfaceLockOptions options)
{
return _Lock (options, IntPtr.Zero);
}

// kern_return_t
// See bug #59201 [iOS (10,0)]
[iOS (11, 0)]
[Mac (10, 12)]
public int Unlock (IOSurfaceLockOptions options, ref int seed)
{
unsafe {
fixed (int *p = &seed){
return _Unlock (options, (IntPtr) p);
}
}
}

// kern_return_t
// See bug #59201 [iOS (10,0)]
[iOS (11, 0)]
[Mac (10, 12)]
public int Unlock (IOSurfaceLockOptions options)
{
return _Unlock (options, IntPtr.Zero);
}

#if !MONOMAC
// kern_return_t
[iOS (11, 0)]
public int SetPurgeable (IOSurfacePurgeabilityState newState, ref IOSurfacePurgeabilityState oldState)
{
unsafe {
fixed (IOSurfacePurgeabilityState *p = &oldState){
return _SetPurgeable (newState, (IntPtr) p);
}
}
}

[iOS (11, 0)]
public int SetPurgeable (IOSurfacePurgeabilityState newState)
{
return _SetPurgeable (newState, IntPtr.Zero);
}
#endif
}
}
#endif
9 changes: 9 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ INTENTS_SOURCES = \
Intents/INWorkoutGoalUnitTypeResolutionResult.cs \
Intents/INWorkoutLocationTypeResolutionResult.cs \

# IOSurface
IOSURFACE_CORE_SOURCES = \
IOSurface/IODefs.cs

IOSURFACE_SOURCES = \
IOSurface/IOSurface.cs

# JavaScriptCore

JAVASCRIPTCORE_SOURCES = \
Expand Down Expand Up @@ -1611,6 +1618,7 @@ MAC_FRAMEWORKS = \
ImageIO \
ImageKit \
Intents \
IOSurface \
JavaScriptCore \
LocalAuthentication \
MapKit \
Expand Down Expand Up @@ -1692,6 +1700,7 @@ IOS_FRAMEWORKS = \
ImageIO \
Intents \
IntentsUI \
IOSurface \
JavaScriptCore \
LocalAuthentication \
MapKit \
Expand Down
Loading