Ticket #1669: 0001-instrumentation-for-TERM_XTRA_FRESH.patch

File 0001-instrumentation-for-TERM_XTRA_FRESH.patch, 2.5 KB (added by mtadd, 7 years ago)
  • src/main-cocoa.m

    From f5d49e280f4b622d2484b6312937d96a87f69586 Mon Sep 17 00:00:00 2001
    From: Matthew Tadd <matt.tadd@gmail.com>
    Date: Thu, 16 Aug 2012 23:22:31 -0400
    Subject: [PATCH] instrumentation for TERM_XTRA_FRESH
    
    ---
     src/main-cocoa.m | 23 ++++++++++++++++++++++-
     1 file changed, 22 insertions(+), 1 deletion(-)
    
    diff --git a/src/main-cocoa.m b/src/main-cocoa.m
    index 8380176..be5680d 100644
    a b  
    3636/* Mac headers */ 
    3737#include <Cocoa/Cocoa.h> 
    3838#include <Carbon/Carbon.h> // For keycodes 
    39  
     39#include <sys/time.h> 
    4040/* We know how to double-buffer either into a CGLayer or a CGImage.  Currently CGLayers are a lot faster, probably because NSImage thrashes between a CGImageRef and a bitmap context. */ 
    4141#ifndef BUFFER_WITH_CGLAYER 
    4242# define BUFFER_WITH_CGLAYER 1 
    static NSFont *default_font; 
    208208 
    209209/* Display (flush) our Angband views */ 
    210210- (void)displayIfNeeded; 
     211- (BOOL)needsDisplay; 
    211212 
    212213/* Called from the view to indicate that it is starting or ending live resize */ 
    213214- (void)viewWillStartLiveResize:(AngbandView *)view; 
    static int compare_advances(const void *ap, const void *bp) 
    607608/* If we're trying to limit ourselves to a certain number of frames per second, then compute how long it's been since we last drew, and then wait until the next frame has passed. */ 
    608609- (void)throttle 
    609610{ 
     611        return; 
    610612    if (frames_per_second > 0) 
    611613    { 
    612614        CFAbsoluteTime now = CFAbsoluteTimeGetCurrent(); 
    static NSMenuItem *superitem(NSMenuItem *self) 
    11311133    [[self activeView] displayIfNeeded]; 
    11321134} 
    11331135 
     1136- (BOOL)needsDisplay 
     1137{ 
     1138        [[self activeView] needsDisplay]; 
     1139} 
     1140 
    11341141@end 
    11351142 
    11361143 
    static errr Term_xtra_cocoa_react(void) 
    14901497 */ 
    14911498static errr Term_xtra_cocoa(int n, int v) 
    14921499{ 
     1500        static counter = 0; 
    14931501    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    14941502    AngbandContext* angbandContext = Term->data; 
    14951503     
    static errr Term_xtra_cocoa(int n, int v) 
    15961604             
    15971605        case TERM_XTRA_FRESH: 
    15981606        { 
     1607                        struct timeval time; 
     1608                        char szTitle[100]; 
     1609                        gettimeofday(&time, NULL); 
     1610                        int needs_display = [angbandContext needsDisplay] == YES ? 1: 0; 
     1611                         
     1612                [[[angbandContext makePrimaryWindow] title] getFileSystemRepresentation:szTitle maxLength:sizeof szTitle]; 
     1613                        printf("%d %d %d.%d %x %s TIME_XTRA_FRESH\n",  
     1614                                        counter++, 
     1615                                    needs_display,       
     1616                                        time.tv_sec %1000, time.tv_usec / 1000, 
     1617                                        angbandContext, 
     1618                                        szTitle 
     1619                                        ); 
    15991620            [angbandContext displayIfNeeded]; 
    16001621            break; 
    16011622        }