mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-19 09:30:56 +00:00
Allow snapshot of window, no matter what the drawing strategy. Mention drawing strategy in benchmark results
This commit is contained in:
parent
3fe9f5701e
commit
762b76f565
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Basilisk II (C) 1997-2002 Christian Bauer
|
* Basilisk II (C) 1997-2003 Christian Bauer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -34,9 +34,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef NSBITMAP
|
#ifdef NSBITMAP
|
||||||
NSBitmapImageRep *bitmap;
|
NSBitmapImageRep *bitmap;
|
||||||
|
#else
|
||||||
|
void *bitmap;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CGDRAWBITMAP
|
#ifdef CGDRAWBITMAP
|
||||||
void *bitmap;
|
|
||||||
short bps, spp, bpp;
|
short bps, spp, bpp;
|
||||||
int bytesPerRow;
|
int bytesPerRow;
|
||||||
BOOL isPlanar, hasAlpha;
|
BOOL isPlanar, hasAlpha;
|
||||||
@ -65,6 +66,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef CGIMAGEREF
|
#ifdef CGIMAGEREF
|
||||||
- (void) readyToDraw: (CGImageRef) image
|
- (void) readyToDraw: (CGImageRef) image
|
||||||
|
bitmap: (void *) theBitmap
|
||||||
imageWidth: (short) width
|
imageWidth: (short) width
|
||||||
imageHeight: (short) height;
|
imageHeight: (short) height;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* EmulatorView.mm - Custom NSView for Basilisk II graphics output
|
* EmulatorView.mm - Custom NSView for Basilisk II windowed graphics output
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Basilisk II (C) 1997-2002 Christian Bauer
|
* Basilisk II (C) 1997-2003 Christian Bauer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -157,9 +157,14 @@ static int prevFlags;
|
|||||||
int i;
|
int i;
|
||||||
float seconds;
|
float seconds;
|
||||||
NSDate *startDate;
|
NSDate *startDate;
|
||||||
|
char *method;
|
||||||
|
|
||||||
if ( ! drawView )
|
if ( ! drawView )
|
||||||
|
{
|
||||||
|
WarningSheet (@"The emulator has not been setup yet.",
|
||||||
|
@"Try to run, then pause the emulator, first.", nil, [self window]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
drawView = NO;
|
drawView = NO;
|
||||||
[self lockFocus];
|
[self lockFocus];
|
||||||
@ -178,9 +183,20 @@ static int prevFlags;
|
|||||||
[self unlockFocus];
|
[self unlockFocus];
|
||||||
drawView = YES;
|
drawView = YES;
|
||||||
|
|
||||||
InfoSheet(@"Benchmark run. 300 frames.",
|
#ifdef NSBITMAP
|
||||||
|
method = "NSBITMAP";
|
||||||
|
#endif
|
||||||
|
#ifdef CGIMAGEREF
|
||||||
|
method = "CGIMAGEREF";
|
||||||
|
#endif
|
||||||
|
#ifdef CGDRAWBITMAP
|
||||||
|
method = "CGDRAWBITMAP";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
InfoSheet(@"Ran benchmark (300 screen redraws)",
|
||||||
[NSString stringWithFormat:
|
[NSString stringWithFormat:
|
||||||
@"%.2f seconds, %.3f frames per second", seconds, i/seconds],
|
@"%.2f seconds, %.3f frames per second (using %s implementation)",
|
||||||
|
seconds, i/seconds, method],
|
||||||
@"Thanks", [self window]);
|
@"Thanks", [self window]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,9 +206,38 @@ static int prevFlags;
|
|||||||
#ifdef NSBITMAP
|
#ifdef NSBITMAP
|
||||||
return [bitmap TIFFRepresentation];
|
return [bitmap TIFFRepresentation];
|
||||||
#else
|
#else
|
||||||
WarningAlert("How do I get a TIFF from a CGImageRef?");
|
NSBitmapImageRep *b = [NSBitmapImageRep alloc];
|
||||||
|
|
||||||
|
b = [b initWithBitmapDataPlanes: (unsigned char **) &bitmap
|
||||||
|
pixelsWide: x
|
||||||
|
pixelsHigh: y
|
||||||
|
#ifdef CGIMAGEREF
|
||||||
|
bitsPerSample: CGImageGetBitsPerComponent(cgImgRep)
|
||||||
|
samplesPerPixel: 3
|
||||||
|
hasAlpha: NO
|
||||||
|
isPlanar: NO
|
||||||
|
colorSpaceName: NSCalibratedRGBColorSpace
|
||||||
|
bytesPerRow: CGImageGetBytesPerRow(cgImgRep)
|
||||||
|
bitsPerPixel: CGImageGetBitsPerPixel(cgImgRep)];
|
||||||
|
#endif
|
||||||
|
#ifdef CGDRAWBITMAP
|
||||||
|
bitsPerSample: bps
|
||||||
|
samplesPerPixel: spp
|
||||||
|
hasAlpha: hasAlpha
|
||||||
|
isPlanar: isPlanar
|
||||||
|
colorSpaceName: NSCalibratedRGBColorSpace
|
||||||
|
bytesPerRow: bytesPerRow
|
||||||
|
bitsPerPixel: bpp];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( ! b )
|
||||||
|
{
|
||||||
|
ErrorAlert("Could not allocate an NSBitmapImageRep for the TIFF");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [b TIFFRepresentation];
|
||||||
#endif
|
#endif
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable display of, and drawing into, the view
|
// Enable display of, and drawing into, the view
|
||||||
@ -201,18 +246,14 @@ static int prevFlags;
|
|||||||
imageWidth: (short) width
|
imageWidth: (short) width
|
||||||
imageHeight: (short) height
|
imageHeight: (short) height
|
||||||
{
|
{
|
||||||
D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
|
|
||||||
|
|
||||||
bitmap = theBitmap;
|
|
||||||
numBytes = [theBitmap bytesPerRow] * height;
|
numBytes = [theBitmap bytesPerRow] * height;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CGIMAGEREF
|
#ifdef CGIMAGEREF
|
||||||
- (void) readyToDraw: (CGImageRef) image
|
- (void) readyToDraw: (CGImageRef) image
|
||||||
|
bitmap: (void *) theBitmap
|
||||||
imageWidth: (short) width
|
imageWidth: (short) width
|
||||||
imageHeight: (short) height
|
imageHeight: (short) height
|
||||||
{
|
{
|
||||||
D(NSLog(@"readyToDraw: theBitmap=%lx\n", [cgImgRef bitmap]));
|
|
||||||
|
|
||||||
cgImgRep = image;
|
cgImgRep = image;
|
||||||
numBytes = CGImageGetBytesPerRow(image) * height;
|
numBytes = CGImageGetBytesPerRow(image) * height;
|
||||||
#endif
|
#endif
|
||||||
@ -227,9 +268,6 @@ static int prevFlags;
|
|||||||
isPlanar: (BOOL) planar
|
isPlanar: (BOOL) planar
|
||||||
hasAlpha: (BOOL) alpha
|
hasAlpha: (BOOL) alpha
|
||||||
{
|
{
|
||||||
D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
|
|
||||||
|
|
||||||
bitmap = theBitmap;
|
|
||||||
bps = bitsPerSample;
|
bps = bitsPerSample;
|
||||||
spp = samplesPerPixel;
|
spp = samplesPerPixel;
|
||||||
bpp = bitsPerPixel;
|
bpp = bitsPerPixel;
|
||||||
@ -238,6 +276,9 @@ static int prevFlags;
|
|||||||
hasAlpha = alpha;
|
hasAlpha = alpha;
|
||||||
numBytes = bpr * height;
|
numBytes = bpr * height;
|
||||||
#endif
|
#endif
|
||||||
|
D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
|
||||||
|
|
||||||
|
bitmap = theBitmap;
|
||||||
x = width, y = height;
|
x = width, y = height;
|
||||||
drawView = YES;
|
drawView = YES;
|
||||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||||
@ -396,17 +437,16 @@ static NSPoint mouse; // Previous/current mouse location
|
|||||||
ADBMouseUp(0);
|
ADBMouseUp(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG && ! defined(CGIMAGEREF)
|
#if DEBUG
|
||||||
- (void) randomise // Draw some coloured snow in the bitmap
|
- (void) randomise // Draw some coloured snow in the bitmap
|
||||||
{
|
{
|
||||||
unsigned char *data,
|
unsigned char *data,
|
||||||
*pixel;
|
*pixel;
|
||||||
|
|
||||||
#ifdef CGDRAWBITMAP
|
|
||||||
data = bitmap;
|
|
||||||
#endif
|
|
||||||
#ifdef NSBITMAP
|
#ifdef NSBITMAP
|
||||||
data = [bitmap bitmapData];
|
data = [bitmap bitmapData];
|
||||||
|
#else
|
||||||
|
data = bitmap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for ( int i = 0; i < 1000; ++i )
|
for ( int i = 0; i < 1000; ++i )
|
||||||
@ -424,9 +464,7 @@ static NSPoint mouse; // Previous/current mouse location
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
NSLog(@"In drawRect");
|
NSLog(@"In drawRect");
|
||||||
# ifndef CGIMAGEREF
|
|
||||||
[self randomise];
|
[self randomise];
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NSBITMAP
|
#ifdef NSBITMAP
|
||||||
|
Loading…
Reference in New Issue
Block a user