Revision: 14644
http://sourceforge.net/p/skim-app/code/14644
Author: hofman
Date: 2024-11-05 16:56:56 +0000 (Tue, 05 Nov 2024)
Log Message:
-----------
No need to separate method to draw pdfview content to a context
Modified Paths:
--------------
trunk/SKBasePDFView.h
trunk/SKBasePDFView.m
trunk/SKSnapshotWindowController.m
Modified: trunk/SKBasePDFView.h
===================================================================
--- trunk/SKBasePDFView.h 2024-11-05 15:48:22 UTC (rev 14643)
+++ trunk/SKBasePDFView.h 2024-11-05 16:56:56 UTC (rev 14644)
@@ -46,8 +46,6 @@
- (void)colorFiltersDidChange;
-- (void)drawPagesInRect:(NSRect)rect toContext:(CGContextRef)context;
-
- (void)scrollToDestination:(SKDestination)destination;
@end
Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m 2024-11-05 15:48:22 UTC (rev 14643)
+++ trunk/SKBasePDFView.m 2024-11-05 16:56:56 UTC (rev 14644)
@@ -376,33 +376,4 @@
}
}
-- (void)drawPagesInRect:(NSRect)rect toContext:(CGContextRef)context {
- PDFDisplayBox *box = [self displayBox];
- CGFloat scale = [self scaleFactor];
- CGContextSetInterpolationQuality(context, [self interpolationQuality] + 1);
- for (PDFPage *page in [self visiblePages]) {
- NSRect pageRect = [self convertRect:[page boundsForBox:box]
fromPage:page];
- if (NSIntersectsRect(pageRect, rect) == NO) continue;
- CGContextSetFillColorWithColor(context,
CGColorGetConstantColor(kCGColorWhite));
- CGContextFillRect(context,
SKPixelAlignedRect(NSRectToCGRect(pageRect), context));
- CGContextSaveGState(context);
- CGContextTranslateCTM(context, NSMinX(pageRect), NSMinY(pageRect));
- CGContextScaleCTM(context, scale, scale);
- [page drawWithBox:box toContext:context];
- CGContextRestoreGState(context);
- }
-}
-
-- (NSBitmapImageRep *)bitmapImageRepCachingDisplay {
- // draw our own bitmap, because macOS 12 does it wrong
- // ignore background and page shadows because
- NSRect rect = [self bounds];
- NSBitmapImageRep *imageRep = [self
bitmapImageRepForCachingDisplayInRect:rect];
- CGContextRef context = [[NSGraphicsContext
graphicsContextWithBitmapImageRep:imageRep] CGContext];
- if (NSEqualPoints(rect.origin, NSZeroPoint) == NO)
- CGContextTranslateCTM(context, -NSMinX(rect), -NSMinY(rect));
- [self drawPagesInRect:rect toContext:context];
- return imageRep;
-}
-
@end
Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m 2024-11-05 15:48:22 UTC (rev 14643)
+++ trunk/SKSnapshotWindowController.m 2024-11-05 16:56:56 UTC (rev 14644)
@@ -570,10 +570,10 @@
bounds.origin = NSZeroPoint;
NSImage *image = [[NSImage alloc] initWithSize:bounds.size];
NSBitmapImageRep *imageRep = [[[[self window] contentView] superview]
bitmapImageRepForCachingDisplayInRect:bounds];
- NSGraphicsContext *context = [NSGraphicsContext
graphicsContextWithBitmapImageRep:imageRep];
+ NSGraphicsContext *nsContext = [NSGraphicsContext
graphicsContextWithBitmapImageRep:imageRep];
[NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:context];
+ [NSGraphicsContext setCurrentContext:nsContext];
[[NSBezierPath bezierPathWithRoundedRect:bounds xRadius:10.0 yRadius:10.0]
addClip];
[[NSColor whiteColor] set];
@@ -580,8 +580,24 @@
NSRectFill(rect);
[[NSBezierPath bezierPathWithRect:rect] addClip];
- [pdfView drawPagesInRect:bounds toContext:[context CGContext]];
+ CGContextRef context = [nsContext CGContext];
+ PDFDisplayBox *box = [pdfView displayBox];
+ CGFloat scale = [pdfView scaleFactor];
+
+ CGContextSetInterpolationQuality(context, [pdfView interpolationQuality] +
1);
+ for (PDFPage *page in [pdfView visiblePages]) {
+ NSRect pageRect = [pdfView convertRect:[page boundsForBox:box]
fromPage:page];
+ if (NSIntersectsRect(pageRect, bounds) == NO) continue;
+ CGContextSetFillColorWithColor(context,
CGColorGetConstantColor(kCGColorWhite));
+ CGContextFillRect(context,
SKPixelAlignedRect(NSRectToCGRect(pageRect), context));
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, NSMinX(pageRect), NSMinY(pageRect));
+ CGContextScaleCTM(context, scale, scale);
+ [page drawWithBox:box toContext:context];
+ CGContextRestoreGState(context);
+ }
+
[NSGraphicsContext restoreGraphicsState];
[image addRepresentation:imageRep];
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