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