changeset 1527:9bab702bd6c1

A bunch of Mac drawing updates to correct issues and improve performance. Switched to using a different (faster) method for drawing rectangles. Fixed subpixel drawing issues related to the fact that drawing occurs centered on the coordinate so adding 0.5 draws at a pixel itself instead of spanning two pixels. And related to that removing the incorrect workaround I had previously used of setting the line width to 0.5. Also added DW_DRAW_NOAA support when drawing to windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 03 Jan 2012 15:59:00 +0000
parents ff78ae1d7429
children 5facb5380944
files mac/dw.m
diffstat 1 files changed, 10 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Mon Jan 02 06:25:36 2012 +0000
+++ b/mac/dw.m	Tue Jan 03 15:59:00 2012 +0000
@@ -5132,12 +5132,11 @@
         _DWLastDrawable = handle;
     }
     NSBezierPath* aPath = [NSBezierPath bezierPath];
-    [aPath setLineWidth: 0.5];
     NSColor *color = pthread_getspecific(_dw_fg_color_key);
     [color set];
 
-    [aPath moveToPoint:NSMakePoint(x1, y1)];
-    [aPath lineToPoint:NSMakePoint(x2, y2)];
+    [aPath moveToPoint:NSMakePoint(x1 + 0.5, y1 + 0.5)];
+    [aPath lineToPoint:NSMakePoint(x2 + 0.5, y2 + 0.5)];
     [aPath stroke];
 
     if(pixmap)
@@ -5309,17 +5308,17 @@
             DW_MUTEX_UNLOCK;
             return;
         }
+        [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
         _DWLastDrawable = handle;
     }
     NSBezierPath* aPath = [NSBezierPath bezierPath];
-    [aPath setLineWidth: 0.5];
     NSColor *color = pthread_getspecific(_dw_fg_color_key);
     [color set];
 
-    [aPath moveToPoint:NSMakePoint(*x, *y)];
+    [aPath moveToPoint:NSMakePoint(*x + 0.5, *y + 0.5)];
     for(z=1;z<npoints;z++)
     {
-        [aPath lineToPoint:NSMakePoint(x[z], y[z])];
+        [aPath lineToPoint:NSMakePoint(x[z] + 0.5, y[z] + 0.5)];
     }
     [aPath closePath];
     if(flags & DW_DRAW_FILL)
@@ -5367,21 +5366,16 @@
             DW_MUTEX_UNLOCK;
             return;
         }
+        [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
         _DWLastDrawable = handle;
     }
-    NSBezierPath* aPath = [NSBezierPath bezierPath];
-    [aPath setLineWidth: 0.5];
     NSColor *color = pthread_getspecific(_dw_fg_color_key);
     [color set];
 
-    [aPath moveToPoint:NSMakePoint(x, y)];
-    [aPath lineToPoint:NSMakePoint(x, y + height)];
-    [aPath lineToPoint:NSMakePoint(x + width, y + height)];
-    [aPath lineToPoint:NSMakePoint(x + width, y)];
-    [aPath closePath];
     if(flags & DW_DRAW_FILL)
-       [aPath fill];
-    [aPath stroke];
+        [NSBezierPath fillRect:NSMakeRect(x, y, width, height)];
+    else
+        [NSBezierPath strokeRect:NSMakeRect(x, y, width, height)];
     if(pixmap)
     {
         [NSGraphicsContext restoreGraphicsState];
@@ -5427,10 +5421,10 @@
             DW_MUTEX_UNLOCK;
             return;
         }
+        [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
         _DWLastDrawable = handle;
     }
     NSBezierPath* aPath = [NSBezierPath bezierPath];
-    [aPath setLineWidth: 0.5];
     NSColor *color = pthread_getspecific(_dw_fg_color_key);
     [color set];