FLTK1.1 Quartz support:

- added a 'test/unittests' which wil check for identical drawing on all
  platforms. This was desperatly needed to fix tremendous problems in
  getting the Quartz drawing routines right
- disabled anti-aliasing for functions that draw straight lines at integer
  coordinates


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3788 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2004-08-26 22:24:24 +00:00
parent 157bf81506
commit c29b4b5e16
5 changed files with 244 additions and 8 deletions
+4 -2
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_mac.cxx,v 1.1.2.59 2004/08/26 06:18:12 matthiaswm Exp $"
// "$Id: Fl_mac.cxx,v 1.1.2.60 2004/08/26 22:24:23 matthiaswm Exp $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -1863,6 +1863,8 @@ void Fl_Window::make_current()
if (!i->gc) {
//CreateCGContextForPort(GetWindowPort(i->xid), &i->gc);
QDBeginCGContext(GetWindowPort(i->xid), &i->gc);
#warning : line capping should not be set. Check AA settings to make this work
CGContextSetLineCap(i->gc, kCGLineCapSquare);
// save the unclipped state for later
CGContextSaveGState(i->gc);
// translate coordinate system to coorespond with fltk's.
@@ -1948,6 +1950,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
//
// End of "$Id: Fl_mac.cxx,v 1.1.2.59 2004/08/26 06:18:12 matthiaswm Exp $".
// End of "$Id: Fl_mac.cxx,v 1.1.2.60 2004/08/26 22:24:23 matthiaswm Exp $".
//
+24 -4
View File
@@ -1,5 +1,5 @@
//
// "$Id: fl_rect.cxx,v 1.10.2.4.2.14 2004/08/26 06:18:12 matthiaswm Exp $"
// "$Id: fl_rect.cxx,v 1.10.2.4.2.15 2004/08/26 22:24:24 matthiaswm Exp $"
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -46,8 +46,10 @@ void fl_rect(int x, int y, int w, int h) {
SetRect(&rect, x, y, x+w, y+h);
FrameRect(&rect);
#elif defined(__APPLE_QUARTZ__)
CGRect rect = CGRectMake(x-1.0f, y-1.0f, w, h);
CGContextSetShouldAntialias(fl_gc, false);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextStrokeRect(fl_gc, rect);
CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1);
#endif
@@ -65,8 +67,10 @@ void fl_rectf(int x, int y, int w, int h) {
SetRect(&rect, x, y, x+w, y+h);
PaintRect(&rect);
#elif defined(__APPLE_QUARTZ__)
CGRect rect = CGRectMake(x-1.0f, y-1.0f, w, h);
CGContextSetShouldAntialias(fl_gc, false);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextFillRect(fl_gc, rect);
CGContextSetShouldAntialias(fl_gc, true);
#else
if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h);
#endif
@@ -78,9 +82,11 @@ void fl_xyline(int x, int y, int x1) {
#elif defined(__APPLE_QD__)
MoveTo(x, y); LineTo(x1, y);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y);
#endif
@@ -98,10 +104,12 @@ void fl_xyline(int x, int y, int x1, int y2) {
LineTo(x1, y);
LineTo(x1, y2);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[3];
p[0].x = x; p[0].y = p[1].y = y;
@@ -124,11 +132,13 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
LineTo(x1, y2);
LineTo(x3, y2);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextAddLineToPoint(fl_gc, x3, y2);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[4];
p[0].x = x; p[0].y = p[1].y = y;
@@ -146,9 +156,11 @@ void fl_yxline(int x, int y, int y1) {
#elif defined(__APPLE_QD__)
MoveTo(x, y); LineTo(x, y1);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1);
#endif
@@ -166,10 +178,12 @@ void fl_yxline(int x, int y, int y1, int x2) {
LineTo(x, y1);
LineTo(x2, y1);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[3];
p[0].x = p[1].x = x; p[0].y = y;
@@ -192,11 +206,13 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
LineTo(x2, y1);
LineTo(x2, y3);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextAddLineToPoint(fl_gc, x2, y3);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[4];
p[0].x = p[1].x = x; p[0].y = y;
@@ -217,9 +233,11 @@ void fl_line(int x, int y, int x1, int y1) {
MoveTo(x, y);
LineTo(x1, y1);
#elif defined(__APPLE_QUARTZ__)
if ( x==x1 || y==y1 ) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1);
#endif
@@ -376,9 +394,11 @@ void fl_point(int x, int y) {
#elif defined(__APPLE_QD__)
MoveTo(x, y); Line(0, 0);
#elif defined(__APPLE_QUARTZ__)
CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y);
CGContextStrokePath(fl_gc);
CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawPoint(fl_display, fl_window, fl_gc, x, y);
#endif
@@ -642,5 +662,5 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
}
//
// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.14 2004/08/26 06:18:12 matthiaswm Exp $".
// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.15 2004/08/26 22:24:24 matthiaswm Exp $".
//