Fix macOS 10.14 Mojave support of the FLTK-cairo interface.

After experimenting with a modified cairo_test program that draws both with
 cairo and with regular FLTK drawing functions to the same window, it seems
 necessary to control for possible changes to the graphics context made by
 cairo in Fl_Window::make_current() rather than in
 cairo_create_surface().

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@13120 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2018-11-09 14:46:49 +00:00
parent 50b8ba6a53
commit 9dfa8a92a9
2 changed files with 8 additions and 7 deletions

View File

@ -106,13 +106,6 @@ static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) {
# elif defined(WIN32)
return cairo_win32_surface_create((HDC) gc);
# elif defined(__APPLE_QUARTZ__)
CGAffineTransform mat = CGContextGetCTM((CGContextRef)gc);
if (mat.d > 0) { // necessary for layer-backed Cairo windows
CGContextRestoreGState((CGContextRef)gc);
CGContextRestoreGState((CGContextRef)gc);
CGContextSaveGState((CGContextRef)gc);
CGContextSaveGState((CGContextRef)gc);
}
return cairo_quartz_surface_create_for_cg_context((CGContext*) gc, W, H);
# else
# error Cairo is not supported under this platform.

View File

@ -3537,6 +3537,14 @@ void Fl_Window::make_current()
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
if (views_use_CA) {
i->gc = ((FLView*)[fl_window contentView])->layer_gc;
# ifdef FLTK_HAVE_CAIRO
// make sure the GC starts with an identity transformation matrix as do native Cocoa GC's
// because cairo may have changed it
CGAffineTransform mat = CGContextGetCTM(i->gc);
if (!CGAffineTransformIsIdentity(mat)) { // 10.4
CGContextConcatCTM(i->gc, CGAffineTransformInvert(mat));
}
# endif
} else
#endif
{