comparison mac/dw.m @ 915:361d80388dc9

Test fix at the partial bitblt issue on Mac. Also combine setting up the flipped graphics context into a single command.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 22 Apr 2011 01:13:38 +0000
parents 1ac9669caf86
children 44a0f9a2e8f9
comparison
equal deleted inserted replaced
914:61732be875c7 915:361d80388dc9
420 420
421 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) 421 if([bltdest isMemberOfClass:[NSBitmapImageRep class]])
422 { 422 {
423 [NSGraphicsContext saveGraphicsState]; 423 [NSGraphicsContext saveGraphicsState];
424 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 424 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
425 graphicsContextWithBitmapImageRep:bltdest]]; 425 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:bltdest] graphicsPort] flipped:YES]];
426 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
427 graphicsContextWithGraphicsPort:[[NSGraphicsContext currentContext] graphicsPort] flipped:YES]];
428 [[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil]; 426 [[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil];
429 } 427 }
430 else 428 else
431 { 429 {
432 if([bltdest lockFocusIfCanDraw] == NO) 430 if([bltdest lockFocusIfCanDraw] == NO)
454 452
455 // by scaling Y negatively, we effectively flip the image: 453 // by scaling Y negatively, we effectively flip the image:
456 [t scaleXBy:1.0 yBy:-1.0]; 454 [t scaleXBy:1.0 yBy:-1.0];
457 455
458 // but we also have to translate it back by its height: 456 // but we also have to translate it back by its height:
459 [t translateXBy:0.0 yBy:-bltinfo->height]; 457 [t translateXBy:0.0 yBy:-[rep size].height];
460 458
461 // apply the transform: 459 // apply the transform:
462 [t concat]; 460 [t concat];
463 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) 461 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)
464 operation:NSCompositeCopy fraction:1.0]; 462 operation:NSCompositeCopy fraction:1.0];
4389 if(pixmap) 4387 if(pixmap)
4390 { 4388 {
4391 image = (id)pixmap->image; 4389 image = (id)pixmap->image;
4392 [NSGraphicsContext saveGraphicsState]; 4390 [NSGraphicsContext saveGraphicsState];
4393 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4391 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4394 graphicsContextWithBitmapImageRep:image]]; 4392 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4395 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4396 graphicsContextWithGraphicsPort:[[NSGraphicsContext currentContext] graphicsPort] flipped:YES]];
4397 } 4393 }
4398 else 4394 else
4399 { 4395 {
4400 if([image lockFocusIfCanDraw] == NO) 4396 if([image lockFocusIfCanDraw] == NO)
4401 { 4397 {
4439 if(pixmap) 4435 if(pixmap)
4440 { 4436 {
4441 image = (id)pixmap->image; 4437 image = (id)pixmap->image;
4442 [NSGraphicsContext saveGraphicsState]; 4438 [NSGraphicsContext saveGraphicsState];
4443 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4439 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4444 graphicsContextWithBitmapImageRep:image]]; 4440 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4445 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4446 graphicsContextWithGraphicsPort:[[NSGraphicsContext currentContext] graphicsPort] flipped:YES]];
4447 } 4441 }
4448 else 4442 else
4449 { 4443 {
4450 if([image lockFocusIfCanDraw] == NO) 4444 if([image lockFocusIfCanDraw] == NO)
4451 { 4445 {
4525 font = [render font]; 4519 font = [render font];
4526 } 4520 }
4527 image = (id)pixmap->image; 4521 image = (id)pixmap->image;
4528 [NSGraphicsContext saveGraphicsState]; 4522 [NSGraphicsContext saveGraphicsState];
4529 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4523 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4530 graphicsContextWithBitmapImageRep:image]]; 4524 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4531 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4532 graphicsContextWithGraphicsPort:[[NSGraphicsContext currentContext] graphicsPort] flipped:YES]];
4533 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); 4525 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key);
4534 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); 4526 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key);
4535 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; 4527 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil];
4536 if(bgcolor) 4528 if(bgcolor)
4537 { 4529 {
4605 if(pixmap) 4597 if(pixmap)
4606 { 4598 {
4607 image = (id)pixmap->image; 4599 image = (id)pixmap->image;
4608 [NSGraphicsContext saveGraphicsState]; 4600 [NSGraphicsContext saveGraphicsState];
4609 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4601 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4610 graphicsContextWithBitmapImageRep:image]]; 4602 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4611 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4612 graphicsContextWithGraphicsPort:[[NSGraphicsContext currentContext] graphicsPort] flipped:YES]];
4613 } 4603 }
4614 else 4604 else
4615 { 4605 {
4616 if([image lockFocusIfCanDraw] == NO) 4606 if([image lockFocusIfCanDraw] == NO)
4617 { 4607 {
4665 if(pixmap) 4655 if(pixmap)
4666 { 4656 {
4667 image = (id)pixmap->image; 4657 image = (id)pixmap->image;
4668 [NSGraphicsContext saveGraphicsState]; 4658 [NSGraphicsContext saveGraphicsState];
4669 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4659 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4670 graphicsContextWithBitmapImageRep:image]]; 4660 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4671 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4672 graphicsContextWithGraphicsPort:[[NSGraphicsContext currentContext] graphicsPort] flipped:YES]];
4673 } 4661 }
4674 else 4662 else
4675 { 4663 {
4676 if([image lockFocusIfCanDraw] == NO) 4664 if([image lockFocusIfCanDraw] == NO)
4677 { 4665 {