From: Jay Freeman (saurik) Date: Sun, 9 Nov 2014 20:48:03 +0000 (-0800) Subject: Use armv7 to switch from CoreSurface to IOSurface. X-Git-Tag: v0.9.3500~14 X-Git-Url: https://git.saurik.com/veency.git/commitdiff_plain/3d5b3ddd1b1cc9f3680aa15ae86ae182abca8cad?ds=sidebyside Use armv7 to switch from CoreSurface to IOSurface. --- diff --git a/.gitignore b/.gitignore index d43f501..db76fbe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ obj .theos _ jpeg-9a +library libjpeg.arm* libvncserver.arm* IOHIDFamily-503.1.13 diff --git a/Tweak.mm b/Tweak.mm index 31f7925..db1f623 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -96,34 +96,58 @@ MSClassHook(UIApplication) - (void) removeStatusBarItem:(NSString *)item; @end -typedef void *CoreSurfaceBufferRef; +#if defined(_ARM_ARCH_6) && !defined(_ARM_ARCH_7) -extern CFStringRef kCoreSurfaceBufferGlobal; -extern CFStringRef kCoreSurfaceBufferMemoryRegion; -extern CFStringRef kCoreSurfaceBufferPitch; -extern CFStringRef kCoreSurfaceBufferWidth; -extern CFStringRef kCoreSurfaceBufferHeight; -extern CFStringRef kCoreSurfaceBufferPixelFormat; -extern CFStringRef kCoreSurfaceBufferAllocSize; +#define kIOSurfaceAllocSize kCoreSurfaceBufferAllocSize +#define kIOSurfaceBytesPerRow kCoreSurfaceBufferPitch +#define kIOSurfaceHeight kCoreSurfaceBufferHeight +#define kIOSurfaceIsGlobal kCoreSurfaceBufferGlobal +#define kIOSurfaceMemoryRegion kCoreSurfaceBufferMemoryRegion +#define kIOSurfacePixelFormat kCoreSurfaceBufferPixelFormat +#define kIOSurfaceWidth kCoreSurfaceBufferWidth -extern "C" CoreSurfaceBufferRef CoreSurfaceBufferCreate(CFDictionaryRef dict); -extern "C" int CoreSurfaceBufferLock(CoreSurfaceBufferRef surface, unsigned int lockType); -extern "C" int CoreSurfaceBufferUnlock(CoreSurfaceBufferRef surface); -extern "C" void *CoreSurfaceBufferGetBaseAddress(CoreSurfaceBufferRef surface); +#define IOSurfaceRef CoreSurfaceBufferRef +#define IOSurfaceAcceleratorRef CoreSurfaceAcceleratorRef -extern "C" void CoreSurfaceBufferFlushProcessorCaches(CoreSurfaceBufferRef buffer); +#define IOSurfaceCreate CoreSurfaceBufferCreate +#define IOSurfaceFlushProcessorCaches CoreSurfaceBufferFlushProcessorCaches +#define IOSurfaceGetBaseAddress CoreSurfaceBufferGetBaseAddress +#define IOSurfaceLock CoreSurfaceBufferLock +#define IOSurfaceUnlock CoreSurfaceBufferUnlock -typedef void *CoreSurfaceAcceleratorRef; +#define IOSurfaceAcceleratorCreate CoreSurfaceAcceleratorCreate +#define IOSurfaceAcceleratorTransferSurface CoreSurfaceAcceleratorTransferSurface -extern "C" int CoreSurfaceAcceleratorCreate(CFAllocatorRef allocator, void *type, CoreSurfaceAcceleratorRef *accel); -extern "C" unsigned int CoreSurfaceAcceleratorTransferSurface(CoreSurfaceAcceleratorRef accelerator, CoreSurfaceBufferRef dest, CoreSurfaceBufferRef src, CFDictionaryRef options/*, void *, void *, void **/); +#endif + +typedef void *IOSurfaceRef; + +extern CFStringRef kIOSurfaceIsGlobal; +extern CFStringRef kIOSurfaceMemoryRegion; +extern CFStringRef kIOSurfaceBytesPerRow; +extern CFStringRef kIOSurfaceWidth; +extern CFStringRef kIOSurfaceHeight; +extern CFStringRef kIOSurfacePixelFormat; +extern CFStringRef kIOSurfaceAllocSize; + +extern "C" IOSurfaceRef IOSurfaceCreate(CFDictionaryRef dict); +extern "C" int IOSurfaceLock(IOSurfaceRef surface, unsigned int lockType); +extern "C" int IOSurfaceUnlock(IOSurfaceRef surface); +extern "C" void *IOSurfaceGetBaseAddress(IOSurfaceRef surface); + +extern "C" void IOSurfaceFlushProcessorCaches(IOSurfaceRef buffer); + +typedef void *IOSurfaceAcceleratorRef; + +extern "C" int IOSurfaceAcceleratorCreate(CFAllocatorRef allocator, void *type, IOSurfaceAcceleratorRef *accel); +extern "C" unsigned int IOSurfaceAcceleratorTransferSurface(IOSurfaceAcceleratorRef accelerator, IOSurfaceRef dest, IOSurfaceRef src, CFDictionaryRef options/*, void *, void *, void **/); typedef void *IOMobileFramebufferRef; extern "C" kern_return_t IOMobileFramebufferSwapSetLayer( IOMobileFramebufferRef fb, int layer, - CoreSurfaceBufferRef buffer, + IOSurfaceRef buffer, CGRect bounds, CGRect frame, int flags @@ -155,8 +179,8 @@ static NSUInteger ratio_ = 0; static const size_t BytesPerPixel = 4; static const size_t BitsPerSample = 8; -static CoreSurfaceAcceleratorRef accelerator_; -static CoreSurfaceBufferRef buffer_; +static IOSurfaceAcceleratorRef accelerator_; +static IOSurfaceRef buffer_; static CFDictionaryRef options_; static NSMutableSet *handlers_; @@ -884,29 +908,29 @@ static void VNCSetup() { bool accelerated(opengles2 != NULL && [(NSNumber *)opengles2 boolValue]); if (accelerated) - CoreSurfaceAcceleratorCreate(NULL, NULL, &accelerator_); + IOSurfaceAcceleratorCreate(NULL, NULL, &accelerator_); if (opengles2 != NULL) CFRelease(opengles2); if (accelerator_ != NULL) - buffer_ = CoreSurfaceBufferCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys: - @"PurpleEDRAM", kCoreSurfaceBufferMemoryRegion, - [NSNumber numberWithBool:YES], kCoreSurfaceBufferGlobal, - [NSNumber numberWithInt:(width_ * BytesPerPixel)], kCoreSurfaceBufferPitch, - [NSNumber numberWithInt:width_], kCoreSurfaceBufferWidth, - [NSNumber numberWithInt:height_], kCoreSurfaceBufferHeight, - [NSNumber numberWithInt:'BGRA'], kCoreSurfaceBufferPixelFormat, - [NSNumber numberWithInt:(width_ * height_ * BytesPerPixel)], kCoreSurfaceBufferAllocSize, + buffer_ = IOSurfaceCreate((CFDictionaryRef) [NSDictionary dictionaryWithObjectsAndKeys: + @"PurpleEDRAM", kIOSurfaceMemoryRegion, + [NSNumber numberWithBool:YES], kIOSurfaceIsGlobal, + [NSNumber numberWithInt:(width_ * BytesPerPixel)], kIOSurfaceBytesPerRow, + [NSNumber numberWithInt:width_], kIOSurfaceWidth, + [NSNumber numberWithInt:height_], kIOSurfaceHeight, + [NSNumber numberWithInt:'BGRA'], kIOSurfacePixelFormat, + [NSNumber numberWithInt:(width_ * height_ * BytesPerPixel)], kIOSurfaceAllocSize, nil]); else VNCBlack(); //screen_->frameBuffer = reinterpret_cast(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0)); - CoreSurfaceBufferLock(buffer_, 3); - screen_->frameBuffer = reinterpret_cast(CoreSurfaceBufferGetBaseAddress(buffer_)); - CoreSurfaceBufferUnlock(buffer_); + IOSurfaceLock(buffer_, 3); + screen_->frameBuffer = reinterpret_cast(IOSurfaceGetBaseAddress(buffer_)); + IOSurfaceUnlock(buffer_); screen_->kbdAddEvent = &VNCKeyboard; screen_->ptrAddEvent = &VNCPointer; @@ -955,9 +979,9 @@ static void VNCNotifyEnabled( void (*$IOMobileFramebufferIsMainDisplay)(IOMobileFramebufferRef, int *); static IOMobileFramebufferRef main_; -static CoreSurfaceBufferRef layer_; +static IOSurfaceRef layer_; -static void OnLayer(IOMobileFramebufferRef fb, CoreSurfaceBufferRef layer) { +static void OnLayer(IOMobileFramebufferRef fb, IOSurfaceRef layer) { if (_unlikely(width_ == 0 || height_ == 0)) { CGSize size; IOMobileFramebufferGetDisplaySize(fb, &size); @@ -985,19 +1009,19 @@ static void OnLayer(IOMobileFramebufferRef fb, CoreSurfaceBufferRef layer) { VNCBlack(); } else { if (accelerator_ != NULL) - CoreSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_); + IOSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_); else { - CoreSurfaceBufferLock(layer, 2); - rfbPixel *data(reinterpret_cast(CoreSurfaceBufferGetBaseAddress(layer))); + IOSurfaceLock(layer, 2); + rfbPixel *data(reinterpret_cast(IOSurfaceGetBaseAddress(layer))); - CoreSurfaceBufferFlushProcessorCaches(layer); + IOSurfaceFlushProcessorCaches(layer); /*rfbPixel corner(data[0]); data[0] = 0; data[0] = corner;*/ screen_->frameBuffer = const_cast(reinterpret_cast(data)); - CoreSurfaceBufferUnlock(layer); + IOSurfaceUnlock(layer); } } @@ -1010,7 +1034,7 @@ static bool wait_ = false; MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer, IOMobileFramebufferRef fb, int layer, - CoreSurfaceBufferRef buffer, + IOSurfaceRef buffer, CGRect bounds, CGRect frame, int flags diff --git a/library.sh b/library.sh index 30fd658..304d19d 100755 --- a/library.sh +++ b/library.sh @@ -21,6 +21,8 @@ set -e +archs=() + function arch() { local arch=$1 local host=$2 @@ -71,7 +73,19 @@ function arch() { configure libvncserver JPEG_LDFLAGS="-L${jpeg}/.libs -ljpeg" make cd .. + + archs+=("${arch}") } arch armv6 arm-apple-darwin10 iphoneos iphoneos 2.0 -mllvm -arm-reserve-r9 +arch armv7 arm-apple-darwin11 iphoneos iphoneos 2.0 arch arm64 aarch64-apple-darwin11 iphoneos iphoneos 2.0 + +rm -rf library +mkdir library +lipo -output library/libjpeg.a -create $(for arch in "${archs[@]}"; do echo libjpeg.${arch}/.libs/libjpeg.a; done) +lipo -output library/libvncserver.a -create $(for arch in "${archs[@]}"; do echo libvncserver.${arch}/libvncserver/.libs/libvncserver.a; done) + +lipo -output library/libsurface-armv6.dylib -thin armv7 "$(xcodebuild -sdk iphoneos -version Path)/System/Library/PrivateFrameworks/CoreSurface.framework/CoreSurface" +LANG=C /sw/bin/sed -i -e 's@\(\xCE\xFA\xED\xFE\x0C\x00\x00\x00\)\x09\x00\x00\x00@\1\x06\x00\x00\x00@' library/libsurface-armv6.dylib +lipo -output library/libsurface.dylib -create library/libsurface-armv6.dylib "$(xcodebuild -sdk iphoneos -version Path)/System/Library/PrivateFrameworks/IOSurface.framework/IOSurface" diff --git a/makefile b/makefile index 60f0486..32e83c2 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ -TARGET := iphone:7.0:2.0 -ARCHS := armv6 arm64 +TARGET := iphone:7.1:2.0 +ARCHS := armv6 armv7 arm64 PACKAGE_VERSION := $(shell ./version.sh) include theos/makefiles/common.mk @@ -8,7 +8,6 @@ TWEAK_NAME := Veency Veency_FILES := Tweak.mm SpringBoardAccess.c Veency_FRAMEWORKS := -Veency_FRAMEWORKS += CoreSurface Veency_FRAMEWORKS += GraphicsServices Veency_FRAMEWORKS += IOMobileFramebuffer Veency_FRAMEWORKS += QuartzCore @@ -25,17 +24,16 @@ ADDITIONAL_OBJCFLAGS += -idirafter xnu-2422.1.72/osfmk ADDITIONAL_OBJCFLAGS += -idirafter include ADDITIONAL_OBJCFLAGS += -Ilibvncserver +# XXX: -Xarch_armv[67] doesn't even work... *sigh* ADDITIONAL_OBJCFLAGS += -Xarch_armv6 -Ilibvncserver.armv6 +ADDITIONAL_OBJCFLAGS += -Xarch_armv7 -Ilibvncserver.armv7 ADDITIONAL_OBJCFLAGS += -Xarch_arm64 -Ilibvncserver.arm64 ADDITIONAL_CFLAGS += -fvisibility=hidden -ADDITIONAL_LDFLAGS += -Xarch_armv6 -Llibvncserver.armv6/libvncserver/.libs -ADDITIONAL_LDFLAGS += -Xarch_arm64 -Llibvncserver.arm64/libvncserver/.libs +ADDITIONAL_LDFLAGS += -Llibrary +ADDITIONAL_LDFLAGS += -lsurface ADDITIONAL_LDFLAGS += -lvncserver - -ADDITIONAL_LDFLAGS += -Xarch_armv6 -Llibjpeg.armv6/.libs -ADDITIONAL_LDFLAGS += -Xarch_arm64 -Llibjpeg.arm64/.libs ADDITIONAL_LDFLAGS += -ljpeg ADDITIONAL_LDFLAGS += -lz