mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:10:47 +00:00
Small bugfix and performance optimisation.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27735 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
49383abd25
commit
4ac3bb0344
4 changed files with 303 additions and 182 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSThemeTools.m: Add checks to prevent problems in the case
|
||||
where the control being drawn is actually smaller than the tiles used.
|
||||
* Headers/AppKit/NSScreen.h:
|
||||
* Source/NSScreen.m: Cache device description dictionary ... when
|
||||
debugging the problem with theme tools (which caused a loop to
|
||||
repeatedly composite the tile image instead of doing it once), I
|
||||
noticed that almost every time I stopped the app in gdb, it was in
|
||||
the process of creating a device description, strongly suggesting
|
||||
that this is actually quite a time consuming part of drawing
|
||||
images.
|
||||
|
||||
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSApplication.m: Try to get behavior to match MacOS-X
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
NSRect _frame;
|
||||
int _screenNumber;
|
||||
NSWindowDepth *_supportedWindowDepths;
|
||||
void *_reserved;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -56,7 +57,7 @@
|
|||
+ (NSScreen*) mainScreen;
|
||||
+ (NSScreen*) deepestScreen;
|
||||
+ (NSArray*) screens;
|
||||
+ (void)resetScreens;
|
||||
+ (void) resetScreens;
|
||||
|
||||
/*
|
||||
* Reading Screen Information
|
||||
|
|
|
@ -476,6 +476,28 @@
|
|||
unsigned count;
|
||||
float y;
|
||||
|
||||
if (rect.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (rect.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (source.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] source width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (source.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] source height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (image == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] image is nil",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
|
||||
ctxt = GSCurrentContext();
|
||||
DPSgsave (ctxt);
|
||||
path = [NSBezierPath bezierPathWithRect: rect];
|
||||
[path addClip];
|
||||
|
@ -500,7 +522,7 @@ withRepeatedImage: (NSImage*)image
|
|||
fromRect: (NSRect)source
|
||||
center: (BOOL)center
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext ();
|
||||
NSGraphicsContext *ctxt;
|
||||
NSBezierPath *path;
|
||||
NSSize size;
|
||||
unsigned xrepetitions;
|
||||
|
@ -508,6 +530,28 @@ withRepeatedImage: (NSImage*)image
|
|||
unsigned x;
|
||||
unsigned y;
|
||||
|
||||
if (rect.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (rect.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (source.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] source width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (source.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] source height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (image == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] image is nil",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
|
||||
ctxt = GSCurrentContext ();
|
||||
DPSgsave (ctxt);
|
||||
path = [NSBezierPath bezierPathWithRect: rect];
|
||||
[path addClip];
|
||||
|
@ -545,9 +589,23 @@ withRepeatedImage: (NSImage*)image
|
|||
NSSize bls = tiles->rects[TileBL].size;
|
||||
NSSize bms = tiles->rects[TileBM].size;
|
||||
NSSize brs = tiles->rects[TileBR].size;
|
||||
NSSize tsz;
|
||||
NSRect inFill;
|
||||
BOOL flipped = [[ctxt focusView] isFlipped];
|
||||
|
||||
if (rect.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (rect.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (tiles == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] tiles is nil",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
|
||||
if (color == nil)
|
||||
{
|
||||
[[NSColor redColor] set];
|
||||
|
@ -558,6 +616,19 @@ withRepeatedImage: (NSImage*)image
|
|||
}
|
||||
NSRectFill(rect);
|
||||
|
||||
tsz.width = tiles->rects[TileTL].size.width
|
||||
+ tiles->rects[TileTR].size.width;
|
||||
if (tiles->images[TileTM] == nil)
|
||||
{
|
||||
tsz.width += tiles->rects[TileTM].size.width;
|
||||
}
|
||||
tsz.height = tiles->rects[TileTL].size.height
|
||||
+ tiles->rects[TileBL].size.height;
|
||||
if (tiles->images[TileCL] == nil)
|
||||
{
|
||||
tsz.height += tiles->rects[TileCL].size.height;
|
||||
}
|
||||
|
||||
if (style == GSThemeFillStyleMatrix)
|
||||
{
|
||||
NSRect grid;
|
||||
|
@ -569,31 +640,21 @@ withRepeatedImage: (NSImage*)image
|
|||
inFill = NSZeroRect;
|
||||
if (tiles->images[TileTM] == nil)
|
||||
{
|
||||
grid.size.width = (tiles->rects[TileTL].size.width
|
||||
+ tiles->rects[TileTR].size.width
|
||||
+ space * 3.0);
|
||||
grid.size.width = tsz.width + space * 3.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.size.width = (tiles->rects[TileTL].size.width
|
||||
+ tiles->rects[TileTM].size.width
|
||||
+ tiles->rects[TileTR].size.width
|
||||
+ space * 4.0);
|
||||
grid.size.width = tsz.width + space * 4.0;
|
||||
}
|
||||
scale = floor(rect.size.width / grid.size.width);
|
||||
|
||||
if (tiles->images[TileCL] == nil)
|
||||
{
|
||||
grid.size.height = (tiles->rects[TileTL].size.height
|
||||
+ tiles->rects[TileBL].size.height
|
||||
+ space * 3.0);
|
||||
grid.size.height = tsz.height + space * 3.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.size.height = (tiles->rects[TileTL].size.height
|
||||
+ tiles->rects[TileCL].size.height
|
||||
+ tiles->rects[TileBL].size.height
|
||||
+ space * 4.0);
|
||||
grid.size.height = tsz.height + space * 4.0;
|
||||
}
|
||||
if ((rect.size.height / grid.size.height) < scale)
|
||||
{
|
||||
|
@ -716,6 +777,8 @@ withRepeatedImage: (NSImage*)image
|
|||
operation: NSCompositeSourceOver];
|
||||
}
|
||||
else if (flipped)
|
||||
{
|
||||
if (tsz.width <= rect.size.width && tsz.height <= rect.size.height)
|
||||
{
|
||||
[self fillHorizontalRect:
|
||||
NSMakeRect (rect.origin.x + bls.width,
|
||||
|
@ -775,6 +838,11 @@ withRepeatedImage: (NSImage*)image
|
|||
rect.origin.y + bms.height,
|
||||
rect.size.width - cls.width - crs.width,
|
||||
rect.size.height - bms.height - tms.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
inFill = rect;
|
||||
}
|
||||
if (style == GSThemeFillStyleCenter)
|
||||
{
|
||||
NSRect r = tiles->rects[TileCM];
|
||||
|
@ -794,6 +862,8 @@ withRepeatedImage: (NSImage*)image
|
|||
withRepeatedImage: tiles->images[TileCM]
|
||||
fromRect: tiles->rects[TileCM]
|
||||
center: NO];
|
||||
NSLog(@"rect %@ too small fire tiles %@",
|
||||
NSStringFromSize(rect.size), NSStringFromSize(tsz));
|
||||
}
|
||||
else if (style == GSThemeFillStyleScale)
|
||||
{
|
||||
|
@ -821,6 +891,8 @@ withRepeatedImage: (NSImage*)image
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tsz.width <= rect.size.width && tsz.height <= rect.size.height)
|
||||
{
|
||||
[self fillHorizontalRect:
|
||||
NSMakeRect(
|
||||
|
@ -888,7 +960,13 @@ withRepeatedImage: (NSImage*)image
|
|||
rect.origin.y + bms.height,
|
||||
rect.size.width - cls.width - crs.width,
|
||||
rect.size.height - bms.height - tms.height);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
inFill = rect;
|
||||
NSLog(@"rect %@ too small fire tiles %@",
|
||||
NSStringFromSize(rect.size), NSStringFromSize(tsz));
|
||||
}
|
||||
if (style == GSThemeFillStyleCenter)
|
||||
{
|
||||
NSRect r = tiles->rects[TileCM];
|
||||
|
@ -941,12 +1019,33 @@ withRepeatedImage: (NSImage*)image
|
|||
fromRect: (NSRect)source
|
||||
flipped: (BOOL)flipped
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
NSGraphicsContext *ctxt;
|
||||
NSBezierPath *path;
|
||||
unsigned repetitions;
|
||||
unsigned count;
|
||||
NSPoint p;
|
||||
|
||||
if (rect.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (rect.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] rect height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (source.size.width <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] source width is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (source.size.height <= 0.0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] source height is not positive",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
if (image == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] image is nil",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
ctxt = GSCurrentContext();
|
||||
DPSgsave (ctxt);
|
||||
path = [NSBezierPath bezierPathWithRect: rect];
|
||||
[path addClip];
|
||||
|
|
|
@ -72,7 +72,7 @@ static NSMutableArray *screenArray = nil;
|
|||
|
||||
+ (void) resetScreens
|
||||
{
|
||||
screenArray = nil;
|
||||
DESTROY(screenArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,6 +260,8 @@ static NSMutableArray *screenArray = nil;
|
|||
*/
|
||||
- (NSDictionary*) deviceDescription
|
||||
{
|
||||
if (_reserved == 0)
|
||||
{
|
||||
NSMutableDictionary *devDesc;
|
||||
int bps = 0;
|
||||
NSSize screenResolution;
|
||||
|
@ -272,7 +274,7 @@ static NSMutableArray *screenArray = nil;
|
|||
*/
|
||||
|
||||
// Set the screen number in the current object.
|
||||
devDesc = [NSMutableDictionary dictionary];
|
||||
devDesc = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
||||
[devDesc setObject: [NSNumber numberWithInt: _screenNumber]
|
||||
forKey: @"NSScreenNumber"];
|
||||
|
||||
|
@ -302,7 +304,10 @@ static NSMutableArray *screenArray = nil;
|
|||
[devDesc setObject: colorSpaceName
|
||||
forKey: NSDeviceColorSpaceName];
|
||||
|
||||
return [NSDictionary dictionaryWithDictionary: devDesc];
|
||||
_reserved = (void*)[devDesc copy];
|
||||
RELEASE(devDesc);
|
||||
}
|
||||
return (NSDictionary*)_reserved;
|
||||
}
|
||||
|
||||
// Mac OS X methods
|
||||
|
@ -393,7 +398,10 @@ static NSMutableArray *screenArray = nil;
|
|||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), _supportedWindowDepths);
|
||||
}
|
||||
|
||||
if (_reserved != 0)
|
||||
{
|
||||
[(id)_reserved release];
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue