mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
Cache needed fonts.
Obtaining a font has become rather expensive in recent gnustep, so cache fonts, obtaining new ones only when needed rather than every redraw. Makes things snappy again :)
This commit is contained in:
parent
36ec375893
commit
fb65cd2b44
9 changed files with 30 additions and 8 deletions
|
@ -179,7 +179,7 @@ XYDrag
|
||||||
[[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
|
[[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
|
||||||
set];
|
set];
|
||||||
|
|
||||||
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
|
[[xyview_i scaledFont] set];
|
||||||
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
|
@ -202,7 +202,7 @@ XYDrag
|
||||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
[[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set];
|
[[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set];
|
||||||
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
|
[[xyview_i scaledFont] set];
|
||||||
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ extern id keypairview_i;
|
||||||
|
|
||||||
@interface KeypairView: NSView
|
@interface KeypairView: NSView
|
||||||
{
|
{
|
||||||
|
NSFont *font;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) calcViewSize;
|
- (id) calcViewSize;
|
||||||
|
|
|
@ -14,6 +14,7 @@ initWithFrame:
|
||||||
- (id) initWithFrame: (NSRect)frameRect
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
[super initWithFrame: frameRect];
|
[super initWithFrame: frameRect];
|
||||||
|
font = [[NSFont systemFontOfSize: FONTSIZE] retain];
|
||||||
keypairview_i = self;
|
keypairview_i = self;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +56,7 @@ initWithFrame:
|
||||||
[[NSColor lightGrayColor] set];
|
[[NSColor lightGrayColor] set];
|
||||||
NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height));
|
NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height));
|
||||||
|
|
||||||
[[NSFont systemFontOfSize: FONTSIZE] set];
|
[font set];
|
||||||
[[NSColor blackColor] set];
|
[[NSColor blackColor] set];
|
||||||
|
|
||||||
pair = [[map_i currentEntity] epairs];
|
pair = [[map_i currentEntity] epairs];
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
@interface TextureView: NSView
|
@interface TextureView: NSView
|
||||||
{
|
{
|
||||||
|
NSFont *font;
|
||||||
id parent_i;
|
id parent_i;
|
||||||
int deselectIndex;
|
int deselectIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
|
font = [[NSFont systemFontOfSize: FONTSIZE] retain];
|
||||||
deselectIndex = -1;
|
deselectIndex = -1;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
selected = [parent_i getSelectedTexture];
|
selected = [parent_i getSelectedTexture];
|
||||||
list_i = [parent_i getList];
|
list_i = [parent_i getList];
|
||||||
[[NSFont systemFontOfSize: FONTSIZE] set];
|
[font set];
|
||||||
|
|
||||||
[[NSColor lightGrayColor] set];
|
[[NSColor lightGrayColor] set];
|
||||||
NSRectFill (rects);
|
NSRectFill (rects);
|
||||||
|
|
|
@ -30,6 +30,8 @@ void XYlineto (vec3_t pt);
|
||||||
{
|
{
|
||||||
NSRect realbounds, newrect, combinedrect;
|
NSRect realbounds, newrect, combinedrect;
|
||||||
NSPoint midpoint;
|
NSPoint midpoint;
|
||||||
|
NSFont *font;
|
||||||
|
NSFont *scaledFont;
|
||||||
int gridsize;
|
int gridsize;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
|
@ -72,6 +74,8 @@ void XYlineto (vec3_t pt);
|
||||||
- (int) gridsize;
|
- (int) gridsize;
|
||||||
- (float) snapToGrid: (float)f;
|
- (float) snapToGrid: (float)f;
|
||||||
|
|
||||||
|
- (NSFont *) scaledFont;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSView (XYView)
|
@interface NSView (XYView)
|
||||||
|
|
|
@ -58,6 +58,8 @@ initWithFrame:
|
||||||
[super initWithFrame: frameRect];
|
[super initWithFrame: frameRect];
|
||||||
[self allocateGState];
|
[self allocateGState];
|
||||||
|
|
||||||
|
font = [[NSFont systemFontOfSize: 10] retain];
|
||||||
|
|
||||||
realbounds = NSMakeRect (0, 0, 0, 0);
|
realbounds = NSMakeRect (0, 0, 0, 0);
|
||||||
|
|
||||||
gridsize = 16;
|
gridsize = 16;
|
||||||
|
@ -273,6 +275,7 @@ Called when the scaler popup on the window is used
|
||||||
{
|
{
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
NSPoint mid, org, origin;
|
NSPoint mid, org, origin;
|
||||||
|
NSFont *f;
|
||||||
float nscale;
|
float nscale;
|
||||||
|
|
||||||
nscale = [[[sender selectedCell] title] floatValue] / 100;
|
nscale = [[[sender selectedCell] title] floatValue] / 100;
|
||||||
|
@ -280,6 +283,10 @@ Called when the scaler popup on the window is used
|
||||||
if (nscale == scale)
|
if (nscale == scale)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
f = [[NSFont systemFontOfSize: 10 / nscale] retain];
|
||||||
|
[scaledFont release];
|
||||||
|
scaledFont = f;
|
||||||
|
|
||||||
// keep the center of the view constant
|
// keep the center of the view constant
|
||||||
rect = [_super_view bounds];
|
rect = [_super_view bounds];
|
||||||
mid.x = rect.size.width / 2;
|
mid.x = rect.size.width / 2;
|
||||||
|
@ -804,7 +811,7 @@ NSRect xy_draw_rect;
|
||||||
newrect.size.width = newrect.size.height = -2 * 99999;
|
newrect.size.width = newrect.size.height = -2 * 99999;
|
||||||
|
|
||||||
// setup for text
|
// setup for text
|
||||||
[[NSFont systemFontOfSize: 10] set];
|
[font set];
|
||||||
|
|
||||||
if (drawmode == dr_texture || drawmode == dr_flat) {
|
if (drawmode == dr_texture || drawmode == dr_flat) {
|
||||||
[quakeed_i xyNoRestore: [self visibleRect]];
|
[quakeed_i xyNoRestore: [self visibleRect]];
|
||||||
|
@ -1319,4 +1326,9 @@ rightMouseDown
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSFont *) scaledFont
|
||||||
|
{
|
||||||
|
return scaledFont;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern float zplanedir;
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
|
|
||||||
NSBezierPath *checker;
|
NSBezierPath *checker;
|
||||||
|
NSFont *font;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) clearBounds;
|
- (id) clearBounds;
|
||||||
|
|
|
@ -27,6 +27,7 @@ initWithFrame:
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
NSBezierPath *path;
|
NSBezierPath *path;
|
||||||
|
|
||||||
|
font = [[NSFont systemFontOfSize: 10] retain];
|
||||||
path = checker = [NSBezierPath new];
|
path = checker = [NSBezierPath new];
|
||||||
[path setLineWidth: 0.3];
|
[path setLineWidth: 0.3];
|
||||||
[path moveToPoint: NSMakePoint (-16, -16)];
|
[path moveToPoint: NSMakePoint (-16, -16)];
|
||||||
|
@ -185,7 +186,7 @@ Called when the scaler popup on the window is used
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) getBounds: (float *)top: (float *)bottom;
|
- (id) getBounds: (float *)top: (float *)bottom
|
||||||
{
|
{
|
||||||
*top = topbound;
|
*top = topbound;
|
||||||
*bottom = bottombound;
|
*bottom = bottombound;
|
||||||
|
@ -363,7 +364,7 @@ Rect is in global world (unscaled) coordinates
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
|
|
||||||
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0] set]; // for text
|
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0] set]; // for text
|
||||||
[[NSFont systemFontOfSize: 10] set];
|
[font set];
|
||||||
|
|
||||||
for ( ; y <= stopy; y += 64) {
|
for ( ; y <= stopy; y += 64) {
|
||||||
if (showcoords) {
|
if (showcoords) {
|
||||||
|
@ -431,7 +432,7 @@ drawSelf
|
||||||
[self drawGrid: rect];
|
[self drawGrid: rect];
|
||||||
|
|
||||||
// draw zplane
|
// draw zplane
|
||||||
// [self drawZplane]; FIXME zplane doesn't do anything yet
|
[self drawZplane]; //FIXME zplane doesn't do anything yet
|
||||||
|
|
||||||
// draw all entities
|
// draw all entities
|
||||||
[map_i makeUnselectedPerform: @selector (ZDrawSelf)];
|
[map_i makeUnselectedPerform: @selector (ZDrawSelf)];
|
||||||
|
|
Loading…
Reference in a new issue