Revision: 25376 http://sourceforge.net/p/bibdesk/svn/25376 Author: hofman Date: 2021-01-12 22:41:04 +0000 (Tue, 12 Jan 2021) Log Message: ----------- Rename method and add to comment
Modified Paths: -------------- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFinderIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.h trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/Notes Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -3018,7 +3018,7 @@ NSSize size = [self respondsToSelector:@selector(convertSizeToBacking:)] ? [self convertSizeToBacking:_iconSize] : _iconSize; // render immediately so the placeholder path doesn't draw if ([anIcon needsRenderForSize:size]) - [anIcon renderOffscreenForSize:size]; + [anIcon renderForSize:size]; [self _setNeedsDisplayForIconInRow:r column:c]; } } Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFinderIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFinderIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFinderIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -114,7 +114,7 @@ return NO; } -- (void)renderOffscreenForSize:(NSSize)size +- (void)renderForSize:(NSSize)size { // no-op } Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.h =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.h 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.h 2021-01-12 22:41:04 UTC (rev 25376) @@ -43,7 +43,7 @@ FVIcon is a class cluster. You should typically never receive an instance of FVIcon from its initializer, but will instead get an instance of a concrete subclass that correctly handles a given URL scheme or file type. - The iconWithURL: factory method is designed to be cheap, in that it does no rendering, should will require very little memory or disk access just for initialization. Only after calling renderOffscreenForSize: will memory usage increase substantially, as data is cached and bitmaps created. Icons that won't be displayed for some time (scrolled out of sight) should be sent a releaseResources message by the view in order to free up (some) of the cached data. Subsequent calls to renderOffscreenForSize: should be substantially less expensive, since data will be read from the disk cache. + The iconWithURL: factory method is designed to be cheap, in that it does no rendering, should will require very little memory or disk access just for initialization. Only after calling renderForSize: will memory usage increase substantially, as data is cached and bitmaps created. Icons that won't be displayed for some time (scrolled out of sight) should be sent a releaseResources message by the view in order to free up (some) of the cached data. Subsequent calls to renderForSize: should be substantially less expensive, since data will be read from the disk cache. This class is thread safe, but it is not reentrant. You can abuse it to create deadlocks. Don't do that. */ @interface FVIcon : FVObject @@ -54,9 +54,9 @@ This is typically the most expensive call for an FVIcon subclass. In general it should be called from a dedicated thread after needsRenderForSize: has been called, unless you're planning to draw synchronously. This is required for correct drawing, since a placeholder will typically be drawn if the bitmap is not available. - @param size The desired icon size in pixels. Subclasses are free to ignore this. + @param size The desired icon size in pixels. Should be the same as the argument of needsRenderForSize:. */ -- (void)renderOffscreenForSize:(NSSize)size; +- (void)renderForSize:(NSSize)size; /** Primitive drawing method. @@ -67,8 +67,8 @@ \li \c any changes to the CGContextRef are wrapped by CGContextSaveGState/CGContextRestoreGState \li \c specific compositing operations should be set in the context before calling this method \li \c shadow will be respected (the clip path is only changed when rendering text) - \li \c needsRenderForSize: and renderOffscreenForSize: must be called first, to check/set size - \li \c a placeholder icon will be drawn if renderOffscreenForSize: has not been called or finished working + \li \c needsRenderForSize: and renderForSize: must be called first, to check/set size + \li \c a placeholder icon will be drawn if renderForSize: has not been called or finished working @param dstRect Destination rect for drawing in the passed-in context's coordinate space. @param context CGContext for drawing content. */ @@ -88,9 +88,9 @@ @return NO if releaseResources will be a no-op or otherwise is not possible. */ - (BOOL)canReleaseResources; -/** Determine if renderOffscreenForSize: is required. +/** Determine if renderForSize: is required. - Clients (i.e. FileView) calls this in order to see if renderOffscreenForSize: should be called. If it returns YES, this method sets the desired size in the case of Finder icons, and the caller should then send renderOffscreenForSize:. By the same token, if this returns NO, don't waste time on renderOffscreenForSize:. + Clients (i.e. FileView) calls this in order to see if renderForSize: should be called. If it returns YES, this method sets the desired size in the case of Finder icons, and the caller should then send renderForSize:. By the same token, if this returns NO, don't waste time on renderForSize:. @param size The desired icon size in pixels. Subclasses are free to ignore this. @return NO if the icon already has a cached version for this size. */ @@ -105,7 +105,7 @@ /** Purge bitmap caches. - Optional override. Get rid of any cached representations; next time the icon is redrawn, its data will be recreated in renderOffscreenForSize:. */ + Optional override. Get rid of any cached representations; next time the icon is redrawn, its data will be recreated in renderForSize:. */ - (void)recache; @end @@ -124,22 +124,22 @@ /** Increments the internal page index. - This does not redisplay the icon; needsRenderForSize: and renderOffscreenForSize: must be called to redraw. */ + This does not redisplay the icon; needsRenderForSize: and renderForSize: must be called to redraw. */ - (void)showNextPage; /** Decrements the internal page index. - This does not redisplay the icon; needsRenderForSize: and renderOffscreenForSize: must be called to redraw. */ + This does not redisplay the icon; needsRenderForSize: and renderForSize: must be called to redraw. */ - (void)showPreviousPage; /** Set the internal page index to 1. - This does not redisplay the icon; needsRenderForSize: and renderOffscreenForSize: must be called to redraw. */ + This does not redisplay the icon; needsRenderForSize: and renderForSize: must be called to redraw. */ - (void)showFirstPage; /** Set the internal page index to the last page. - This does not redisplay the icon; needsRenderForSize: and renderOffscreenForSize: must be called to redraw. */ + This does not redisplay the icon; needsRenderForSize: and renderForSize: must be called to redraw. */ - (void)showLastPage; @end Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -80,7 +80,7 @@ // these methods are all required - (void)drawInRect:(NSRect)dstRect ofContext:(CGContextRef)context { [self doesNotRecognizeSelector:_cmd]; } -- (void)renderOffscreenForSize:(NSSize)size { [self doesNotRecognizeSelector:_cmd]; } +- (void)renderForSize:(NSSize)size { [self doesNotRecognizeSelector:_cmd]; } @end Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconOperation.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -129,7 +129,7 @@ { if (NO == [self isCancelled]) { NSAutoreleasePool *pool = [NSAutoreleasePool new]; - [_icon renderOffscreenForSize:_desiredSize]; + [_icon renderForSize:_desiredSize]; FVIconUpdateOperation *op = [[FVIconUpdateOperation alloc] initWithIcon:_icon view:_view]; [[FVOperationQueue mainQueue] addOperation:op]; [op release]; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -140,7 +140,7 @@ return (CFDataRef)[[NSData allocWithZone:FVDefaultZone()] initWithContentsOfURL:_fileURL options:NSUncachedRead error:NULL]; } -- (void)renderOffscreenForSize:(NSSize)size +- (void)renderForSize:(NSSize)size { [[self class] _startRenderingForKey:_cacheKey]; @@ -149,11 +149,11 @@ if ([NSThread instancesRespondToSelector:@selector(setName:)] && pthread_main_np() == 0) [[NSThread currentThread] setName:[_fileURL path]]; - [_fallbackIcon renderOffscreenForSize:size]; + [_fallbackIcon renderForSize:size]; // !!! early returns here after a cache check if (NULL != _fullImage && NULL != _thumbnail) { - // may be non-NULL if we were added to the FVOperationQueue multiple times before renderOffscreenForSize: was actually called + // may be non-NULL if we were added to the FVOperationQueue multiple times before renderForSize: was actually called [self unlock]; [[self class] _stopRenderingForKey:_cacheKey]; return; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -90,7 +90,7 @@ - (void)lock { /* do nothing */ } - (void)unlock { /* do nothing */ } -- (void)renderOffscreenForSize:(NSSize)size { /* no-op */ } +- (void)renderForSize:(NSSize)size { /* no-op */ } - (NSSize)size { return FVDefaultThumbnailSize(); } Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -309,7 +309,7 @@ CGContextDrawLayerInRect(ctxt, lockRect, layer); } -- (void)renderOffscreenForSize:(NSSize)size +- (void)renderForSize:(NSSize)size { [[self class] _startRenderingForKey:_cacheKey]; // hold the lock while initializing these variables, so we don't waste time trying to render again, since we may be returning YES from needsRender @@ -320,7 +320,7 @@ // only the first page is cached to disk; ignore this branch if we should be drawing a later page or if the size has changed - // handle the case where multiple render tasks were pushed into the queue before renderOffscreenForSize: was called + // handle the case where multiple render tasks were pushed into the queue before renderForSize: was called if ((NULL != _thumbnail || NULL != _pdfDoc) && 1 == _currentPage) { BOOL exitEarly; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -155,7 +155,7 @@ return needsRender; } -- (void)renderOffscreenForSize:(NSSize)size +- (void)renderForSize:(NSSize)size { [self lock]; @@ -196,7 +196,7 @@ // preceding calls may have set the failure flag if (_quickLookFailed) { if ([_fallbackIcon needsRenderForSize:size]) - [_fallbackIcon renderOffscreenForSize:size]; + [_fallbackIcon renderForSize:size]; } [self unlock]; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVScaledImageView.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -153,7 +153,7 @@ CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort]; NSSize size = [self respondsToSelector:@selector(convertSizeToBacking:)] ? [self convertSizeToBacking:aRect.size] : aRect.size; if ([_icon needsRenderForSize:size]) - [_icon renderOffscreenForSize:size]; + [_icon renderForSize:size]; aRect = NSInsetRect([self bounds], 25, 25); NSRect iconRect = aRect; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -345,7 +345,7 @@ return image; } -- (void)renderOffscreenForSize:(NSSize)size +- (void)renderForSize:(NSSize)size { [[self class] _startRenderingForKey:_cacheKey]; @@ -358,7 +358,7 @@ // !!! two early returns here after a cache check if (NULL != _fullImage) { - // note that _fullImage may be non-NULL if we were added to the FVOperationQueue multiple times before renderOffscreenForSize: was called + // note that _fullImage may be non-NULL if we were added to the FVOperationQueue multiple times before renderForSize: was called [self unlock]; [[self class] _stopRenderingForKey:_cacheKey]; return; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m 2021-01-12 22:41:04 UTC (rev 25376) @@ -284,7 +284,7 @@ // currently a noop [_fallbackIcon releaseResources]; - // reset condition so -renderOffscreenForSize: will complete if it's called again + // reset condition so -renderForSize: will complete if it's called again [_condLock unlockWithCondition:IDLE]; } @@ -352,7 +352,7 @@ // condition should always be LOADING, but -releaseResources may have the lock if ([_condLock tryLockWhenCondition:LOADING]) { - // return to -renderOffscreenForSize: to handle the failure + // return to -renderForSize: to handle the failure [_condLock unlockWithCondition:LOADED]; } } @@ -425,7 +425,7 @@ [self _releaseWebView]; [_condLock unlockWithCondition:LOADED]; - // return to -renderOffscreenForSize: for scaling and caching + // return to -renderForSize: for scaling and caching } } @@ -556,7 +556,7 @@ return [NSString stringWithFormat:@"%@: { \n\tURL = %@\n\tWebView = %@\n\tFull image = %@\n\tThumbnail = %@\n }", [self description], _httpURL, _webView, _fullImage, _thumbnail]; } -- (void)renderOffscreenForSize:(NSSize)size +- (void)renderForSize:(NSSize)size { [[self class] _startRenderingForKey:_cacheKey]; @@ -567,7 +567,7 @@ // check the disk cache first - // note that _fullImage may be non-NULL if we were added to the FVOperationQueue multiple times before renderOffscreenForSize: was called + // note that _fullImage may be non-NULL if we were added to the FVOperationQueue multiple times before renderForSize: was called if (NULL == _fullImage && FVShouldDrawFullImageWithThumbnailSize(size, [self _thumbnailSize])) _fullImage = [FVCGImageCache newImageForKey:_cacheKey]; @@ -579,7 +579,7 @@ if (NULL == _thumbnail && NULL == _fullImage) { - // make sure needsRenderForSize: knows that we're actively rendering, so renderOffscreenForSize: doesn't get called again + // make sure needsRenderForSize: knows that we're actively rendering, so renderForSize: doesn't get called again [_condLock unlockWithCondition:LOADING]; [self performSelectorOnMainThread:@selector(_startWebView) withObject:nil waitUntilDone:NO modes:[NSArray arrayWithObject:(id)kCFRunLoopCommonModes]]; [_condLock lockWhenCondition:LOADED]; Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/Notes =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/Notes 2021-01-12 22:33:11 UTC (rev 25375) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/Notes 2021-01-12 22:41:04 UTC (rev 25376) @@ -14,4 +14,4 @@ Page-based FVIcon instances (PDF/PS/text) may use an on-disk cache (FVIconCache) for storing rendered CGImageRef data for fast reinitialization of large bitmaps. This was a big performance win, especially for PDF files, where the bitmap data may be 14 MB of ARGB data. These are never removed, so the cache can grow without bound. Up to 500 PDF files, cache sizes are under 20 MB with the zlib compression I'm using, so I'm not too concerned about it. -FVIcon is designed to be thread safe, and still fairly lightweight. Most drawing to offscreen bitmap contexts should be performed asynchronously in a thread, since rendering in the offscreen bitmap context will block. If you need synchronous rendering, call the renderOffscreenForSize: method, wait until it's done, then draw the icon. Some classes will draw a blank "page" while working in the thread; non page-based types don't do this. The FVIconQueue handles all of this transparently, using a single thread shared amongst all FileView instances in an application. +FVIcon is designed to be thread safe, and still fairly lightweight. Most drawing to offscreen bitmap contexts should be performed asynchronously in a thread, since rendering in the offscreen bitmap context will block. If you need synchronous rendering, call the renderForSize: method, wait until it's done, then draw the icon. Some classes will draw a blank "page" while working in the thread; non page-based types don't do this. The FVIconQueue handles all of this transparently, using a single thread shared amongst all FileView instances in an application. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit