Revision: 5191
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5191&view=rev
Author:   hofman
Date:     2009-02-02 18:41:23 +0000 (Mon, 02 Feb 2009)

Log Message:
-----------
remove unused code for image drawing improvements

Modified Paths:
--------------
    trunk/NSImage_SKExtensions.h
    trunk/NSImage_SKExtensions.m
    trunk/SKTextWithIconCell.m

Modified: trunk/NSImage_SKExtensions.h
===================================================================
--- trunk/NSImage_SKExtensions.h        2009-02-02 10:03:13 UTC (rev 5190)
+++ trunk/NSImage_SKExtensions.h        2009-02-02 18:41:23 UTC (rev 5191)
@@ -145,6 +145,4 @@
 - (void)drawMirroredAndFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect 
operation:(NSCompositingOperation)op fraction:(float)delta;
 - (void)drawMirroredAndFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect 
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op 
fraction:(float)delta;
 
-- (NSBitmapImageRep *)bestImageRepForSize:(NSSize)preferredSize 
device:(NSDictionary *)deviceDescription;
-
 @end

Modified: trunk/NSImage_SKExtensions.m
===================================================================
--- trunk/NSImage_SKExtensions.m        2009-02-02 10:03:13 UTC (rev 5190)
+++ trunk/NSImage_SKExtensions.m        2009-02-02 18:41:23 UTC (rev 5191)
@@ -2034,39 +2034,4 @@
         [self drawMirroredInRect:dstRect fromRect:srcRect operation:op 
fraction:delta];
 }
 
-static NSComparisonResult compareImageRepWidths(NSBitmapImageRep *r1, 
NSBitmapImageRep *r2, void *ctxt)
-{
-    NSSize s1 = [r1 size];
-    NSSize s2 = [r2 size];
-    if (NSEqualSizes(s1, s2))
-        return NSOrderedSame;
-    return s1.width > s2.width ? NSOrderedDescending : NSOrderedAscending;
-}
-
-- (NSBitmapImageRep *)bestImageRepForSize:(NSSize)preferredSize 
device:(NSDictionary *)deviceDescription {
-    // We need to get the correct color space, or we can end up with a mask 
image in some cases
-    NSString *preferredColorSpaceName = [[self 
bestRepresentationForDevice:deviceDescription] colorSpaceName];
-
-    // sort the image reps by increasing width, so we can easily pick the next 
largest one
-    NSMutableArray *reps = [[self representations] mutableCopy];
-    [reps sortUsingFunction:compareImageRepWidths context:NULL];
-    unsigned i, iMax = [reps count];
-    NSBitmapImageRep *toReturn = nil;
-    
-    for (i = 0; i < iMax && nil == toReturn; i++) {
-        NSBitmapImageRep *rep = [reps objectAtIndex:i];
-        BOOL hasPreferredColorSpace = [[rep colorSpaceName] 
isEqualToString:preferredColorSpaceName];
-        NSSize size = [rep size];
-        
-        if (hasPreferredColorSpace) {
-            if (NSEqualSizes(size, preferredSize))
-                toReturn = rep;
-            else if (size.width > preferredSize.width)
-                toReturn = rep;
-        }
-    }
-    [reps release];
-    return toReturn;    
-}
-
 @end

Modified: trunk/SKTextWithIconCell.m
===================================================================
--- trunk/SKTextWithIconCell.m  2009-02-02 10:03:13 UTC (rev 5190)
+++ trunk/SKTextWithIconCell.m  2009-02-02 18:41:23 UTC (rev 5191)
@@ -100,59 +100,21 @@
         srcRect.size = [img size];
         
         NSRect drawFrame = iconRect;
+        float ratio = MIN(NSWidth(drawFrame) / srcRect.size.width, 
NSHeight(drawFrame) / srcRect.size.height);
+        drawFrame.size.width = ratio * srcRect.size.width;
+        drawFrame.size.height = ratio * srcRect.size.height;
         
-        // NSImage will use the largest rep if it doesn't find an exact size 
match; we can improve on that by choosing the next larger one with respect to 
our drawing rect, and scaling it down.
-        NSBitmapImageRep *rep = [img bestImageRepForSize:drawFrame.size 
device:nil];
+        drawFrame = SKCenterRect(drawFrame, drawFrame.size, [controlView 
isFlipped]);
         
-        // draw the image rep directly to avoid creating a new NSImage and 
adding the rep to it
-        if (0 && rep) {
-            
-            srcRect.size = [rep size];
-            float ratio = fminf(NSWidth(drawFrame) / srcRect.size.width, 
NSHeight(drawFrame) / srcRect.size.height);
-            drawFrame.size.width = ratio * srcRect.size.width;
-            drawFrame.size.height = ratio * srcRect.size.height;
-            
-            drawFrame = SKCenterRect(drawFrame, drawFrame.size, [controlView 
isFlipped]);
-            
-            CGContextRef context = [[NSGraphicsContext currentContext] 
graphicsPort];
-            CGContextSaveGState(context);
-            CGContextClipToRect(context, *(CGRect *)&drawFrame);
-            CGContextSetAllowsAntialiasing(context, true);
-            CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
-            
-            // draw into a new layer so we preserve the background of the 
tableview
-            CGContextBeginTransparencyLayer(context, NULL);
-            
-            if ([controlView isFlipped]) {
-                CGContextTranslateCTM(context, 0, NSMaxY(drawFrame));
-                CGContextScaleCTM(context, 1, -1);
-                drawFrame.origin.y = 0;
-                [rep drawInRect:drawFrame];
-            } else {
-                [rep drawInRect:drawFrame];
-            }
-            
-            CGContextEndTransparencyLayer(context);
-            CGContextRestoreGState(context);
-            
-        } else {
-            
-            float ratio = MIN(NSWidth(drawFrame) / srcRect.size.width, 
NSHeight(drawFrame) / srcRect.size.height);
-            drawFrame.size.width = ratio * srcRect.size.width;
-            drawFrame.size.height = ratio * srcRect.size.height;
-            
-            drawFrame = SKCenterRect(drawFrame, drawFrame.size, [controlView 
isFlipped]);
-            
-            NSGraphicsContext *ctxt = [NSGraphicsContext currentContext];
-            [ctxt saveGraphicsState];
-            
-            // this is the critical part that NSImageCell doesn't do
-            [ctxt setImageInterpolation:NSImageInterpolationHigh];
-            
-            [img drawFlipped:[controlView isFlipped] inRect:drawFrame 
fromRect:srcRect operation:NSCompositeSourceOver fraction:1.0];
-            
-            [ctxt restoreGraphicsState];
-        }
+        NSGraphicsContext *ctxt = [NSGraphicsContext currentContext];
+        [ctxt saveGraphicsState];
+        
+        // this is the critical part that NSImageCell doesn't do
+        [ctxt setImageInterpolation:NSImageInterpolationHigh];
+        
+        [img drawFlipped:[controlView isFlipped] inRect:drawFrame 
fromRect:srcRect operation:NSCompositeSourceOver fraction:1.0];
+        
+        [ctxt restoreGraphicsState];
     }
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to