comparison mac/dw.m @ 1941:b498fb0360fc

Mac: 10.14 seems to have drastically changed the drawing mechanism. Disable video memory and flush window code when building for Mojave.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 22 Jun 2019 19:50:15 +0000
parents 38a50e0820b1
children 5658f703a22e
comparison
equal deleted inserted replaced
1940:38a50e0820b1 1941:b498fb0360fc
148 148
149 /* Handle deprecation of several constants in 10.14... 149 /* Handle deprecation of several constants in 10.14...
150 * the replacements are not available in earlier versions. 150 * the replacements are not available in earlier versions.
151 */ 151 */
152 #if defined(MAC_OS_X_VERSION_10_14) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED)) 152 #if defined(MAC_OS_X_VERSION_10_14) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED))
153 #define DWProgressIndicatorStyleBar NSProgressIndicatorStyleBar
153 #define DWWebView WKWebView 154 #define DWWebView WKWebView
154 #define BUILDING_FOR_MOJAVE 155 #define BUILDING_FOR_MOJAVE
155 #else 156 #else
157 #define DWProgressIndicatorStyleBar NSProgressIndicatorBarStyle
156 #define DWWebView WebView 158 #define DWWebView WebView
157 #endif 159 #endif
158 160
159 unsigned long _colors[] = 161 unsigned long _colors[] =
160 { 162 {
450 exp.x = rect.origin.x; 452 exp.x = rect.origin.x;
451 exp.y = rect.origin.y; 453 exp.y = rect.origin.y;
452 exp.width = rect.size.width; 454 exp.width = rect.size.width;
453 exp.height = rect.size.height; 455 exp.height = rect.size.height;
454 int result = exposefunc(object, &exp, handler->data); 456 int result = exposefunc(object, &exp, handler->data);
457 #ifndef BUILDING_FOR_MOJAVE
455 [[object window] flushWindow]; 458 [[object window] flushWindow];
459 #endif
456 return result; 460 return result;
457 } 461 }
458 /* Clicked event for buttons and menu items */ 462 /* Clicked event for buttons and menu items */
459 case 8: 463 case 8:
460 { 464 {
622 data1:0 626 data1:0
623 data2:0] 627 data2:0]
624 atStart:NO]; 628 atStart:NO];
625 } 629 }
626 630
631 NSGraphicsContext *_dw_draw_context(NSBitmapImageRep *image);
632
627 /* Used for doing bitblts from the main thread */ 633 /* Used for doing bitblts from the main thread */
628 typedef struct _bitbltinfo 634 typedef struct _bitbltinfo
629 { 635 {
630 id src; 636 id src;
631 id dest; 637 id dest;
686 id bltsrc = bltinfo->src; 692 id bltsrc = bltinfo->src;
687 693
688 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) 694 if([bltdest isMemberOfClass:[NSBitmapImageRep class]])
689 { 695 {
690 [NSGraphicsContext saveGraphicsState]; 696 [NSGraphicsContext saveGraphicsState];
691 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 697 [NSGraphicsContext setCurrentContext:_dw_draw_context(bltdest)];
692 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:bltdest] graphicsPort] flipped:YES]];
693 [[[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil] autorelease]; 698 [[[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil] autorelease];
694 } 699 }
695 else 700 else
696 { 701 {
697 if([bltdest lockFocusIfCanDraw] == NO) 702 if([bltdest lockFocusIfCanDraw] == NO)
743 } 748 }
744 free(bltinfo); 749 free(bltinfo);
745 } 750 }
746 -(void)doFlush:(id)param 751 -(void)doFlush:(id)param
747 { 752 {
753 #ifndef BUILDING_FOR_MOJAVE
748 if(_DWLastDrawable) 754 if(_DWLastDrawable)
749 { 755 {
750 id object = _DWLastDrawable; 756 id object = _DWLastDrawable;
751 NSWindow *window = [object window]; 757 NSWindow *window = [object window];
752 [window flushWindow]; 758 [window flushWindow];
753 } 759 }
760 #endif
754 } 761 }
755 -(void)doWindowFunc:(id)param 762 -(void)doWindowFunc:(id)param
756 { 763 {
757 NSValue *v = (NSValue *)param; 764 NSValue *v = (NSValue *)param;
758 void **params = (void **)[v pointerValue]; 765 void **params = (void **)[v pointerValue];
2886 if([handle isMemberOfClass:[DWRender class]]) 2893 if([handle isMemberOfClass:[DWRender class]])
2887 { 2894 {
2888 DWRender *render = (DWRender *)handle; 2895 DWRender *render = (DWRender *)handle;
2889 NSSize oldsize = [render size]; 2896 NSSize oldsize = [render size];
2890 NSSize newsize = [render frame].size; 2897 NSSize newsize = [render frame].size;
2898
2899 /* The 10.14 appkit warns this property does nothing... not sure
2900 * how long that has been the case but just removing it for Mojave.
2901 */
2902 #ifndef BUILDING_FOR_MOJAVE
2891 NSWindow *window = [render window]; 2903 NSWindow *window = [render window];
2892 2904
2893 if([window preferredBackingLocation] != NSWindowBackingLocationVideoMemory) 2905 if([window preferredBackingLocation] != NSWindowBackingLocationVideoMemory)
2894 { 2906 {
2895 [window setPreferredBackingLocation:NSWindowBackingLocationVideoMemory]; 2907 [window setPreferredBackingLocation:NSWindowBackingLocationVideoMemory];
2896 } 2908 }
2897 2909 #endif
2910
2898 /* Eliminate duplicate configure requests */ 2911 /* Eliminate duplicate configure requests */
2899 if(oldsize.width != newsize.width || oldsize.height != newsize.height) 2912 if(oldsize.width != newsize.width || oldsize.height != newsize.height)
2900 { 2913 {
2901 if(newsize.width > 0 && newsize.height > 0) 2914 if(newsize.width > 0 && newsize.height > 0)
2902 { 2915 {
4834 } 4847 }
4835 else 4848 else
4836 { 4849 {
4837 scrollbar = [[DWScrollbar alloc] initWithFrame:NSMakeRect(0,0,100,5)]; 4850 scrollbar = [[DWScrollbar alloc] initWithFrame:NSMakeRect(0,0,100,5)];
4838 } 4851 }
4852 #ifndef BUILDING_FOR_YOSEMITE
4839 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; 4853 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting];
4854 #endif
4840 [scrollbar setRange:0.0 andVisible:0.0]; 4855 [scrollbar setRange:0.0 andVisible:0.0];
4841 [scrollbar setKnobProportion:1.0]; 4856 [scrollbar setKnobProportion:1.0];
4842 [scrollbar setTarget:scrollbar]; 4857 [scrollbar setTarget:scrollbar];
4843 [scrollbar setAction:@selector(scrollerChanged:)]; 4858 [scrollbar setAction:@selector(scrollerChanged:)];
4844 [scrollbar setTag:cid]; 4859 [scrollbar setTag:cid];
9676 void API dw_window_redraw(HWND handle) 9691 void API dw_window_redraw(HWND handle)
9677 { 9692 {
9678 DWWindow *window = handle; 9693 DWWindow *window = handle;
9679 [window setRedraw:YES]; 9694 [window setRedraw:YES];
9680 [[window contentView] showWindow]; 9695 [[window contentView] showWindow];
9696 #ifndef BUILDING_FOR_MOJAVE
9681 [window flushWindow]; 9697 [window flushWindow];
9698 #endif
9682 [window setRedraw:NO]; 9699 [window setRedraw:NO];
9683 } 9700 }
9684 9701
9685 /* 9702 /*
9686 * Makes the window topmost. 9703 * Makes the window topmost.