mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:10:48 +00:00
Some debug stuff added and some minor optimisation done.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5361 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cc38e74b05
commit
2dce1c2233
1 changed files with 31 additions and 28 deletions
|
@ -51,8 +51,8 @@
|
||||||
#include <AppKit/NSScreen.h>
|
#include <AppKit/NSScreen.h>
|
||||||
#include <AppKit/NSColor.h>
|
#include <AppKit/NSColor.h>
|
||||||
|
|
||||||
BOOL NSImageDoesCaching = NO; /* enable caching */
|
BOOL NSImageDoesCaching = YES; /* enable caching */
|
||||||
BOOL NSImageForceCaching = NO; /* use on missmatch */
|
BOOL NSImageForceCaching = YES; /* use on missmatch */
|
||||||
|
|
||||||
// Resource directories
|
// Resource directories
|
||||||
static NSString* gnustep_libdir = @GNUSTEP_INSTALL_LIBDIR;
|
static NSString* gnustep_libdir = @GNUSTEP_INSTALL_LIBDIR;
|
||||||
|
@ -108,18 +108,19 @@ NSArray *iterate_reps_for_types(NSArray *imageReps, SEL method);
|
||||||
GSRepData*
|
GSRepData*
|
||||||
repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
||||||
{
|
{
|
||||||
unsigned i, count;
|
NSEnumerator *enumerator = [_reps objectEnumerator];
|
||||||
|
IMP nextImp = [enumerator methodForSelector: @selector(nextObject)];
|
||||||
GSRepData *repd;
|
GSRepData *repd;
|
||||||
|
|
||||||
count = [_reps count];
|
while ((repd = (*nextImp)(enumerator, @selector(nextObject))) != nil)
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
repd = [_reps objectAtIndex: i];
|
|
||||||
if (repd->rep == rep)
|
if (repd->rep == rep)
|
||||||
return repd;
|
{
|
||||||
|
return repd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Cannot find stored representation"];
|
format: @"Cannot find stored representation"];
|
||||||
/* NOT REACHED */
|
/* NOT REACHED */
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -286,6 +287,7 @@ static Class cacheClass = 0;
|
||||||
}
|
}
|
||||||
_flags.colorMatchPreferred = YES;
|
_flags.colorMatchPreferred = YES;
|
||||||
_flags.multipleResolutionMatching = YES;
|
_flags.multipleResolutionMatching = YES;
|
||||||
|
_color = RETAIN(clearColor);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -528,13 +530,15 @@ static Class cacheClass = 0;
|
||||||
|
|
||||||
- (void) setBackgroundColor: (NSColor *)aColor
|
- (void) setBackgroundColor: (NSColor *)aColor
|
||||||
{
|
{
|
||||||
|
if (aColor == nil)
|
||||||
|
{
|
||||||
|
aColor = clearColor;
|
||||||
|
}
|
||||||
ASSIGN(_color, aColor);
|
ASSIGN(_color, aColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor *) backgroundColor
|
- (NSColor *) backgroundColor
|
||||||
{
|
{
|
||||||
if (_color == nil)
|
|
||||||
_color = RETAIN(clearColor);
|
|
||||||
return _color;
|
return _color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,17 +582,16 @@ static Class cacheClass = 0;
|
||||||
repd = repd_for_rep(_reps, [self bestRepresentationForDevice: deviceDesc]);
|
repd = repd_for_rep(_reps, [self bestRepresentationForDevice: deviceDesc]);
|
||||||
rep = repd->rep;
|
rep = repd->rep;
|
||||||
|
|
||||||
|
NSDebugLLog(@"NSImage", @"Getting image rep %d", (int)rep);
|
||||||
if (NSImageDoesCaching == YES)
|
if (NSImageDoesCaching == YES)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If this is not a cached image rep - create a cache to be used to
|
* If this is not a cached image rep - create a cache to be used to
|
||||||
* render the image rep into, and switch to the cached rep.
|
* render the image rep into, and switch to the cached rep.
|
||||||
*/
|
*/
|
||||||
if ([rep isKindOfClass: cacheClass] == NO)
|
rep = [self cacheForRep: rep onDevice: deviceDesc];
|
||||||
{
|
repd = repd_for_rep(_reps, rep);
|
||||||
rep = [self cacheForRep: rep onDevice: deviceDesc];
|
NSDebugLLog(@"NSImage", @"Cached image rep is %d", (int)rep);
|
||||||
repd = repd_for_rep(_reps, rep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the cache is not valid, it's background color will not exist
|
* if the cache is not valid, it's background color will not exist
|
||||||
|
@ -609,7 +612,14 @@ static Class cacheClass = 0;
|
||||||
[self drawRepresentation: repd->original
|
[self drawRepresentation: repd->original
|
||||||
inRect: NSMakeRect(0, 0, _size.width, _size.height)];
|
inRect: NSMakeRect(0, 0, _size.width, _size.height)];
|
||||||
[self unlockFocus];
|
[self unlockFocus];
|
||||||
repd->bg = _color ? [_color copy] : [clearColor copy];
|
if (_color == nil)
|
||||||
|
{
|
||||||
|
repd->bg = [clearColor copy];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
repd->bg = [_color copy];
|
||||||
|
}
|
||||||
if ([repd->bg alphaComponent] == 1.0)
|
if ([repd->bg alphaComponent] == 1.0)
|
||||||
{
|
{
|
||||||
[rep setOpaque: YES];
|
[rep setOpaque: YES];
|
||||||
|
@ -618,6 +628,7 @@ static Class cacheClass = 0;
|
||||||
{
|
{
|
||||||
[rep setOpaque: [repd->original isOpaque]];
|
[rep setOpaque: [repd->original isOpaque]];
|
||||||
}
|
}
|
||||||
|
NSDebugLLog(@"NSImage", @"Rendered rep %d", (int)rep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,10 +803,7 @@ static Class cacheClass = 0;
|
||||||
|
|
||||||
if (!(rep = [self bestRepresentationForDevice: nil]))
|
if (!(rep = [self bestRepresentationForDevice: nil]))
|
||||||
{
|
{
|
||||||
if ([rep isKindOfClass: cacheClass] == NO)
|
rep = [self cacheForRep: rep onDevice: nil];
|
||||||
{
|
|
||||||
rep = [self cacheForRep: rep onDevice: nil];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[self lockFocusOnRepresentation: rep];
|
[self lockFocusOnRepresentation: rep];
|
||||||
}
|
}
|
||||||
|
@ -810,10 +818,7 @@ static Class cacheClass = 0;
|
||||||
{
|
{
|
||||||
NSWindow *window;
|
NSWindow *window;
|
||||||
|
|
||||||
if ([imageRep isKindOfClass: cacheClass] == NO)
|
imageRep = [self cacheForRep: imageRep onDevice: nil];
|
||||||
{
|
|
||||||
imageRep = [self cacheForRep: imageRep onDevice: nil];
|
|
||||||
}
|
|
||||||
window = [(NSCachedImageRep *)imageRep window];
|
window = [(NSCachedImageRep *)imageRep window];
|
||||||
_lockedView = [window contentView];
|
_lockedView = [window contentView];
|
||||||
[_lockedView lockFocus];
|
[_lockedView lockFocus];
|
||||||
|
@ -928,7 +933,6 @@ static Class cacheClass = 0;
|
||||||
if ([validCache->bg alphaComponent] != 1.0)
|
if ([validCache->bg alphaComponent] != 1.0)
|
||||||
{
|
{
|
||||||
DESTROY(validCache->bg);
|
DESTROY(validCache->bg);
|
||||||
[validCache->rep setOpaque: YES];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cacheRep = validCache->rep;
|
cacheRep = validCache->rep;
|
||||||
|
@ -949,7 +953,6 @@ static Class cacheClass = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DESTROY(partialCache->bg);
|
DESTROY(partialCache->bg);
|
||||||
[partialCache->rep setOpaque: YES];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cacheRep = partialCache->rep;
|
cacheRep = partialCache->rep;
|
||||||
|
@ -975,8 +978,8 @@ static Class cacheClass = 0;
|
||||||
alpha: NO];
|
alpha: NO];
|
||||||
[self addRepresentation: cacheRep];
|
[self addRepresentation: cacheRep];
|
||||||
RELEASE(cacheRep); /* Retained in _reps array. */
|
RELEASE(cacheRep); /* Retained in _reps array. */
|
||||||
repd = repd_for_rep(_reps, cacheRep);
|
repd = repd_for_rep(_reps, cacheRep);
|
||||||
repd->original = rep;
|
repd->original = rep;
|
||||||
}
|
}
|
||||||
return cacheRep;
|
return cacheRep;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue