aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsterm.h
diff options
context:
space:
mode:
authorAlan Third2021-05-29 09:48:51 +0100
committerAlan Third2021-05-31 17:09:42 +0100
commit784ec4b75221e254d2d434578be04466d7ef8786 (patch)
treefd27b889b8e02a4be1a6c8fed77c6beaff86ab5e /src/nsterm.h
parent6bf76258161ca724a87fab2066c1c862ee61cf88 (diff)
downloademacs-scratch/ns/surface-stuff.tar.gz
emacs-scratch/ns/surface-stuff.zip
Simplify macOS drawing codescratch/ns/surface-stuff
Convert EmacsSurface into a CALayer subclass so we can use the built-in relationships. Also simplify the macOS versioning code. This will result in more warnings on older versions of macOS but makes reading the code easier. * configure.ac: Add QuartzCore framework. * src/nsterm.h (NS_DRAW_TO_BUFFER): Remove define and all references. (EmacsSurface, EmacsLayer): Rename EmacsSurface to EmacsLayer and modify the definition to fit the new function. * src/nsterm.m (ns_update_begin): (ns_update_end): (ns_focus): (ns_unfocus): Use the new overridden lockFocus and unlockFocus and simplify the frame management. ([EmacsView dealloc]): ([EmacsView viewDidResize:]):Don't explicitly release surfaces. ([EmacsView initFrameFromEmacs:]): Move the layer code to after the NSWindow has been created as creating the layer now relies on some of it's properties. ([EmacsView makeBackingLayer]): New function. ([EmacsView lockFocus]): ([EmacsView focusOnDrawingBuffer]): Rename to lockFocus. ([EmacsView unlockFocus]): ([EmacsView unfocusDrawingBuffer]): Rename to unlockFocus. ([EmacsView windowDidChangeBackingProperties]): Don't explicitly release surfaces but reset EmacsLayer properties. ([EmacsView layout]): ([EmacsView viewWillDraw]): Rename to layout. ([EmacsView wantsUpdateLayer]): Remove function and change all callers to [EmacsView wantsLayer]. (EmacsSurface, EmacsLayer): Rename to EmacsLayer. ([EmacsSurface getSize]): ([EmacsSurface initWithSize:ColorSpace:Scale:]): Remove methods. ([EmacsSurface initWithColorSpace:]): ([EmacsLayer checkDimensions]): ([EmacsLayer releaseSurfaces]): ([EmacsLayer display]): New functions. * src/nsterm.m ([EmacsLayer dealloc]): Use releaseSurfaces. ([EmacsSurface getContext]): Automatically detect frame property changes and clear the cache if required. Use built-in CALayer properties where available. ([EmacsLayer copyContentsTo:]): Use [CALayer contents] as source.
Diffstat (limited to 'src/nsterm.h')
-rw-r--r--src/nsterm.h35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/nsterm.h b/src/nsterm.h
index 0596f3f3c10..4c61a50ecb2 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -348,16 +348,6 @@ typedef id instancetype;
348#endif 348#endif
349 349
350 350
351/* macOS 10.14 and above cannot draw directly "to the glass" and
352 therefore we draw to an offscreen buffer and swap it in when the
353 toolkit wants to draw the frame. GNUstep and macOS 10.7 and below
354 do not support this method, so we revert to drawing directly to the
355 glass. */
356#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
357#define NS_DRAW_TO_BUFFER 1
358#endif
359
360
361/* ========================================================================== 351/* ==========================================================================
362 352
363 NSColor, EmacsColor category. 353 NSColor, EmacsColor category.
@@ -423,7 +413,7 @@ typedef id instancetype;
423 ========================================================================== */ 413 ========================================================================== */
424 414
425@class EmacsToolbar; 415@class EmacsToolbar;
426@class EmacsSurface; 416@class EmacsLayer;
427 417
428#ifdef NS_IMPL_COCOA 418#ifdef NS_IMPL_COCOA
429@interface EmacsView : NSView <NSTextInput, NSWindowDelegate> 419@interface EmacsView : NSView <NSTextInput, NSWindowDelegate>
@@ -444,9 +434,6 @@ typedef id instancetype;
444 NSWindow *nonfs_window; 434 NSWindow *nonfs_window;
445 BOOL fs_is_native; 435 BOOL fs_is_native;
446 BOOL in_fullscreen_transition; 436 BOOL in_fullscreen_transition;
447#ifdef NS_DRAW_TO_BUFFER
448 EmacsSurface *surface;
449#endif
450@public 437@public
451 struct frame *emacsframe; 438 struct frame *emacsframe;
452 int scrollbarsNeedingUpdate; 439 int scrollbarsNeedingUpdate;
@@ -486,9 +473,9 @@ typedef id instancetype;
486#endif 473#endif
487- (int)fullscreenState; 474- (int)fullscreenState;
488 475
489#ifdef NS_DRAW_TO_BUFFER 476#ifdef NS_IMPL_COCOA
490- (void)focusOnDrawingBuffer; 477- (void)lockFocus;
491- (void)unfocusDrawingBuffer; 478- (void)unlockFocus;
492#endif 479#endif
493- (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect; 480- (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect;
494 481
@@ -715,23 +702,17 @@ typedef id instancetype;
715+ (CGFloat)scrollerWidth; 702+ (CGFloat)scrollerWidth;
716@end 703@end
717 704
718#ifdef NS_DRAW_TO_BUFFER 705#ifdef NS_IMPL_COCOA
719@interface EmacsSurface : NSObject 706@interface EmacsLayer : CALayer
720{ 707{
721 NSMutableArray *cache; 708 NSMutableArray *cache;
722 NSSize size;
723 CGColorSpaceRef colorSpace; 709 CGColorSpaceRef colorSpace;
724 IOSurfaceRef currentSurface; 710 IOSurfaceRef currentSurface;
725 IOSurfaceRef lastSurface;
726 CGContextRef context; 711 CGContextRef context;
727 CGFloat scale;
728} 712}
729- (id) initWithSize: (NSSize)s ColorSpace: (CGColorSpaceRef)cs Scale: (CGFloat)scale; 713- (id) initWithColorSpace: (CGColorSpaceRef)cs;
730- (void) dealloc; 714- (void) setColorSpace: (CGColorSpaceRef)cs;
731- (NSSize) getSize;
732- (CGContextRef) getContext; 715- (CGContextRef) getContext;
733- (void) releaseContext;
734- (IOSurfaceRef) getSurface;
735@end 716@end
736#endif 717#endif
737 718