mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 14:50:38 +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
|
@ -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…
Add table
Add a link
Reference in a new issue