Revision: 25426
http://sourceforge.net/p/bibdesk/svn/25426
Author: hofman
Date: 2021-01-17 22:45:44 +0000 (Sun, 17 Jan 2021)
Log Message:
-----------
create document description table and releasable icons split set lazily, thread
safe because they are accessed behind locks
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m 2021-01-17
22:34:17 UTC (rev 25425)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m 2021-01-17
22:45:44 UTC (rev 25426)
@@ -62,29 +62,13 @@
FVINITIALIZE(FVPDFIcon);
pthread_mutex_init(&_releaseLock, NULL);
-
- unsigned char split = [_FVMappedDataProvider maxProviderCount] / 2 - 1;
- _releaseableIcons = [[_FVSplitSet allocWithZone:[self zone]]
initWithSplit:split];
-
pthread_mutex_init(&_descriptionLock, NULL);
- _documentDescriptions = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSOwnedPointerMapValueCallBacks, 0);
const CGSize layerSize = { 1, 1 };
CGContextRef context =
[FVWindowGraphicsContextWithSize(NSSizeFromCGSize(layerSize)) graphicsPort];
_pageLayer = CGLayerCreateWithContext(context, layerSize, NULL);
context = CGLayerGetContext(_pageLayer);
- CGColorRef color = NULL;
- if (NULL != kCGColorWhite && NULL != &CGColorGetConstantColor) {
- color = CGColorRetain(CGColorGetConstantColor(kCGColorWhite));
- }
- else {
- CGFloat components[4] = { 1, 1 };
- CGColorSpaceRef cspace =
CGColorSpaceCreateWithName(kCGColorSpaceGenericGray);
- color = CGColorCreate(cspace, components);
- CGColorSpaceRelease(cspace);
- }
- CGContextSetFillColorWithColor(context, color);
- CGColorRelease(color);
+ CGContextSetFillColorWithColor(context,
CGColorGetConstantColor(kCGColorWhite));
CGRect pageRect = CGRectZero;
pageRect.size = CGLayerGetSize(_pageLayer);
CGContextClipToRect(context, pageRect);
@@ -101,6 +85,10 @@
+ (void)_addIconForMappedRelease:(FVPDFIcon *)anIcon;
{
pthread_mutex_lock(&_releaseLock);
+ if (_releaseableIcons == nil) {
+ unsigned char split = [_FVMappedDataProvider maxProviderCount] / 2 - 1;
+ _releaseableIcons = [[_FVSplitSet allocWithZone:[self zone]]
initWithSplit:split];
+ }
[_releaseableIcons addObject:anIcon];
NSSet *oldObjects = nil;
// ??? is the second condition really required?
@@ -202,7 +190,8 @@
{
[FVCGImageCache invalidateCachesForKey:_cacheKey];
pthread_mutex_lock(&_descriptionLock);
- NSMapRemove(_documentDescriptions, _cacheKey);
+ if (_documentDescriptions)
+ NSMapRemove(_documentDescriptions, _cacheKey);
pthread_mutex_unlock(&_descriptionLock);
[self lock];
CGImageRelease(_thumbnail);
@@ -348,8 +337,10 @@
if (NULL != _thumbnail) {
_thumbnailSize = FVCGImageSize(_thumbnail);
// retain since there's a possible race here if another thread
inserts a description (although multiple instances shouldn't be rendering for
the same cache key)
+ _FVDocumentDescription *desc = NULL;
pthread_mutex_lock(&_descriptionLock);
- _FVDocumentDescription *desc = (_FVDocumentDescription
*)NSMapGet(_documentDescriptions, _cacheKey);
+ if (_documentDescriptions)
+ desc = (_FVDocumentDescription
*)NSMapGet(_documentDescriptions, _cacheKey);
pthread_mutex_unlock(&_descriptionLock);
if (desc) {
_pageCount = desc->_pageCount ?: 1;
@@ -400,6 +391,8 @@
desc->_pageCount = _isLocked ? 0 : _pageCount;
desc->_fullSize = _fullSize;
pthread_mutex_lock(&_descriptionLock);
+ if (nil == _documentDescriptions)
+ _documentDescriptions =
NSCreateMapTable(NSObjectMapKeyCallBacks, NSOwnedPointerMapValueCallBacks, 0);
NSMapInsert(_documentDescriptions, _cacheKey, desc);
pthread_mutex_unlock(&_descriptionLock);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit