diff options
| author | Alan Third | 2021-08-21 13:09:37 +0100 |
|---|---|---|
| committer | Alan Third | 2021-08-21 13:12:56 +0100 |
| commit | 2837e25cafefea84d39a613b0d809194e0f75af0 (patch) | |
| tree | 4ffa6569a2bd71e10de5ad117373c3f16e2607b8 | |
| parent | 5eab7c3f70a048dab708512e8ef8114fbe85992e (diff) | |
| download | emacs-2837e25cafefea84d39a613b0d809194e0f75af0.tar.gz emacs-2837e25cafefea84d39a613b0d809194e0f75af0.zip | |
Fix display bug on macOS (bug#50112)
* src/nsterm.m ([EmacsLayer initWithColorSpace:]): Use the colorspace
setter.
([EmacsLayer setColorSpace:]): Sometimes we seem to get null
colorspaces, so set a default in this case.
([EmacsLayer getContext]): Check whether there's been a surface or
graphics context allocation failure and log it.
| -rw-r--r-- | src/nsterm.m | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index ba5d81fb6cd..1c1f0c8f239 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -9394,7 +9394,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9394 | if (self) | 9394 | if (self) |
| 9395 | { | 9395 | { |
| 9396 | cache = [[NSMutableArray arrayWithCapacity:CACHE_MAX_SIZE] retain]; | 9396 | cache = [[NSMutableArray arrayWithCapacity:CACHE_MAX_SIZE] retain]; |
| 9397 | colorSpace = cs; | 9397 | [self setColorSpace:cs]; |
| 9398 | } | 9398 | } |
| 9399 | else | 9399 | else |
| 9400 | { | 9400 | { |
| @@ -9409,7 +9409,10 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9409 | { | 9409 | { |
| 9410 | /* We don't need to clear the cache because the new colorspace will | 9410 | /* We don't need to clear the cache because the new colorspace will |
| 9411 | be used next time we create a new context. */ | 9411 | be used next time we create a new context. */ |
| 9412 | colorSpace = cs; | 9412 | if (cs) |
| 9413 | colorSpace = cs; | ||
| 9414 | else | ||
| 9415 | colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); | ||
| 9413 | } | 9416 | } |
| 9414 | 9417 | ||
| 9415 | 9418 | ||
| @@ -9505,6 +9508,12 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9505 | (id)kIOSurfacePixelFormat:[NSNumber numberWithUnsignedInt:'BGRA']}); | 9508 | (id)kIOSurfacePixelFormat:[NSNumber numberWithUnsignedInt:'BGRA']}); |
| 9506 | } | 9509 | } |
| 9507 | 9510 | ||
| 9511 | if (!surface) | ||
| 9512 | { | ||
| 9513 | NSLog (@"Failed to create IOSurface for frame %@", [self delegate]); | ||
| 9514 | return nil; | ||
| 9515 | } | ||
| 9516 | |||
| 9508 | IOReturn lockStatus = IOSurfaceLock (surface, 0, nil); | 9517 | IOReturn lockStatus = IOSurfaceLock (surface, 0, nil); |
| 9509 | if (lockStatus != kIOReturnSuccess) | 9518 | if (lockStatus != kIOReturnSuccess) |
| 9510 | NSLog (@"Failed to lock surface: %x", lockStatus); | 9519 | NSLog (@"Failed to lock surface: %x", lockStatus); |
| @@ -9522,6 +9531,15 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9522 | (kCGImageAlphaPremultipliedFirst | 9531 | (kCGImageAlphaPremultipliedFirst |
| 9523 | | kCGBitmapByteOrder32Host)); | 9532 | | kCGBitmapByteOrder32Host)); |
| 9524 | 9533 | ||
| 9534 | if (!context) | ||
| 9535 | { | ||
| 9536 | NSLog (@"Failed to create context for frame %@", [self delegate]); | ||
| 9537 | IOSurfaceUnlock (currentSurface, 0, nil); | ||
| 9538 | CFRelease (currentSurface); | ||
| 9539 | currentSurface = nil; | ||
| 9540 | return nil; | ||
| 9541 | } | ||
| 9542 | |||
| 9525 | CGContextTranslateCTM(context, 0, IOSurfaceGetHeight (currentSurface)); | 9543 | CGContextTranslateCTM(context, 0, IOSurfaceGetHeight (currentSurface)); |
| 9526 | CGContextScaleCTM(context, scale, -scale); | 9544 | CGContextScaleCTM(context, scale, -scale); |
| 9527 | } | 9545 | } |