From 3265d439f351d3a4d48bb1f99047f24134f1e5aa Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 15 Jan 2020 18:18:59 +0100 Subject: =?UTF-8?q?Slightly=20improve=20Fl=5FQuartz=5FGraphics=5FDriver::c?= =?UTF-8?q?opy=5Foffscreen()=20when=20macOS=20=E2=89=A5=2010.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index bd0504833..e0383cebd 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -92,16 +92,23 @@ void Fl_Quartz_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Of void *data = CGBitmapContextGetData(src); int sw = CGBitmapContextGetWidth(src); int sh = CGBitmapContextGetHeight(src); - CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src); - CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); - // when output goes to a Quartz printercontext, release of the bitmap must be - // delayed after the end of the printed page - CFRetain(src); - CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data, sw*sh*4, bmProviderRelease); - CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha, - src_bytes, 0L, false, kCGRenderingIntentDefault); - CGDataProviderRelease(src_bytes); - CGColorSpaceRelease(lut); + CGImageRef img; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (fl_mac_os_version >= 100400) img = CGBitmapContextCreateImage(src); // requires 10.4 + else +#endif + { + CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src); + CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); + // when output goes to a Quartz printercontext, release of the bitmap must be + // delayed after the end of the printed page + CFRetain(src); + CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data, sw*sh*4, bmProviderRelease); + img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha, + src_bytes, 0L, false, kCGRenderingIntentDefault); + CGDataProviderRelease(src_bytes); + CGColorSpaceRelease(lut); + } float s = scale(); Fl_Surface_Device *current = Fl_Surface_Device::surface(); // test whether osrc was created by fl_create_offscreen() -- cgit v1.2.3