Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
1522:c98b2ce2d5b2 | 1523:026c0b4d6ee9 |
---|---|
5265 { | 5265 { |
5266 *height = size.height; | 5266 *height = size.height; |
5267 } | 5267 } |
5268 } | 5268 } |
5269 | 5269 |
5270 /* Internal function to create an image graphics context... | |
5271 * with or without antialiasing enabled. | |
5272 */ | |
5273 id _create_gc(id image, bool antialiased) | |
5274 { | |
5275 CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort]; | |
5276 NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES]; | |
5277 [gc setShouldAntialias:antialiased]; | |
5278 CGContextSetAllowsAntialiasing(context, antialiased); | |
5279 return gc; | |
5280 } | |
5281 | |
5270 /* Draw a polygon on a window (preferably a render window). | 5282 /* Draw a polygon on a window (preferably a render window). |
5271 * Parameters: | 5283 * Parameters: |
5272 * handle: Handle to the window. | 5284 * handle: Handle to the window. |
5273 * pixmap: Handle to the pixmap. (choose only one of these) | 5285 * pixmap: Handle to the pixmap. (choose only one of these) |
5274 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0). | 5286 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0). |
5284 id image = handle; | 5296 id image = handle; |
5285 int z; | 5297 int z; |
5286 if(pixmap) | 5298 if(pixmap) |
5287 { | 5299 { |
5288 image = (id)pixmap->image; | 5300 image = (id)pixmap->image; |
5301 id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES); | |
5289 [NSGraphicsContext saveGraphicsState]; | 5302 [NSGraphicsContext saveGraphicsState]; |
5290 [NSGraphicsContext setCurrentContext:[NSGraphicsContext | 5303 [NSGraphicsContext setCurrentContext:gc]; |
5291 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; | |
5292 } | 5304 } |
5293 else | 5305 else |
5294 { | 5306 { |
5295 if([image lockFocusIfCanDraw] == NO) | 5307 if([image lockFocusIfCanDraw] == NO) |
5296 { | 5308 { |
5342 DW_MUTEX_LOCK; | 5354 DW_MUTEX_LOCK; |
5343 id image = handle; | 5355 id image = handle; |
5344 if(pixmap) | 5356 if(pixmap) |
5345 { | 5357 { |
5346 image = (id)pixmap->image; | 5358 image = (id)pixmap->image; |
5359 id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES); | |
5347 [NSGraphicsContext saveGraphicsState]; | 5360 [NSGraphicsContext saveGraphicsState]; |
5348 [NSGraphicsContext setCurrentContext:[NSGraphicsContext | 5361 [NSGraphicsContext setCurrentContext:gc]; |
5349 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; | |
5350 } | 5362 } |
5351 else | 5363 else |
5352 { | 5364 { |
5353 if([image lockFocusIfCanDraw] == NO) | 5365 if([image lockFocusIfCanDraw] == NO) |
5354 { | 5366 { |
5402 double r, a1, a2, a; | 5414 double r, a1, a2, a; |
5403 | 5415 |
5404 if(pixmap) | 5416 if(pixmap) |
5405 { | 5417 { |
5406 image = (id)pixmap->image; | 5418 image = (id)pixmap->image; |
5419 id gc = _create_gc(image, flags & DW_DRAW_NOAA ? NO : YES); | |
5407 [NSGraphicsContext saveGraphicsState]; | 5420 [NSGraphicsContext saveGraphicsState]; |
5408 [NSGraphicsContext setCurrentContext:[NSGraphicsContext | 5421 [NSGraphicsContext setCurrentContext:gc]; |
5409 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; | |
5410 } | 5422 } |
5411 else | 5423 else |
5412 { | 5424 { |
5413 if([image lockFocusIfCanDraw] == NO) | 5425 if([image lockFocusIfCanDraw] == NO) |
5414 { | 5426 { |