# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1562953273 0 # Node ID 85229fe9ae5ab2ed6253103713da7689db170ece # Parent 77d156c3f01c870b0cfb37621515914dcc7388ee Mac: 10.14 doesn't like too many needsDisplays so instead we keep a list of dirty drawables, and only set needsDisplay when dw_flush() is called. We remove the drawable from the dirty list when it is actually drawn. diff -r 77d156c3f01c -r 85229fe9ae5a mac/dw.m --- a/mac/dw.m Fri Jul 12 02:03:09 2019 +0000 +++ b/mac/dw.m Fri Jul 12 17:41:13 2019 +0000 @@ -615,7 +615,9 @@ #if !defined(GARBAGE_COLLECT) NSAutoreleasePool *pool; #endif -#ifndef BUILDING_FOR_MOJAVE +#ifdef BUILDING_FOR_MOJAVE +NSMutableArray *_DWDirtyDrawables; +#else HWND _DWLastDrawable; #endif HMTX DWRunMutex; @@ -892,7 +894,9 @@ cachedDrawingRep = [self bitmapImageRepForCachingDisplayInRect:self.bounds]; [cachedDrawingRep retain]; } - self.needsDisplay = YES; + /* Mark this render dirty if something is requesting it to draw */ + if(![_DWDirtyDrawables containsObject:self]) + [_DWDirtyDrawables addObject:self]; return cachedDrawingRep; } #endif @@ -911,7 +915,10 @@ _event_handler(self, nil, 7); #ifdef BUILDING_FOR_MOJAVE if (cachedDrawingRep) + { [cachedDrawingRep drawInRect:self.bounds]; + [_DWDirtyDrawables removeObject:self]; + } #endif } -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); } @@ -923,6 +930,7 @@ dw_signal_disconnect_by_window(self); #ifdef BUILDING_FOR_MOJAVE [cachedDrawingRep release]; + [_DWDirtyDrawables removeObject:self]; #endif [super dealloc]; } @@ -1045,12 +1053,20 @@ } -(void)doFlush:(id)param { -#ifndef BUILDING_FOR_MOJAVE +#ifdef BUILDING_FOR_MOJAVE + NSEnumerator *enumerator = [_DWDirtyDrawables objectEnumerator]; + DWRender *rend; + + while (rend = [enumerator nextObject]) + rend.needsDisplay = YES; + [_DWDirtyDrawables removeAllObjects]; +#else if(_DWLastDrawable) { id object = _DWLastDrawable; NSWindow *window = [object window]; [window flushWindow]; + _DWLastDrawable = nil; } #endif } @@ -11406,6 +11422,9 @@ DWRunMutex = dw_mutex_new(); DWThreadMutex = dw_mutex_new(); DWThreadMutex2 = dw_mutex_new(); +#ifdef BUILDING_FOR_MOJAVE + _DWDirtyDrawables = [[NSMutableArray alloc] init]; +#endif /* Use NSThread to start a dummy thread to initialize the threading subsystem */ NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; [thread start];