diff --git a/ChangeLog b/ChangeLog index a577a7b9b..6dc617c9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,16 @@ -Wen Dec 1 11:55:00 1999 Richard Frith-Macdonald +Wed Dec 1 14:55:00 1999 Richard Frith-Macdonald + + * Source/NSImage.m: Caching rewrite - using NSCachedImageRep - works + with xgps, but probably not xdps. There are two global variables to + control this - + 1. NSImageDoesCaching + To turn caching on - when an image is drawn it is cached, if it is + redrawn with the same background color set (excluding transparent) + then the cached version is used. + 2. NSImageForceCaching + To force the cache to be used irrespective of the background color. + +Wed Dec 1 11:55:00 1999 Richard Frith-Macdonald * Source/NSWindow.m: Removed spurious setNeedsDisplay when changing the contentView of a window - it's up to the programmer to do that. @@ -6,7 +18,7 @@ Wen Dec 1 11:55:00 1999 Richard Frith-Macdonald altering the view hierarchy - it's up to the programmer to do a single call at the end of the work. -Wen Dec 1 8:27:00 1999 Richard Frith-Macdonald +Wed Dec 1 8:27:00 1999 Richard Frith-Macdonald Applied and modified/rewrote patch by Jonathan Gapen * Headers/gnustep/gui/NSImage.h: Moved excess BOOL ivar to _flags. diff --git a/Source/NSImage.m b/Source/NSImage.m index 245c29089..745e4eb24 100644 --- a/Source/NSImage.m +++ b/Source/NSImage.m @@ -51,7 +51,8 @@ #include #include -BOOL doesCaching = NO; +BOOL NSImageDoesCaching = NO; /* enable caching */ +BOOL NSImageForceCaching = NO; /* use on missmatch */ // Resource directories static NSString* gnustep_libdir = @GNUSTEP_INSTALL_LIBDIR; @@ -491,8 +492,7 @@ static Class cacheClass = 0; { GSRepData *repd = (GSRepData*)[_reps objectAtIndex: i]; - if (repd->bg != nil - || [repd->rep isKindOfClass: cacheClass] == NO) + if (repd->bg != nil || [repd->rep isKindOfClass: cacheClass] == NO) { valid = YES; break; @@ -580,7 +580,7 @@ static Class cacheClass = 0; repd = repd_for_rep(_reps, [self bestRepresentationForDevice: deviceDesc]); rep = repd->rep; - if (doesCaching == YES) + if (NSImageDoesCaching == YES) { /* * If this is not a cached image rep - create a cache to be used to @@ -800,7 +800,7 @@ static Class cacheClass = 0; [NSException raise: NSInvalidArgumentException format: @"Cannot lock focus on nil rep"]; - if (doesCaching == YES) + if (NSImageDoesCaching == YES) { NSWindow *window; @@ -867,7 +867,7 @@ static Class cacheClass = 0; - (NSImageRep*) cacheForRep: (NSImageRep*)rep onDevice: (NSDictionary*)deviceDescription { - if (doesCaching == YES) + if (NSImageDoesCaching == YES) { NSImageRep *cacheRep = nil; unsigned count = [_reps count]; @@ -875,6 +875,7 @@ static Class cacheClass = 0; if (count > 0) { GSRepData *invalidCache = nil; + GSRepData *partialCache = nil; GSRepData *validCache = nil; GSRepData *reps[count]; unsigned i; @@ -902,24 +903,46 @@ static Class cacheClass = 0; validCache = repd; break; } + else + { + partialCache = repd; + } } } if (validCache != nil) { - /* - * If the image rep has transparencey and we are drawing - * without a background (background is clear) then the - * cache can't really be valid 'cos we might be drawing - * transparency on top of anything. So we invalidate - * the cache by removing the background color information. - */ - if ([rep hasAlpha] && [validCache->bg isEqual: clearColor]) + if (NSImageForceCaching == NO) { - DESTROY(validCache->bg); + /* + * If the image rep has transparencey and we are drawing + * without a background (background is clear) then the + * cache can't really be valid 'cos we might be drawing + * transparency on top of anything. So we invalidate + * the cache by removing the background color information. + */ + if ([rep hasAlpha] && [validCache->bg isEqual: clearColor]) + { + DESTROY(validCache->bg); + } } cacheRep = validCache->rep; } + else if (partialCache != nil) + { + if (NSImageForceCaching == NO) + { + if (invalidCache != nil) + { + partialCache = invalidCache; + } + else + { + DESTROY(validCache->bg); + } + } + cacheRep = partialCache->rep; + } else if (invalidCache != nil) { cacheRep = invalidCache->rep;