mirror of
https://github.com/holub/mame
synced 2025-04-27 02:33:13 +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
|
// create the register view
|
||||||
regView = [[MAMERegistersView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
regView = [[MAMERegistersView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||||
regScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
regScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||||
[regScroll setDrawsBackground:YES];
|
|
||||||
[regScroll setHasHorizontalScroller:YES];
|
[regScroll setHasHorizontalScroller:YES];
|
||||||
[regScroll setHasVerticalScroller:YES];
|
[regScroll setHasVerticalScroller:YES];
|
||||||
[regScroll setAutohidesScrollers:YES];
|
[regScroll setAutohidesScrollers:YES];
|
||||||
@ -57,7 +56,6 @@
|
|||||||
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||||
[dasmView setExpression:@"curpc"];
|
[dasmView setExpression:@"curpc"];
|
||||||
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||||
[dasmScroll setDrawsBackground:YES];
|
|
||||||
[dasmScroll setHasHorizontalScroller:YES];
|
[dasmScroll setHasHorizontalScroller:YES];
|
||||||
[dasmScroll setHasVerticalScroller:YES];
|
[dasmScroll setHasVerticalScroller:YES];
|
||||||
[dasmScroll setAutohidesScrollers:YES];
|
[dasmScroll setAutohidesScrollers:YES];
|
||||||
@ -68,7 +66,6 @@
|
|||||||
// create the console view
|
// create the console view
|
||||||
consoleView = [[MAMEConsoleView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
consoleView = [[MAMEConsoleView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||||
consoleScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
consoleScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||||
[consoleScroll setDrawsBackground:YES];
|
|
||||||
[consoleScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
[consoleScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||||
[consoleScroll setHasHorizontalScroller:YES];
|
[consoleScroll setHasHorizontalScroller:YES];
|
||||||
[consoleScroll setHasVerticalScroller:YES];
|
[consoleScroll setHasVerticalScroller:YES];
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
- (IBAction)paste:(id)sender;
|
- (IBAction)paste:(id)sender;
|
||||||
|
|
||||||
- (void)viewBoundsDidChange:(NSNotification *)notification;
|
- (void)viewBoundsDidChange:(NSNotification *)notification;
|
||||||
|
- (void)viewFrameDidChange:(NSNotification *)notification;
|
||||||
|
|
||||||
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
||||||
- (void)windowDidResignKey:(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 {
|
+ (NSFont *)defaultFont {
|
||||||
return [NSFont userFixedPitchFontOfSize:0];
|
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);
|
BOOL const resized = (newSize.x != totalWidth) || (newSize.y != totalHeight);
|
||||||
if (resized)
|
if (resized)
|
||||||
{
|
{
|
||||||
[self setFrameSize:NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
|
NSScrollView *const scroller = [self enclosingScrollView];
|
||||||
fontHeight * newSize.y)];
|
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;
|
totalWidth = newSize.x;
|
||||||
totalHeight = newSize.y;
|
totalHeight = newSize.y;
|
||||||
}
|
}
|
||||||
@ -407,7 +423,14 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
|||||||
- (void)viewBoundsDidChange:(NSNotification *)notification {
|
- (void)viewBoundsDidChange:(NSNotification *)notification {
|
||||||
NSView *const changed = [notification object];
|
NSView *const changed = [notification object];
|
||||||
if (changed == [[self enclosingScrollView] contentView])
|
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;
|
debug_view_xy pos;
|
||||||
view->set_cursor_visible(true);
|
view->set_cursor_visible(true);
|
||||||
pos = view->cursor_position();
|
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];
|
[self setNeedsDisplay:YES];
|
||||||
return [super becomeFirstResponder];
|
return [super becomeFirstResponder];
|
||||||
}
|
}
|
||||||
@ -475,16 +501,24 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
|||||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
name:NSViewBoundsDidChangeNotification
|
name:NSViewBoundsDidChangeNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
|
name:NSViewFrameDidChangeNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
NSScrollView *const scroller = [self enclosingScrollView];
|
NSScrollView *const scroller = [self enclosingScrollView];
|
||||||
if (scroller != nil)
|
if (scroller != nil)
|
||||||
{
|
{
|
||||||
[scroller setLineScroll:fontHeight];
|
[scroller setLineScroll:fontHeight];
|
||||||
[[scroller contentView] setPostsBoundsChangedNotifications:YES];
|
[[scroller contentView] setPostsBoundsChangedNotifications:YES];
|
||||||
|
[[scroller contentView] setPostsFrameChangedNotifications:YES];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(viewBoundsDidChange:)
|
selector:@selector(viewBoundsDidChange:)
|
||||||
name:NSViewBoundsDidChangeNotification
|
name:NSViewBoundsDidChangeNotification
|
||||||
object:[scroller contentView]];
|
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();
|
debug_view_xy const size = view->visible_size();
|
||||||
|
|
||||||
// work out how much we need to draw
|
// work out how much we need to draw
|
||||||
INT32 position, clip;
|
INT32 row, clip;
|
||||||
[self convertBounds:dirtyRect toFirstAffectedLine:&position count:&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
|
// this gets the text for the whole visible area
|
||||||
debug_view_char const *data = view->viewdata();
|
debug_view_char const *data = view->viewdata();
|
||||||
if (!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data += ((position - origin.y) * size.x);
|
// clear any space above the available content
|
||||||
for (UINT32 row = position; row < position + clip; row++, data += size.x)
|
data += ((row - origin.y) * size.x);
|
||||||
{
|
if (dirtyRect.origin.y < (row * fontHeight))
|
||||||
if ((row < origin.y) || (row >= origin.y + size.y))
|
|
||||||
{
|
{
|
||||||
[DefaultBackground set];
|
[DefaultBackground set];
|
||||||
[NSBezierPath fillRect:NSMakeRect(0,
|
[NSBezierPath fillRect:NSMakeRect(0,
|
||||||
row * fontHeight,
|
dirtyRect.origin.y,
|
||||||
[self bounds].size.width,
|
[self bounds].size.width,
|
||||||
fontHeight)];
|
(row * fontHeight) - dirtyRect.origin.y)];
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
int attr = -1;
|
||||||
NSUInteger start = 0, length = 0;
|
NSUInteger start = 0, length = 0;
|
||||||
for (UINT32 col = origin.x; col < origin.x + size.x; col++)
|
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];
|
inTextContainer:textContainer];
|
||||||
if (start == 0)
|
if (start == 0)
|
||||||
box.origin.x = 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];
|
[[self backgroundForAttribute:attr] set];
|
||||||
[NSBezierPath fillRect:NSMakeRect(box.origin.x,
|
[NSBezierPath fillRect:NSMakeRect(box.origin.x,
|
||||||
row * fontHeight,
|
row * fontHeight,
|
||||||
@ -609,6 +646,16 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
|||||||
atPoint:NSMakePoint(0, row * fontHeight)];
|
atPoint:NSMakePoint(0, row * fontHeight)];
|
||||||
[text deleteCharactersInRange:NSMakeRange(0, length)];
|
[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 += desired.width;
|
||||||
windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
|
windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
|
||||||
windowFrame.size.height += desired.height;
|
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.x = available.origin.x + available.size.width - windowFrame.size.width;
|
||||||
windowFrame.origin.y = available.origin.y;
|
windowFrame.origin.y = available.origin.y;
|
||||||
[window setFrame:windowFrame display:YES];
|
[window setFrame:windowFrame display:YES];
|
||||||
|
@ -77,7 +77,6 @@
|
|||||||
0,
|
0,
|
||||||
contentBounds.size.width,
|
contentBounds.size.width,
|
||||||
expressionFrame.origin.y)];
|
expressionFrame.origin.y)];
|
||||||
[dasmScroll setDrawsBackground:YES];
|
|
||||||
[dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
[dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||||
[dasmScroll setHasHorizontalScroller:YES];
|
[dasmScroll setHasHorizontalScroller:YES];
|
||||||
[dasmScroll setHasVerticalScroller:YES];
|
[dasmScroll setHasVerticalScroller:YES];
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
// create the error log view
|
// create the error log view
|
||||||
logView = [[MAMEErrorLogView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
logView = [[MAMEErrorLogView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||||
logScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
logScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||||
[logScroll setDrawsBackground:YES];
|
|
||||||
[logScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
[logScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||||
[logScroll setHasHorizontalScroller:YES];
|
[logScroll setHasHorizontalScroller:YES];
|
||||||
[logScroll setHasVerticalScroller:YES];
|
[logScroll setHasVerticalScroller:YES];
|
||||||
|
@ -77,7 +77,6 @@
|
|||||||
0,
|
0,
|
||||||
contentBounds.size.width,
|
contentBounds.size.width,
|
||||||
expressionFrame.origin.y)];
|
expressionFrame.origin.y)];
|
||||||
[memoryScroll setDrawsBackground:YES];
|
|
||||||
[memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
[memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||||
[memoryScroll setHasHorizontalScroller:YES];
|
[memoryScroll setHasHorizontalScroller:YES];
|
||||||
[memoryScroll setHasVerticalScroller:YES];
|
[memoryScroll setHasVerticalScroller:YES];
|
||||||
|
@ -65,7 +65,6 @@
|
|||||||
0,
|
0,
|
||||||
contentBounds.size.width,
|
contentBounds.size.width,
|
||||||
contentBounds.size.height - 19)];
|
contentBounds.size.height - 19)];
|
||||||
[breakScroll setDrawsBackground:YES];
|
|
||||||
[breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
[breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||||
[breakScroll setHasHorizontalScroller:YES];
|
[breakScroll setHasHorizontalScroller:YES];
|
||||||
[breakScroll setHasVerticalScroller:YES];
|
[breakScroll setHasVerticalScroller:YES];
|
||||||
@ -84,7 +83,6 @@
|
|||||||
0,
|
0,
|
||||||
contentBounds.size.width,
|
contentBounds.size.width,
|
||||||
contentBounds.size.height - 19)];
|
contentBounds.size.height - 19)];
|
||||||
[watchScroll setDrawsBackground:YES];
|
|
||||||
[watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
[watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||||
[watchScroll setHasHorizontalScroller:YES];
|
[watchScroll setHasHorizontalScroller:YES];
|
||||||
[watchScroll setHasVerticalScroller:YES];
|
[watchScroll setHasVerticalScroller:YES];
|
||||||
|
Loading…
Reference in New Issue
Block a user