Revision: 15970
http://sourceforge.net/p/skim-app/code/15970
Author: hofman
Date: 2026-01-07 16:44:55 +0000 (Wed, 07 Jan 2026)
Log Message:
-----------
Do nothing when there are no custom highlights for page, pass thread safe ivar
we already got
Modified Paths:
--------------
trunk/SKPDFView.m
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2026-01-07 15:29:22 UTC (rev 15969)
+++ trunk/SKPDFView.m 2026-01-07 16:44:55 UTC (rev 15970)
@@ -425,55 +425,56 @@
return NSWidth([self convertRect:NSMakeRect(0.0, 0.0, 1.0, 1.0)
toPage:page]);
}
-- (void)drawSelectionForPage:(PDFPage *)pdfPage
inContext:(CGContextRef)context {
+- (void)drawSelectionRect:(NSRect)rect atIndex:(NSUInteger)pageIndex
forPage:(PDFPage *)pdfPage inContext:(CGContextRef)context {
+ NSRect bounds = [pdfPage boundsForBox:[self displayBox]];
+ CGColorRef color = CGColorCreateGenericGray(0.0, 0.6);
+ rect = CGContextConvertRectToUserSpace(context,
CGRectIntegral(CGContextConvertRectToDeviceSpace(context, rect)));
+ CGContextSetFillColorWithColor(context, color);
+ CGColorRelease(color);
+ CGContextBeginPath(context);
+ CGContextAddRect(context, NSRectToCGRect(bounds));
+ CGContextAddRect(context, NSRectToCGRect(rect));
+ CGContextEOFillPath(context);
+ if ([pdfPage pageIndex] != pageIndex) {
+ color = CGColorCreateGenericGray(0.0, 0.3);
+ CGContextSetFillColorWithColor(context, color);
+ CGColorRelease(color);
+ CGContextFillRect(context, NSRectToCGRect(rect));
+ }
+ SKDrawResizeHandles(context, rect, [self unitWidthOnPage:pdfPage], NO,
[self drawsActiveSelections]);
+}
+
+- (void)drawHighlights:(BOOL)drawAnnotationHighlight forPage:(PDFPage
*)pdfPage toContext:(CGContextRef)context {
+ PDFAnnotation *annotation = nil;
NSRect rect;
NSUInteger pageIndex;
@synchronized (self) {
+ if (drawAnnotationHighlight && [[currentAnnotation page]
isEqual:pdfPage])
+ annotation = currentAnnotation;
pageIndex = selectionPageIndex;
rect = selectionRect;
}
- if (pageIndex != NSNotFound) {
- NSRect bounds = [pdfPage boundsForBox:[self displayBox]];
- CGColorRef color = CGColorCreateGenericGray(0.0, 0.6);
- rect = CGContextConvertRectToUserSpace(context,
CGRectIntegral(CGContextConvertRectToDeviceSpace(context, rect)));
- CGContextSetFillColorWithColor(context, color);
- CGColorRelease(color);
- CGContextBeginPath(context);
- CGContextAddRect(context, NSRectToCGRect(bounds));
- CGContextAddRect(context, NSRectToCGRect(rect));
- CGContextEOFillPath(context);
- if ([pdfPage pageIndex] != pageIndex) {
- color = CGColorCreateGenericGray(0.0, 0.3);
- CGContextSetFillColorWithColor(context, color);
- CGColorRelease(color);
- CGContextFillRect(context, NSRectToCGRect(rect));
- }
- SKDrawResizeHandles(context, rect, [self unitWidthOnPage:pdfPage], NO,
[self drawsActiveSelections]);
- }
-}
-
-- (void)drawPageHighlights:(PDFPage *)pdfPage toContext:(CGContextRef)context {
+ SKReadingBar *aReadingBar = [self readingBar];
+ SKSyncDot *aSyncDot = [self syncDot];
+ if ([[aSyncDot page] isEqual:pdfPage] == NO)
+ aSyncDot = nil;
+
+ if (annotation == nil && pageIndex == NSNotFound && aReadingBar == nil &&
aSyncDot == nil)
+ return;
+
CGContextSaveGState(context);
[pdfPage transformContext:context forBox:[self displayBox]];
- [[self readingBar] drawForPage:pdfPage withBox:[self displayBox]
inContext:context];
+ [aReadingBar drawForPage:pdfPage withBox:[self displayBox]
inContext:context];
- if (atomic_load(&highlightLayerState) != SKLayerUse) {
- PDFAnnotation *annotation = nil;
- @synchronized (self) {
- annotation = currentAnnotation;
- }
-
- if ([[annotation page] isEqual:pdfPage])
- [annotation drawSelectionHighlightWithUnitWidth:[self
unitWidthOnPage:pdfPage] active:[self drawsActiveSelections] inContext:context];
- }
+ if (annotation)
+ [annotation drawSelectionHighlightWithUnitWidth:[self
unitWidthOnPage:pdfPage] active:[self drawsActiveSelections] inContext:context];
- [self drawSelectionForPage:pdfPage inContext:context];
+ if (pageIndex != NSNotFound)
+ [self drawSelectionRect:rect atIndex:pageIndex forPage:pdfPage
inContext:context];
- SKSyncDot *aSyncDot = [self syncDot];
- if ([[aSyncDot page] isEqual:pdfPage])
- [aSyncDot drawInContext:context];
+ [aSyncDot drawInContext:context];
CGContextRestoreGState(context);
}
@@ -481,9 +482,11 @@
- (void)drawPage:(PDFPage *)pdfPage toContext:(CGContextRef)context {
NSInteger state = atomic_load(&highlightLayerState);
if (state == SKLayerAdd) {
+ state = SKLayerUse;
atomic_store(&highlightLayerState, SKLayerUse);
dispatch_async(dispatch_get_main_queue(), ^{ [self
makeHighlightLayerForType:SKLayerTypeNote]; });
} else if (state == SKLayerRemove) {
+ state = SKLayerNone;
atomic_store(&highlightLayerState, SKLayerNone);
dispatch_async(dispatch_get_main_queue(), ^{ [self
removeHighlightLayer]; });
}
@@ -490,7 +493,7 @@
// Let PDFView do most of the hard work.
[super drawPage:pdfPage toContext:context];
- [self drawPageHighlights:pdfPage toContext:context];
+ [self drawHighlights:state != SKLayerUse forPage:pdfPage
toContext:context];
}
- (void)drawLayerControllerInContext:(CGContextRef)context {
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