diff mac/dw.m @ 1523:026c0b4d6ee9

Initial implmentation of DW_DRAW_NOAA on Mac... only works on pixmaps right now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 31 Dec 2011 17:04:51 +0000
parents c98b2ce2d5b2
children 9bab702bd6c1
line wrap: on
line diff
--- a/mac/dw.m	Fri Dec 30 21:30:24 2011 +0000
+++ b/mac/dw.m	Sat Dec 31 17:04:51 2011 +0000
@@ -5267,6 +5267,18 @@
     }
 }
 
+/* Internal function to create an image graphics context...
+ * with or without antialiasing enabled.
+ */
+id _create_gc(id image, bool antialiased)
+{
+    CGContextRef  context = (CGContextRef)[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort];
+    NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
+    [gc setShouldAntialias:antialiased];
+    CGContextSetAllowsAntialiasing(context, antialiased);
+    return gc;
+}
+
 /* Draw a polygon on a window (preferably a render window).
  * Parameters:
  *       handle: Handle to the window.
@@ -5286,9 +5298,9 @@
     if(pixmap)
     {
         image = (id)pixmap->image;
+        id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES);
         [NSGraphicsContext saveGraphicsState];
-        [NSGraphicsContext setCurrentContext:[NSGraphicsContext
-                                              graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
+        [NSGraphicsContext setCurrentContext:gc];
     }
     else
     {
@@ -5344,9 +5356,9 @@
     if(pixmap)
     {
         image = (id)pixmap->image;
+        id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES);
         [NSGraphicsContext saveGraphicsState];
-        [NSGraphicsContext setCurrentContext:[NSGraphicsContext
-                                              graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
+        [NSGraphicsContext setCurrentContext:gc];
     }
     else
     {
@@ -5404,9 +5416,9 @@
     if(pixmap)
     {
         image = (id)pixmap->image;
+        id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES);
         [NSGraphicsContext saveGraphicsState];
-        [NSGraphicsContext setCurrentContext:[NSGraphicsContext
-                                              graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
+        [NSGraphicsContext setCurrentContext:gc];
     }
     else
     {