diff --git a/src/frameworks/IOSurface/CMakeLists.txt b/src/frameworks/IOSurface/CMakeLists.txt index e87169c6a..f2e38dbf0 100644 --- a/src/frameworks/IOSurface/CMakeLists.txt +++ b/src/frameworks/IOSurface/CMakeLists.txt @@ -9,11 +9,14 @@ add_framework(IOSurface VERSION "A" SOURCES - src/IOSurface.m - src/IOSurface.m + src/stubs.m + src/api.m + src/constants.m + src/IOSurfaceObjC.m DEPENDENCIES system objc Foundation + IOKit ) diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurface.h b/src/frameworks/IOSurface/include/IOSurface/IOSurface.h index d1b832b7a..7e586bbc2 100644 --- a/src/frameworks/IOSurface/include/IOSurface/IOSurface.h +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurface.h @@ -21,152 +21,7 @@ #ifndef _IOSurface_H_ #define _IOSurface_H_ -#import - -@interface IOSurface : NSObject - -@end - -void* IOSurfaceAlignProperty(void); -void* IOSurfaceAllowsPixelSizeCasting(void); -void* IOSurfaceBindAccel(void); -void* IOSurfaceBindAccelOnPlane(void); -void* IOSurfaceClientAlignProperty(void); -void* IOSurfaceClientAllowsPixelSizeCasting(void); -void* IOSurfaceClientBindAccel(void); -void* IOSurfaceClientCopyAllValues(void); -void* IOSurfaceClientCopyDataValueBytes(void); -void* IOSurfaceClientCopyValue(void); -void* IOSurfaceClientCreate(void); -void* IOSurfaceClientCreateMachPort(void); -void* IOSurfaceClientDecrementUseCount(void); -void* IOSurfaceClientFlushProcessorCaches(void); -void* IOSurfaceClientGetAllocSize(void); -void* IOSurfaceClientGetBaseAddress(void); -void* IOSurfaceClientGetBaseAddressOfPlane(void); -void* IOSurfaceClientGetBitDepthOfComponentOfPlane(void); -void* IOSurfaceClientGetBitOffsetOfComponentOfPlane(void); -void* IOSurfaceClientGetBulkAttachments(void); -void* IOSurfaceClientGetBytesPerElement(void); -void* IOSurfaceClientGetBytesPerElementOfPlane(void); -void* IOSurfaceClientGetBytesPerRow(void); -void* IOSurfaceClientGetBytesPerRowOfPlane(void); -void* IOSurfaceClientGetCacheMode(void); -void* IOSurfaceClientGetElementHeight(void); -void* IOSurfaceClientGetElementHeightOfPlane(void); -void* IOSurfaceClientGetElementWidth(void); -void* IOSurfaceClientGetElementWidthOfPlane(void); -void* IOSurfaceClientGetHeight(void); -void* IOSurfaceClientGetHeightOfPlane(void); -void* IOSurfaceClientGetID(void); -void* IOSurfaceClientGetNameOfComponentOfPlane(void); -void* IOSurfaceClientGetNumberOfComponentsOfPlane(void); -void* IOSurfaceClientGetPixelFormat(void); -void* IOSurfaceClientGetPlaneCount(void); -void* IOSurfaceClientGetPropertyAlignment(void); -void* IOSurfaceClientGetPropertyMaximum(void); -void* IOSurfaceClientGetProtectionOptions(void); -void* IOSurfaceClientGetRangeOfComponentOfPlane(void); -void* IOSurfaceClientGetSeed(void); -void* IOSurfaceClientGetSubsampling(void); -void* IOSurfaceClientGetTypeOfComponentOfPlane(void); -void* IOSurfaceClientGetUseCount(void); -void* IOSurfaceClientGetWidth(void); -void* IOSurfaceClientGetWidthOfPlane(void); -void* IOSurfaceClientGetYCbCrMatrix(void); -void* IOSurfaceClientIncrementUseCount(void); -void* IOSurfaceClientIsDisplayable(void); -void* IOSurfaceClientIsInUse(void); -void* IOSurfaceClientLock(void); -void* IOSurfaceClientLookup(void); -void* IOSurfaceClientLookupFromMachPort(void); -void* IOSurfaceClientNeedsBindAccel(void); -void* IOSurfaceClientRelease(void); -void* IOSurfaceClientRemoveSurfaceNotify(void); -void* IOSurfaceClientRemoveValue(void); -void* IOSurfaceClientRetain(void); -void* IOSurfaceClientSetBulkAttachments(void); -void* IOSurfaceClientSetPurgeable(void); -void* IOSurfaceClientSetSurfaceNotify(void); -void* IOSurfaceClientSetValue(void); -void* IOSurfaceClientSetYCbCrMatrix(void); -void* IOSurfaceClientSupportsProtectionOptions(void); -void* IOSurfaceClientUnlock(void); -void* IOSurfaceCopyAllValues(void); -void* IOSurfaceCopyDataValueBytes(void); -void* IOSurfaceCopyValue(void); -void* IOSurfaceCreate(void); -void* IOSurfaceCreateMachPort(void); -void* IOSurfaceCreateXPCObject(void); -void* IOSurfaceDecrementUseCount(void); -void* IOSurfaceFlushProcessorCaches(void); -void* IOSurfaceGetAllocSize(void); -void* IOSurfaceGetBaseAddress(void); -void* IOSurfaceGetBaseAddressOfPlane(void); -void* IOSurfaceGetBitDepthOfComponentOfPlane(void); -void* IOSurfaceGetBitOffsetOfComponentOfPlane(void); -void* IOSurfaceGetBitsPerBlock(void); -void* IOSurfaceGetBitsPerBlockOfPlane(void); -void* IOSurfaceGetBlockHeightOfPlane(void); -void* IOSurfaceGetBlockWidthOfPlane(void); -void* IOSurfaceGetBulkAttachments(void); -void* IOSurfaceGetBytesPerElement(void); -void* IOSurfaceGetBytesPerElementOfPlane(void); -void* IOSurfaceGetBytesPerRow(void); -void* IOSurfaceGetBytesPerRowOfPlane(void); -void* IOSurfaceGetCacheMode(void); -void* IOSurfaceGetElementHeight(void); -void* IOSurfaceGetElementHeightOfPlane(void); -void* IOSurfaceGetElementWidth(void); -void* IOSurfaceGetElementWidthOfPlane(void); -void* IOSurfaceGetGraphicsCommPageAddress(void); -void* IOSurfaceGetHeight(void); -void* IOSurfaceGetHeightOfPlane(void); -void* IOSurfaceGetID(void); -void* IOSurfaceGetNameOfComponentOfPlane(void); -void* IOSurfaceGetNumberOfComponentsOfPlane(void); -void* IOSurfaceGetPixelFormat(void); -void* IOSurfaceGetPlaneCount(void); -void* IOSurfaceGetPropertyAlignment(void); -void* IOSurfaceGetPropertyMaximum(void); -void* IOSurfaceGetProtectionOptions(void); -void* IOSurfaceGetRangeOfComponentOfPlane(void); -void* IOSurfaceGetSeed(void); -void* IOSurfaceGetSeedOfPlane(void); -void* IOSurfaceGetSubsampling(void); -void* IOSurfaceGetTypeID(void); -void* IOSurfaceGetTypeOfComponentOfPlane(void); -void* IOSurfaceGetUseCount(void); -void* IOSurfaceGetWidth(void); -void* IOSurfaceGetWidthOfPlane(void); -void* IOSurfaceGetYCbCrMatrix(void); -void* IOSurfaceIncrementUseCount(void); -void* IOSurfaceIsDisplayable(void); -void* IOSurfaceIsInUse(void); -void* IOSurfaceLock(void); -void* IOSurfaceLockPlane(void); -void* IOSurfaceLog(void); -void* IOSurfaceLookup(void); -void* IOSurfaceLookupFromMachPort(void); -void* IOSurfaceLookupFromXPCObject(void); -void* IOSurfaceNeedsBindAccel(void); -void* IOSurfaceNeedsBindAccelOnPlane(void); -void* IOSurfaceNotifierCreate(void); -void* IOSurfaceNotifierGetMachPort(void); -void* IOSurfaceNotifierGetRunLoopSource(void); -void* IOSurfaceNotifierGetTypeID(void); -void* IOSurfaceNotifierSetDispatchQueue(void); -void* IOSurfaceRemoveAllValues(void); -void* IOSurfaceRemoveValue(void); -void* IOSurfaceSetBulkAttachments(void); -void* IOSurfaceSetBulkAttachments2(void); -void* IOSurfaceSetPurgeable(void); -void* IOSurfaceSetValue(void); -void* IOSurfaceSetValues(void); -void* IOSurfaceSetYCbCrMatrix(void); -void* IOSurfaceSupportsProtectionOptions(void); -void* IOSurfaceUnlock(void); -void* IOSurfaceUnlockPlane(void); -void* _ioSurfaceAddClientRef(void); +#include +#include #endif diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurfaceAPI.h b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceAPI.h new file mode 100644 index 000000000..57b0fbd96 --- /dev/null +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceAPI.h @@ -0,0 +1,17 @@ +#ifndef IOSURFACE_API_H +#define IOSURFACE_API_H + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +xpc_object_t IOSurfaceCreateXPCObject(IOSurfaceRef surface); +IOSurfaceRef IOSurfaceLookupFromXPCObject(xpc_object_t obj); + +__END_DECLS + +#endif diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurfaceBase.h b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceBase.h new file mode 100644 index 000000000..7766cbd48 --- /dev/null +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceBase.h @@ -0,0 +1,9 @@ +#ifndef IOSURFACE_BASE_H +#define IOSURFACE_BASE_H + +#include +#include +#include +#include + +#endif diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurfaceObjC.h b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceObjC.h new file mode 100644 index 000000000..cee46a8fc --- /dev/null +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceObjC.h @@ -0,0 +1,96 @@ +#ifndef IOSURFACE_OBJC_H +#define IOSURFACE_OBJC_H + +#ifdef __OBJC__ + +#import +#import +#import + +typedef NSString *IOSurfacePropertyKey; + +__BEGIN_DECLS + + +extern IOSurfacePropertyKey IOSurfacePropertyKeyAllocSize; +extern IOSurfacePropertyKey IOSurfacePropertyKeyWidth; +extern IOSurfacePropertyKey IOSurfacePropertyKeyHeight; +extern IOSurfacePropertyKey IOSurfacePropertyKeyBytesPerRow; +extern IOSurfacePropertyKey IOSurfacePropertyKeyBytesPerElement; +extern IOSurfacePropertyKey IOSurfacePropertyKeyElementWidth; +extern IOSurfacePropertyKey IOSurfacePropertyKeyElementHeight; +extern IOSurfacePropertyKey IOSurfacePropertyKeyOffset; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneInfo; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneWidth; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneHeight; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneBytesPerRow; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneOffset; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneSize; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneBase; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneBytesPerElement; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneElementWidth; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPlaneElementHeight; +extern IOSurfacePropertyKey IOSurfacePropertyKeyCacheMode; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPixelFormat; +extern IOSurfacePropertyKey IOSurfacePropertyKeyPixelSizeCastingAllowed; + + +@interface IOSurface : NSObject +{ +@package + void * _impl; +} + +- (nullable instancetype)initWithProperties:(NSDictionary *)properties; +- (nullable instancetype)initWithMachPort:(mach_port_t)port; +- (nullable instancetype)initWithSurfaceID:(IOSurfaceID)surfaceID; +- (kern_return_t)lockWithOptions:(IOSurfaceLockOptions)options seed:(nullable uint32_t *)seed; +- (kern_return_t)unlockWithOptions:(IOSurfaceLockOptions)options seed:(nullable uint32_t *)seed; + + +@property (readonly) NSInteger allocationSize; + +@property (readonly) NSInteger width; +@property (readonly) NSInteger height; +@property (readonly) void *baseAddress; +@property (readonly) OSType pixelFormat; + +@property (readonly) NSInteger bytesPerRow; +@property (readonly) NSInteger bytesPerElement; +@property (readonly) NSInteger elementWidth; +@property (readonly) NSInteger elementHeight; +@property (readonly) uint32_t seed; +@property (readonly) NSUInteger planeCount; + +- (NSInteger)widthOfPlaneAtIndex:(NSUInteger)planeIndex; +- (NSInteger)heightOfPlaneAtIndex:(NSUInteger)planeIndex; +- (NSInteger)bytesPerRowOfPlaneAtIndex:(NSUInteger)planeIndex; +- (NSInteger)bytesPerElementOfPlaneAtIndex:(NSUInteger)planeIndex; +- (NSInteger)elementWidthOfPlaneAtIndex:(NSUInteger)planeIndex; +- (NSInteger)elementHeightOfPlaneAtIndex:(NSUInteger)planeIndex; +- (void *)baseAddressOfPlaneAtIndex:(NSUInteger)planeIndex; + +- (void)setAttachment:(id)anObject forKey:(NSString *)key; +- (nullable id)attachmentForKey:(NSString *)key; +- (void)removeAttachmentForKey:(NSString *)key; +- (void)setAllAttachments:(NSDictionary *)dict; +- (nullable NSDictionary *)allAttachments; +- (void)removeAllAttachments; +@property (readonly, getter = isInUse) BOOL inUse; +- (void)incrementUseCount; +- (void)decrementUseCount; + +@property (readonly ) int32_t localUseCount; +@property (readonly) BOOL allowsPixelSizeCasting; + +- (kern_return_t)setPurgeable:(IOSurfacePurgeabilityState)newState oldState:(IOSurfacePurgeabilityState * _Nullable)oldState; + +@end + + +extern IOSurfacePropertyKey IOSurfacePropertyAllocSizeKey; + +__END_DECLS + +#endif // __OBJC__ +#endif diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurfacePriv.h b/src/frameworks/IOSurface/include/IOSurface/IOSurfacePriv.h new file mode 100644 index 000000000..95e11e474 --- /dev/null +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurfacePriv.h @@ -0,0 +1,85 @@ +/* + This file is part of Darling. + + Copyright (C) 2020 Lubos Dolezel + + Darling is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Darling is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Darling. If not, see . +*/ + +#ifndef IOSURFACE_PRIV_H +#define IOSURFACE_PRIV_H +#include +#include + +// Private API definition between IOSurface.framework and iokitd + +// IOSurfaceID is passed in as "input" if it's the only argument +// struct contents as passed in "inputStruct". +// See IOConnectCallMethod(). + +enum +{ + // in: dictionary + // out: _IOSurfaceObjectRetval + kIOSurfaceMethodCreate = 0, + // in: IOSurfaceID + kIOSurfaceMethodRelease = 1, + // in: struct _IOSurfaceLockUnlock + kIOSurfaceMethodLock = 2, + // in: struct _IOSurfaceLockUnlock + kIOSurfaceMethodUnlock = 3, + kIOSurfaceMethodLookupByID = 4, + kIOSurfaceMethodSetValue = 9, + // out: data for IOCFUnserializeWithSize() + kIOSurfaceMethodGetValues = 10, + kIOSurfaceMethodRemoveValue = 11, + // in: IOSurfaceID + kIOSurfaceMethodIncrementUseCount = 14, + // in: IOSurfaceID + kIOSurfaceMethodDecrementUseCount = 15, + // in: mach_port_t as a plain value + kIOSurfaceMethodCreateByMachPort = 34, + // out: mach_port_t as a plain value + kIOSurfaceMethodCreateMachPort = 35, +}; + +struct _IOSurfacePlane +{ + uint64_t memoryOffset; + + uint32_t bytesPerElement; + uint32_t width; + uint32_t height; + uint32_t bytesPerRow; +}; + +struct _IOSurfaceObjectRetval +{ + IOSurfaceID surfaceID; + uint32_t pixelFormat; + + // Where mapped into memory + uint64_t address; + + uint32_t planeCount; + struct _IOSurfacePlane planes[1]; +}; + +struct _IOSurfaceLockUnlock +{ + IOSurfaceID surfaceID; + uint32_t options; +}; + +#endif diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurfaceRef.h b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceRef.h new file mode 100644 index 000000000..94292d5fe --- /dev/null +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceRef.h @@ -0,0 +1,184 @@ +#ifndef IOSURFACE_REF_H +#define IOSURFACE_REF_H + +#include +#include + +__BEGIN_DECLS + +typedef struct __IOSurface *IOSurfaceRef; + + +extern const CFStringRef kIOSurfaceAllocSize; +extern const CFStringRef kIOSurfaceWidth; +extern const CFStringRef kIOSurfaceHeight; +extern const CFStringRef kIOSurfaceBytesPerRow; +extern const CFStringRef kIOSurfaceBytesPerElement; +extern const CFStringRef kIOSurfaceElementWidth; +extern const CFStringRef kIOSurfaceElementHeight; +extern const CFStringRef kIOSurfaceOffset; +extern const CFStringRef kIOSurfacePlaneInfo; +extern const CFStringRef kIOSurfacePlaneWidth; +extern const CFStringRef kIOSurfacePlaneHeight; +extern const CFStringRef kIOSurfacePlaneBytesPerRow; +extern const CFStringRef kIOSurfacePlaneOffset; +extern const CFStringRef kIOSurfacePlaneSize; +extern const CFStringRef kIOSurfacePlaneBase; +extern const CFStringRef kIOSurfacePlaneBitsPerElement; +extern const CFStringRef kIOSurfacePlaneBytesPerElement; +extern const CFStringRef kIOSurfacePlaneElementWidth; +extern const CFStringRef kIOSurfacePlaneElementHeight; +extern const CFStringRef kIOSurfaceCacheMode; +extern const CFStringRef kIOSurfaceIsGlobal; +extern const CFStringRef kIOSurfacePixelFormat; +extern const CFStringRef kIOSurfacePixelSizeCastingAllowed; +extern const CFStringRef kIOSurfacePlaneComponentBitDepths; +extern const CFStringRef kIOSurfacePlaneComponentBitOffsets; + +typedef int32_t IOSurfaceComponentName; enum { + kIOSurfaceComponentNameUnknown = 0, + kIOSurfaceComponentNameAlpha = 1, + kIOSurfaceComponentNameRed = 2, + kIOSurfaceComponentNameGreen = 3, + kIOSurfaceComponentNameBlue = 4, + kIOSurfaceComponentNameLuma = 5, + kIOSurfaceComponentNameChromaRed = 6, + kIOSurfaceComponentNameChromaBlue = 7, +}; + + + +extern const CFStringRef kIOSurfacePlaneComponentNames; + +typedef int32_t IOSurfaceComponentType; enum { + kIOSurfaceComponentTypeUnknown = 0, + kIOSurfaceComponentTypeUnsignedInteger = 1, + kIOSurfaceComponentTypeSignedInteger = 2, + kIOSurfaceComponentTypeFloat = 3, +}; + + +extern const CFStringRef kIOSurfacePlaneComponentTypes; + +typedef int32_t IOSurfaceComponentRange; enum { + kIOSurfaceComponentRangeUnknown = 0, + kIOSurfaceComponentRangeFullRange = 1, + kIOSurfaceComponentRangeVideoRange = 2, + kIOSurfaceComponentRangeWideRange = 3, +}; + + +extern const CFStringRef kIOSurfacePlaneComponentRanges; + +typedef int32_t IOSurfaceSubsampling; enum { + kIOSurfaceSubsamplingUnknown = 0, + kIOSurfaceSubsamplingNone = 1, + kIOSurfaceSubsampling422 = 2, + kIOSurfaceSubsampling420 = 3, + kIOSurfaceSubsampling411 = 4, +}; + + +extern const CFStringRef kIOSurfaceSubsampling; + +CFTypeID IOSurfaceGetTypeID(void); + +IOSurfaceRef _Nullable IOSurfaceCreate(CFDictionaryRef properties); + +IOSurfaceRef _Nullable IOSurfaceLookup(IOSurfaceID csid); + +IOSurfaceID IOSurfaceGetID(IOSurfaceRef buffer); +kern_return_t IOSurfaceLock(IOSurfaceRef buffer, IOSurfaceLockOptions options, uint32_t * _Nullable seed); +kern_return_t IOSurfaceUnlock(IOSurfaceRef buffer, IOSurfaceLockOptions options, uint32_t * _Nullable seed); + + +size_t IOSurfaceGetAllocSize(IOSurfaceRef buffer); + +size_t IOSurfaceGetWidth(IOSurfaceRef buffer); + +size_t IOSurfaceGetHeight(IOSurfaceRef buffer); + +size_t IOSurfaceGetBytesPerElement(IOSurfaceRef buffer); + +size_t IOSurfaceGetBytesPerRow(IOSurfaceRef buffer); + +void *IOSurfaceGetBaseAddress(IOSurfaceRef buffer); + +size_t IOSurfaceGetElementWidth(IOSurfaceRef buffer); + +size_t IOSurfaceGetElementHeight(IOSurfaceRef buffer); + +OSType IOSurfaceGetPixelFormat(IOSurfaceRef buffer); + + +uint32_t IOSurfaceGetSeed(IOSurfaceRef buffer); + + +size_t IOSurfaceGetPlaneCount(IOSurfaceRef buffer); +size_t IOSurfaceGetWidthOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +size_t IOSurfaceGetHeightOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +size_t IOSurfaceGetBytesPerElementOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +size_t IOSurfaceGetBytesPerRowOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +void *IOSurfaceGetBaseAddressOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +size_t IOSurfaceGetElementWidthOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +size_t IOSurfaceGetElementHeightOfPlane(IOSurfaceRef buffer, size_t planeIndex); + + +size_t IOSurfaceGetNumberOfComponentsOfPlane(IOSurfaceRef buffer, size_t planeIndex); + +IOSurfaceComponentName IOSurfaceGetNameOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex); + +IOSurfaceComponentType IOSurfaceGetTypeOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex); + +IOSurfaceComponentRange IOSurfaceGetRangeOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex); + +size_t IOSurfaceGetBitDepthOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex); + +size_t IOSurfaceGetBitOffsetOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex); + +IOSurfaceSubsampling IOSurfaceGetSubsampling(IOSurfaceRef buffer); + + +void IOSurfaceSetValue(IOSurfaceRef buffer, CFStringRef key, CFTypeRef value); + +CFTypeRef _Nullable IOSurfaceCopyValue(IOSurfaceRef buffer, CFStringRef key); + +void IOSurfaceRemoveValue(IOSurfaceRef buffer, CFStringRef key); + +void IOSurfaceSetValues(IOSurfaceRef buffer, CFDictionaryRef keysAndValues); + +CFDictionaryRef _Nullable IOSurfaceCopyAllValues(IOSurfaceRef buffer); + +void IOSurfaceRemoveAllValues(IOSurfaceRef buffer); + + +mach_port_t IOSurfaceCreateMachPort(IOSurfaceRef buffer); + + +IOSurfaceRef _Nullable IOSurfaceLookupFromMachPort(mach_port_t port); +size_t IOSurfaceGetPropertyMaximum(CFStringRef property); +size_t IOSurfaceGetPropertyAlignment(CFStringRef property); + + +size_t IOSurfaceAlignProperty(CFStringRef property, size_t value); +void IOSurfaceIncrementUseCount(IOSurfaceRef buffer); + +void IOSurfaceDecrementUseCount(IOSurfaceRef buffer); + +int32_t IOSurfaceGetUseCount(IOSurfaceRef buffer); + +Boolean IOSurfaceIsInUse(IOSurfaceRef buffer); + + +Boolean IOSurfaceAllowsPixelSizeCasting(IOSurfaceRef buffer); +kern_return_t IOSurfaceSetPurgeable(IOSurfaceRef buffer, uint32_t newState, uint32_t * _Nullable oldState); + +__END_DECLS + +#endif diff --git a/src/frameworks/IOSurface/include/IOSurface/IOSurfaceTypes.h b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceTypes.h new file mode 100644 index 000000000..b75b8b679 --- /dev/null +++ b/src/frameworks/IOSurface/include/IOSurface/IOSurfaceTypes.h @@ -0,0 +1,45 @@ +#ifndef IOSURFACE_TYPES_H +#define IOSURFACE_TYPES_H + +#include + +#define kIOSurfaceSuccess KERN_SUCCESS + +typedef uint32_t IOSurfaceID; + +typedef CF_OPTIONS(uint32_t, IOSurfaceLockOptions) +{ + kIOSurfaceLockReadOnly = 1, + kIOSurfaceLockAvoidSync = 2, +}; + +typedef CF_OPTIONS(uint32_t, IOSurfacePurgeabilityState) +{ + kIOSurfacePurgeableNonVolatile = 0, + kIOSurfacePurgeableVolatile = 1, + kIOSurfacePurgeableEmpty = 2, + kIOSurfacePurgeableKeepCurrent = 3, +}; + +enum +{ + kIOSurfaceDefaultCache = 0, + kIOSurfaceInhibitCache = 1, + kIOSurfaceWriteThruCache = 2, + kIOSurfaceCopybackCache = 3, + kIOSurfaceWriteCombineCache = 4, + kIOSurfaceCopybackInnerCache = 5, +}; + +enum +{ + kIOSurfaceMapCacheShift = 8, + kIOSurfaceMapDefaultCache = kIOSurfaceDefaultCache << kIOSurfaceMapCacheShift, + kIOSurfaceMapInhibitCache = kIOSurfaceInhibitCache << kIOSurfaceMapCacheShift, + kIOSurfaceMapWriteThruCache = kIOSurfaceWriteThruCache << kIOSurfaceMapCacheShift, + kIOSurfaceMapCopybackCache = kIOSurfaceCopybackCache << kIOSurfaceMapCacheShift, + kIOSurfaceMapWriteCombineCache = kIOSurfaceWriteCombineCache << kIOSurfaceMapCacheShift, + kIOSurfaceMapCopybackInnerCache = kIOSurfaceCopybackInnerCache << kIOSurfaceMapCacheShift, +}; + +#endif diff --git a/src/frameworks/IOSurface/src/IOSurface.m b/src/frameworks/IOSurface/src/IOSurface.m deleted file mode 100644 index 8d9b9da4c..000000000 --- a/src/frameworks/IOSurface/src/IOSurface.m +++ /dev/null @@ -1,749 +0,0 @@ -/* - This file is part of Darling. - - Copyright (C) 2017 Lubos Dolezel - - Darling is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Darling is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Darling. If not, see . -*/ - -#include -#include -#import - -#include - -const CFStringRef kIOSurfaceBytesPerElement = CFSTR("kIOSurfaceBytesPerElement"); -const CFStringRef kIOSurfaceHeight = CFSTR("kIOSurfaceHeight"); -const CFStringRef kIOSurfaceIsGlobal = CFSTR("kIOSurfaceIsGlobal"); -const CFStringRef kIOSurfacePixelFormat = CFSTR("kIOSurfacePixelFormat"); -const CFStringRef kIOSurfaceWidth = CFSTR("kIOSurfaceWidth"); - -static int verbose = 0; - -__attribute__((constructor)) -static void initme(void) { - verbose = getenv("STUB_VERBOSE") != NULL; -} - -@implementation IOSurface - -- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { - return [NSMethodSignature signatureWithObjCTypes: "v@:"]; -} - -- (void)forwardInvocation:(NSInvocation *)anInvocation { - NSLog(@"Stub called: %@ in %@", NSStringFromSelector([anInvocation selector]), [self class]); -} - -@end - -void* IOSurfaceAllowsPixelSizeCasting(void) { - if (verbose) puts("STUB: IOSurfaceAllowsPixelSizeCasting called"); - return NULL; -} - -void* IOSurfaceBindAccel(void) { - if (verbose) puts("STUB: IOSurfaceBindAccel called"); - return NULL; -} - -void* IOSurfaceBindAccelOnPlane(void) { - if (verbose) puts("STUB: IOSurfaceBindAccelOnPlane called"); - return NULL; -} - -void* IOSurfaceClientAlignProperty(void) { - if (verbose) puts("STUB: IOSurfaceClientAlignProperty called"); - return NULL; -} - -void* IOSurfaceClientAllowsPixelSizeCasting(void) { - if (verbose) puts("STUB: IOSurfaceClientAllowsPixelSizeCasting called"); - return NULL; -} - -void* IOSurfaceClientBindAccel(void) { - if (verbose) puts("STUB: IOSurfaceClientBindAccel called"); - return NULL; -} - -void* IOSurfaceClientCopyAllValues(void) { - if (verbose) puts("STUB: IOSurfaceClientCopyAllValues called"); - return NULL; -} - -void* IOSurfaceClientCopyDataValueBytes(void) { - if (verbose) puts("STUB: IOSurfaceClientCopyDataValueBytes called"); - return NULL; -} - -void* IOSurfaceClientCopyValue(void) { - if (verbose) puts("STUB: IOSurfaceClientCopyValue called"); - return NULL; -} - -void* IOSurfaceClientCreate(void) { - if (verbose) puts("STUB: IOSurfaceClientCreate called"); - return NULL; -} - -void* IOSurfaceClientCreateMachPort(void) { - if (verbose) puts("STUB: IOSurfaceClientCreateMachPort called"); - return NULL; -} - -void* IOSurfaceClientDecrementUseCount(void) { - if (verbose) puts("STUB: IOSurfaceClientDecrementUseCount called"); - return NULL; -} - -void* IOSurfaceClientFlushProcessorCaches(void) { - if (verbose) puts("STUB: IOSurfaceClientFlushProcessorCaches called"); - return NULL; -} - -void* IOSurfaceClientGetAllocSize(void) { - if (verbose) puts("STUB: IOSurfaceClientGetAllocSize called"); - return NULL; -} - -void* IOSurfaceClientGetBaseAddress(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBaseAddress called"); - return NULL; -} - -void* IOSurfaceClientGetBaseAddressOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBaseAddressOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetBitDepthOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBitDepthOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetBitOffsetOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBitOffsetOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetBulkAttachments(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBulkAttachments called"); - return NULL; -} - -void* IOSurfaceClientGetBytesPerElement(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBytesPerElement called"); - return NULL; -} - -void* IOSurfaceClientGetBytesPerElementOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBytesPerElementOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetBytesPerRow(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBytesPerRow called"); - return NULL; -} - -void* IOSurfaceClientGetBytesPerRowOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetBytesPerRowOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetCacheMode(void) { - if (verbose) puts("STUB: IOSurfaceClientGetCacheMode called"); - return NULL; -} - -void* IOSurfaceClientGetElementHeight(void) { - if (verbose) puts("STUB: IOSurfaceClientGetElementHeight called"); - return NULL; -} - -void* IOSurfaceClientGetElementHeightOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetElementHeightOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetElementWidth(void) { - if (verbose) puts("STUB: IOSurfaceClientGetElementWidth called"); - return NULL; -} - -void* IOSurfaceClientGetElementWidthOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetElementWidthOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetHeight(void) { - if (verbose) puts("STUB: IOSurfaceClientGetHeight called"); - return NULL; -} - -void* IOSurfaceClientGetHeightOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetHeightOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetID(void) { - if (verbose) puts("STUB: IOSurfaceClientGetID called"); - return NULL; -} - -void* IOSurfaceClientGetNameOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetNameOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetNumberOfComponentsOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetNumberOfComponentsOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetPixelFormat(void) { - if (verbose) puts("STUB: IOSurfaceClientGetPixelFormat called"); - return NULL; -} - -void* IOSurfaceClientGetPlaneCount(void) { - if (verbose) puts("STUB: IOSurfaceClientGetPlaneCount called"); - return NULL; -} - -void* IOSurfaceClientGetPropertyAlignment(void) { - if (verbose) puts("STUB: IOSurfaceClientGetPropertyAlignment called"); - return NULL; -} - -void* IOSurfaceClientGetPropertyMaximum(void) { - if (verbose) puts("STUB: IOSurfaceClientGetPropertyMaximum called"); - return NULL; -} - -void* IOSurfaceClientGetProtectionOptions(void) { - if (verbose) puts("STUB: IOSurfaceClientGetProtectionOptions called"); - return NULL; -} - -void* IOSurfaceClientGetRangeOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetRangeOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetSeed(void) { - if (verbose) puts("STUB: IOSurfaceClientGetSeed called"); - return NULL; -} - -void* IOSurfaceClientGetSubsampling(void) { - if (verbose) puts("STUB: IOSurfaceClientGetSubsampling called"); - return NULL; -} - -void* IOSurfaceClientGetTypeOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetTypeOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetUseCount(void) { - if (verbose) puts("STUB: IOSurfaceClientGetUseCount called"); - return NULL; -} - -void* IOSurfaceClientGetWidth(void) { - if (verbose) puts("STUB: IOSurfaceClientGetWidth called"); - return NULL; -} - -void* IOSurfaceClientGetWidthOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceClientGetWidthOfPlane called"); - return NULL; -} - -void* IOSurfaceClientGetYCbCrMatrix(void) { - if (verbose) puts("STUB: IOSurfaceClientGetYCbCrMatrix called"); - return NULL; -} - -void* IOSurfaceClientIncrementUseCount(void) { - if (verbose) puts("STUB: IOSurfaceClientIncrementUseCount called"); - return NULL; -} - -void* IOSurfaceClientIsDisplayable(void) { - if (verbose) puts("STUB: IOSurfaceClientIsDisplayable called"); - return NULL; -} - -void* IOSurfaceClientIsInUse(void) { - if (verbose) puts("STUB: IOSurfaceClientIsInUse called"); - return NULL; -} - -void* IOSurfaceClientLock(void) { - if (verbose) puts("STUB: IOSurfaceClientLock called"); - return NULL; -} - -void* IOSurfaceClientLookup(void) { - if (verbose) puts("STUB: IOSurfaceClientLookup called"); - return NULL; -} - -void* IOSurfaceClientLookupFromMachPort(void) { - if (verbose) puts("STUB: IOSurfaceClientLookupFromMachPort called"); - return NULL; -} - -void* IOSurfaceClientNeedsBindAccel(void) { - if (verbose) puts("STUB: IOSurfaceClientNeedsBindAccel called"); - return NULL; -} - -void* IOSurfaceClientRelease(void) { - if (verbose) puts("STUB: IOSurfaceClientRelease called"); - return NULL; -} - -void* IOSurfaceClientRemoveSurfaceNotify(void) { - if (verbose) puts("STUB: IOSurfaceClientRemoveSurfaceNotify called"); - return NULL; -} - -void* IOSurfaceClientRemoveValue(void) { - if (verbose) puts("STUB: IOSurfaceClientRemoveValue called"); - return NULL; -} - -void* IOSurfaceClientRetain(void) { - if (verbose) puts("STUB: IOSurfaceClientRetain called"); - return NULL; -} - -void* IOSurfaceClientSetBulkAttachments(void) { - if (verbose) puts("STUB: IOSurfaceClientSetBulkAttachments called"); - return NULL; -} - -void* IOSurfaceClientSetPurgeable(void) { - if (verbose) puts("STUB: IOSurfaceClientSetPurgeable called"); - return NULL; -} - -void* IOSurfaceClientSetSurfaceNotify(void) { - if (verbose) puts("STUB: IOSurfaceClientSetSurfaceNotify called"); - return NULL; -} - -void* IOSurfaceClientSetValue(void) { - if (verbose) puts("STUB: IOSurfaceClientSetValue called"); - return NULL; -} - -void* IOSurfaceClientSetYCbCrMatrix(void) { - if (verbose) puts("STUB: IOSurfaceClientSetYCbCrMatrix called"); - return NULL; -} - -void* IOSurfaceClientSupportsProtectionOptions(void) { - if (verbose) puts("STUB: IOSurfaceClientSupportsProtectionOptions called"); - return NULL; -} - -void* IOSurfaceClientUnlock(void) { - if (verbose) puts("STUB: IOSurfaceClientUnlock called"); - return NULL; -} - -void* IOSurfaceCopyAllValues(void) { - if (verbose) puts("STUB: IOSurfaceCopyAllValues called"); - return NULL; -} - -void* IOSurfaceCopyDataValueBytes(void) { - if (verbose) puts("STUB: IOSurfaceCopyDataValueBytes called"); - return NULL; -} - -void* IOSurfaceCopyValue(void) { - if (verbose) puts("STUB: IOSurfaceCopyValue called"); - return NULL; -} - -void* IOSurfaceCreate(void) { - if (verbose) puts("STUB: IOSurfaceCreate called"); - return NULL; -} - -void* IOSurfaceCreateMachPort(void) { - if (verbose) puts("STUB: IOSurfaceCreateMachPort called"); - return NULL; -} - -void* IOSurfaceCreateXPCObject(void) { - if (verbose) puts("STUB: IOSurfaceCreateXPCObject called"); - return NULL; -} - -void* IOSurfaceDecrementUseCount(void) { - if (verbose) puts("STUB: IOSurfaceDecrementUseCount called"); - return NULL; -} - -void* IOSurfaceFlushProcessorCaches(void) { - if (verbose) puts("STUB: IOSurfaceFlushProcessorCaches called"); - return NULL; -} - -void* IOSurfaceGetAllocSize(void) { - if (verbose) puts("STUB: IOSurfaceGetAllocSize called"); - return NULL; -} - -void* IOSurfaceGetBaseAddress(void) { - if (verbose) puts("STUB: IOSurfaceGetBaseAddress called"); - return NULL; -} - -void* IOSurfaceGetBaseAddressOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBaseAddressOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBitDepthOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBitDepthOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBitOffsetOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBitOffsetOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBitsPerBlock(void) { - if (verbose) puts("STUB: IOSurfaceGetBitsPerBlock called"); - return NULL; -} - -void* IOSurfaceGetBitsPerBlockOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBitsPerBlockOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBlockHeightOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBlockHeightOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBlockWidthOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBlockWidthOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBulkAttachments(void) { - if (verbose) puts("STUB: IOSurfaceGetBulkAttachments called"); - return NULL; -} - -void* IOSurfaceGetBytesPerElement(void) { - if (verbose) puts("STUB: IOSurfaceGetBytesPerElement called"); - return NULL; -} - -void* IOSurfaceGetBytesPerElementOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBytesPerElementOfPlane called"); - return NULL; -} - -void* IOSurfaceGetBytesPerRow(void) { - if (verbose) puts("STUB: IOSurfaceGetBytesPerRow called"); - return NULL; -} - -void* IOSurfaceGetBytesPerRowOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetBytesPerRowOfPlane called"); - return NULL; -} - -void* IOSurfaceGetCacheMode(void) { - if (verbose) puts("STUB: IOSurfaceGetCacheMode called"); - return NULL; -} - -void* IOSurfaceGetElementHeight(void) { - if (verbose) puts("STUB: IOSurfaceGetElementHeight called"); - return NULL; -} - -void* IOSurfaceGetElementHeightOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetElementHeightOfPlane called"); - return NULL; -} - -void* IOSurfaceGetElementWidth(void) { - if (verbose) puts("STUB: IOSurfaceGetElementWidth called"); - return NULL; -} - -void* IOSurfaceGetElementWidthOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetElementWidthOfPlane called"); - return NULL; -} - -void* IOSurfaceGetGraphicsCommPageAddress(void) { - if (verbose) puts("STUB: IOSurfaceGetGraphicsCommPageAddress called"); - return NULL; -} - -void* IOSurfaceGetHeight(void) { - if (verbose) puts("STUB: IOSurfaceGetHeight called"); - return NULL; -} - -void* IOSurfaceGetHeightOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetHeightOfPlane called"); - return NULL; -} - -void* IOSurfaceGetID(void) { - if (verbose) puts("STUB: IOSurfaceGetID called"); - return NULL; -} - -void* IOSurfaceGetNameOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetNameOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceGetNumberOfComponentsOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetNumberOfComponentsOfPlane called"); - return NULL; -} - -void* IOSurfaceGetPixelFormat(void) { - if (verbose) puts("STUB: IOSurfaceGetPixelFormat called"); - return NULL; -} - -void* IOSurfaceGetPlaneCount(void) { - if (verbose) puts("STUB: IOSurfaceGetPlaneCount called"); - return NULL; -} - -void* IOSurfaceGetPropertyAlignment(void) { - if (verbose) puts("STUB: IOSurfaceGetPropertyAlignment called"); - return NULL; -} - -void* IOSurfaceGetPropertyMaximum(void) { - if (verbose) puts("STUB: IOSurfaceGetPropertyMaximum called"); - return NULL; -} - -void* IOSurfaceGetProtectionOptions(void) { - if (verbose) puts("STUB: IOSurfaceGetProtectionOptions called"); - return NULL; -} - -void* IOSurfaceGetRangeOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetRangeOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceGetSeed(void) { - if (verbose) puts("STUB: IOSurfaceGetSeed called"); - return NULL; -} - -void* IOSurfaceGetSeedOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetSeedOfPlane called"); - return NULL; -} - -void* IOSurfaceGetSubsampling(void) { - if (verbose) puts("STUB: IOSurfaceGetSubsampling called"); - return NULL; -} - -void* IOSurfaceGetTypeID(void) { - if (verbose) puts("STUB: IOSurfaceGetTypeID called"); - return NULL; -} - -void* IOSurfaceGetTypeOfComponentOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetTypeOfComponentOfPlane called"); - return NULL; -} - -void* IOSurfaceGetUseCount(void) { - if (verbose) puts("STUB: IOSurfaceGetUseCount called"); - return NULL; -} - -void* IOSurfaceGetWidth(void) { - if (verbose) puts("STUB: IOSurfaceGetWidth called"); - return NULL; -} - -void* IOSurfaceGetWidthOfPlane(void) { - if (verbose) puts("STUB: IOSurfaceGetWidthOfPlane called"); - return NULL; -} - -void* IOSurfaceGetYCbCrMatrix(void) { - if (verbose) puts("STUB: IOSurfaceGetYCbCrMatrix called"); - return NULL; -} - -void* IOSurfaceIncrementUseCount(void) { - if (verbose) puts("STUB: IOSurfaceIncrementUseCount called"); - return NULL; -} - -void* IOSurfaceIsDisplayable(void) { - if (verbose) puts("STUB: IOSurfaceIsDisplayable called"); - return NULL; -} - -void* IOSurfaceIsInUse(void) { - if (verbose) puts("STUB: IOSurfaceIsInUse called"); - return NULL; -} - -void* IOSurfaceLock(void) { - if (verbose) puts("STUB: IOSurfaceLock called"); - return NULL; -} - -void* IOSurfaceLockPlane(void) { - if (verbose) puts("STUB: IOSurfaceLockPlane called"); - return NULL; -} - -void* IOSurfaceLog(void) { - if (verbose) puts("STUB: IOSurfaceLog called"); - return NULL; -} - -void* IOSurfaceLookup(void) { - if (verbose) puts("STUB: IOSurfaceLookup called"); - return NULL; -} - -void* IOSurfaceLookupFromMachPort(void) { - if (verbose) puts("STUB: IOSurfaceLookupFromMachPort called"); - return NULL; -} - -void* IOSurfaceLookupFromXPCObject(void) { - if (verbose) puts("STUB: IOSurfaceLookupFromXPCObject called"); - return NULL; -} - -void* IOSurfaceNeedsBindAccel(void) { - if (verbose) puts("STUB: IOSurfaceNeedsBindAccel called"); - return NULL; -} - -void* IOSurfaceNeedsBindAccelOnPlane(void) { - if (verbose) puts("STUB: IOSurfaceNeedsBindAccelOnPlane called"); - return NULL; -} - -void* IOSurfaceNotifierCreate(void) { - if (verbose) puts("STUB: IOSurfaceNotifierCreate called"); - return NULL; -} - -void* IOSurfaceNotifierGetMachPort(void) { - if (verbose) puts("STUB: IOSurfaceNotifierGetMachPort called"); - return NULL; -} - -void* IOSurfaceNotifierGetRunLoopSource(void) { - if (verbose) puts("STUB: IOSurfaceNotifierGetRunLoopSource called"); - return NULL; -} - -void* IOSurfaceNotifierGetTypeID(void) { - if (verbose) puts("STUB: IOSurfaceNotifierGetTypeID called"); - return NULL; -} - -void* IOSurfaceNotifierSetDispatchQueue(void) { - if (verbose) puts("STUB: IOSurfaceNotifierSetDispatchQueue called"); - return NULL; -} - -void* IOSurfaceRemoveAllValues(void) { - if (verbose) puts("STUB: IOSurfaceRemoveAllValues called"); - return NULL; -} - -void* IOSurfaceRemoveValue(void) { - if (verbose) puts("STUB: IOSurfaceRemoveValue called"); - return NULL; -} - -void* IOSurfaceSetBulkAttachments(void) { - if (verbose) puts("STUB: IOSurfaceSetBulkAttachments called"); - return NULL; -} - -void* IOSurfaceSetBulkAttachments2(void) { - if (verbose) puts("STUB: IOSurfaceSetBulkAttachments2 called"); - return NULL; -} - -void* IOSurfaceSetPurgeable(void) { - if (verbose) puts("STUB: IOSurfaceSetPurgeable called"); - return NULL; -} - -void* IOSurfaceSetValue(void) { - if (verbose) puts("STUB: IOSurfaceSetValue called"); - return NULL; -} - -void* IOSurfaceSetValues(void) { - if (verbose) puts("STUB: IOSurfaceSetValues called"); - return NULL; -} - -void* IOSurfaceSetYCbCrMatrix(void) { - if (verbose) puts("STUB: IOSurfaceSetYCbCrMatrix called"); - return NULL; -} - -void* IOSurfaceSupportsProtectionOptions(void) { - if (verbose) puts("STUB: IOSurfaceSupportsProtectionOptions called"); - return NULL; -} - -void* IOSurfaceUnlock(void) { - if (verbose) puts("STUB: IOSurfaceUnlock called"); - return NULL; -} - -void* IOSurfaceUnlockPlane(void) { - if (verbose) puts("STUB: IOSurfaceUnlockPlane called"); - return NULL; -} - -void* _ioSurfaceAddClientRef(void) { - if (verbose) puts("STUB: _ioSurfaceAddClientRef called"); - return NULL; -} diff --git a/src/frameworks/IOSurface/src/IOSurfaceObjC.m b/src/frameworks/IOSurface/src/IOSurfaceObjC.m new file mode 100644 index 000000000..7821ba7a4 --- /dev/null +++ b/src/frameworks/IOSurface/src/IOSurfaceObjC.m @@ -0,0 +1,293 @@ +/* + This file is part of Darling. + + Copyright (C) 2020 Lubos Dolezel + + Darling is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Darling is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Darling. If not, see . +*/ + +#import +#import +#import +#import +#import +#include + +static io_service_t g_surfaceService; + +typedef struct +{ + struct _IOSurfaceObjectRetval* surface; + _Atomic int32_t localUseCount; +} ImplData; + +@implementation IOSurface + ++ (void)initialize +{ + if (self == [IOSurface self]) + { + CFMutableDictionaryRef matching = IOServiceNameMatching("IOSurfaceRoot"); + + g_surfaceService = IOServiceGetMatchingService(kIOMasterPortDefault, matching); + + CFRelease(matching); + + if (!g_surfaceService) + NSLog(@"Cannot obtain IOSurfaceRoot!\n"); + } +} + +- (nullable instancetype)initWithResponse:(const void*)bytes length:(size_t)length +{ + ImplData* idata = (ImplData*) malloc(sizeof(ImplData)); + idata->surface = malloc(length); + memcpy(idata->surface, bytes, length); + + idata->localUseCount = 0; + self->_impl = idata; + + return self; +} + +- (nullable instancetype)initWithProperties:(NSDictionary *)properties +{ + CFDataRef data = IOCFSerialize((CFTypeRef) properties, kIOCFSerializeToBinary); + uint8_t responseBuffer[3500]; + + const void* bytes = CFDataGetBytePtr(data); + size_t length = CFDataGetLength(data); + size_t responseLength = sizeof(responseBuffer); + + kern_return_t ret = IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodCreate, NULL, 0, bytes, length, NULL, 0, responseBuffer, &responseLength); + CFRelease(data); + + if (ret != kIOSurfaceSuccess) + { + [self release]; + return nil; + } + + return [self initWithResponse: responseBuffer length: responseLength]; +} + +- (nullable instancetype)initWithSurfaceID:(IOSurfaceID)surfaceID +{ + uint8_t responseBuffer[3500]; + size_t responseLength = sizeof(responseBuffer); + + uint64_t scalar = surfaceID; + kern_return_t ret = IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodLookupByID, &scalar, 1, NULL, 0, NULL, 0, responseBuffer, &responseLength); + + if (ret != kIOSurfaceSuccess) + { + [self release]; + return nil; + } + + return [self initWithResponse: responseBuffer length: responseLength]; +} + +- (void) dealloc +{ + ImplData* data = (ImplData*) _impl; + if (data != NULL) + { + if (data->surface != NULL) + { + IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodRelease, NULL, 0, &data->surface->surfaceID, 1, NULL, 0, NULL, 0); + + free(data->surface); + } + + free(data); + } + [super dealloc]; +} + +- (NSUInteger) hash +{ + ImplData* data = (ImplData*) _impl; + return data->surface->surfaceID; +} + +- (BOOL)isEqual:(id)object +{ + if (![object isKindOfClass: [self class]]) + return NO; + + IOSurface* that = (IOSurface*) object; + return ((ImplData*) self->_impl)->surface->surfaceID == ((ImplData*) that->_impl)->surface->surfaceID; +} + +- (CFTypeID) _cfTypeID +{ + return IOSurfaceGetTypeID(); +} + +- (NSInteger) width +{ + return [self widthOfPlaneAtIndex: 0]; +} + +- (NSInteger) height +{ + return [self heightOfPlaneAtIndex: 0]; +} + +- (void *) baseAddress +{ + return [self baseAddressOfPlaneAtIndex: 0]; +} + +- (NSInteger) bytesPerRow +{ + return [self bytesPerRowOfPlaneAtIndex: 0]; +} + +- (NSInteger) bytesPerElement +{ + return [self bytesPerElementOfPlaneAtIndex: 0]; +} + +- (NSInteger) elementWidth +{ + return [self elementWidthOfPlaneAtIndex: 0]; +} + +- (NSInteger) elementHeight +{ + return [self elementHeightOfPlaneAtIndex: 0]; +} + +- (OSType) pixelFormat +{ + return ((ImplData*) _impl)->surface->pixelFormat; +} + +- (NSUInteger) planeCount +{ + return ((ImplData*) _impl)->surface->planeCount; +} + +- (NSInteger)widthOfPlaneAtIndex:(NSUInteger)planeIndex +{ + if (planeIndex >= [self planeCount]) + return 0; + + ImplData* data = (ImplData*) _impl; + return data->surface->planes[planeIndex].width; +} + +- (NSInteger)heightOfPlaneAtIndex:(NSUInteger)planeIndex +{ + if (planeIndex >= [self planeCount]) + return 0; + + ImplData* data = (ImplData*) _impl; + return data->surface->planes[planeIndex].height; +} + +- (NSInteger)bytesPerRowOfPlaneAtIndex:(NSUInteger)planeIndex +{ + if (planeIndex >= [self planeCount]) + return 0; + + ImplData* data = (ImplData*) _impl; + return data->surface->planes[planeIndex].bytesPerRow; +} + +- (NSInteger)bytesPerElementOfPlaneAtIndex:(NSUInteger)planeIndex +{ + if (planeIndex >= [self planeCount]) + return 0; + + ImplData* data = (ImplData*) _impl; + return data->surface->planes[planeIndex].bytesPerElement; +} + +- (NSInteger)elementWidthOfPlaneAtIndex:(NSUInteger)planeIndex +{ + return 1; +} + +- (NSInteger)elementHeightOfPlaneAtIndex:(NSUInteger)planeIndex +{ + return 1; +} + +- (void *)baseAddressOfPlaneAtIndex:(NSUInteger)planeIndex +{ + if (planeIndex >= [self planeCount]) + return NULL; + + ImplData* data = (ImplData*) _impl; + return (void*)(data->surface->address + data->surface->planes[planeIndex].memoryOffset); +} + +- (void)incrementUseCount +{ + ImplData* data = (ImplData*) _impl; + if ((data->localUseCount++) == 0) + { + uint64_t scalar = data->surface->surfaceID; + IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodIncrementUseCount, &scalar, 1, NULL, 0, NULL, 0, NULL, 0); + } +} + +- (void)decrementUseCount +{ + ImplData* data = (ImplData*) _impl; + if (--data->localUseCount == 0) + { + uint64_t scalar = data->surface->surfaceID; + IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodDecrementUseCount, &scalar, 1, NULL, 0, NULL, 0, NULL, 0); + } +} + +- (int32_t) localUseCount +{ + ImplData* data = (ImplData*) _impl; + return data->localUseCount; +} + +- (kern_return_t)lockWithOptions:(IOSurfaceLockOptions)options seed:(nullable uint32_t *)seed +{ + ImplData* data = (ImplData*) _impl; + struct _IOSurfaceLockUnlock args = { + .surfaceID = data->surface->surfaceID, + .options = options, + }; + return IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodLock, NULL, 0, &args, sizeof(args), NULL, 0, NULL, 0); +} + +- (kern_return_t)unlockWithOptions:(IOSurfaceLockOptions)options seed:(nullable uint32_t *)seed +{ + ImplData* data = (ImplData*) _impl; + struct _IOSurfaceLockUnlock args = { + .surfaceID = data->surface->surfaceID, + .options = options, + }; + return IOConnectCallMethod(g_surfaceService, kIOSurfaceMethodUnlock, NULL, 0, &args, sizeof(args), NULL, 0, NULL, 0); +} + +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { + return [NSMethodSignature signatureWithObjCTypes: "v@:"]; +} + +- (void)forwardInvocation:(NSInvocation *)anInvocation { + NSLog(@"Stub called: %@ in %@", NSStringFromSelector([anInvocation selector]), [self class]); +} + +@end diff --git a/src/frameworks/IOSurface/src/api.m b/src/frameworks/IOSurface/src/api.m new file mode 100644 index 000000000..dea76c18a --- /dev/null +++ b/src/frameworks/IOSurface/src/api.m @@ -0,0 +1,218 @@ +/* + This file is part of Darling. + + Copyright (C) 2020 Lubos Dolezel + + Darling is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Darling is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Darling. If not, see . +*/ + +#import +#import + +CFTypeID IOSurfaceGetTypeID(void) +{ + return (CFTypeID) [IOSurface self]; +} + +IOSurfaceRef _Nullable IOSurfaceCreate(CFDictionaryRef properties) +{ + return (IOSurfaceRef) [[IOSurface alloc] initWithProperties: (NSDictionary*) properties]; +} + +IOSurfaceRef _Nullable IOSurfaceLookupFromMachPort(mach_port_t port) +{ + return (IOSurfaceRef) [[IOSurface alloc] initWithMachPort: port]; +} + +xpc_object_t IOSurfaceCreateXPCObject(IOSurfaceRef surface) +{ + return 0; +} + +IOSurfaceRef IOSurfaceLookupFromXPCObject(xpc_object_t obj) +{ +#if NOTYET + if (xpc_get_type(obj) == _xpc_type_mach_send) + { + mach_port_t port = xpc_mach_send_get_right(obj); + return IOSurfaceLookupFromMachPort(port); + } +#endif + return NULL; +} + +kern_return_t IOSurfaceLock(IOSurfaceRef buffer, IOSurfaceLockOptions options, uint32_t * _Nullable seed) +{ + return [(IOSurface*)buffer lockWithOptions: options seed: seed]; +} + +kern_return_t IOSurfaceUnlock(IOSurfaceRef buffer, IOSurfaceLockOptions options, uint32_t * _Nullable seed) +{ + return [(IOSurface*)buffer unlockWithOptions: options seed: seed]; +} + +size_t IOSurfaceGetWidth(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer width]; +} + +size_t IOSurfaceGetHeight(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer height]; +} + +void *IOSurfaceGetBaseAddress(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer baseAddress]; +} + +OSType IOSurfaceGetPixelFormat(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer pixelFormat]; +} + +void IOSurfaceSetValue(IOSurfaceRef buffer, CFStringRef key, CFTypeRef value) +{ + return [(IOSurface*)buffer setAttachment: (id) value forKey: (NSString*) key]; +} + + +CFTypeRef _Nullable IOSurfaceCopyValue(IOSurfaceRef buffer, CFStringRef key) +{ + return (CFTypeRef) [[(IOSurface*) buffer attachmentForKey: (NSString*) key] retain]; +} + + +void IOSurfaceRemoveValue(IOSurfaceRef buffer, CFStringRef key) +{ + [(IOSurface*)buffer removeAttachmentForKey: (NSString*) key]; +} + + +void IOSurfaceSetValues(IOSurfaceRef buffer, CFDictionaryRef keysAndValues) +{ + [(IOSurface*)buffer setAllAttachments: (NSDictionary*)keysAndValues]; +} + + +CFDictionaryRef _Nullable IOSurfaceCopyAllValues(IOSurfaceRef buffer) +{ + return (CFDictionaryRef) [[(IOSurface*)buffer allAttachments] retain]; +} + + +void IOSurfaceRemoveAllValues(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer removeAllAttachments]; +} + +size_t IOSurfaceGetBytesPerRow(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer bytesPerRow]; +} + +void IOSurfaceIncrementUseCount(IOSurfaceRef buffer) +{ + [(IOSurface*)buffer incrementUseCount]; +} + + +void IOSurfaceDecrementUseCount(IOSurfaceRef buffer) +{ + [(IOSurface*)buffer decrementUseCount]; +} + + +int32_t IOSurfaceGetUseCount(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer localUseCount]; +} + +size_t IOSurfaceGetPlaneCount(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer planeCount]; +} + +uint32_t IOSurfaceGetSeed(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer seed]; +} + +size_t IOSurfaceGetWidthOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer widthOfPlaneAtIndex: planeIndex]; +} + + +size_t IOSurfaceGetHeightOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer heightOfPlaneAtIndex: planeIndex]; +} + + +size_t IOSurfaceGetBytesPerElementOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer bytesPerElementOfPlaneAtIndex: planeIndex]; +} + + +size_t IOSurfaceGetBytesPerRowOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer bytesPerRowOfPlaneAtIndex: planeIndex]; +} + + +void *IOSurfaceGetBaseAddressOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer baseAddressOfPlaneAtIndex: planeIndex]; +} + + +size_t IOSurfaceGetElementWidthOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer elementWidthOfPlaneAtIndex: planeIndex]; +} + + +size_t IOSurfaceGetElementHeightOfPlane(IOSurfaceRef buffer, size_t planeIndex) +{ + return [(IOSurface*)buffer elementHeightOfPlaneAtIndex: planeIndex]; +} + +size_t IOSurfaceGetBytesPerElement(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer bytesPerElementOfPlaneAtIndex: 0]; +} + + +size_t IOSurfaceGetElementWidth(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer widthOfPlaneAtIndex: 0]; +} + + +size_t IOSurfaceGetElementHeight(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer heightOfPlaneAtIndex: 0]; +} + +Boolean IOSurfaceIsInUse(IOSurfaceRef buffer) +{ + return [(IOSurface*)buffer isInUse]; +} + +kern_return_t IOSurfaceSetPurgeable(IOSurfaceRef buffer, uint32_t newState, uint32_t * _Nullable oldState) +{ + return [(IOSurface*)buffer setPurgeable:newState oldState:oldState]; +} diff --git a/src/frameworks/IOSurface/src/constants.m b/src/frameworks/IOSurface/src/constants.m new file mode 100644 index 000000000..af7bb356f --- /dev/null +++ b/src/frameworks/IOSurface/src/constants.m @@ -0,0 +1,69 @@ +/* + This file is part of Darling. + + Copyright (C) 2020 Lubos Dolezel + + Darling is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Darling is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Darling. If not, see . +*/ +#import +#import + +const CFStringRef kIOSurfaceAllocSize = CFSTR("IOSurfaceAllocSize"); +const CFStringRef kIOSurfaceWidth = CFSTR("IOSurfaceWidth"); +const CFStringRef kIOSurfaceHeight = CFSTR("IOSurfaceHeight"); +const CFStringRef kIOSurfaceBytesPerRow = CFSTR("IOSurfaceBytesPerRow"); +const CFStringRef kIOSurfaceBytesPerElement = CFSTR("IOSurfaceBytesPerElement"); +const CFStringRef kIOSurfaceElementWidth = CFSTR("IOSurfaceElementWidth"); +const CFStringRef kIOSurfaceElementHeight = CFSTR("IOSurfaceElementHeight"); +const CFStringRef kIOSurfaceOffset = CFSTR("IOSurfaceOffset"); +const CFStringRef kIOSurfacePlaneInfo = CFSTR("IOSurfacePlaneInfo"); +const CFStringRef kIOSurfacePlaneWidth = CFSTR("IOSurfacePlaneWidth"); +const CFStringRef kIOSurfacePlaneHeight = CFSTR("IOSurfacePlaneHeight"); +const CFStringRef kIOSurfacePlaneBytesPerRow = CFSTR("IOSurfacePlaneBytesPerRow"); +const CFStringRef kIOSurfacePlaneOffset = CFSTR("IOSurfacePlaneOffset"); +const CFStringRef kIOSurfacePlaneSize = CFSTR("IOSurfacePlaneSize"); +const CFStringRef kIOSurfacePlaneBase = CFSTR("IOSurfacePlaneBase"); +const CFStringRef kIOSurfacePlaneBitsPerElement = CFSTR("IOSurfacePlaneBitsPerElement"); +const CFStringRef kIOSurfacePlaneBytesPerElement = CFSTR("IOSurfacePlaneBytesPerElement"); +const CFStringRef kIOSurfacePlaneElementWidth = CFSTR("IOSurfacePlaneElementWidth"); +const CFStringRef kIOSurfacePlaneElementHeight = CFSTR("IOSurfacePlaneElementHeight"); +const CFStringRef kIOSurfaceCacheMode = CFSTR("IOSurfaceCacheMode"); +const CFStringRef kIOSurfaceIsGlobal = CFSTR("IOSurfaceIsGlobal"); +const CFStringRef kIOSurfacePixelFormat = CFSTR("IOSurfacePixelFormat"); +const CFStringRef kIOSurfacePixelSizeCastingAllowed = CFSTR("IOSurfacePixelSizeCastingAllowed"); +const CFStringRef kIOSurfacePlaneComponentBitDepths = CFSTR("IOSurfacePlaneComponentBitDepths"); +const CFStringRef kIOSurfacePlaneComponentBitOffsets = CFSTR("IOSurfacePlaneComponentBitOffsets"); + +IOSurfacePropertyKey IOSurfacePropertyKeyAllocSize = @"IOSurfacePropertyKeyAllocSize"; +IOSurfacePropertyKey IOSurfacePropertyKeyWidth = @"IOSurfacePropertyKeyWidth"; +IOSurfacePropertyKey IOSurfacePropertyKeyHeight = @"IOSurfacePropertyKeyHeight"; +IOSurfacePropertyKey IOSurfacePropertyKeyBytesPerRow = @"IOSurfacePropertyKeyBytesPerRow"; +IOSurfacePropertyKey IOSurfacePropertyKeyBytesPerElement = @"IOSurfacePropertyKeyBytesPerElement"; +IOSurfacePropertyKey IOSurfacePropertyKeyElementWidth = @"IOSurfacePropertyKeyElementWidth"; +IOSurfacePropertyKey IOSurfacePropertyKeyElementHeight = @"IOSurfacePropertyKeyElementHeight"; +IOSurfacePropertyKey IOSurfacePropertyKeyOffset = @"IOSurfacePropertyKeyOffset"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneInfo = @"IOSurfacePropertyKeyPlaneInfo"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneWidth = @"IOSurfacePropertyKeyPlaneWidth"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneHeight = @"IOSurfacePropertyKeyPlaneHeight"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneBytesPerRow = @"IOSurfacePropertyKeyPlaneBytesPerRow"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneOffset = @"IOSurfacePropertyKeyPlaneOffset"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneSize = @"IOSurfacePropertyKeyPlaneSize"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneBase = @"IOSurfacePropertyKeyPlaneBase"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneBytesPerElement = @"IOSurfacePropertyKeyPlaneBytesPerElement"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneElementWidth = @"IOSurfacePropertyKeyPlaneElementWidth"; +IOSurfacePropertyKey IOSurfacePropertyKeyPlaneElementHeight = @"IOSurfacePropertyKeyPlaneElementHeight"; +IOSurfacePropertyKey IOSurfacePropertyKeyCacheMode = @"IOSurfacePropertyKeyCacheMode"; +IOSurfacePropertyKey IOSurfacePropertyKeyPixelFormat = @"IOSurfacePropertyKeyPixelFormat"; +IOSurfacePropertyKey IOSurfacePropertyKeyPixelSizeCastingAllowed = @"IOSurfacePropertyKeyPixelSizeCastingAllowed"; + diff --git a/src/frameworks/IOSurface/src/stubs.m b/src/frameworks/IOSurface/src/stubs.m new file mode 100644 index 000000000..7e5976f2f --- /dev/null +++ b/src/frameworks/IOSurface/src/stubs.m @@ -0,0 +1,126 @@ +/* + This file is part of Darling. + + Copyright (C) 2017 Lubos Dolezel + + Darling is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Darling is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Darling. If not, see . +*/ + +#include +#include +#import + +#include + +static int verbose = 0; + +__attribute__((constructor)) +static void initme(void) { + verbose = getenv("STUB_VERBOSE") != NULL; +} + + +IOSurfaceRef _Nullable IOSurfaceLookup(IOSurfaceID csid){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +IOSurfaceID IOSurfaceGetID(IOSurfaceRef buffer){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +size_t IOSurfaceGetAllocSize(IOSurfaceRef buffer){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + + +size_t IOSurfaceGetNumberOfComponentsOfPlane(IOSurfaceRef buffer, size_t planeIndex){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +IOSurfaceComponentName IOSurfaceGetNameOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +IOSurfaceComponentType IOSurfaceGetTypeOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +IOSurfaceComponentRange IOSurfaceGetRangeOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +size_t IOSurfaceGetBitDepthOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +size_t IOSurfaceGetBitOffsetOfComponentOfPlane(IOSurfaceRef buffer, size_t planeIndex, size_t componentIndex){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +IOSurfaceSubsampling IOSurfaceGetSubsampling(IOSurfaceRef buffer){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + + +mach_port_t IOSurfaceCreateMachPort(IOSurfaceRef buffer){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + +size_t IOSurfaceGetPropertyMaximum(CFStringRef property){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + +size_t IOSurfaceGetPropertyAlignment(CFStringRef property){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + + +size_t IOSurfaceAlignProperty(CFStringRef property, size_t value){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + + + +Boolean IOSurfaceAllowsPixelSizeCasting(IOSurfaceRef buffer){ + if (verbose) printf("STUB: %s called\n", __FUNCTION__); + return 0; +} + +