summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2015-02-22 21:11:30 +1100
committer Vas Crabb <vas@vastheman.com>2015-02-22 21:12:00 +1100
commit79fcba5fe62d42c9d3e7c1d96122785a44c00ba8 (patch)
tree42212d19c1f749d10fbdc1d8f712b6d16e7c8373
parente3d08464782de6c86c21cbfb1c090d28817729ac (diff)
Slight improvement in Cocoa debug view performance
-rw-r--r--src/osd/modules/debugger/osx/debugconsole.m3
-rw-r--r--src/osd/modules/debugger/osx/debugview.h1
-rw-r--r--src/osd/modules/debugger/osx/debugview.m85
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.m2
-rw-r--r--src/osd/modules/debugger/osx/disassemblyviewer.m1
-rw-r--r--src/osd/modules/debugger/osx/errorlogviewer.m1
-rw-r--r--src/osd/modules/debugger/osx/memoryviewer.m1
-rw-r--r--src/osd/modules/debugger/osx/pointsviewer.m2
8 files changed, 68 insertions, 28 deletions
diff --git a/src/osd/modules/debugger/osx/debugconsole.m b/src/osd/modules/debugger/osx/debugconsole.m
index 1028e718642..a0410fcedfa 100644
--- a/src/osd/modules/debugger/osx/debugconsole.m
+++ b/src/osd/modules/debugger/osx/debugconsole.m
@@ -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];
diff --git a/src/osd/modules/debugger/osx/debugview.h b/src/osd/modules/debugger/osx/debugview.h
index b6b63547032..12bfa3c3ca7 100644
--- a/src/osd/modules/debugger/osx/debugview.h
+++ b/src/osd/modules/debugger/osx/debugview.h
@@ -52,6 +52,7 @@
- (IBAction)paste:(id)sender;
- (void)viewBoundsDidChange:(NSNotification *)notification;
+- (void)viewFrameDidChange:(NSNotification *)notification;
- (void)windowDidBecomeKey:(NSNotification *)notification;
- (void)windowDidResignKey:(NSNotification *)notification;
diff --git a/src/osd/modules/debugger/osx/debugview.m b/src/osd/modules/debugger/osx/debugview.m
index abedc1c3170..eda265db976 100644
--- a/src/osd/modules/debugger/osx/debugview.m
+++ b/src/osd/modules/debugger/osx/debugview.m
@@ -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))];
+ }
}
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m
index 924208a33cd..65ef6d5b7ba 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.m
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.m
@@ -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];
diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.m b/src/osd/modules/debugger/osx/disassemblyviewer.m
index 6f7d9176082..7653b322d32 100644
--- a/src/osd/modules/debugger/osx/disassemblyviewer.m
+++ b/src/osd/modules/debugger/osx/disassemblyviewer.m
@@ -77,7 +77,6 @@
0,
contentBounds.size.width,
expressionFrame.origin.y)];
- [dasmScroll setDrawsBackground:YES];
[dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[dasmScroll setHasHorizontalScroller:YES];
[dasmScroll setHasVerticalScroller:YES];
diff --git a/src/osd/modules/debugger/osx/errorlogviewer.m b/src/osd/modules/debugger/osx/errorlogviewer.m
index f049286aaa4..b4e204d45f7 100644
--- a/src/osd/modules/debugger/osx/errorlogviewer.m
+++ b/src/osd/modules/debugger/osx/errorlogviewer.m
@@ -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];
diff --git a/src/osd/modules/debugger/osx/memoryviewer.m b/src/osd/modules/debugger/osx/memoryviewer.m
index 517efa9fd0a..18aa0b380da 100644
--- a/src/osd/modules/debugger/osx/memoryviewer.m
+++ b/src/osd/modules/debugger/osx/memoryviewer.m
@@ -77,7 +77,6 @@
0,
contentBounds.size.width,
expressionFrame.origin.y)];
- [memoryScroll setDrawsBackground:YES];
[memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[memoryScroll setHasHorizontalScroller:YES];
[memoryScroll setHasVerticalScroller:YES];
diff --git a/src/osd/modules/debugger/osx/pointsviewer.m b/src/osd/modules/debugger/osx/pointsviewer.m
index 7c85324fd70..dca14527b92 100644
--- a/src/osd/modules/debugger/osx/pointsviewer.m
+++ b/src/osd/modules/debugger/osx/pointsviewer.m
@@ -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];