Previous 199869 Revisions Next

r35202 Sunday 22nd February, 2015 at 10:12:00 UTC by Vasantha Crabb
Slight improvement in Cocoa debug view performance
[src/osd/modules/debugger/osx]debugconsole.m debugview.h debugview.m debugwindowhandler.m disassemblyviewer.m errorlogviewer.m memoryviewer.m pointsviewer.m

trunk/src/osd/modules/debugger/osx/debugconsole.m
r243713r243714
4545   // create the register view
4646   regView = [[MAMERegistersView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
4747   regScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
48   [regScroll setDrawsBackground:YES];
4948   [regScroll setHasHorizontalScroller:YES];
5049   [regScroll setHasVerticalScroller:YES];
5150   [regScroll setAutohidesScrollers:YES];
r243713r243714
5756   dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
5857   [dasmView setExpression:@"curpc"];
5958   dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
60   [dasmScroll setDrawsBackground:YES];
6159   [dasmScroll setHasHorizontalScroller:YES];
6260   [dasmScroll setHasVerticalScroller:YES];
6361   [dasmScroll setAutohidesScrollers:YES];
r243713r243714
6866   // create the console view
6967   consoleView = [[MAMEConsoleView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
7068   consoleScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
71   [consoleScroll setDrawsBackground:YES];
7269   [consoleScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
7370   [consoleScroll setHasHorizontalScroller:YES];
7471   [consoleScroll setHasVerticalScroller:YES];
trunk/src/osd/modules/debugger/osx/debugview.h
r243713r243714
5252- (IBAction)paste:(id)sender;
5353
5454- (void)viewBoundsDidChange:(NSNotification *)notification;
55- (void)viewFrameDidChange:(NSNotification *)notification;
5556
5657- (void)windowDidBecomeKey:(NSNotification *)notification;
5758- (void)windowDidResignKey:(NSNotification *)notification;
trunk/src/osd/modules/debugger/osx/debugview.m
r243713r243714
194194}
195195
196196
197- (void)adjustSizeAndRecomputeVisible {
198   NSSize const clip = [[[self enclosingScrollView] contentView] bounds].size;
199   NSSize const content = NSMakeSize((fontWidth * totalWidth) + (2 * [textContainer lineFragmentPadding]),
200                             fontHeight * totalHeight);
201   [self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))];
202   [self recomputeVisible];
203}
204
205
197206+ (NSFont *)defaultFont {
198207   return [NSFont userFixedPitchFontOfSize:0];
199208}
r243713r243714
245254   BOOL const resized = (newSize.x != totalWidth) || (newSize.y != totalHeight);
246255   if (resized)
247256   {
248      [self setFrameSize:NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
249                             fontHeight * newSize.y)];
257      NSScrollView *const scroller = [self enclosingScrollView];
258      if (scroller)
259      {
260         NSSize const clip = [[scroller contentView] bounds].size;
261         NSSize const content = NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
262                                   fontHeight * newSize.y);
263         [self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))];
264         [self recomputeVisible];
265      }
250266      totalWidth = newSize.x;
251267      totalHeight = newSize.y;
252268   }
r243713r243714
407423- (void)viewBoundsDidChange:(NSNotification *)notification {
408424   NSView *const changed = [notification object];
409425   if (changed == [[self enclosingScrollView] contentView])
410      [self recomputeVisible];
426      [self adjustSizeAndRecomputeVisible];
411427}
412428
413429
430- (void)viewFrameDidChange:(NSNotification *)notification {
431   NSView *const changed = [notification object];
432   if (changed == [[self enclosingScrollView] contentView])
433      [self adjustSizeAndRecomputeVisible];
434}
435
436
414437- (void)windowDidBecomeKey:(NSNotification *)notification {
415438   NSWindow *const win = [notification object];
416439   if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported())
r243713r243714
451474      debug_view_xy pos;
452475      view->set_cursor_visible(true);
453476      pos = view->cursor_position();
454      [self scrollRectToVisible:NSMakeRect((pos.x * fontWidth) + [textContainer lineFragmentPadding], pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics
477      [self scrollRectToVisible:NSMakeRect((pos.x * fontWidth) + [textContainer lineFragmentPadding],
478                                  pos.y * fontHeight,
479                                  fontWidth,
480                                  fontHeight)]; // FIXME: metrics
455481      [self setNeedsDisplay:YES];
456482      return [super becomeFirstResponder];
457483   }
r243713r243714
475501   [[NSNotificationCenter defaultCenter] removeObserver:self
476502                                       name:NSViewBoundsDidChangeNotification
477503                                      object:nil];
504   [[NSNotificationCenter defaultCenter] removeObserver:self
505                                       name:NSViewFrameDidChangeNotification
506                                      object:nil];
478507
479508   NSScrollView *const scroller = [self enclosingScrollView];
480509   if (scroller != nil)
481510   {
482511      [scroller setLineScroll:fontHeight];
483512      [[scroller contentView] setPostsBoundsChangedNotifications:YES];
513      [[scroller contentView] setPostsFrameChangedNotifications:YES];
484514      [[NSNotificationCenter defaultCenter] addObserver:self
485515                                     selector:@selector(viewBoundsDidChange:)
486516                                        name:NSViewBoundsDidChangeNotification
487517                                       object:[scroller contentView]];
518      [[NSNotificationCenter defaultCenter] addObserver:self
519                                     selector:@selector(viewFrameDidChange:)
520                                        name:NSViewFrameDidChangeNotification
521                                       object:[scroller contentView]];
488522   }
489523}
490524
r243713r243714
531565   debug_view_xy const size = view->visible_size();
532566
533567   // work out how much we need to draw
534   INT32 position, clip;
535   [self convertBounds:dirtyRect toFirstAffectedLine:&position count:&clip];
568   INT32 row, clip;
569   [self convertBounds:dirtyRect toFirstAffectedLine:&row count:&clip];
570   clip += row;
571   row = MAX(row, origin.y);
572   clip = MIN(clip, origin.y + size.y);
536573
537574   // this gets the text for the whole visible area
538575   debug_view_char const *data = view->viewdata();
539576   if (!data)
540577      return;
541578
542   data += ((position - origin.y) * size.x);
543   for (UINT32 row = position; row < position + clip; row++, data += size.x)
579   // clear any space above the available content
580   data += ((row - origin.y) * size.x);
581   if (dirtyRect.origin.y < (row * fontHeight))
544582   {
545      if ((row < origin.y) || (row >= origin.y + size.y))
546      {
547         [DefaultBackground set];
548         [NSBezierPath fillRect:NSMakeRect(0,
549                                   row * fontHeight,
550                                   [self bounds].size.width,
551                                   fontHeight)];
552         continue;
553      }
583      [DefaultBackground set];
584      [NSBezierPath fillRect:NSMakeRect(0,
585                                dirtyRect.origin.y,
586                                [self bounds].size.width,
587                                (row * fontHeight) - dirtyRect.origin.y)];
588   }
554589
555      // render entire lines to get character alignment right
590   // render entire lines to get character alignment right
591   for ( ; row < clip; row++, data += size.x)
592   {
556593      int         attr = -1;
557594      NSUInteger   start = 0, length = 0;
558595      for (UINT32 col = origin.x; col < origin.x + size.x; col++)
r243713r243714
599636                                   inTextContainer:textContainer];
600637      if (start == 0)
601638         box.origin.x = 0;
602      box.size.width = [self bounds].size.width - box.origin.x;
639      box.size.width = MAX([self bounds].size.width - box.origin.x, 0);
603640      [[self backgroundForAttribute:attr] set];
604641      [NSBezierPath fillRect:NSMakeRect(box.origin.x,
605642                                row * fontHeight,
r243713r243714
609646                              atPoint:NSMakePoint(0, row * fontHeight)];
610647      [text deleteCharactersInRange:NSMakeRange(0, length)];
611648   }
649
650   // clear any space below the available content
651   if ((dirtyRect.origin.y + dirtyRect.size.height) > (row * fontHeight))
652   {
653      [DefaultBackground set];
654      [NSBezierPath fillRect:NSMakeRect(0,
655                                row * fontHeight,
656                                [self bounds].size.width,
657                                (dirtyRect.origin.y + dirtyRect.size.height) - (row * fontHeight))];
658   }
612659}
613660
614661
trunk/src/osd/modules/debugger/osx/debugwindowhandler.m
r243713r243714
326326   windowFrame.size.width += desired.width;
327327   windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
328328   windowFrame.size.height += desired.height;
329   windowFrame.size.height = MIN(MIN(windowFrame.size.height, 320), available.size.height);
329   windowFrame.size.height = MIN(MIN(MAX(windowFrame.size.height, 120), 320), available.size.height);
330330   windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
331331   windowFrame.origin.y = available.origin.y;
332332   [window setFrame:windowFrame display:YES];
trunk/src/osd/modules/debugger/osx/disassemblyviewer.m
r243713r243714
7777                                                0,
7878                                                contentBounds.size.width,
7979                                                expressionFrame.origin.y)];
80   [dasmScroll setDrawsBackground:YES];
8180   [dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
8281   [dasmScroll setHasHorizontalScroller:YES];
8382   [dasmScroll setHasVerticalScroller:YES];
trunk/src/osd/modules/debugger/osx/errorlogviewer.m
r243713r243714
2929   // create the error log view
3030   logView = [[MAMEErrorLogView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
3131   logScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
32   [logScroll setDrawsBackground:YES];
3332   [logScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
3433   [logScroll setHasHorizontalScroller:YES];
3534   [logScroll setHasVerticalScroller:YES];
trunk/src/osd/modules/debugger/osx/memoryviewer.m
r243713r243714
7777                                                  0,
7878                                                  contentBounds.size.width,
7979                                                  expressionFrame.origin.y)];
80   [memoryScroll setDrawsBackground:YES];
8180   [memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
8281   [memoryScroll setHasHorizontalScroller:YES];
8382   [memoryScroll setHasVerticalScroller:YES];
trunk/src/osd/modules/debugger/osx/pointsviewer.m
r243713r243714
6565                                                 0,
6666                                                 contentBounds.size.width,
6767                                                 contentBounds.size.height - 19)];
68   [breakScroll setDrawsBackground:YES];
6968   [breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
7069   [breakScroll setHasHorizontalScroller:YES];
7170   [breakScroll setHasVerticalScroller:YES];
r243713r243714
8483                                                 0,
8584                                                 contentBounds.size.width,
8685                                                 contentBounds.size.height - 19)];
87   [watchScroll setDrawsBackground:YES];
8886   [watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
8987   [watchScroll setHasHorizontalScroller:YES];
9088   [watchScroll setHasVerticalScroller:YES];


Previous 199869 Revisions Next


© 1997-2024 The MAME Team