Revision: 13508
          http://sourceforge.net/p/skim-app/code/13508
Author:   hofman
Date:     2023-06-25 14:54:02 +0000 (Sun, 25 Jun 2023)
Log Message:
-----------
draw background and border of drag image in cached bitmap rather than extra 
created bitmap image

Modified Paths:
--------------
    trunk/SKLineWell.m

Modified: trunk/SKLineWell.m
===================================================================
--- trunk/SKLineWell.m  2023-06-25 14:25:09 UTC (rev 13507)
+++ trunk/SKLineWell.m  2023-06-25 14:54:02 UTC (rev 13508)
@@ -40,7 +40,6 @@
 #import "SKLineInspector.h"
 #import "NSGraphics_SKExtensions.h"
 #import "NSBezierPath_SKExtensions.h"
-#import "NSImage_SKExtensions.h"
 #import "NSView_SKExtensions.h"
 
 NSString *SKPasteboardTypeLineStyle = 
@"net.sourceforge.skim-app.pasteboard.line-style";
@@ -297,20 +296,23 @@
     imageRep = [self bitmapImageRepCachingDisplayInRect:bounds];
     lwFlags.active = wasActive;
     
-    __block NSImage *image = nil;
-    CGFloat scale = [imageRep pixelsWide] / NSWidth(bounds);
+    NSGraphicsContext *context = [NSGraphicsContext 
graphicsContextWithBitmapImageRep:imageRep];
     
+    [NSGraphicsContext saveGraphicsState];
+    [NSGraphicsContext setCurrentContext:context];
     SKRunWithAppearance(self, ^{
-        image = [NSImage bitmapImageWithSize:bounds.size scale:scale 
drawingHandler:^(NSRect rect){
-            [[NSColor windowBackgroundColor] setFill];
-            [NSBezierPath fillRect:rect];
-            [[[NSColor textColor] colorWithAlphaComponent:0.6] setStroke];
-            [NSBezierPath strokeRect:NSInsetRect(rect, 0.5, 0.5)];
-            rect = NSInsetRect(rect, 1.0, 1.0);
-            [imageRep drawInRect:rect fromRect:rect 
operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:NO 
hints:nil];
-        }];
+        [context setCompositingOperation:NSCompositeDestinationOver];
+        [[NSColor windowBackgroundColor] setFill];
+        [NSBezierPath fillRect:bounds];
+        [context setCompositingOperation:NSCompositeSourceOver];
+        [[[NSColor textColor] colorWithAlphaComponent:0.6] setStroke];
+        [NSBezierPath strokeRect:NSInsetRect(bounds, 0.5, 0.5)];
     });
+    [NSGraphicsContext restoreGraphicsState];
     
+    NSImage *image = [[[NSImage alloc] initWithSize:bounds.size] autorelease];
+    [image addRepresentation:imageRep];
+    
     return image;
 }
 

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to