diff options
| author | Manolo Gouy <Manolo> | 2015-08-01 16:56:04 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2015-08-01 16:56:04 +0000 |
| commit | ca1990c3148f7b165c4f698b57f1d914b2f2f68e (patch) | |
| tree | 2ac07746a0c47bae43c49733f4d12b48f2a36bf5 /src | |
| parent | eb7d55e218fc89ec1b5582ed5d0f8cdede29cae5 (diff) | |
Fix for Mac OS 10.11 El Capitan bugged CGContextStrokePath() function:
replace it by CGContextReplacePathWithStrokedPath() + CGContextFillPath()
that does the same without error.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10821 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/fl_rect.cxx | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index 189bca7a7..18b965653 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -195,6 +195,20 @@ void Fl_Graphics_Driver::rectf(int x, int y, int w, int h) { #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) { #if defined(USE_X11) XDrawLine(fl_display, fl_window, fl_gc, clip_x(x), clip_x(y), clip_x(x1), clip_x(y)); @@ -202,21 +216,16 @@ void Fl_Graphics_Driver::xyline(int x, int y, int x1) { MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1+1, y); #elif defined(__APPLE_QUARTZ__) if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true); - if (fl_mac_os_version >= 101100) { - // bizarrely, the line drawing does not always work with 10.11, draw a thin rectangle instead - CGContextFillRect(fl_gc, CGRectMake((x1>x?x:x1) - 0.5, y - fl_quartz_line_width_/2, (x1>x?x1-x:x-x1)+1, fl_quartz_line_width_)); - } else { - CGContextMoveToPoint(fl_gc, x, y); - CGContextAddLineToPoint(fl_gc, x1, y); - CGContextStrokePath(fl_gc); - if (Fl_Display_Device::high_resolution()) { - /* 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 - of size one unit by 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-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); - } + CGContextMoveToPoint(fl_gc, x, y); + CGContextAddLineToPoint(fl_gc, x1, y); + CGContextStrokePath_fixed(fl_gc); + if (Fl_Display_Device::high_resolution()) { + /* 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 + of size one unit by 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-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); } if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); #else @@ -241,7 +250,7 @@ void Fl_Graphics_Driver::xyline(int x, int y, int x1, int y2) { CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y); CGContextAddLineToPoint(fl_gc, x1, y2); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); 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(x1 - fl_quartz_line_width_/2, y2-0.5, fl_quartz_line_width_, 1)); @@ -272,7 +281,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, y2); CGContextAddLineToPoint(fl_gc, x3, y2); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); 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(x3-0.5, y2 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); @@ -292,20 +301,13 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1) { MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1); #elif defined(__APPLE_QUARTZ__) if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true); - if (fl_mac_os_version >= 101100) { - // bizarrely, the line drawing does not always work with 10.11, draw a thin rectangle instead - CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, (y>y1?y1:y) - 0.5, - fl_quartz_line_width_ , (y>y1?y-y1:y1-y)+1)); - } - else { CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x, y1); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); 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, y1-0.5, fl_quartz_line_width_, 1)); } - } if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); #else # error unsupported platform @@ -329,7 +331,7 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1, int x2) { CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x2, y1); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); 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(x2-0.5, y1 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_)); @@ -360,7 +362,7 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) { CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x2, y1); CGContextAddLineToPoint(fl_gc, x2, y3); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); 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(x2 - fl_quartz_line_width_/2, y3-0.5, fl_quartz_line_width_, 1)); @@ -384,7 +386,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); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); #else # error unsupported platform @@ -410,7 +412,7 @@ void Fl_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) { CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); CGContextAddLineToPoint(fl_gc, x2, y2); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false); #else # error unsupported platform @@ -436,7 +438,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, x2, y2); CGContextClosePath(fl_gc); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); CGContextSetShouldAntialias(fl_gc, false); #else # error unsupported platform @@ -465,7 +467,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, x3, y3); CGContextClosePath(fl_gc); - CGContextStrokePath(fl_gc); + CGContextStrokePath_fixed(fl_gc); CGContextSetShouldAntialias(fl_gc, false); #else # error unsupported platform |
