Fix[renderer]: let (slow version) Zink run on iOS 16

Backport of: Fix CGImageCreate returning NULL on iOS 16 (4c2f9e5)
This commit is contained in:
khanhduytran0 committed 2023-09-15 17:48:45 +07:00
1 parent 1f67b22f09
commit dfab68b2d4
3 files changed
+11 -17

No files matched your search

+4 -15
View File
@@ -4,18 +4,14 @@
#import "utils.h"
@implementation GameSurfaceView
const void * _CGDataProviderGetBytePointerCallbackOSMESA(void *info) {
return gbuffer;
}
- (void)displayLayer {
CGDataProviderRef bitmapProvider = CGDataProviderCreateDirect(NULL, windowWidth * windowHeight * 4, &callbacks);
CGImageRef bitmap = CGImageCreate(windowWidth, windowHeight, 8, 32, 4 * windowWidth, colorSpace, kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder16Little, bitmapProvider, NULL, FALSE, kCGRenderingIntentDefault);
CGDataProviderRef bitmapProvider = CGDataProviderCreateWithData(NULL, gbuffer, windowWidth * windowHeight * 4, NULL);
CGImageRef bitmap = CGImageCreate(windowWidth, windowHeight, 8, 32, 4 * windowWidth, colorSpace, kCGImageAlphaNoneSkipLast | kCGBitmapByteOrderDefault, bitmapProvider, NULL, FALSE, kCGRenderingIntentDefault);
self.layer.contents = (__bridge id) bitmap;
CGImageRelease(bitmap);
CGDataProviderRelease(bitmapProvider);
// CGColorSpaceRelease(colorSpace);
//CGColorSpaceRelease(colorSpace);
}
- (id)initWithFrame:(CGRect)frame {
@@ -23,15 +19,8 @@ const void * _CGDataProviderGetBytePointerCallbackOSMESA(void *info) {
self.layer.drawsAsynchronously = YES;
self.layer.opaque = YES;
if ([[PLProfiles resolveKeyForCurrentProfile:@"renderer"] hasPrefix:@"libOSMesaOverride"]) {
if ([[PLProfiles resolveKeyForCurrentProfile:@"renderer"] hasPrefix:@"libOSMesa"]) {
colorSpace = CGColorSpaceCreateDeviceRGB();
callbacks.version = 0;
callbacks.getBytePointer = _CGDataProviderGetBytePointerCallbackOSMESA;
callbacks.releaseBytePointer = _CGDataProviderReleaseBytePointerCallback;
callbacks.getBytesAtPosition = NULL;
callbacks.releaseInfo = NULL;
}
return self;
+4
View File
@@ -551,6 +551,10 @@ void CallbackBridge_nativeSendMouseButton(int button, int action, int mods) {
}
void CallbackBridge_nativeSendScreenSize(int width, int height) {
if (gbuffer) {
gbuffer = realloc(gbuffer, 4*width*height + 1);
}
windowWidth = width;
windowHeight = height;
+3 -2
View File
@@ -36,7 +36,7 @@
#define RENDERER_NAME_GL4ES "libgl4es_114.dylib"
#define RENDERER_NAME_MTL_ANGLE "libtinygl4angle.dylib"
#define RENDERER_NAME_VK_ZINK "libOSMesaOverride.dylib"
#define RENDERER_NAME_VK_ZINK "libOSMesa.8.dylib"
#define SPECIALBTN_KEYBOARD -1
#define SPECIALBTN_TOGGLECTRL -2
@@ -88,7 +88,8 @@ void _CGDataProviderReleaseBytePointerCallback(void *info,const void *pointer);
jboolean attachThread(bool isAndroid, JNIEnv** secondJNIEnvPtr);
void sendData(short type, short i1, short i2, short i3, short i4);
void sendData(short type, int i1, int i2, short i3, short i4);
void sendDataFloat(short type, float i1, float i2, short i3, short i4);
void closeGLFWWindow();
void callback_LauncherViewController_installMinecraft();