Revision: 12982
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12982&view=rev
Author:   hofman
Date:     2008-03-06 04:37:57 -0800 (Thu, 06 Mar 2008)

Log Message:
-----------
Add a code path using the old icon queue, activated by #defining 
USE_ICON_QUEUE. Mostly for testing purposes.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m        2008-03-06 
09:09:14 UTC (rev 12981)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m        2008-03-06 
12:37:57 UTC (rev 12982)
@@ -54,6 +54,7 @@
 #import "FVColorMenuView.h"
 #import "FVBitmapContextCache.h"
 
+
 static NSString *FVWeblocFilePboardType = @"CorePasteboardFlavorType 
0x75726C20";
 
 static const NSSize DEFAULT_ICON_SIZE = { 64, 64 };
@@ -212,7 +213,10 @@
     _activeDownloads = CFDictionaryCreateMutable(alloc, 0, 
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
     _progressTimer = NULL;
     
+#ifdef USE_ICON_QUEUE
+#else
     _operationQueue = [FVOperationQueue new];
+#endif
 }
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)context
@@ -258,8 +262,11 @@
     // takes care of the timer as well
     [self _cancelActiveDownloads];
     CFRelease(_activeDownloads);
-    //[_operationQueue terminate];
-    //[_operationQueue release];
+#ifdef USE_ICON_QUEUE
+#else
+    [_operationQueue terminate];
+    [_operationQueue release];
+#endif
     CGLayerRelease(_selectionOverlay);
     [super dealloc];
 }
@@ -368,8 +375,10 @@
     
     // make sure these get cleaned up; if the datasource is now nil, we're 
probably going to deallocate soon
     [self _cancelActiveDownloads];
+#ifdef USE_ICON_QUEUE
+#else
     [_operationQueue cancel];
-    
+#endif
     _padding = [self _paddingForScale:[self iconScale]];
     
     [self _registerForDraggedTypes];
@@ -656,7 +665,10 @@
     if (nil == newSuperview) {
         [self removeObserver:self forKeyPath:@"selectionIndexes"];
         [[NSNotificationCenter defaultCenter] removeObserver:self 
name:FVWebIconUpdatedNotificationName object:nil];
+#ifdef USE_ICON_QUEUE
+#else
         [_operationQueue cancel];
+#endif
         
         // break a retain cycle; binding is retaining this view
         [[_sliderWindow slider] unbind:@"value"];
@@ -912,9 +924,11 @@
     _isRescaling = NO;
 }
 
-// @@ OperationQueue: change this to enable the operation queue
 - (void)_enqueueReleaseOperationForIcons:(NSArray *)icons;
 {    
+#ifdef USE_ICON_QUEUE
+    [[FVIconQueue sharedQueue] enqueueReleaseResourcesForIcons:icons];
+#else
     NSUInteger i, iMax = [icons count];
     NSMutableArray *operations = [[NSMutableArray alloc] 
initWithCapacity:iMax];
     FVIcon *icon;
@@ -930,11 +944,15 @@
     if ([operations count])
         [_operationQueue addOperations:operations];
     [operations release];
+#endif
 }
 
-// @@ OperationQueue: change this to enable the operation queue
 - (void)_enqueueRenderOperationForIcons:(NSArray *)icons 
withPriority:(FVOperationQueuePriority)priority;
 {    
+#ifdef USE_ICON_QUEUE
+    if ([icons count])
+        [[FVIconQueue sharedQueue] enqueueRenderIcons:icons forObject:self];
+#else
     NSUInteger i, iMax = [icons count];
     NSMutableArray *operations = [[NSMutableArray alloc] 
initWithCapacity:iMax];
     FVIcon *icon;
@@ -950,10 +968,14 @@
     if ([operations count])
         [_operationQueue addOperations:operations];
     [operations release];
+#endif
 }
 
-// @@ OperationQueue: change this to enable the operation queue
+#ifdef USE_ICON_QUEUE
+- (void)iconQueueUpdated:(NSArray *)updatedIcons;
+#else
 - (void)iconUpdated:(FVIcon *)updatedIcon;
+#endif
 {
     // Only iterate icons in the visible range, since we know the overall 
geometry
     NSRange rowRange, columnRange;
@@ -974,7 +996,11 @@
     for (i = iMin; i < iMax; i++) {
         
         FVIcon *anIcon = (id)CFDictionaryGetValue(_iconIndexMap, (const void 
*)i);
+#ifdef USE_ICON_QUEUE
+        if ([updatedIcons containsObject:anIcon]) {
+#else
         if (anIcon == updatedIcon) {
+#endif
             NSUInteger r, c;
             if ([self _getGridRow:&r column:&c ofIndex:i])
                 [self _setNeedsDisplayForIconInRow:r column:c];
@@ -982,47 +1008,6 @@
     }
 }
 
-/*
-// @@ OperationQueue: change this to enable the operation queue
-- (void)_updateThreadQueue:(NSArray *)icons;
-{    
-    if ([icons count])
-        [[FVIconQueue sharedQueue] enqueueRenderIcons:icons forObject:self];
-}
-
-// @@ OperationQueue: change this to enable the operation queue
-- (void)iconQueueUpdated:(NSArray *)updatedIcons;
-{
-    // Only iterate icons in the visible range, since we know the overall 
geometry
-    NSRange rowRange, columnRange;
-    [self _getRangeOfRows:&rowRange columns:&columnRange inRect:[self 
visibleRect]];
-    
-    NSUInteger iMin, iMax = [self numberOfIcons];
-    
-    // _indexForGridRow:column: returns NSNotFound if we're in a short row 
(empty column)
-    iMin = [self _indexForGridRow:rowRange.location 
column:columnRange.location];
-    if (NSNotFound == iMin)
-        iMin = [self numberOfIcons];
-    else
-        iMax = MIN([self numberOfIcons], iMin + rowRange.length * [self 
numberOfColumns]);
-    
-    NSUInteger i;
-    NSSet *updatedIconSet = [[NSSet alloc] initWithArray:updatedIcons];
-    
-    // If an icon isn't visible, there's no need to redisplay anything.  
Similarly, if 20 icons are displayed and only 5 updated, there's no need to 
redraw all 20.  Geometry calculations are much faster than redrawing, in 
general.
-    for (i = iMin; i < iMax; i++) {
-        
-        FVIcon *anIcon = (id)CFDictionaryGetValue(_iconIndexMap, (const void 
*)i);
-        if ([updatedIconSet containsObject:anIcon]) {
-            NSUInteger r, c;
-            if ([self _getGridRow:&r column:&c ofIndex:i])
-                [self _setNeedsDisplayForIconInRow:r column:c];
-        }
-    }
-    [updatedIconSet release];
-}
-*/
-
 // drawRect: uses -releaseResources on icons that aren't visible but present 
in the datasource, so we just need a way to cull icons that are cached but not 
currently in the datasource
 - (void)_zombieTimerFired:(CFRunLoopTimerRef)timer
 {
@@ -1050,8 +1035,11 @@
 
 - (void)_handleWebIconNotification:(NSNotification *)aNote
 {
-    //[self iconQueueUpdated:[NSArray arrayWithObject:[aNote object]]];
+#ifdef USE_ICON_QUEUE
+    [self iconQueueUpdated:[NSArray arrayWithObject:[aNote object]]];
+#else
     [self iconUpdated:[aNote object]];
+#endif
 }
 
 #pragma mark Drawing
@@ -1294,8 +1282,6 @@
     // this isn't obvious from the method name; it all takes place in a single 
op to avoid locking twice
     
     // enqueue visible icons with high priority
-    //[self _updateThreadQueue:[self iconsAtIndexes:visibleIndexes]];
-    // @@ OperationQueue: change this to enable the operation queue
     [self _enqueueRenderOperationForIcons:[self iconsAtIndexes:visibleIndexes] 
withPriority:FVOperationQueuePriorityHigh];
     
     // Call this only for icons that we're not going to display "soon."  The 
problem with this approach is that if you only have a single icon displayed at 
a time (say in a master-detail view), FVIcon cache resources will continue to 
be used up since each one is cached and then never touched again (if it doesn't 
show up in this loop, that is).  We handle this by using a timer that culls 
icons which are no longer present in the datasource.  I suppose this is only a 
symptom of the larger problem of a view maintaining a cache of model 
objects...but expecting a client to be aware of our caching strategy and icon 
management is a bit much.  
@@ -1323,8 +1309,6 @@
         }
 
         if ([unusedIndexes count]) {
-            //[[FVIconQueue sharedQueue] enqueueReleaseResourcesForIcons:[self 
iconsAtIndexes:unusedIndexes]];
-            // @@ OperationQueue: change this to enable the operation queue
             [self _enqueueReleaseOperationForIcons:[self 
iconsAtIndexes:unusedIndexes]];
         }
         


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to