Revision: 14320
http://sourceforge.net/p/skim-app/code/14320
Author: hofman
Date: 2024-06-10 14:52:18 +0000 (Mon, 10 Jun 2024)
Log Message:
-----------
Update thumbnails and snapshots for changes on low priority queue, so initial
generation is handled first. Draw snapshot thumbnails on background queue when
the snapshot table is not visible.
Modified Paths:
--------------
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKThumbnail.h
trunk/SKThumbnail.m
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2024-06-08 22:34:40 UTC (rev 14319)
+++ trunk/SKMainWindowController.h 2024-06-10 14:52:18 UTC (rev 14320)
@@ -314,7 +314,7 @@
- (void)allThumbnailsNeedUpdate;
- (void)resetSnapshotSizeIfNeeded;
-- (void)snapshotNeedsUpdate:(SKSnapshotWindowController *)dirstySnapshot;
+- (void)snapshotNeedsUpdate:(SKSnapshotWindowController *)dirstySnapshot
placeholder:(BOOL)isPlaceholder;
- (void)allSnapshotsNeedUpdate;
- (void)setPdfDocument:(nullable PDFDocument *)pdfDocument
addAnnotationsFromDictionaries:(nullable NSArray<NSDictionary<NSString *, id>
*> *)noteDicts;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2024-06-08 22:34:40 UTC (rev 14319)
+++ trunk/SKMainWindowController.m 2024-06-10 14:52:18 UTC (rev 14320)
@@ -2112,7 +2112,7 @@
NSUInteger idx = [page pageIndex];
for (SKSnapshotWindowController *wc in snapshots) {
if ([wc isPageVisible:page]) {
- [self snapshotNeedsUpdate:wc];
+ [self snapshotNeedsUpdate:wc placeholder:NO];
[wc redisplay];
}
}
@@ -2180,7 +2180,7 @@
[self updateThumbnailAtPageIndex:[page pageIndex]];
for (SKSnapshotWindowController *wc in snapshots) {
if ([wc isPageVisible:page])
- [self snapshotNeedsUpdate:wc];
+ [self snapshotNeedsUpdate:wc placeholder:NO];
}
[secondaryPdfView setNeedsDisplayForAddedAnnotation:annotation
onPage:page];
}
@@ -2220,7 +2220,7 @@
[self updateThumbnailAtPageIndex:[page pageIndex]];
for (SKSnapshotWindowController *wc in snapshots) {
if ([wc isPageVisible:page])
- [self snapshotNeedsUpdate:wc];
+ [self snapshotNeedsUpdate:wc placeholder:NO];
}
[secondaryPdfView setNeedsDisplayForRemovedAnnotation:annotation
onPage:page];
}
@@ -2242,7 +2242,7 @@
[self updateThumbnailAtPageIndex:[newPage pageIndex]];
for (SKSnapshotWindowController *wc in snapshots) {
if ([wc isPageVisible:oldPage] || [wc isPageVisible:newPage])
- [self snapshotNeedsUpdate:wc];
+ [self snapshotNeedsUpdate:wc placeholder:NO];
}
[secondaryPdfView setNeedsDisplayForRemovedAnnotation:annotation
onPage:oldPage];
[secondaryPdfView setNeedsDisplayForAddedAnnotation:annotation
onPage:newPage];
@@ -2338,7 +2338,7 @@
[controller setThumbnail:image];
if (needsUpdate)
- [self snapshotNeedsUpdate:controller];
+ [self snapshotNeedsUpdate:controller placeholder:YES];
if (openType == SKSnapshotOpenFromSetup) {
[self insertObject:controller inSnapshotsAtIndex:[snapshots count]];
@@ -2380,7 +2380,7 @@
- (void)snapshotControllerDidChange:(SKSnapshotWindowController *)controller {
if (controller != presentationPreview) {
- [self snapshotNeedsUpdate:controller];
+ [self snapshotNeedsUpdate:controller placeholder:NO];
[rightSideController.snapshotArrayController rearrangeObjects];
[rightSideController.snapshotTableView reloadData];
[self setRecentInfoNeedsUpdate:YES];
@@ -2682,7 +2682,7 @@
for (SKSnapshotWindowController *wc in snapshots) {
if ([wc isPageVisible:[note page]]) {
- [self snapshotNeedsUpdate:wc];
+ [self snapshotNeedsUpdate:wc placeholder:NO];
[wc setNeedsDisplayForAnnotation:note onPage:page];
if (NSIsEmptyRect(oldRect) == NO)
[wc setNeedsDisplayInRect:oldRect ofPage:page];
@@ -2828,7 +2828,7 @@
return thumbnailQueue;
}
-+ (dispatch_queue_t)lowPriorityThumbnailQueue {
++ (dispatch_queue_t)utilityThumbnailQueue {
static dispatch_queue_t thumbnailQueue = nil;
if (thumbnailQueue == nil) {
dispatch_queue_attr_t queuePriority =
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT,
QOS_CLASS_UTILITY, 0);
@@ -2837,6 +2837,15 @@
return thumbnailQueue;
}
++ (dispatch_queue_t)backgroundThumbnailQueue {
+ static dispatch_queue_t thumbnailQueue = nil;
+ if (thumbnailQueue == nil) {
+ dispatch_queue_attr_t queuePriority =
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT,
QOS_CLASS_BACKGROUND, 0);
+ thumbnailQueue =
dispatch_queue_create("net.sourceforge.skim-app.skim.queue.thumbnails",
queuePriority);
+ }
+ return thumbnailQueue;
+}
+
- (PDFPage *)pageForThumbnail:(SKThumbnail *)thumbnail {
return [[pdfView document] pageAtIndex:[thumbnail pageIndex]];
}
@@ -2849,11 +2858,12 @@
NSArray *highlights = page && [[[pdfView readingBar] page] isEqual:page] ?
@[[pdfView readingBar]] : nil;
PDFDisplayBox box = [pdfView displayBox];
CGFloat scale = [[self window] backingScaleFactor];
+ dispatch_queue_t queue = [thumbnail isPlaceholder] ? [[self class]
thumbnailQueue] : [[self class] utilityThumbnailQueue];
if ([self interactionMode] == SKPresentationMode &&
mwcFlags.thumbnailsNeedUpdateAfterPresentaton == 0 && fabs([mainWindow
backingScaleFactor] - scale) > 0.0)
mwcFlags.thumbnailsNeedUpdateAfterPresentaton = 1;
- dispatch_async([[self class] thumbnailQueue], ^{
+ dispatch_async(queue, ^{
NSImage *image = [page thumbnailWithSize:thumbnailCacheSize
scale:scale forBox:box hasShadow:YES highlights:highlights];
[image setAccessibilityDescription:[NSString
stringWithFormat:NSLocalizedString(@"Page %@", @""), [page displayLabel]]];
@@ -3028,16 +3038,18 @@
}
}
-- (void)snapshotNeedsUpdate:(SKSnapshotWindowController *)controller {
+- (void)snapshotNeedsUpdate:(SKSnapshotWindowController *)controller
placeholder:(BOOL)isPlaceholder {
CGFloat backingScale = [[self window] backingScaleFactor];
SKSnapshotConfiguration *configuration = [controller currentConfiguration];
NSDate *date = [NSDate date];
dispatch_queue_t queue;
- if ([rightSideController.snapshotTableView window])
+ if ([rightSideController.snapshotTableView window] == nil)
+ queue = [[self class] backgroundThumbnailQueue];
+ else if (isPlaceholder)
queue = [[self class] thumbnailQueue];
else
- queue = [[self class] lowPriorityThumbnailQueue];
+ queue = [[self class] utilityThumbnailQueue];
dispatch_async(queue, ^{
@@ -3067,7 +3079,7 @@
- (void)allSnapshotsNeedUpdate {
for (SKSnapshotWindowController *controller in [self snapshots])
- [self snapshotNeedsUpdate:controller];
+ [self snapshotNeedsUpdate:controller placeholder:NO];
}
Modified: trunk/SKThumbnail.h
===================================================================
--- trunk/SKThumbnail.h 2024-06-08 22:34:40 UTC (rev 14319)
+++ trunk/SKThumbnail.h 2024-06-10 14:52:18 UTC (rev 14320)
@@ -49,6 +49,7 @@
NSString *label;
NSUInteger pageIndex;
BOOL needsUpdate;
+ BOOL placeholder;
__weak id <SKThumbnailDelegate> delegate;
}
@@ -58,6 +59,7 @@
@property (nonatomic, readonly) NSUInteger pageIndex;
@property (nonatomic, readonly) NSSize size;
@property (nonatomic, nullable, readonly) PDFPage *page;
+@property (nonatomic, readonly, getter=isPlaceholder) BOOL placeholder;
- (instancetype)initWithImage:(NSImage *)anImage label:(NSString *)aLabel
pageIndex:(NSUInteger)anIndex;
Modified: trunk/SKThumbnail.m
===================================================================
--- trunk/SKThumbnail.m 2024-06-08 22:34:40 UTC (rev 14319)
+++ trunk/SKThumbnail.m 2024-06-10 14:52:18 UTC (rev 14320)
@@ -41,7 +41,7 @@
@implementation SKThumbnail
-@synthesize delegate, image, label, pageIndex;
+@synthesize delegate, image, label, pageIndex, placeholder;
@dynamic size, page;
- (instancetype)initWithImage:(NSImage *)anImage label:(NSString *)aLabel
pageIndex:(NSUInteger)anIndex {
@@ -51,6 +51,7 @@
label = aLabel;
pageIndex = anIndex;
needsUpdate = YES;
+ placeholder = YES;
}
return self;
}
@@ -61,6 +62,11 @@
return image;
}
+- (void)setImage:(NSImage *)newImage {
+ image = newImage;
+ placeholder = NO;
+}
+
- (NSSize)size {
return [image size];
}
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