Revision: 15224
http://sourceforge.net/p/skim-app/code/15224
Author: hofman
Date: 2025-05-17 15:25:02 +0000 (Sat, 17 May 2025)
Log Message:
-----------
redisplay quickly when resolution changes
Modified Paths:
--------------
trunk/SKPresentationView.m
Modified: trunk/SKPresentationView.m
===================================================================
--- trunk/SKPresentationView.m 2025-05-16 21:31:28 UTC (rev 15223)
+++ trunk/SKPresentationView.m 2025-05-17 15:25:02 UTC (rev 15224)
@@ -81,6 +81,7 @@
@interface SKPDFPageView ()
- (void)displayCurrentPage:(void (^)(void))completionHandler;
+- (void)redisplayAtCurrentScaleFactorIfNeeded;
@end
@implementation SKPDFPageView
@@ -146,6 +147,7 @@
CGFloat scale = [[self window] backingScaleFactor];
if (fabs([pageLayer contentsScale] - scale) > 0.0) {
[pageLayer setContentsScale:scale];
+ [self redisplayAtCurrentScaleFactorIfNeeded];
[self removePredrawnImageAtIndex:NSNotFound];
[self displayCurrentPage:nil];
}
@@ -380,6 +382,24 @@
}
+- (void)redisplayAtCurrentScaleFactorIfNeeded {
+ CALayerContentsGravity gravity = [pageLayer contentsGravity];
+ if (gravity != kCAGravityResize && gravity != kCAGravityResizeAspect &&
gravity != kCAGravityResizeAspectFill) {
+ NSImage *image = [pageLayer contents];
+ if ([image isKindOfClass:[NSImage class]]) {
+ NSRect bounds = [self bounds];
+ NSBitmapImageRep *imageRep = [self
bitmapImageRepForCachingDisplayInRect:bounds];
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithBitmapImageRep:imageRep]];
+ [image drawInRect:bounds];
+ [NSGraphicsContext restoreGraphicsState];
+ image = [[NSImage alloc] initWithSize:bounds.size];
+ [image removeRepresentation:[[image representations] firstObject]];
+ [pageLayer setContents:image];
+ }
+ }
+}
+
- (NSBitmapImageRep *)bitmapImageRepCachingDisplay {
NSImage *image = [pageLayer contents];
if ([image isKindOfClass:[NSImage class]]) {
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