diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-10-12 16:02:00 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-10-12 16:02:00 +0200 |
| commit | 9863fef25a77478acc622f2618165a6ea3bf02e7 (patch) | |
| tree | 5a461be8027e19062018af2ec6033d9a6ba52476 | |
| parent | 72e712efbdf7f7c8d1391794700dea46d5cc0db0 (diff) | |
Fix for macOS Catalina 10.15
Under Catalina, the bitmap graphics context prepared by the system when drawRect: runs
sometimes changes its number of bytes/row even if the width and height are unchanged.
| -rw-r--r-- | src/Fl_cocoa.mm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 2357400c6..5d5596042 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2262,7 +2262,14 @@ static FLTextInputContext* fltextinputcontext_instance = nil; } #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 else if (gc && aux_bitmap && ( Fl_X::i(window)->region || !(window->damage()&FL_DAMAGE_ALL)) ) { - memcpy(CGBitmapContextGetData(gc), CGBitmapContextGetData(aux_bitmap), CGBitmapContextGetHeight(gc) * CGBitmapContextGetBytesPerRow(gc)); + if (CGBitmapContextGetBytesPerRow(gc) != CGBitmapContextGetBytesPerRow(aux_bitmap)) { + // this condition (unchanged W and H but changed BytesPerRow) occurs with 10.15 + CGImageRef img = CGBitmapContextCreateImage(aux_bitmap); + CGContextDrawImage(gc, [self frame], img); + CGImageRelease(img); + } else { + memcpy(CGBitmapContextGetData(gc), CGBitmapContextGetData(aux_bitmap), CGBitmapContextGetHeight(gc) * CGBitmapContextGetBytesPerRow(gc)); + } } #endif through_drawRect = YES; @@ -2270,6 +2277,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil; if (!through_Fl_X_flush) window->clear_damage(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 if (gc) { + if (aux_bitmap && CGBitmapContextGetBytesPerRow(gc) != CGBitmapContextGetBytesPerRow(aux_bitmap)) [self reset_aux_bitmap]; if (!aux_bitmap) [self create_aux_bitmap:gc retina:d->mapped_to_retina()]; memcpy(CGBitmapContextGetData(aux_bitmap), CGBitmapContextGetData(gc), CGBitmapContextGetHeight(gc) * CGBitmapContextGetBytesPerRow(gc)); Fl_Cocoa_Window_Driver::q_release_context(); |
