mirror of
https://github.com/holub/mame
synced 2025-04-26 02:07:14 +03:00
Slight improvement in Cocoa debug view performance
This commit is contained in:
parent
e3d0846478
commit
79fcba5fe6
@ -45,7 +45,6 @@
|
||||
// create the register view
|
||||
regView = [[MAMERegistersView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||
regScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||
[regScroll setDrawsBackground:YES];
|
||||
[regScroll setHasHorizontalScroller:YES];
|
||||
[regScroll setHasVerticalScroller:YES];
|
||||
[regScroll setAutohidesScrollers:YES];
|
||||
@ -57,7 +56,6 @@
|
||||
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||
[dasmView setExpression:@"curpc"];
|
||||
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||
[dasmScroll setDrawsBackground:YES];
|
||||
[dasmScroll setHasHorizontalScroller:YES];
|
||||
[dasmScroll setHasVerticalScroller:YES];
|
||||
[dasmScroll setAutohidesScrollers:YES];
|
||||
@ -68,7 +66,6 @@
|
||||
// create the console view
|
||||
consoleView = [[MAMEConsoleView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||
consoleScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||
[consoleScroll setDrawsBackground:YES];
|
||||
[consoleScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[consoleScroll setHasHorizontalScroller:YES];
|
||||
[consoleScroll setHasVerticalScroller:YES];
|
||||
|
@ -52,6 +52,7 @@
|
||||
- (IBAction)paste:(id)sender;
|
||||
|
||||
- (void)viewBoundsDidChange:(NSNotification *)notification;
|
||||
- (void)viewFrameDidChange:(NSNotification *)notification;
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
||||
- (void)windowDidResignKey:(NSNotification *)notification;
|
||||
|
@ -194,6 +194,15 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
}
|
||||
|
||||
|
||||
- (void)adjustSizeAndRecomputeVisible {
|
||||
NSSize const clip = [[[self enclosingScrollView] contentView] bounds].size;
|
||||
NSSize const content = NSMakeSize((fontWidth * totalWidth) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * totalHeight);
|
||||
[self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))];
|
||||
[self recomputeVisible];
|
||||
}
|
||||
|
||||
|
||||
+ (NSFont *)defaultFont {
|
||||
return [NSFont userFixedPitchFontOfSize:0];
|
||||
}
|
||||
@ -245,8 +254,15 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
BOOL const resized = (newSize.x != totalWidth) || (newSize.y != totalHeight);
|
||||
if (resized)
|
||||
{
|
||||
[self setFrameSize:NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * newSize.y)];
|
||||
NSScrollView *const scroller = [self enclosingScrollView];
|
||||
if (scroller)
|
||||
{
|
||||
NSSize const clip = [[scroller contentView] bounds].size;
|
||||
NSSize const content = NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * newSize.y);
|
||||
[self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))];
|
||||
[self recomputeVisible];
|
||||
}
|
||||
totalWidth = newSize.x;
|
||||
totalHeight = newSize.y;
|
||||
}
|
||||
@ -407,7 +423,14 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
- (void)viewBoundsDidChange:(NSNotification *)notification {
|
||||
NSView *const changed = [notification object];
|
||||
if (changed == [[self enclosingScrollView] contentView])
|
||||
[self recomputeVisible];
|
||||
[self adjustSizeAndRecomputeVisible];
|
||||
}
|
||||
|
||||
|
||||
- (void)viewFrameDidChange:(NSNotification *)notification {
|
||||
NSView *const changed = [notification object];
|
||||
if (changed == [[self enclosingScrollView] contentView])
|
||||
[self adjustSizeAndRecomputeVisible];
|
||||
}
|
||||
|
||||
|
||||
@ -451,7 +474,10 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
debug_view_xy pos;
|
||||
view->set_cursor_visible(true);
|
||||
pos = view->cursor_position();
|
||||
[self scrollRectToVisible:NSMakeRect((pos.x * fontWidth) + [textContainer lineFragmentPadding], pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics
|
||||
[self scrollRectToVisible:NSMakeRect((pos.x * fontWidth) + [textContainer lineFragmentPadding],
|
||||
pos.y * fontHeight,
|
||||
fontWidth,
|
||||
fontHeight)]; // FIXME: metrics
|
||||
[self setNeedsDisplay:YES];
|
||||
return [super becomeFirstResponder];
|
||||
}
|
||||
@ -475,16 +501,24 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:NSViewBoundsDidChangeNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:NSViewFrameDidChangeNotification
|
||||
object:nil];
|
||||
|
||||
NSScrollView *const scroller = [self enclosingScrollView];
|
||||
if (scroller != nil)
|
||||
{
|
||||
[scroller setLineScroll:fontHeight];
|
||||
[[scroller contentView] setPostsBoundsChangedNotifications:YES];
|
||||
[[scroller contentView] setPostsFrameChangedNotifications:YES];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(viewBoundsDidChange:)
|
||||
name:NSViewBoundsDidChangeNotification
|
||||
object:[scroller contentView]];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(viewFrameDidChange:)
|
||||
name:NSViewFrameDidChangeNotification
|
||||
object:[scroller contentView]];
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,28 +565,31 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
debug_view_xy const size = view->visible_size();
|
||||
|
||||
// work out how much we need to draw
|
||||
INT32 position, clip;
|
||||
[self convertBounds:dirtyRect toFirstAffectedLine:&position count:&clip];
|
||||
INT32 row, clip;
|
||||
[self convertBounds:dirtyRect toFirstAffectedLine:&row count:&clip];
|
||||
clip += row;
|
||||
row = MAX(row, origin.y);
|
||||
clip = MIN(clip, origin.y + size.y);
|
||||
|
||||
// this gets the text for the whole visible area
|
||||
debug_view_char const *data = view->viewdata();
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
data += ((position - origin.y) * size.x);
|
||||
for (UINT32 row = position; row < position + clip; row++, data += size.x)
|
||||
// clear any space above the available content
|
||||
data += ((row - origin.y) * size.x);
|
||||
if (dirtyRect.origin.y < (row * fontHeight))
|
||||
{
|
||||
if ((row < origin.y) || (row >= origin.y + size.y))
|
||||
{
|
||||
[DefaultBackground set];
|
||||
[NSBezierPath fillRect:NSMakeRect(0,
|
||||
row * fontHeight,
|
||||
[self bounds].size.width,
|
||||
fontHeight)];
|
||||
continue;
|
||||
}
|
||||
[DefaultBackground set];
|
||||
[NSBezierPath fillRect:NSMakeRect(0,
|
||||
dirtyRect.origin.y,
|
||||
[self bounds].size.width,
|
||||
(row * fontHeight) - dirtyRect.origin.y)];
|
||||
}
|
||||
|
||||
// render entire lines to get character alignment right
|
||||
// render entire lines to get character alignment right
|
||||
for ( ; row < clip; row++, data += size.x)
|
||||
{
|
||||
int attr = -1;
|
||||
NSUInteger start = 0, length = 0;
|
||||
for (UINT32 col = origin.x; col < origin.x + size.x; col++)
|
||||
@ -599,7 +636,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
inTextContainer:textContainer];
|
||||
if (start == 0)
|
||||
box.origin.x = 0;
|
||||
box.size.width = [self bounds].size.width - box.origin.x;
|
||||
box.size.width = MAX([self bounds].size.width - box.origin.x, 0);
|
||||
[[self backgroundForAttribute:attr] set];
|
||||
[NSBezierPath fillRect:NSMakeRect(box.origin.x,
|
||||
row * fontHeight,
|
||||
@ -609,6 +646,16 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
atPoint:NSMakePoint(0, row * fontHeight)];
|
||||
[text deleteCharactersInRange:NSMakeRange(0, length)];
|
||||
}
|
||||
|
||||
// clear any space below the available content
|
||||
if ((dirtyRect.origin.y + dirtyRect.size.height) > (row * fontHeight))
|
||||
{
|
||||
[DefaultBackground set];
|
||||
[NSBezierPath fillRect:NSMakeRect(0,
|
||||
row * fontHeight,
|
||||
[self bounds].size.width,
|
||||
(dirtyRect.origin.y + dirtyRect.size.height) - (row * fontHeight))];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -326,7 +326,7 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
|
||||
windowFrame.size.width += desired.width;
|
||||
windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
|
||||
windowFrame.size.height += desired.height;
|
||||
windowFrame.size.height = MIN(MIN(windowFrame.size.height, 320), available.size.height);
|
||||
windowFrame.size.height = MIN(MIN(MAX(windowFrame.size.height, 120), 320), available.size.height);
|
||||
windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
|
||||
windowFrame.origin.y = available.origin.y;
|
||||
[window setFrame:windowFrame display:YES];
|
||||
|
@ -77,7 +77,6 @@
|
||||
0,
|
||||
contentBounds.size.width,
|
||||
expressionFrame.origin.y)];
|
||||
[dasmScroll setDrawsBackground:YES];
|
||||
[dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[dasmScroll setHasHorizontalScroller:YES];
|
||||
[dasmScroll setHasVerticalScroller:YES];
|
||||
|
@ -29,7 +29,6 @@
|
||||
// create the error log view
|
||||
logView = [[MAMEErrorLogView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||
logScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||
[logScroll setDrawsBackground:YES];
|
||||
[logScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[logScroll setHasHorizontalScroller:YES];
|
||||
[logScroll setHasVerticalScroller:YES];
|
||||
|
@ -77,7 +77,6 @@
|
||||
0,
|
||||
contentBounds.size.width,
|
||||
expressionFrame.origin.y)];
|
||||
[memoryScroll setDrawsBackground:YES];
|
||||
[memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[memoryScroll setHasHorizontalScroller:YES];
|
||||
[memoryScroll setHasVerticalScroller:YES];
|
||||
|
@ -65,7 +65,6 @@
|
||||
0,
|
||||
contentBounds.size.width,
|
||||
contentBounds.size.height - 19)];
|
||||
[breakScroll setDrawsBackground:YES];
|
||||
[breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[breakScroll setHasHorizontalScroller:YES];
|
||||
[breakScroll setHasVerticalScroller:YES];
|
||||
@ -84,7 +83,6 @@
|
||||
0,
|
||||
contentBounds.size.width,
|
||||
contentBounds.size.height - 19)];
|
||||
[watchScroll setDrawsBackground:YES];
|
||||
[watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[watchScroll setHasHorizontalScroller:YES];
|
||||
[watchScroll setHasVerticalScroller:YES];
|
||||
|
Loading…
Reference in New Issue
Block a user