mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 13:30:55 +00:00
Image caching stuff
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5346 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
804630d3ae
commit
218c203684
2 changed files with 52 additions and 17 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,4 +1,16 @@
|
|||
Wen Dec 1 11:55:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Wed Dec 1 14:55:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* 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 <richard@brainstorm.co.uk>
|
||||
|
||||
* 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 <richard@brainstorm.co.uk>
|
|||
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 <richard@brainstorm.co.uk>
|
||||
Wed Dec 1 8:27:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
Applied and modified/rewrote patch by Jonathan Gapen
|
||||
* Headers/gnustep/gui/NSImage.h: Moved excess BOOL ivar to _flags.
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
#include <AppKit/NSScreen.h>
|
||||
#include <AppKit/NSColor.h>
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue