-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xcode9] Add IOSurface bindings (#2363)
* This framework was a private framework before iOS 11. This framework was a private framework before iOS 11, yet the headers claim many API were introduced in iOS 10. So take account of this difference by using the private framework location in iOS 10.3 or earlier. Testing these API from Xcode works fine when run on an iOS 10.3 device, and I've confirmed the IOSurface framework is loaded from the private frameworks path on older devices (and when built using Xcode 9 and linked with the public framework path). * Disable code to make IOSurface work on iOS 10. Disable the code to make IOSurface work on iOS 10, since it may be rejected by the App Store. This also means adjusting the availability attributes, so that the introspection tests pass (and to document that technically these API won't work when used with Xamarin.iOS in iOS 10). I've filed bug #[59201][1] to keep track of this, maybe we can re-enable this later. [1]: https://bugzilla.xamarin.com/show_bug.cgi?id=59201
- Loading branch information
1 parent
03711e6
commit c453776
Showing
17 changed files
with
413 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// IOSurface | ||
// | ||
// Authors: | ||
// Miguel de Icaza ([email protected]) | ||
// | ||
// 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, | ||
}; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.