ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/EmulatorView.mm
(Generate patch)

Comparing BasiliskII/src/MacOSX/EmulatorView.mm (file contents):
Revision 1.6 by nigel, 2002-10-06T23:26:07Z vs.
Revision 1.7 by nigel, 2002-12-18T11:53:11Z

# Line 49 | Line 49
49          drawView = NO;          // Disable drawing until later
50          fullScreen = NO;
51  
52 #ifdef SAVE_GSTATE
53        [self allocateGState];
54 #endif
55
52          return self;
53   }
54  
59 - (void) dealloc
60 {
61 #ifdef SAVE_GSTATE
62        [self releaseGState];
63 #endif
64        [super dealloc];
65 }
66
55   // Mouse click in this window. If window is not active,
56   // should the click be passed to this view?
57   - (BOOL) acceptsFirstMouse: (NSEvent *) event
# Line 163 | Line 151 | static int prevFlags;
151                  [bitmap draw];
152   #endif
153   #ifdef CGIMAGEREF
154 <                cgDrawInto([self bounds], bitmap);
154 >                cgDrawInto([self bounds], cgImgRep);
155   #endif
156   #ifdef CGDRAWBITMAP
157                  [self CGDrawBitmap];
# Line 196 | Line 184 | static int prevFlags;
184                   imageHeight: (short) height
185   {
186          bitmap = theBitmap;
187 +        numBytes = [theBitmap bytesPerRow] * height;
188   #endif
189   #ifdef CGIMAGEREF
190   - (void) readyToDraw: (CGImageRef) image
191                    imageWidth: (short) width
192                   imageHeight: (short) height
193   {
194 <        bitmap = image;
194 >        cgImgRep = image;
195 >        numBytes = CGImageGetBytesPerRow(image);
196   #endif
197   #ifdef CGDRAWBITMAP
198   - (void) readyToDraw: (void *) theBitmap
# Line 222 | Line 212 | static int prevFlags;
212          bytesPerRow = bpr;
213          isPlanar = planar;
214          hasAlpha = alpha;
215 +        numBytes = bpr * height;
216   #endif
217          x = width, y = height;
218          drawView = YES;
# Line 370 | Line 361 | static NSPoint mouse;                  // Previous/curr
361          ADBMouseUp(0);
362   }
363  
364 < #if DEBUG
364 > #if DEBUG && ! defined(CGIMAGEREF)
365   - (void) randomise              // Draw some coloured snow in the bitmap
366   {
367 <        unsigned char    *pixel;
367 >        unsigned char   *data,
368 >                                        *pixel;
369 >
370 >  #ifdef CGDRAWBITMAP
371 >        data = bitmap;
372 >  #endif
373 >  #ifdef NSBITMAP
374 >        data = [bitmap bitmapData];
375 >  #endif
376  
377          for ( int i = 0; i < 1000; ++i )
378          {
379 <                pixel = [bitmap bitmapData]
381 <                                + (int) (1.0 * [bitmap bytesPerRow] * 342       //[bitmap height]
382 <                                                         * rand() / RAND_MAX);
379 >                pixel  = data + (int) (numBytes * rand() / RAND_MAX);
380                  *pixel = (unsigned char) (256.0 * rand() / RAND_MAX);
381          }
382   }
# Line 392 | Line 389 | static NSPoint mouse;                  // Previous/curr
389  
390   #if DEBUG
391          NSLog(@"In drawRect");
392 <        //[self randomise];
392 > # ifndef CGIMAGEREF
393 >        [self randomise];
394 > # endif
395   #endif
396  
397   #ifdef NSBITMAP
# Line 400 | Line 399 | static NSPoint mouse;                  // Previous/curr
399          [bitmap draw];
400   #endif
401   #ifdef CGIMAGEREF
402 <        cgDrawInto(rect, bitmap);
402 >        cgDrawInto(rect, cgImgRep);
403   #endif
404   #ifdef CGDRAWBITMAP
405          [self CGDrawBitmap];
# Line 416 | Line 415 | extern "C" void CGDrawBitmap(...);
415  
416   - (void) CGDrawBitmap
417   {
418 <        CGContextRef    cgContext = [[NSGraphicsContext currentContext]
419 <                                                                                                                graphicsPort];
418 >        CGContextRef    cgContext = (CGContextRef) [[NSGraphicsContext currentContext]
419 >                                                                                                graphicsPort];
420          NSRect                  rect = [self bounds];
421          CGRect                  cgRect = {
422                                                                  {rect.origin.x, rect.origin.y},
# Line 427 | Line 426 | extern "C" void CGDrawBitmap(...);
426          CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
427  
428  
429 <        CGContextSetShouldAntialias(cgContext, NO);             // Seems to have no effect?
429 > //      CGContextSetShouldAntialias(cgContext, NO);             // Seems to have no effect?
430  
431          CGDrawBitmap(cgContext, cgRect, x, y, bps, spp, bpp,
432                                          bytesPerRow, isPlanar, hasAlpha, colourSpace, &bitmap);
# Line 436 | Line 435 | extern "C" void CGDrawBitmap(...);
435  
436   #ifdef CGIMAGEREF
437   void
438 < cgDrawInto(NSRect rect, CGImageRef bitmap)
438 > cgDrawInto(NSRect rect, CGImageRef cgImgRep)
439   {
440 <        CGContextRef    cgContext = [[NSGraphicsContext currentContext]
441 <                                                                                                                graphicsPort];
440 >        CGContextRef    cgContext = (CGContextRef) [[NSGraphicsContext currentContext]
441 >                                                                                                graphicsPort];
442          CGRect                  cgRect = {
443                                                                  {rect.origin.x, rect.origin.y},
444                                                                  {rect.size.width, rect.size.height}
445                                                           };
446  
447 <        CGContextSetShouldAntialias(cgContext, NO);             // Seems to have no effect?
447 > //      CGContextSetShouldAntialias(cgContext, NO);             // Seems to have no effect?
448  
449 <        CGContextDrawImage(cgContext, cgRect, bitmap);
449 >        CGContextDrawImage(cgContext, cgRect, cgImgRep);
450   }
451   #endif
452  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines