mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 12:20:42 +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>
|
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSApplication.m: Try to get behavior to match MacOS-X
|
* Source/NSApplication.m: Try to get behavior to match MacOS-X
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
NSRect _frame;
|
NSRect _frame;
|
||||||
int _screenNumber;
|
int _screenNumber;
|
||||||
NSWindowDepth *_supportedWindowDepths;
|
NSWindowDepth *_supportedWindowDepths;
|
||||||
|
void *_reserved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -476,6 +476,28 @@
|
||||||
unsigned count;
|
unsigned count;
|
||||||
float y;
|
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);
|
DPSgsave (ctxt);
|
||||||
path = [NSBezierPath bezierPathWithRect: rect];
|
path = [NSBezierPath bezierPathWithRect: rect];
|
||||||
[path addClip];
|
[path addClip];
|
||||||
|
@ -500,7 +522,7 @@ withRepeatedImage: (NSImage*)image
|
||||||
fromRect: (NSRect)source
|
fromRect: (NSRect)source
|
||||||
center: (BOOL)center
|
center: (BOOL)center
|
||||||
{
|
{
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext ();
|
NSGraphicsContext *ctxt;
|
||||||
NSBezierPath *path;
|
NSBezierPath *path;
|
||||||
NSSize size;
|
NSSize size;
|
||||||
unsigned xrepetitions;
|
unsigned xrepetitions;
|
||||||
|
@ -508,6 +530,28 @@ withRepeatedImage: (NSImage*)image
|
||||||
unsigned x;
|
unsigned x;
|
||||||
unsigned y;
|
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);
|
DPSgsave (ctxt);
|
||||||
path = [NSBezierPath bezierPathWithRect: rect];
|
path = [NSBezierPath bezierPathWithRect: rect];
|
||||||
[path addClip];
|
[path addClip];
|
||||||
|
@ -545,9 +589,23 @@ withRepeatedImage: (NSImage*)image
|
||||||
NSSize bls = tiles->rects[TileBL].size;
|
NSSize bls = tiles->rects[TileBL].size;
|
||||||
NSSize bms = tiles->rects[TileBM].size;
|
NSSize bms = tiles->rects[TileBM].size;
|
||||||
NSSize brs = tiles->rects[TileBR].size;
|
NSSize brs = tiles->rects[TileBR].size;
|
||||||
|
NSSize tsz;
|
||||||
NSRect inFill;
|
NSRect inFill;
|
||||||
BOOL flipped = [[ctxt focusView] isFlipped];
|
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)
|
if (color == nil)
|
||||||
{
|
{
|
||||||
[[NSColor redColor] set];
|
[[NSColor redColor] set];
|
||||||
|
@ -558,6 +616,19 @@ withRepeatedImage: (NSImage*)image
|
||||||
}
|
}
|
||||||
NSRectFill(rect);
|
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)
|
if (style == GSThemeFillStyleMatrix)
|
||||||
{
|
{
|
||||||
NSRect grid;
|
NSRect grid;
|
||||||
|
@ -569,31 +640,21 @@ withRepeatedImage: (NSImage*)image
|
||||||
inFill = NSZeroRect;
|
inFill = NSZeroRect;
|
||||||
if (tiles->images[TileTM] == nil)
|
if (tiles->images[TileTM] == nil)
|
||||||
{
|
{
|
||||||
grid.size.width = (tiles->rects[TileTL].size.width
|
grid.size.width = tsz.width + space * 3.0;
|
||||||
+ tiles->rects[TileTR].size.width
|
|
||||||
+ space * 3.0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grid.size.width = (tiles->rects[TileTL].size.width
|
grid.size.width = tsz.width + space * 4.0;
|
||||||
+ tiles->rects[TileTM].size.width
|
|
||||||
+ tiles->rects[TileTR].size.width
|
|
||||||
+ space * 4.0);
|
|
||||||
}
|
}
|
||||||
scale = floor(rect.size.width / grid.size.width);
|
scale = floor(rect.size.width / grid.size.width);
|
||||||
|
|
||||||
if (tiles->images[TileCL] == nil)
|
if (tiles->images[TileCL] == nil)
|
||||||
{
|
{
|
||||||
grid.size.height = (tiles->rects[TileTL].size.height
|
grid.size.height = tsz.height + space * 3.0;
|
||||||
+ tiles->rects[TileBL].size.height
|
|
||||||
+ space * 3.0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grid.size.height = (tiles->rects[TileTL].size.height
|
grid.size.height = tsz.height + space * 4.0;
|
||||||
+ tiles->rects[TileCL].size.height
|
|
||||||
+ tiles->rects[TileBL].size.height
|
|
||||||
+ space * 4.0);
|
|
||||||
}
|
}
|
||||||
if ((rect.size.height / grid.size.height) < scale)
|
if ((rect.size.height / grid.size.height) < scale)
|
||||||
{
|
{
|
||||||
|
@ -716,6 +777,8 @@ withRepeatedImage: (NSImage*)image
|
||||||
operation: NSCompositeSourceOver];
|
operation: NSCompositeSourceOver];
|
||||||
}
|
}
|
||||||
else if (flipped)
|
else if (flipped)
|
||||||
|
{
|
||||||
|
if (tsz.width <= rect.size.width && tsz.height <= rect.size.height)
|
||||||
{
|
{
|
||||||
[self fillHorizontalRect:
|
[self fillHorizontalRect:
|
||||||
NSMakeRect (rect.origin.x + bls.width,
|
NSMakeRect (rect.origin.x + bls.width,
|
||||||
|
@ -775,6 +838,11 @@ withRepeatedImage: (NSImage*)image
|
||||||
rect.origin.y + bms.height,
|
rect.origin.y + bms.height,
|
||||||
rect.size.width - cls.width - crs.width,
|
rect.size.width - cls.width - crs.width,
|
||||||
rect.size.height - bms.height - tms.height);
|
rect.size.height - bms.height - tms.height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inFill = rect;
|
||||||
|
}
|
||||||
if (style == GSThemeFillStyleCenter)
|
if (style == GSThemeFillStyleCenter)
|
||||||
{
|
{
|
||||||
NSRect r = tiles->rects[TileCM];
|
NSRect r = tiles->rects[TileCM];
|
||||||
|
@ -794,6 +862,8 @@ withRepeatedImage: (NSImage*)image
|
||||||
withRepeatedImage: tiles->images[TileCM]
|
withRepeatedImage: tiles->images[TileCM]
|
||||||
fromRect: tiles->rects[TileCM]
|
fromRect: tiles->rects[TileCM]
|
||||||
center: NO];
|
center: NO];
|
||||||
|
NSLog(@"rect %@ too small fire tiles %@",
|
||||||
|
NSStringFromSize(rect.size), NSStringFromSize(tsz));
|
||||||
}
|
}
|
||||||
else if (style == GSThemeFillStyleScale)
|
else if (style == GSThemeFillStyleScale)
|
||||||
{
|
{
|
||||||
|
@ -821,6 +891,8 @@ withRepeatedImage: (NSImage*)image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (tsz.width <= rect.size.width && tsz.height <= rect.size.height)
|
||||||
{
|
{
|
||||||
[self fillHorizontalRect:
|
[self fillHorizontalRect:
|
||||||
NSMakeRect(
|
NSMakeRect(
|
||||||
|
@ -888,7 +960,13 @@ withRepeatedImage: (NSImage*)image
|
||||||
rect.origin.y + bms.height,
|
rect.origin.y + bms.height,
|
||||||
rect.size.width - cls.width - crs.width,
|
rect.size.width - cls.width - crs.width,
|
||||||
rect.size.height - bms.height - tms.height);
|
rect.size.height - bms.height - tms.height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inFill = rect;
|
||||||
|
NSLog(@"rect %@ too small fire tiles %@",
|
||||||
|
NSStringFromSize(rect.size), NSStringFromSize(tsz));
|
||||||
|
}
|
||||||
if (style == GSThemeFillStyleCenter)
|
if (style == GSThemeFillStyleCenter)
|
||||||
{
|
{
|
||||||
NSRect r = tiles->rects[TileCM];
|
NSRect r = tiles->rects[TileCM];
|
||||||
|
@ -941,12 +1019,33 @@ withRepeatedImage: (NSImage*)image
|
||||||
fromRect: (NSRect)source
|
fromRect: (NSRect)source
|
||||||
flipped: (BOOL)flipped
|
flipped: (BOOL)flipped
|
||||||
{
|
{
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
NSGraphicsContext *ctxt;
|
||||||
NSBezierPath *path;
|
NSBezierPath *path;
|
||||||
unsigned repetitions;
|
unsigned repetitions;
|
||||||
unsigned count;
|
unsigned count;
|
||||||
NSPoint p;
|
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);
|
DPSgsave (ctxt);
|
||||||
path = [NSBezierPath bezierPathWithRect: rect];
|
path = [NSBezierPath bezierPathWithRect: rect];
|
||||||
[path addClip];
|
[path addClip];
|
||||||
|
|
|
@ -72,7 +72,7 @@ static NSMutableArray *screenArray = nil;
|
||||||
|
|
||||||
+ (void) resetScreens
|
+ (void) resetScreens
|
||||||
{
|
{
|
||||||
screenArray = nil;
|
DESTROY(screenArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -259,6 +259,8 @@ static NSMutableArray *screenArray = nil;
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
- (NSDictionary*) deviceDescription
|
- (NSDictionary*) deviceDescription
|
||||||
|
{
|
||||||
|
if (_reserved == 0)
|
||||||
{
|
{
|
||||||
NSMutableDictionary *devDesc;
|
NSMutableDictionary *devDesc;
|
||||||
int bps = 0;
|
int bps = 0;
|
||||||
|
@ -272,7 +274,7 @@ static NSMutableArray *screenArray = nil;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Set the screen number in the current object.
|
// Set the screen number in the current object.
|
||||||
devDesc = [NSMutableDictionary dictionary];
|
devDesc = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
||||||
[devDesc setObject: [NSNumber numberWithInt: _screenNumber]
|
[devDesc setObject: [NSNumber numberWithInt: _screenNumber]
|
||||||
forKey: @"NSScreenNumber"];
|
forKey: @"NSScreenNumber"];
|
||||||
|
|
||||||
|
@ -302,7 +304,10 @@ static NSMutableArray *screenArray = nil;
|
||||||
[devDesc setObject: colorSpaceName
|
[devDesc setObject: colorSpaceName
|
||||||
forKey: NSDeviceColorSpaceName];
|
forKey: NSDeviceColorSpaceName];
|
||||||
|
|
||||||
return [NSDictionary dictionaryWithDictionary: devDesc];
|
_reserved = (void*)[devDesc copy];
|
||||||
|
RELEASE(devDesc);
|
||||||
|
}
|
||||||
|
return (NSDictionary*)_reserved;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mac OS X methods
|
// Mac OS X methods
|
||||||
|
@ -393,7 +398,10 @@ static NSMutableArray *screenArray = nil;
|
||||||
{
|
{
|
||||||
NSZoneFree(NSDefaultMallocZone(), _supportedWindowDepths);
|
NSZoneFree(NSDefaultMallocZone(), _supportedWindowDepths);
|
||||||
}
|
}
|
||||||
|
if (_reserved != 0)
|
||||||
|
{
|
||||||
|
[(id)_reserved release];
|
||||||
|
}
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue