]> git.saurik.com Git - veency.git/commitdiff
Use armv7 to switch from CoreSurface to IOSurface.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 9 Nov 2014 20:48:03 +0000 (12:48 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 9 Nov 2014 20:48:03 +0000 (12:48 -0800)
.gitignore
Tweak.mm
library.sh
makefile

index d43f5013eab78052e2c2faaf274d5ceaeffa9e32..db76fbe336e9fef05335136c86218991209175b1 100644 (file)
@@ -3,6 +3,7 @@ obj
 .theos
 _
 jpeg-9a
 .theos
 _
 jpeg-9a
+library
 libjpeg.arm*
 libvncserver.arm*
 IOHIDFamily-503.1.13
 libjpeg.arm*
 libvncserver.arm*
 IOHIDFamily-503.1.13
index 31f7925d9d779c503eca82fd6e345e37a3e04dd8..db1f6232568a81ff1ebf1cdac9c8f4eb2db7fbbf 100644 (file)
--- a/Tweak.mm
+++ b/Tweak.mm
@@ -96,34 +96,58 @@ MSClassHook(UIApplication)
 - (void) removeStatusBarItem:(NSString *)item;
 @end
 
 - (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,
 
 typedef void *IOMobileFramebufferRef;
 
 extern "C" kern_return_t IOMobileFramebufferSwapSetLayer(
     IOMobileFramebufferRef fb,
     int layer,
-    CoreSurfaceBufferRef buffer,
+    IOSurfaceRef buffer,
     CGRect bounds,
     CGRect frame,
     int flags
     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 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_;
 static CFDictionaryRef options_;
 
 static NSMutableSet *handlers_;
@@ -884,29 +908,29 @@ static void VNCSetup() {
     bool accelerated(opengles2 != NULL && [(NSNumber *)opengles2 boolValue]);
 
     if (accelerated)
     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)
 
     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<char *>(mmap(NULL, sizeof(rfbPixel) * width_ * height_, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_NOCACHE, VM_FLAGS_PURGABLE, 0));
 
         nil]);
     else
         VNCBlack();
 
     //screen_->frameBuffer = reinterpret_cast<char *>(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<char *>(CoreSurfaceBufferGetBaseAddress(buffer_));
-    CoreSurfaceBufferUnlock(buffer_);
+    IOSurfaceLock(buffer_, 3);
+    screen_->frameBuffer = reinterpret_cast<char *>(IOSurfaceGetBaseAddress(buffer_));
+    IOSurfaceUnlock(buffer_);
 
     screen_->kbdAddEvent = &VNCKeyboard;
     screen_->ptrAddEvent = &VNCPointer;
 
     screen_->kbdAddEvent = &VNCKeyboard;
     screen_->ptrAddEvent = &VNCPointer;
@@ -955,9 +979,9 @@ static void VNCNotifyEnabled(
 void (*$IOMobileFramebufferIsMainDisplay)(IOMobileFramebufferRef, int *);
 
 static IOMobileFramebufferRef main_;
 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);
     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)
                 VNCBlack();
         } else {
             if (accelerator_ != NULL)
-                CoreSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_);
+                IOSurfaceAcceleratorTransferSurface(accelerator_, layer, buffer_, options_);
             else {
             else {
-                CoreSurfaceBufferLock(layer, 2);
-                rfbPixel *data(reinterpret_cast<rfbPixel *>(CoreSurfaceBufferGetBaseAddress(layer)));
+                IOSurfaceLock(layer, 2);
+                rfbPixel *data(reinterpret_cast<rfbPixel *>(IOSurfaceGetBaseAddress(layer)));
 
 
-                CoreSurfaceBufferFlushProcessorCaches(layer);
+                IOSurfaceFlushProcessorCaches(layer);
 
                 /*rfbPixel corner(data[0]);
                 data[0] = 0;
                 data[0] = corner;*/
 
                 screen_->frameBuffer = const_cast<char *>(reinterpret_cast<volatile char *>(data));
 
                 /*rfbPixel corner(data[0]);
                 data[0] = 0;
                 data[0] = corner;*/
 
                 screen_->frameBuffer = const_cast<char *>(reinterpret_cast<volatile char *>(data));
-                CoreSurfaceBufferUnlock(layer);
+                IOSurfaceUnlock(layer);
             }
         }
 
             }
         }
 
@@ -1010,7 +1034,7 @@ static bool wait_ = false;
 MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
     IOMobileFramebufferRef fb,
     int layer,
 MSHook(kern_return_t, IOMobileFramebufferSwapSetLayer,
     IOMobileFramebufferRef fb,
     int layer,
-    CoreSurfaceBufferRef buffer,
+    IOSurfaceRef buffer,
     CGRect bounds,
     CGRect frame,
     int flags
     CGRect bounds,
     CGRect frame,
     int flags
index 30fd658375555c516948eeecaad4cff3ce29bec5..304d19d1f5bba9fc589243ed68e6c1b76ec8cd0a 100755 (executable)
@@ -21,6 +21,8 @@
 
 set -e
 
 
 set -e
 
+archs=()
+
 function arch() {
     local arch=$1
     local host=$2
 function arch() {
     local arch=$1
     local host=$2
@@ -71,7 +73,19 @@ function arch() {
     configure libvncserver JPEG_LDFLAGS="-L${jpeg}/.libs -ljpeg"
     make
     cd ..
     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 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
 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"
index 60f0486dfe1c49b1a07b3d46f15163d605ca6a1b..32e83c2c1b5450992ce292e450f1d6ad2b0b484f 100644 (file)
--- 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
 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_FILES := Tweak.mm SpringBoardAccess.c
 
 Veency_FRAMEWORKS := 
-Veency_FRAMEWORKS += CoreSurface
 Veency_FRAMEWORKS += GraphicsServices
 Veency_FRAMEWORKS += IOMobileFramebuffer
 Veency_FRAMEWORKS += QuartzCore
 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
 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_armv6 -Ilibvncserver.armv6
+ADDITIONAL_OBJCFLAGS += -Xarch_armv7 -Ilibvncserver.armv7
 ADDITIONAL_OBJCFLAGS += -Xarch_arm64 -Ilibvncserver.arm64
 
 ADDITIONAL_CFLAGS += -fvisibility=hidden
 
 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 += -lvncserver
-
-ADDITIONAL_LDFLAGS += -Xarch_armv6 -Llibjpeg.armv6/.libs
-ADDITIONAL_LDFLAGS += -Xarch_arm64 -Llibjpeg.arm64/.libs
 ADDITIONAL_LDFLAGS += -ljpeg
 
 ADDITIONAL_LDFLAGS += -lz
 ADDITIONAL_LDFLAGS += -ljpeg
 
 ADDITIONAL_LDFLAGS += -lz