mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
iOS: fix launcher drawing upside down
and fix it without leaking lots of memory.. still always redraws the entire window though
This commit is contained in:
parent
48c70bf66d
commit
24fb2e5e09
@ -204,44 +204,26 @@ int Window_GetWindowState(void) { return WINDOW_STATE_NORMAL; }
|
|||||||
cc_result Window_EnterFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
cc_result Window_EnterFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
||||||
cc_result Window_ExitFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
cc_result Window_ExitFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
||||||
|
|
||||||
|
void Window_EnableRawMouse(void) { }
|
||||||
|
void Window_UpdateRawMouse(void) { }
|
||||||
|
void Window_DisableRawMouse(void) { }
|
||||||
|
|
||||||
|
void Window_LockLandscapeOrientation(cc_bool lock) {
|
||||||
|
// TODO implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*#########################################################################################################################*
|
||||||
|
*--------------------------------------------------------2D window--------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
static CGContextRef win_ctx;
|
||||||
static struct Bitmap fb_bmp;
|
static struct Bitmap fb_bmp;
|
||||||
void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
||||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
|
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
|
||||||
fb_bmp = *bmp;
|
fb_bmp = *bmp;
|
||||||
}
|
|
||||||
|
|
||||||
static void DoDrawFramebuffer(CGRect dirty) {
|
|
||||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
||||||
CGContextRef context = NULL;
|
|
||||||
CGDataProviderRef provider;
|
|
||||||
CGImageRef image;
|
|
||||||
CGRect rect;
|
|
||||||
|
|
||||||
// Unfortunately CGImageRef is immutable, so changing the
|
win_ctx = CGBitmapContextCreate(bmp->scan0, bmp->width, bmp->height, 8, bmp->width * 4,
|
||||||
// underlying data doesn't change what shows when drawing.
|
CGColorSpaceCreateDeviceRGB(), kCGBitmapByteOrder32Host | kCGImageAlphaNoneSkipFirst);
|
||||||
// TODO: Find a better way of doing this in cocoa..
|
|
||||||
if (!fb_bmp.scan0) return;
|
|
||||||
context = UIGraphicsGetCurrentContext();
|
|
||||||
//CGContextTranslateCTM(context, 0, -WindowInfo.Height);
|
|
||||||
//CGContextScaleCTM(context, 1.0, -1.0); // invert upside down
|
|
||||||
|
|
||||||
// TODO: Only update changed bit..
|
|
||||||
rect.origin.x = 0; rect.origin.y = 0;
|
|
||||||
rect.size.width = WindowInfo.Width;
|
|
||||||
rect.size.height = WindowInfo.Height;
|
|
||||||
|
|
||||||
// TODO: REPLACE THIS AWFUL HACK
|
|
||||||
provider = CGDataProviderCreateWithData(NULL, fb_bmp.scan0,
|
|
||||||
Bitmap_DataSize(fb_bmp.width, fb_bmp.height), NULL);
|
|
||||||
image = CGImageCreate(fb_bmp.width, fb_bmp.height, 8, 32, fb_bmp.width * 4, colorSpace,
|
|
||||||
kCGBitmapByteOrder32Host | kCGImageAlphaNoneSkipFirst, provider, NULL, 0, 0);
|
|
||||||
|
|
||||||
CGContextDrawImage(context, rect, image);
|
|
||||||
CGContextSynchronize(context);
|
|
||||||
|
|
||||||
CGImageRelease(image);
|
|
||||||
CGDataProviderRelease(provider);
|
|
||||||
CGColorSpaceRelease(colorSpace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_DrawFramebuffer(Rect2D r) {
|
void Window_DrawFramebuffer(Rect2D r) {
|
||||||
@ -250,28 +232,20 @@ void Window_DrawFramebuffer(Rect2D r) {
|
|||||||
rect.origin.y = WindowInfo.Height - r.Y - r.Height;
|
rect.origin.y = WindowInfo.Height - r.Y - r.Height;
|
||||||
rect.size.width = r.Width;
|
rect.size.width = r.Width;
|
||||||
rect.size.height = r.Height;
|
rect.size.height = r.Height;
|
||||||
[win_handle setNeedsDisplayInRect:rect];
|
win_handle.layer.contents = CFBridgingRelease(CGBitmapContextCreateImage(win_ctx));
|
||||||
|
// TODO always redraws entire launcher which is quite terrible performance wise
|
||||||
|
//[win_handle setNeedsDisplayInRect:rect];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
||||||
Mem_Free(bmp->scan0);
|
Mem_Free(bmp->scan0);
|
||||||
}
|
CGContextRelease(win_ctx);
|
||||||
|
|
||||||
void Window_EnableRawMouse(void) { }
|
|
||||||
void Window_UpdateRawMouse(void) { }
|
|
||||||
void Window_DisableRawMouse(void) { }
|
|
||||||
|
|
||||||
|
|
||||||
cc_bool Window_RemakeSurface(void) {
|
|
||||||
// TODO implement
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window_LockLandscapeOrientation(cc_bool lock) {
|
|
||||||
// TODO implement
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*#########################################################################################################################*
|
||||||
|
*--------------------------------------------------------3D window--------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
@interface CCGLView : UIView
|
@interface CCGLView : UIView
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -297,6 +271,7 @@ void Window_Create3D(int width, int height) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------GLContext--------------------------------------------------------*
|
*--------------------------------------------------------GLContext--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user