From b97e6b864f2bb6c3ffbc12cba81f3be250f48d92 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 4 Apr 2014 22:51:30 -0400 Subject: [PATCH] Fixed 32-bit Mac OS X builds: Area crashed due to random ABI changes. Also more TODOs. --- bleh_darwin.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bleh_darwin.m b/bleh_darwin.m index b8f7d93..0e1cce5 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -243,6 +243,12 @@ static SEL s_drawInRect; static SEL s_release; static BOOL drawImage_init = NO; +/* +hey guys you know what's fun? 32-bit ABI changes! +*/ +static BOOL (*objc_msgSend_drawInRect)(id, SEL, NSRect, NSRect, NSCompositingOperation, CGFloat, BOOL, id) = + (BOOL (*)(id, SEL, NSRect, NSRect, NSCompositingOperation, CGFloat, BOOL, id)) objc_msgSend; + void drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int64_t xdest, int64_t ydest) { unsigned char *planes[1]; /* NSBitmapImageRep wants an array of planes; we have one plane */ @@ -270,7 +276,8 @@ void drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int6 (NSBitmapFormat) NSAlphaNonpremultipliedBitmapFormat, /* bitmapFormat: | this is where the flag for placing alpha first would go if alpha came first; the default is alpha last, which is how we're doing things (otherwise the docs say "Color planes are arranged in the standard order—for example, red before green before blue for RGB color.") */ (NSInteger) stride, /* bytesPerRow: */ (NSInteger) 32); /* bitsPerPixel: */ - objc_msgSend(bitmap, s_drawInRect, + /* TODO this CAN fail; check error */ + objc_msgSend_drawInRect(bitmap, s_drawInRect, NSMakeRect((CGFloat) xdest, (CGFloat) ydest, (CGFloat) width, (CGFloat) height), /* drawInRect: */ NSZeroRect, /* fromRect: | draw whole image */