Changeset 924


Ignore:
Timestamp:
Sep 25, 2006, 9:20:08 PM (15 years ago)
Author:
livings124
Message:

Use setNeedsDisplay rather than resetting the image on each refresh.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PiecesView.h

    r923 r924  
    1414    int8_t  * fPieces;
    1515   
    16     NSImage * fExistingImage, * fBack, * fWhitePiece, * fGreenPiece,
     16    NSImage * fBack, * fWhitePiece, * fGreenPiece,
    1717            * fBlue1Piece, * fBlue2Piece, * fBlue3Piece;
    1818   
  • trunk/PiecesView.m

    r923 r924  
    4949        [fBlue3Piece setScalesWhenResized: YES];
    5050        [fBlue3Piece setSize: size];
    51        
    52         fExistingImage = [fBack copy];
    5351    }
    5452   
     
    6260    if (fTorrent)
    6361        [fTorrent release];
    64     [fExistingImage release];
    6562    [super dealloc];
    6663}
     
    7572        {
    7673            fTorrent = nil;
    77             [fImageView setImage: fBack];
     74            [fImageView setImage: [[fBack copy] autorelease]];
    7875        }
    7976    }
     
    9693            fAcross = MAX_ACROSS;
    9794       
    98         fWidth = ([fExistingImage size].width - (fAcross + 1) * BETWEEN) / fAcross;
    99         fExtraBorder = ([fExistingImage size].width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
     95        fWidth = ([[fImageView image] size].width - (fAcross + 1) * BETWEEN) / fAcross;
     96        fExtraBorder = ([[fImageView image] size].width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
    10097       
    10198        [self updateView: YES];
     
    109106   
    110107    if (first)
    111     {
    112         [fExistingImage release];
    113         fExistingImage = [fBack copy];
    114     }
     108        [fImageView setImage: [[fBack copy] autorelease]];
     109   
     110    NSImage * image = [fImageView image];
    115111   
    116112    int8_t * pieces = malloc(fNumPieces);
     
    179175                if (!change)
    180176                {
    181                     [fExistingImage lockFocus];
     177                    [image lockFocus];
    182178                    change = YES;
    183179                }
    184180               
    185181                point = NSMakePoint(j * (fWidth + BETWEEN) + BETWEEN + fExtraBorder,
    186                                     [fExistingImage size].width - (i + 1) * (fWidth + BETWEEN) - fExtraBorder);
     182                                    [[fImageView image] size].width - (i + 1) * (fWidth + BETWEEN) - fExtraBorder);
    187183               
    188184                [pieceImage compositeToPoint: point fromRect: rect operation: NSCompositeSourceOver];
     
    192188    if (change)
    193189    {
    194         [fExistingImage unlockFocus];
    195        
    196         [fImageView setImage: nil];
    197         [fImageView setImage: fExistingImage];
     190        [image unlockFocus];
     191        [fImageView setNeedsDisplay];
    198192    }
    199193   
Note: See TracChangeset for help on using the changeset viewer.