Changeset 6129


Ignore:
Timestamp:
Jun 10, 2008, 9:46:34 PM (13 years ago)
Author:
livings124
Message:

only lock focus and redraw the pieces view if it has been updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PiecesView.m

    r6128 r6129  
    129129    }
    130130   
     131    NSImage * image = [self image];
     132   
    131133    int i, j, index = -1;
    132134    NSRect rect = NSMakeRect(0, 0, fWidth, fWidth);
    133    
    134     NSImage * image = [self image];
    135     [image lockFocus];
     135    BOOL change = NO;
    136136   
    137137    for (i = 0; i < fAcross; i++)
     
    190190            if (pieceColor)
    191191            {
     192                //avoid unneeded memory usage by only locking focus if drawing will occur
     193                if (!change)
     194                {
     195                    change = YES;
     196                    [image lockFocus];
     197                }
     198               
    192199                rect.origin = NSMakePoint(j * (fWidth + BETWEEN) + BETWEEN + fExtraBorder,
    193200                                        [image size].width - (i + 1) * (fWidth + BETWEEN) - fExtraBorder);
     
    198205        }
    199206   
    200     [image unlockFocus];
    201     [self setNeedsDisplay];
     207    if (change)
     208    {
     209        [image unlockFocus];
     210        [self setNeedsDisplay];
     211    }
    202212   
    203213    tr_free(pieces);
Note: See TracChangeset for help on using the changeset viewer.