The CGContextStrokePath bug has been fixed in Mac OS El Capitan (10.11) public beta 4.

It's no longer necessary to apply a workaround for it.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10825 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy
2015-08-05 20:20:30 +00:00
parent 99c536234e
commit 9a38c24d63
3 changed files with 20 additions and 39 deletions
+1 -2
View File
@@ -66,8 +66,7 @@ void Fl_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) {
float r = (w+h)*0.25f-0.5f; float r = (w+h)*0.25f-0.5f;
CGContextAddArc(fl_gc, cx, cy, r, a1, a2, 1); CGContextAddArc(fl_gc, cx, cy, r, a1, a2, 1);
} }
extern void CGContextStrokePath_fixed(CGContextRef); CGContextStrokePath(fl_gc);
CGContextStrokePath_fixed(fl_gc);
CGContextSetShouldAntialias(fl_gc, false); CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
+16 -30
View File
@@ -195,20 +195,6 @@ void Fl_Graphics_Driver::rectf(int x, int y, int w, int h) {
#endif #endif
} }
#ifdef __APPLE_QUARTZ__
void CGContextStrokePath_fixed(CGContextRef c)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if (fl_mac_os_version >= 101100) {
// bizarrely, CGContextStrokePath does not work with 10.11 after mouse click or keydown event
CGContextReplacePathWithStrokedPath(c); // needs 10.4
CGContextFillPath(c);
} else
#endif
CGContextStrokePath(c);
}
#endif
void Fl_Graphics_Driver::xyline(int x, int y, int x1) { void Fl_Graphics_Driver::xyline(int x, int y, int x1) {
#if defined(USE_X11) #if defined(USE_X11)
XDrawLine(fl_display, fl_window, fl_gc, clip_x(x), clip_x(y), clip_x(x1), clip_x(y)); XDrawLine(fl_display, fl_window, fl_gc, clip_x(x), clip_x(y), clip_x(x1), clip_x(y));
@@ -218,7 +204,7 @@ void Fl_Graphics_Driver::xyline(int x, int y, int x1) {
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true); if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y); CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y); CGContextAddLineToPoint(fl_gc, x1, y);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (Fl_Display_Device::high_resolution()) { if (Fl_Display_Device::high_resolution()) {
/* On retina displays, all xyline() and yxline() functions produce lines that are half-unit /* On retina displays, all xyline() and yxline() functions produce lines that are half-unit
(or one pixel) too short at both ends. This is corrected by filling at both ends rectangles (or one pixel) too short at both ends. This is corrected by filling at both ends rectangles
@@ -250,7 +236,7 @@ void Fl_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
CGContextMoveToPoint(fl_gc, x, y); CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y); CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2); CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (Fl_Display_Device::high_resolution()) { if (Fl_Display_Device::high_resolution()) {
CGContextFillRect(fl_gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); CGContextFillRect(fl_gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
CGContextFillRect(fl_gc, CGRectMake(x1 - fl_quartz_line_width_/2, y2-0.5, fl_quartz_line_width_, 1)); CGContextFillRect(fl_gc, CGRectMake(x1 - fl_quartz_line_width_/2, y2-0.5, fl_quartz_line_width_, 1));
@@ -281,7 +267,7 @@ void Fl_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
CGContextAddLineToPoint(fl_gc, x1, y); CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2); CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextAddLineToPoint(fl_gc, x3, y2); CGContextAddLineToPoint(fl_gc, x3, y2);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (Fl_Display_Device::high_resolution()) { if (Fl_Display_Device::high_resolution()) {
CGContextFillRect(fl_gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); CGContextFillRect(fl_gc, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
CGContextFillRect(fl_gc, CGRectMake(x3-0.5, y2 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); CGContextFillRect(fl_gc, CGRectMake(x3-0.5, y2 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
@@ -301,13 +287,13 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1) {
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1); MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1);
#elif defined(__APPLE_QUARTZ__) #elif defined(__APPLE_QUARTZ__)
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true); if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y); CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x, y1);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (Fl_Display_Device::high_resolution()) { if (Fl_Display_Device::high_resolution()) {
CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1)); CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1)); CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1));
} }
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
@@ -331,7 +317,7 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
CGContextMoveToPoint(fl_gc, x, y); CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1); CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (Fl_Display_Device::high_resolution()) { if (Fl_Display_Device::high_resolution()) {
CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1)); CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
CGContextFillRect(fl_gc, CGRectMake(x2-0.5, y1 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); CGContextFillRect(fl_gc, CGRectMake(x2-0.5, y1 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
@@ -362,7 +348,7 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1); CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextAddLineToPoint(fl_gc, x2, y3); CGContextAddLineToPoint(fl_gc, x2, y3);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (Fl_Display_Device::high_resolution()) { if (Fl_Display_Device::high_resolution()) {
CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1)); CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
CGContextFillRect(fl_gc, CGRectMake(x2 - fl_quartz_line_width_/2, y3-0.5, fl_quartz_line_width_, 1)); CGContextFillRect(fl_gc, CGRectMake(x2 - fl_quartz_line_width_/2, y3-0.5, fl_quartz_line_width_, 1));
@@ -386,7 +372,7 @@ void Fl_Graphics_Driver::line(int x, int y, int x1, int y1) {
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true); if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y); CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1); CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
@@ -412,7 +398,7 @@ void Fl_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
CGContextMoveToPoint(fl_gc, x, y); CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1); CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2); CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
@@ -438,7 +424,7 @@ void Fl_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) {
CGContextAddLineToPoint(fl_gc, x1, y1); CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2); CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextClosePath(fl_gc); CGContextClosePath(fl_gc);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, false); CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
@@ -467,7 +453,7 @@ void Fl_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, int
CGContextAddLineToPoint(fl_gc, x2, y2); CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextAddLineToPoint(fl_gc, x3, y3); CGContextAddLineToPoint(fl_gc, x3, y3);
CGContextClosePath(fl_gc); CGContextClosePath(fl_gc);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, false); CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
+3 -7
View File
@@ -35,10 +35,6 @@
#include <FL/math.h> #include <FL/math.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(__APPLE_QUARTZ__)
extern void CGContextStrokePath_fixed(CGContextRef);
#endif
void Fl_Graphics_Driver::push_matrix() { void Fl_Graphics_Driver::push_matrix() {
if (sptr==matrix_stack_size) if (sptr==matrix_stack_size)
Fl::error("fl_push_matrix(): matrix stack overflow."); Fl::error("fl_push_matrix(): matrix stack overflow.");
@@ -126,7 +122,7 @@ void Fl_Graphics_Driver::end_points() {
for (int i=0; i<n; i++) { for (int i=0; i<n; i++) {
CGContextMoveToPoint(fl_gc, p[i].x, p[i].y); CGContextMoveToPoint(fl_gc, p[i].x, p[i].y);
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y); CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
} }
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
#else #else
@@ -149,7 +145,7 @@ void Fl_Graphics_Driver::end_line() {
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y); CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
for (int i=1; i<n; i++) for (int i=1; i<n; i++)
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y); CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
CGContextStrokePath_fixed(fl_gc); CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, false); CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform
@@ -269,7 +265,7 @@ void Fl_Graphics_Driver::circle(double x, double y,double r) {
// Last argument must be 0 (counter-clockwise) or it draws nothing under __LP64__ !!!! // Last argument must be 0 (counter-clockwise) or it draws nothing under __LP64__ !!!!
CGContextSetShouldAntialias(fl_gc, true); CGContextSetShouldAntialias(fl_gc, true);
CGContextAddArc(fl_gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 0); CGContextAddArc(fl_gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 0);
(what == POLYGON ? CGContextFillPath : CGContextStrokePath_fixed)(fl_gc); (what == POLYGON ? CGContextFillPath : CGContextStrokePath)(fl_gc);
CGContextSetShouldAntialias(fl_gc, false); CGContextSetShouldAntialias(fl_gc, false);
#else #else
# error unsupported platform # error unsupported platform