Skip to content

Commit 153cbca

Browse files
committed
Stateful, fast renderer for MMCoreTextView
This change replaces the current rendering paths in `MMCoreTextView` with one which draws from an array of structs that represent the state of each character cell. It applies draw commands to the array and marks any touched cells as needing display instead of drawing to a view or image buffer. In my own tests, this renderer seems to be roughly twice as fast of the current one. Because it seems to work for the use cases of all of the current renderers and reused a lot of code, this PR replaces the other paths instead of adding a preference. Fixes macvim-dev#796.
1 parent d6892b2 commit 153cbca

13 files changed

+358
-922
lines changed

src/MacVim/MMAppController.m

-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ + (void)initialize
247247
[NSNumber numberWithBool:NO], MMSuppressTerminationAlertKey,
248248
[NSNumber numberWithBool:YES], MMNativeFullScreenKey,
249249
[NSNumber numberWithDouble:0.25], MMFullScreenFadeTimeKey,
250-
[NSNumber numberWithBool:NO], MMUseCGLayerAlwaysKey,
251-
@(shouldUseBufferedDrawing()), MMBufferedDrawingKey,
252250
[NSNumber numberWithBool:YES], MMShareFindPboardKey,
253251
nil];
254252

src/MacVim/MMCoreTextView.h

+1-34
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,11 @@
3131
BOOL antialias;
3232
BOOL ligatures;
3333
BOOL thinStrokes;
34-
BOOL drawPending;
35-
NSMutableArray *drawData;
3634

3735
MMTextViewHelper *helper;
3836

39-
unsigned maxlen;
40-
CGGlyph *glyphs;
41-
CGPoint *positions;
4237
NSMutableArray *fontCache;
43-
44-
// Issue draws onto an CGImage that caches the drawn results instead of
45-
// directly in drawRect:. This is the default behavior in cases where simply
46-
// drawing incrementally in drawRect: doesn't work. Those cases are:
47-
// 1. Non-native fullscreen
48-
// 2. 10.14+ (views are always layer-backed which means the view buffer will
49-
// be cleared and we can't incrementally draw in drawRect:)
50-
//
51-
// This can be configured by setting MMBufferedDrawingKey in user defaults.
52-
BOOL cgBufferDrawEnabled;
53-
BOOL cgBufferDrawNeedsUpdateContext;
54-
CGContextRef cgContext;
55-
56-
// *Deprecated*
57-
// Draw onto a CGLayer instead of lazily updating the view's buffer in
58-
// drawRect: which is error-prone and relying on undocumented behaviors
59-
// (that the OS will preserve the old buffer).
60-
//
61-
// This is deprecated. Use cgBufferDrawEnabled instead which is more
62-
// efficient.
63-
//
64-
// This can be configured by setting MMUseCGLayerAlwaysKey in user defaults.
65-
BOOL cgLayerEnabled;
66-
CGLayerRef cgLayer;
67-
CGContextRef cgLayerContext;
68-
NSLock *cgLayerLock;
38+
NSMutableDictionary<NSNumber*,NSFont*> *fontVariantCache;
6939

7040
// These are used in MMCoreTextView+ToolTip.m
7141
id trackingRectOwner_; // (not retained)
@@ -113,13 +83,10 @@
11383
- (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column;
11484
- (NSRect)rectForRow:(int)row column:(int)column numRows:(int)nr
11585
numColumns:(int)nc;
116-
- (void)setCGLayerEnabled:(BOOL)enabled;
117-
- (BOOL)getCGLayerEnabled;
11886

11987
//
12088
// NSTextView methods
12189
//
122-
- (void)setFrameSize:(NSSize)newSize;
12390
- (void)keyDown:(NSEvent *)event;
12491
- (void)insertText:(id)string;
12592
- (void)doCommandBySelector:(SEL)selector;

0 commit comments

Comments
 (0)