mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 11:25:22 +08:00
Cairo support under macOS 10.14 Mojave: slightly simpler implementation
This post http://www.fltk.org/newsgroups.php?s36927+gfltk.general+v36944 reports a full-size Cairo-using FLTK app to be OK under Mojave with the equivalent of this fix for the 1.4 branch. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@13114 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -166,9 +166,6 @@ public: // should be private!
|
|||||||
static int compose_state; // used for dead keys (WIN32) or marked text (MacOS)
|
static int compose_state; // used for dead keys (WIN32) or marked text (MacOS)
|
||||||
static void call_screen_init(); // recompute screen number and dimensions
|
static void call_screen_init(); // recompute screen number and dimensions
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# ifdef FLTK_HAVE_CAIRO
|
|
||||||
static bool using_cairo_context;
|
|
||||||
# endif
|
|
||||||
static void reset_marked_text(); // resets marked text
|
static void reset_marked_text(); // resets marked text
|
||||||
static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
|
static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
# elif defined(WIN32)
|
# elif defined(WIN32)
|
||||||
# include <cairo-win32.h>
|
# include <cairo-win32.h>
|
||||||
# elif defined(__APPLE_QUARTZ__)
|
# elif defined(__APPLE_QUARTZ__)
|
||||||
bool Fl::using_cairo_context = false;
|
|
||||||
# include <cairo-quartz.h>
|
# include <cairo-quartz.h>
|
||||||
# else
|
# else
|
||||||
# error Cairo is not supported on this platform.
|
# error Cairo is not supported on this platform.
|
||||||
@@ -79,15 +78,9 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) {
|
|||||||
if (fl_gc==0) { // means remove current cc
|
if (fl_gc==0) { // means remove current cc
|
||||||
Fl::cairo_cc(0); // destroy any previous cc
|
Fl::cairo_cc(0); // destroy any previous cc
|
||||||
cairo_state_.window(0);
|
cairo_state_.window(0);
|
||||||
#if defined(__APPLE_QUARTZ__)
|
|
||||||
Fl::using_cairo_context = false;
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE_QUARTZ__)
|
|
||||||
Fl::using_cairo_context = true;
|
|
||||||
#endif
|
|
||||||
// don't re-create a context if it's the same gc/window couple
|
// don't re-create a context if it's the same gc/window couple
|
||||||
if (fl_gc==Fl::cairo_state_.gc() && fl_xid(wi) == (Window) Fl::cairo_state_.window())
|
if (fl_gc==Fl::cairo_state_.gc() && fl_xid(wi) == (Window) Fl::cairo_state_.window())
|
||||||
return Fl::cairo_cc();
|
return Fl::cairo_cc();
|
||||||
|
|||||||
+8
-13
@@ -2420,20 +2420,8 @@ static CGContextRef prepare_bitmap_for_layer(int w, int h ) {
|
|||||||
}
|
}
|
||||||
if (window->damage()) {
|
if (window->damage()) {
|
||||||
through_drawRect = YES;
|
through_drawRect = YES;
|
||||||
#ifdef FLTK_HAVE_CAIRO
|
|
||||||
CGFloat before_flush = CGContextGetCTM(layer_gc).d;
|
|
||||||
Fl::using_cairo_context = false;
|
|
||||||
#endif
|
|
||||||
i->flush();
|
i->flush();
|
||||||
Fl_X::q_release_context();
|
Fl_X::q_release_context();
|
||||||
#ifdef FLTK_HAVE_CAIRO
|
|
||||||
if (Fl::using_cairo_context && CGContextGetCTM(layer_gc).d != before_flush ) {
|
|
||||||
// necessary for Cairo and layer-backed views
|
|
||||||
CGContextRestoreGState(layer_gc);
|
|
||||||
CGContextSaveGState(layer_gc);
|
|
||||||
}
|
|
||||||
Fl::using_cairo_context = false;
|
|
||||||
#endif
|
|
||||||
through_drawRect = NO;
|
through_drawRect = NO;
|
||||||
window->clear_damage();
|
window->clear_damage();
|
||||||
if (layer_gc) {
|
if (layer_gc) {
|
||||||
@@ -3549,6 +3537,13 @@ void Fl_Window::make_current()
|
|||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
|
||||||
if (views_use_CA) {
|
if (views_use_CA) {
|
||||||
i->gc = ((FLView*)[fl_window contentView])->layer_gc;
|
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
|
||||||
|
CGAffineTransform mat = CGContextGetCTM(i->gc);
|
||||||
|
if (!CGAffineTransformIsIdentity(mat)) { // 10.4
|
||||||
|
CGContextConcatCTM(i->gc, CGAffineTransformInvert(mat));
|
||||||
|
}
|
||||||
|
# endif
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -4480,7 +4475,7 @@ static NSBitmapImageRep* rect_to_NSBitmapImageRep_layer(Fl_Window *win, int x, i
|
|||||||
int resolution = i->mapped_to_retina() ? 2 : 1;
|
int resolution = i->mapped_to_retina() ? 2 : 1;
|
||||||
if (x || y || w != win->w() || h != win->h()) {
|
if (x || y || w != win->w() || h != win->h()) {
|
||||||
CGRect rect = CGRectMake(x * resolution, y * resolution, w * resolution, h * resolution);
|
CGRect rect = CGRectMake(x * resolution, y * resolution, w * resolution, h * resolution);
|
||||||
CGImageRef cgimg2 = CGImageCreateWithImageInRect(cgimg, rect);
|
CGImageRef cgimg2 = CGImageCreateWithImageInRect(cgimg, rect); //10.4
|
||||||
CGImageRelease(cgimg);
|
CGImageRelease(cgimg);
|
||||||
cgimg = cgimg2;
|
cgimg = cgimg2;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user