diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-01-15 18:18:59 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-01-15 18:18:59 +0100 |
| commit | 3265d439f351d3a4d48bb1f99047f24134f1e5aa (patch) | |
| tree | bdc33d6f05affedf636c893e87aa58303ef077b6 /src/drivers | |
| parent | afcc79c3f7d5ffd9f9bd2185494688a5d5927aab (diff) | |
Slightly improve Fl_Quartz_Graphics_Driver::copy_offscreen() when macOS ≥ 10.4
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 27 |
1 files 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() |
